##// END OF EJS Templates
PRC: add tr on text...
perrinel -
r102:e7845df8634c
parent child
Show More
@@ -1,212 +1,224
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SciQLop Software
3 3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "MainWindow.h"
23 23 #include "ui_MainWindow.h"
24 24
25 25 #include <DataSource/DataSourceController.h>
26 26 #include <DataSource/DataSourceWidget.h>
27 27 #include <SidePane/SqpSidePane.h>
28 28 #include <SqpApplication.h>
29 29
30 30 #include <QAction>
31 31 #include <QDate>
32 32 #include <QDateTime>
33 33 #include <QDir>
34 34 #include <QFileDialog>
35 35 #include <QToolBar>
36 36 #include <memory.h>
37 37
38 38 //#include <omp.h>
39 39 //#include <network/filedownloader.h>
40 40 //#include <qlopdatabase.h>
41 41 //#include <qlopsettings.h>
42 42 //#include <qlopgui.h>
43 43 //#include <spacedata.h>
44 44 //#include "qlopcore.h"
45 45 //#include "qlopcodecmanager.h"
46 46 //#include "cdfcodec.h"
47 47 //#include "amdatxtcodec.h"
48 48 //#include <qlopplotmanager.h>
49 49
50 50 #include "iostream"
51 51
52 52 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
53 53
54 namespace {
55 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
56 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
57 const auto VIEWPLITTERINDEX = 2;
58 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
59 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
60 }
61
54 62 class MainWindow::MainWindowPrivate {
55 63 public:
56 64 QSize m_LastOpenLeftInspectorSize;
57 65 QSize m_LastOpenRightInspectorSize;
58 66 };
59 67
60 68 MainWindow::MainWindow(QWidget *parent)
61 69 : QMainWindow{parent},
62 70 m_Ui{new Ui::MainWindow},
63 71 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
64 72 {
65 73 m_Ui->setupUi(this);
66 74
75 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
76 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
67 77
68 m_Ui->splitter->setCollapsible(1, false);
69 m_Ui->splitter->setCollapsible(3, false);
78 // NOTE: These lambda could be factorized. Be careful of theirs parameters
70 79 // Lambda that defines what's happened when clicking on the leftSidePaneInspector open button
71 auto openLeftInspector = [&](bool checked) {
80 auto openLeftInspector = [this](bool checked) {
72 81
73 82 // Update of the last opened geometry
74 83 if (checked) {
75 84 impl->m_LastOpenLeftInspectorSize = m_Ui->leftMainInspectorWidget->size();
76 85 }
77 86
78 87 auto startSize = impl->m_LastOpenLeftInspectorSize;
79 88 auto endSize = startSize;
80 89 endSize.setWidth(0);
81 90
82 QList<int> currentSizes = m_Ui->splitter->sizes();
91 auto currentSizes = m_Ui->splitter->sizes();
83 92 if (checked) {
84 93 // adjust sizes individually here, e.g.
85 currentSizes[0] -= impl->m_LastOpenLeftInspectorSize.width();
86 currentSizes[2] += impl->m_LastOpenLeftInspectorSize.width();
94 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
95 -= impl->m_LastOpenLeftInspectorSize.width();
96 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenLeftInspectorSize.width();
87 97 m_Ui->splitter->setSizes(currentSizes);
88 98 }
89 99 else {
90 100 // adjust sizes individually here, e.g.
91 currentSizes[0] += impl->m_LastOpenLeftInspectorSize.width();
92 currentSizes[2] -= impl->m_LastOpenLeftInspectorSize.width();
101 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
102 += impl->m_LastOpenLeftInspectorSize.width();
103 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenLeftInspectorSize.width();
93 104 m_Ui->splitter->setSizes(currentSizes);
94 105 }
95 106
96 107 };
97 108
98 109 // Lambda that defines what's happened when clicking on the SidePaneInspector open button
99 auto openRightInspector = [&](bool checked) {
110 auto openRightInspector = [this](bool checked) {
100 111
101 112 // Update of the last opened geometry
102 113 if (checked) {
103 114 impl->m_LastOpenRightInspectorSize = m_Ui->rightMainInspectorWidget->size();
104 115 }
105 116
106 117 auto startSize = impl->m_LastOpenRightInspectorSize;
107 118 auto endSize = startSize;
108 119 endSize.setWidth(0);
109 120
110 QList<int> currentSizes = m_Ui->splitter->sizes();
121 auto currentSizes = m_Ui->splitter->sizes();
111 122 if (checked) {
112 123 // adjust sizes individually here, e.g.
113 currentSizes[4] -= impl->m_LastOpenRightInspectorSize.width();
114 currentSizes[2] += impl->m_LastOpenRightInspectorSize.width();
124 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
125 -= impl->m_LastOpenRightInspectorSize.width();
126 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenRightInspectorSize.width();
115 127 m_Ui->splitter->setSizes(currentSizes);
116 128 }
117 129 else {
118 130 // adjust sizes individually here, e.g.
119 currentSizes[4] += impl->m_LastOpenRightInspectorSize.width();
120 currentSizes[2] -= impl->m_LastOpenRightInspectorSize.width();
131 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
132 += impl->m_LastOpenRightInspectorSize.width();
133 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenRightInspectorSize.width();
121 134 m_Ui->splitter->setSizes(currentSizes);
122 135 }
123 136
124 137 };
125 138
126 139
127 140 QToolBar *leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
128 141 auto openLeftInspectorAction = leftSidePane->addAction(
129 142 QIcon{
130 143 ":/icones/openInspector.png",
131 144 },
132 "ACTION L1", openLeftInspector);
145 tr("Show/hide the left inspector"), openLeftInspector);
133 146
134 147 openLeftInspectorAction->setCheckable(true);
135 148
136 149 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
137 150 auto openRightInspectorAction = rightSidePane->addAction(
138 151 QIcon{
139 152 ":/icones/openInspector.png",
140 153 },
141 "ACTION L1", openRightInspector);
154 tr("Show/hide the right inspector"), openRightInspector);
142 155
143 156 openRightInspectorAction->setCheckable(true);
144 157
145
146 this->menuBar()->addAction("File");
147 auto mainToolBar = this->addToolBar("MainToolBar");
148 mainToolBar->addAction("A1");
158 this->menuBar()->addAction(tr("File"));
159 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
160 mainToolBar->addAction(QStringLiteral("A1"));
149 161
150 162 // Widgets / controllers connections
151 163 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
152 164 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
153 165
154 166 /* QLopGUI::registerMenuBar(menuBar());
155 167 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
156 168 this->m_progressWidget = new QWidget();
157 169 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
158 170 this->m_progressWidget->setLayout(this->m_progressLayout);
159 171 this->m_progressWidget->setWindowModality(Qt::WindowModal);
160 172 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
161 173 for(int i=0;i<OMP_THREADS;i++)
162 174 {
163 175 this->m_progress.append(new QProgressBar(this->m_progressWidget));
164 176 this->m_progress.last()->setMinimum(0);
165 177 this->m_progress.last()->setMaximum(100);
166 178 this->m_progressLayout->addWidget(this->m_progress.last());
167 179 this->m_progressWidget->hide();
168 180 this->m_progressThreadIds[i] = -1;
169 181 }
170 182 this->m_progressWidget->setWindowTitle("Loading File");
171 183 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
172 184 << QLopCore::self()
173 185 << QLopPlotManager::self()
174 186 << QLopCodecManager::self()
175 187 << FileDownloader::self()
176 188 << QLopDataBase::self()
177 189 << SpaceData::self();
178 190
179 191 CDFCodec::registerToManager();
180 192 AMDATXTCodec::registerToManager();
181 193
182 194
183 195 for(int i=0;i<ServicesToLoad.count();i++)
184 196 {
185 197 qDebug()<<ServicesToLoad.at(i)->serviceName();
186 198 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
187 199 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
188 200 if(wdgt)
189 201 {
190 202 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
191 203 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
192 204 }
193 205 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
194 206 }*/
195 207 }
196 208
197 209 MainWindow::~MainWindow()
198 210 {
199 211 }
200 212
201 213
202 214 void MainWindow::changeEvent(QEvent *e)
203 215 {
204 216 QMainWindow::changeEvent(e);
205 217 switch (e->type()) {
206 218 case QEvent::LanguageChange:
207 219 m_Ui->retranslateUi(this);
208 220 break;
209 221 default:
210 222 break;
211 223 }
212 224 }
General Comments 0
You need to be logged in to leave comments. Login now