##// END OF EJS Templates
Removed side bars which were too big......
jeandet -
r1375:0dd942c2cda8
parent child
Show More
@@ -1,404 +1,375
1 /*------------------------------------------------------------------------------
1 /*------------------------------------------------------------------------------
2 -- This file is a part of the SciQLop Software
2 -- This file is a part of the SciQLop Software
3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2017, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@member.fsf.org
20 -- Mail : alexis.jeandet@member.fsf.org
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "MainWindow.h"
22 #include "MainWindow.h"
23 #include "ui_MainWindow.h"
23 #include "ui_MainWindow.h"
24
24
25 #include <Catalogue/CatalogueController.h>
25 #include <Catalogue/CatalogueController.h>
26 #include <Catalogue/CatalogueExplorer.h>
26 #include <Catalogue/CatalogueExplorer.h>
27 #include <DataSource/DataSourceController.h>
27 #include <DataSource/DataSourceController.h>
28 #include <DataSource/DataSourceWidget.h>
28 #include <DataSource/DataSourceWidget.h>
29 #include <Settings/SqpSettingsDialog.h>
29 #include <Settings/SqpSettingsDialog.h>
30 #include <Settings/SqpSettingsGeneralWidget.h>
30 #include <Settings/SqpSettingsGeneralWidget.h>
31 #include <SidePane/SqpSidePane.h>
31 #include <SidePane/SqpSidePane.h>
32 #include <SqpApplication.h>
32 #include <SqpApplication.h>
33 #include <Time/TimeController.h>
33 #include <Time/TimeController.h>
34 #include <TimeWidget/TimeWidget.h>
34 #include <TimeWidget/TimeWidget.h>
35 #include <Variable/Variable.h>
35 #include <Variable/Variable.h>
36 #include <Visualization/VisualizationController.h>
36 #include <Visualization/VisualizationController.h>
37
37
38 #include <QAction>
38 #include <QAction>
39 #include <QCloseEvent>
39 #include <QCloseEvent>
40 #include <QDate>
40 #include <QDate>
41 #include <QDir>
41 #include <QDir>
42 #include <QFileDialog>
42 #include <QFileDialog>
43 #include <QMessageBox>
43 #include <QMessageBox>
44 #include <QToolBar>
44 #include <QToolBar>
45 #include <QToolButton>
45 #include <QToolButton>
46 #include <memory.h>
46 #include <memory.h>
47
47
48 #include "iostream"
48 #include "iostream"
49
49
50 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
50 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
51
51
52 namespace {
52 namespace {
53 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
53 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
54 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
54 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
55 const auto VIEWPLITTERINDEX = 2;
55 const auto VIEWPLITTERINDEX = 2;
56 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
56 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
57 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
57 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
58 }
58 }
59
59
60 class MainWindow::MainWindowPrivate {
60 class MainWindow::MainWindowPrivate {
61 public:
61 public:
62 explicit MainWindowPrivate(MainWindow *mainWindow)
62 explicit MainWindowPrivate(MainWindow *mainWindow)
63 : m_LastOpenLeftInspectorSize{},
63 : m_LastOpenLeftInspectorSize{},
64 m_LastOpenRightInspectorSize{},
64 m_LastOpenRightInspectorSize{},
65 m_GeneralSettingsWidget{new SqpSettingsGeneralWidget{mainWindow}},
65 m_GeneralSettingsWidget{new SqpSettingsGeneralWidget{mainWindow}},
66 m_SettingsDialog{new SqpSettingsDialog{mainWindow}},
66 m_SettingsDialog{new SqpSettingsDialog{mainWindow}},
67 m_CatalogExplorer{new CatalogueExplorer{mainWindow}}
67 m_CatalogExplorer{new CatalogueExplorer{mainWindow}}
68 {
68 {
69 }
69 }
70
70
71 QSize m_LastOpenLeftInspectorSize;
71 QSize m_LastOpenLeftInspectorSize;
72 QSize m_LastOpenRightInspectorSize;
72 QSize m_LastOpenRightInspectorSize;
73 /// General settings widget. MainWindow has the ownership
73 /// General settings widget. MainWindow has the ownership
74 SqpSettingsGeneralWidget *m_GeneralSettingsWidget;
74 SqpSettingsGeneralWidget *m_GeneralSettingsWidget;
75 /// Settings dialog. MainWindow has the ownership
75 /// Settings dialog. MainWindow has the ownership
76 SqpSettingsDialog *m_SettingsDialog;
76 SqpSettingsDialog *m_SettingsDialog;
77 /// Catalogue dialog. MainWindow has the ownership
77 /// Catalogue dialog. MainWindow has the ownership
78 CatalogueExplorer *m_CatalogExplorer;
78 CatalogueExplorer *m_CatalogExplorer;
79
79
80 bool checkDataToSave(QWidget *parentWidget);
80 bool checkDataToSave(QWidget *parentWidget);
81 };
81 };
82
82
83 MainWindow::MainWindow(QWidget *parent)
83 MainWindow::MainWindow(QWidget *parent)
84 : QMainWindow{parent},
84 : QMainWindow{parent},
85 m_Ui{new Ui::MainWindow},
85 m_Ui{new Ui::MainWindow},
86 impl{spimpl::make_unique_impl<MainWindowPrivate>(this)}
86 impl{spimpl::make_unique_impl<MainWindowPrivate>(this)}
87 {
87 {
88 m_Ui->setupUi(this);
88 m_Ui->setupUi(this);
89
89
90 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
90 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
91 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
91 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
92
92
93 impl->m_CatalogExplorer->setVisualizationWidget(m_Ui->view);
93 impl->m_CatalogExplorer->setVisualizationWidget(m_Ui->view);
94
94
95
95
96 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
96
97 auto openLeftInspectorAction = new QAction{QIcon{
98 ":/icones/previous.png",
99 },
100 tr("Show/hide the left inspector"), this};
101
97
102
98
103 auto spacerLeftTop = new QWidget{};
99 auto spacerLeftTop = new QWidget{};
104 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
100 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
105
101
106 auto spacerLeftBottom = new QWidget{};
102 auto spacerLeftBottom = new QWidget{};
107 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
103 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
108
104
109 leftSidePane->addWidget(spacerLeftTop);
110 leftSidePane->addAction(openLeftInspectorAction);
111 leftSidePane->addWidget(spacerLeftBottom);
112
113
114 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
115 auto openRightInspectorAction = new QAction{QIcon{
116 ":/icones/next.png",
117 },
118 tr("Show/hide the right inspector"), this};
119
105
120 auto spacerRightTop = new QWidget{};
106 auto spacerRightTop = new QWidget{};
121 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
107 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
122
108
123 auto spacerRightBottom = new QWidget{};
109 auto spacerRightBottom = new QWidget{};
124 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
110 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
125
111
126 rightSidePane->addWidget(spacerRightTop);
127 rightSidePane->addAction(openRightInspectorAction);
128 rightSidePane->addWidget(spacerRightBottom);
129
130 openLeftInspectorAction->setCheckable(true);
131 openRightInspectorAction->setCheckable(true);
132
112
133 auto openInspector = [this](bool checked, bool right, auto action) {
113 auto openInspector = [this](bool checked, bool right, auto action) {
134
114
135 action->setIcon(QIcon{(checked ^ right) ? ":/icones/next.png" : ":/icones/previous.png"});
115 action->setIcon(QIcon{(checked ^ right) ? ":/icones/next.png" : ":/icones/previous.png"});
136
116
137 auto &lastInspectorSize
117 auto &lastInspectorSize
138 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
118 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
139
119
140 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
120 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
141 : m_Ui->leftMainInspectorWidget->size();
121 : m_Ui->leftMainInspectorWidget->size();
142
122
143 // Update of the last opened geometry
123 // Update of the last opened geometry
144 if (checked) {
124 if (checked) {
145 lastInspectorSize = nextInspectorSize;
125 lastInspectorSize = nextInspectorSize;
146 }
126 }
147
127
148 auto startSize = lastInspectorSize;
128 auto startSize = lastInspectorSize;
149 auto endSize = startSize;
129 auto endSize = startSize;
150 endSize.setWidth(0);
130 endSize.setWidth(0);
151
131
152 auto splitterInspectorIndex
132 auto splitterInspectorIndex
153 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
133 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
154
134
155 auto currentSizes = m_Ui->splitter->sizes();
135 auto currentSizes = m_Ui->splitter->sizes();
156 if (checked) {
136 if (checked) {
157 // adjust sizes individually here, e.g.
137 // adjust sizes individually here, e.g.
158 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
138 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
159 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
139 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
160 m_Ui->splitter->setSizes(currentSizes);
140 m_Ui->splitter->setSizes(currentSizes);
161 }
141 }
162 else {
142 else {
163 // adjust sizes individually here, e.g.
143 // adjust sizes individually here, e.g.
164 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
144 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
165 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
145 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
166 m_Ui->splitter->setSizes(currentSizes);
146 m_Ui->splitter->setSizes(currentSizes);
167 }
147 }
168
148
169 };
149 };
170
150
171
151
172 connect(openLeftInspectorAction, &QAction::triggered,
173 [openInspector, openLeftInspectorAction](bool checked) {
174 openInspector(checked, false, openLeftInspectorAction);
175 });
176 connect(openRightInspectorAction, &QAction::triggered,
177 [openInspector, openRightInspectorAction](bool checked) {
178 openInspector(checked, true, openRightInspectorAction);
179 });
180
181 // //////////////// //
152 // //////////////// //
182 // Menu and Toolbar //
153 // Menu and Toolbar //
183 // //////////////// //
154 // //////////////// //
184 this->menuBar()->addAction(tr("File"));
155 this->menuBar()->addAction(tr("File"));
185 auto toolsMenu = this->menuBar()->addMenu(tr("Tools"));
156 auto toolsMenu = this->menuBar()->addMenu(tr("Tools"));
186 toolsMenu->addAction(tr("Settings..."), [this]() {
157 toolsMenu->addAction(tr("Settings..."), [this]() {
187 // Loads settings
158 // Loads settings
188 impl->m_SettingsDialog->loadSettings();
159 impl->m_SettingsDialog->loadSettings();
189
160
190 // Open settings dialog and save settings if the dialog is accepted
161 // Open settings dialog and save settings if the dialog is accepted
191 if (impl->m_SettingsDialog->exec() == QDialog::Accepted) {
162 if (impl->m_SettingsDialog->exec() == QDialog::Accepted) {
192 impl->m_SettingsDialog->saveSettings();
163 impl->m_SettingsDialog->saveSettings();
193 }
164 }
194
165
195 });
166 });
196
167
197 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
168 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
198
169
199 auto timeWidget = new TimeWidget{};
170 auto timeWidget = new TimeWidget{};
200 mainToolBar->addWidget(timeWidget);
171 mainToolBar->addWidget(timeWidget);
201
172
202 // Interaction modes
173 // Interaction modes
203 auto actionPointerMode = new QAction{QIcon(":/icones/pointer.png"), "Move", this};
174 auto actionPointerMode = new QAction{QIcon(":/icones/pointer.png"), "Move", this};
204 actionPointerMode->setCheckable(true);
175 actionPointerMode->setCheckable(true);
205 actionPointerMode->setChecked(sqpApp->plotsInteractionMode()
176 actionPointerMode->setChecked(sqpApp->plotsInteractionMode()
206 == SqpApplication::PlotsInteractionMode::None);
177 == SqpApplication::PlotsInteractionMode::None);
207 connect(actionPointerMode, &QAction::triggered,
178 connect(actionPointerMode, &QAction::triggered,
208 []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::None); });
179 []() { sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::None); });
209
180
210 auto actionZoomMode = new QAction{QIcon(":/icones/zoom.png"), "Zoom", this};
181 auto actionZoomMode = new QAction{QIcon(":/icones/zoom.png"), "Zoom", this};
211 actionZoomMode->setCheckable(true);
182 actionZoomMode->setCheckable(true);
212 actionZoomMode->setChecked(sqpApp->plotsInteractionMode()
183 actionZoomMode->setChecked(sqpApp->plotsInteractionMode()
213 == SqpApplication::PlotsInteractionMode::ZoomBox);
184 == SqpApplication::PlotsInteractionMode::ZoomBox);
214 connect(actionZoomMode, &QAction::triggered, []() {
185 connect(actionZoomMode, &QAction::triggered, []() {
215 sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::ZoomBox);
186 sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::ZoomBox);
216 });
187 });
217
188
218 auto actionOrganisationMode = new QAction{QIcon(":/icones/drag.png"), "Organize", this};
189 auto actionOrganisationMode = new QAction{QIcon(":/icones/drag.png"), "Organize", this};
219 actionOrganisationMode->setCheckable(true);
190 actionOrganisationMode->setCheckable(true);
220 actionOrganisationMode->setChecked(sqpApp->plotsInteractionMode()
191 actionOrganisationMode->setChecked(sqpApp->plotsInteractionMode()
221 == SqpApplication::PlotsInteractionMode::DragAndDrop);
192 == SqpApplication::PlotsInteractionMode::DragAndDrop);
222 connect(actionOrganisationMode, &QAction::triggered, []() {
193 connect(actionOrganisationMode, &QAction::triggered, []() {
223 sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::DragAndDrop);
194 sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::DragAndDrop);
224 });
195 });
225
196
226 auto actionZonesMode = new QAction{QIcon(":/icones/rectangle.png"), "Zones", this};
197 auto actionZonesMode = new QAction{QIcon(":/icones/rectangle.png"), "Zones", this};
227 actionZonesMode->setCheckable(true);
198 actionZonesMode->setCheckable(true);
228 actionZonesMode->setChecked(sqpApp->plotsInteractionMode()
199 actionZonesMode->setChecked(sqpApp->plotsInteractionMode()
229 == SqpApplication::PlotsInteractionMode::SelectionZones);
200 == SqpApplication::PlotsInteractionMode::SelectionZones);
230 connect(actionZonesMode, &QAction::triggered, []() {
201 connect(actionZonesMode, &QAction::triggered, []() {
231 sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::SelectionZones);
202 sqpApp->setPlotsInteractionMode(SqpApplication::PlotsInteractionMode::SelectionZones);
232 });
203 });
233
204
234 auto modeActionGroup = new QActionGroup{this};
205 auto modeActionGroup = new QActionGroup{this};
235 modeActionGroup->addAction(actionZoomMode);
206 modeActionGroup->addAction(actionZoomMode);
236 modeActionGroup->addAction(actionZonesMode);
207 modeActionGroup->addAction(actionZonesMode);
237 modeActionGroup->addAction(actionOrganisationMode);
208 modeActionGroup->addAction(actionOrganisationMode);
238 modeActionGroup->addAction(actionPointerMode);
209 modeActionGroup->addAction(actionPointerMode);
239 modeActionGroup->setExclusive(true);
210 modeActionGroup->setExclusive(true);
240
211
241 mainToolBar->addSeparator();
212 mainToolBar->addSeparator();
242 mainToolBar->addAction(actionPointerMode);
213 mainToolBar->addAction(actionPointerMode);
243 mainToolBar->addAction(actionZoomMode);
214 mainToolBar->addAction(actionZoomMode);
244 mainToolBar->addAction(actionOrganisationMode);
215 mainToolBar->addAction(actionOrganisationMode);
245 mainToolBar->addAction(actionZonesMode);
216 mainToolBar->addAction(actionZonesMode);
246 mainToolBar->addSeparator();
217 mainToolBar->addSeparator();
247
218
248 // Cursors
219 // Cursors
249 auto btnCursor = new QToolButton{this};
220 auto btnCursor = new QToolButton{this};
250 btnCursor->setIcon(QIcon(":/icones/cursor.png"));
221 btnCursor->setIcon(QIcon(":/icones/cursor.png"));
251 btnCursor->setText("Cursor");
222 btnCursor->setText("Cursor");
252 btnCursor->setToolTip("Cursor");
223 btnCursor->setToolTip("Cursor");
253 btnCursor->setPopupMode(QToolButton::InstantPopup);
224 btnCursor->setPopupMode(QToolButton::InstantPopup);
254 auto cursorMenu = new QMenu("CursorMenu", this);
225 auto cursorMenu = new QMenu("CursorMenu", this);
255 btnCursor->setMenu(cursorMenu);
226 btnCursor->setMenu(cursorMenu);
256
227
257 auto noCursorAction = cursorMenu->addAction("No Cursor");
228 auto noCursorAction = cursorMenu->addAction("No Cursor");
258 noCursorAction->setCheckable(true);
229 noCursorAction->setCheckable(true);
259 noCursorAction->setChecked(sqpApp->plotsCursorMode()
230 noCursorAction->setChecked(sqpApp->plotsCursorMode()
260 == SqpApplication::PlotsCursorMode::NoCursor);
231 == SqpApplication::PlotsCursorMode::NoCursor);
261 connect(noCursorAction, &QAction::triggered,
232 connect(noCursorAction, &QAction::triggered,
262 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::NoCursor); });
233 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::NoCursor); });
263
234
264 cursorMenu->addSeparator();
235 cursorMenu->addSeparator();
265 auto verticalCursorAction = cursorMenu->addAction("Vertical Cursor");
236 auto verticalCursorAction = cursorMenu->addAction("Vertical Cursor");
266 verticalCursorAction->setCheckable(true);
237 verticalCursorAction->setCheckable(true);
267 verticalCursorAction->setChecked(sqpApp->plotsCursorMode()
238 verticalCursorAction->setChecked(sqpApp->plotsCursorMode()
268 == SqpApplication::PlotsCursorMode::Vertical);
239 == SqpApplication::PlotsCursorMode::Vertical);
269 connect(verticalCursorAction, &QAction::triggered,
240 connect(verticalCursorAction, &QAction::triggered,
270 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Vertical); });
241 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Vertical); });
271
242
272 auto temporalCursorAction = cursorMenu->addAction("Temporal Cursor");
243 auto temporalCursorAction = cursorMenu->addAction("Temporal Cursor");
273 temporalCursorAction->setCheckable(true);
244 temporalCursorAction->setCheckable(true);
274 temporalCursorAction->setChecked(sqpApp->plotsCursorMode()
245 temporalCursorAction->setChecked(sqpApp->plotsCursorMode()
275 == SqpApplication::PlotsCursorMode::Temporal);
246 == SqpApplication::PlotsCursorMode::Temporal);
276 connect(temporalCursorAction, &QAction::triggered,
247 connect(temporalCursorAction, &QAction::triggered,
277 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Temporal); });
248 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Temporal); });
278
249
279 auto horizontalCursorAction = cursorMenu->addAction("Horizontal Cursor");
250 auto horizontalCursorAction = cursorMenu->addAction("Horizontal Cursor");
280 horizontalCursorAction->setCheckable(true);
251 horizontalCursorAction->setCheckable(true);
281 horizontalCursorAction->setChecked(sqpApp->plotsCursorMode()
252 horizontalCursorAction->setChecked(sqpApp->plotsCursorMode()
282 == SqpApplication::PlotsCursorMode::Horizontal);
253 == SqpApplication::PlotsCursorMode::Horizontal);
283 connect(horizontalCursorAction, &QAction::triggered,
254 connect(horizontalCursorAction, &QAction::triggered,
284 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Horizontal); });
255 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Horizontal); });
285
256
286 auto crossCursorAction = cursorMenu->addAction("Cross Cursor");
257 auto crossCursorAction = cursorMenu->addAction("Cross Cursor");
287 crossCursorAction->setCheckable(true);
258 crossCursorAction->setCheckable(true);
288 crossCursorAction->setChecked(sqpApp->plotsCursorMode()
259 crossCursorAction->setChecked(sqpApp->plotsCursorMode()
289 == SqpApplication::PlotsCursorMode::Cross);
260 == SqpApplication::PlotsCursorMode::Cross);
290 connect(crossCursorAction, &QAction::triggered,
261 connect(crossCursorAction, &QAction::triggered,
291 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Cross); });
262 []() { sqpApp->setPlotsCursorMode(SqpApplication::PlotsCursorMode::Cross); });
292
263
293 mainToolBar->addWidget(btnCursor);
264 mainToolBar->addWidget(btnCursor);
294
265
295 auto cursorModeActionGroup = new QActionGroup{this};
266 auto cursorModeActionGroup = new QActionGroup{this};
296 cursorModeActionGroup->setExclusive(true);
267 cursorModeActionGroup->setExclusive(true);
297 cursorModeActionGroup->addAction(noCursorAction);
268 cursorModeActionGroup->addAction(noCursorAction);
298 cursorModeActionGroup->addAction(verticalCursorAction);
269 cursorModeActionGroup->addAction(verticalCursorAction);
299 cursorModeActionGroup->addAction(temporalCursorAction);
270 cursorModeActionGroup->addAction(temporalCursorAction);
300 cursorModeActionGroup->addAction(horizontalCursorAction);
271 cursorModeActionGroup->addAction(horizontalCursorAction);
301 cursorModeActionGroup->addAction(crossCursorAction);
272 cursorModeActionGroup->addAction(crossCursorAction);
302
273
303 // Catalog
274 // Catalog
304 mainToolBar->addSeparator();
275 mainToolBar->addSeparator();
305 mainToolBar->addAction(QIcon(":/icones/catalogue.png"), "Catalogues",
276 mainToolBar->addAction(QIcon(":/icones/catalogue.png"), "Catalogues",
306 [this]() { impl->m_CatalogExplorer->show(); });
277 [this]() { impl->m_CatalogExplorer->show(); });
307
278
308 // //////// //
279 // //////// //
309 // Settings //
280 // Settings //
310 // //////// //
281 // //////// //
311
282
312 // Registers "general settings" widget to the settings dialog
283 // Registers "general settings" widget to the settings dialog
313 impl->m_SettingsDialog->registerWidget(QStringLiteral("General"),
284 impl->m_SettingsDialog->registerWidget(QStringLiteral("General"),
314 impl->m_GeneralSettingsWidget);
285 impl->m_GeneralSettingsWidget);
315
286
316 // /////////// //
287 // /////////// //
317 // Connections //
288 // Connections //
318 // /////////// //
289 // /////////// //
319
290
320 // Controllers / controllers connections
291 // Controllers / controllers connections
321 // connect(&sqpApp->timeController(), SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->variableController(),
292 // connect(&sqpApp->timeController(), SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->variableController(),
322 // SLOT(onDateTimeOnSelection(DateTimeRange)));
293 // SLOT(onDateTimeOnSelection(DateTimeRange)));
323
294
324 // Widgets / controllers connections
295 // Widgets / controllers connections
325
296
326 // DataSource
297 // DataSource
327 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
298 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
328 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
299 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
329
300
330 // Time
301 // Time
331 connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(),
302 connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(),
332 SLOT(onTimeToUpdate(DateTimeRange)));
303 SLOT(onTimeToUpdate(DateTimeRange)));
333
304
334 // Visualization
305 // Visualization
335 connect(&sqpApp->visualizationController(),
306 connect(&sqpApp->visualizationController(),
336 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view,
307 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view,
337 SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>)));
308 SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>)));
338
309
339 connect(&sqpApp->visualizationController(),
310 connect(&sqpApp->visualizationController(),
340 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)), m_Ui->view,
311 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)), m_Ui->view,
341 SLOT(onRangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)));
312 SLOT(onRangeChanged(std::shared_ptr<Variable>, const DateTimeRange &)));
342
313
343 // Widgets / widgets connections
314 // Widgets / widgets connections
344
315
345 // For the following connections, we use DirectConnection to allow each widget that can
316 // For the following connections, we use DirectConnection to allow each widget that can
346 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
317 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
347 // The order of connections is also important, since it determines the order in which each
318 // The order of connections is also important, since it determines the order in which each
348 // widget will attach its menu
319 // widget will attach its menu
349 connect(
320 connect(
350 m_Ui->variableInspectorWidget,
321 m_Ui->variableInspectorWidget,
351 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
322 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
352 m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
323 m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
353 Qt::DirectConnection);
324 Qt::DirectConnection);
354 }
325 }
355
326
356 MainWindow::~MainWindow()
327 MainWindow::~MainWindow()
357 {
328 {
358 }
329 }
359
330
360 void MainWindow::changeEvent(QEvent *e)
331 void MainWindow::changeEvent(QEvent *e)
361 {
332 {
362 QMainWindow::changeEvent(e);
333 QMainWindow::changeEvent(e);
363 switch (e->type()) {
334 switch (e->type()) {
364 case QEvent::LanguageChange:
335 case QEvent::LanguageChange:
365 m_Ui->retranslateUi(this);
336 m_Ui->retranslateUi(this);
366 break;
337 break;
367 default:
338 default:
368 break;
339 break;
369 }
340 }
370 }
341 }
371
342
372 void MainWindow::closeEvent(QCloseEvent *event)
343 void MainWindow::closeEvent(QCloseEvent *event)
373 {
344 {
374 if (!impl->checkDataToSave(this)) {
345 if (!impl->checkDataToSave(this)) {
375 event->ignore();
346 event->ignore();
376 }
347 }
377 else {
348 else {
378 event->accept();
349 event->accept();
379 }
350 }
380 }
351 }
381
352
382 bool MainWindow::MainWindowPrivate::checkDataToSave(QWidget *parentWidget)
353 bool MainWindow::MainWindowPrivate::checkDataToSave(QWidget *parentWidget)
383 {
354 {
384 auto hasChanges = sqpApp->catalogueController().hasChanges();
355 auto hasChanges = sqpApp->catalogueController().hasChanges();
385 if (hasChanges) {
356 if (hasChanges) {
386 // There are some unsaved changes
357 // There are some unsaved changes
387 switch (QMessageBox::question(
358 switch (QMessageBox::question(
388 parentWidget, tr("Save changes"),
359 parentWidget, tr("Save changes"),
389 tr("The catalogue controller has unsaved changes.\nDo you want to save them ?"),
360 tr("The catalogue controller has unsaved changes.\nDo you want to save them ?"),
390 QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel,
361 QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel,
391 QMessageBox::SaveAll)) {
362 QMessageBox::SaveAll)) {
392 case QMessageBox::SaveAll:
363 case QMessageBox::SaveAll:
393 sqpApp->catalogueController().saveAll();
364 sqpApp->catalogueController().saveAll();
394 break;
365 break;
395 case QMessageBox::Discard:
366 case QMessageBox::Discard:
396 break;
367 break;
397 case QMessageBox::Cancel:
368 case QMessageBox::Cancel:
398 default:
369 default:
399 return false;
370 return false;
400 }
371 }
401 }
372 }
402
373
403 return true;
374 return true;
404 }
375 }
@@ -1,170 +1,162
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
2 <ui version="4.0">
3 <class>MainWindow</class>
3 <class>MainWindow</class>
4 <widget class="QMainWindow" name="MainWindow">
4 <widget class="QMainWindow" name="MainWindow">
5 <property name="geometry">
5 <property name="geometry">
6 <rect>
6 <rect>
7 <x>0</x>
7 <x>0</x>
8 <y>0</y>
8 <y>0</y>
9 <width>800</width>
9 <width>800</width>
10 <height>600</height>
10 <height>600</height>
11 </rect>
11 </rect>
12 </property>
12 </property>
13 <property name="windowTitle">
13 <property name="windowTitle">
14 <string>SciQlop v0.0.1</string>
14 <string>SciQlop v0.0.1</string>
15 </property>
15 </property>
16 <property name="dockNestingEnabled">
16 <property name="dockNestingEnabled">
17 <bool>true</bool>
17 <bool>true</bool>
18 </property>
18 </property>
19 <widget class="QWidget" name="centralWidget">
19 <widget class="QWidget" name="centralWidget">
20 <property name="enabled">
20 <property name="enabled">
21 <bool>true</bool>
21 <bool>true</bool>
22 </property>
22 </property>
23 <property name="sizePolicy">
23 <property name="sizePolicy">
24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
24 <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
25 <horstretch>0</horstretch>
25 <horstretch>0</horstretch>
26 <verstretch>0</verstretch>
26 <verstretch>0</verstretch>
27 </sizepolicy>
27 </sizepolicy>
28 </property>
28 </property>
29 <property name="maximumSize">
29 <property name="maximumSize">
30 <size>
30 <size>
31 <width>16777215</width>
31 <width>16777215</width>
32 <height>16777215</height>
32 <height>16777215</height>
33 </size>
33 </size>
34 </property>
34 </property>
35 <layout class="QHBoxLayout" name="horizontalLayout">
35 <layout class="QHBoxLayout" name="horizontalLayout">
36 <property name="spacing">
36 <property name="spacing">
37 <number>0</number>
37 <number>0</number>
38 </property>
38 </property>
39 <property name="leftMargin">
39 <property name="leftMargin">
40 <number>0</number>
40 <number>0</number>
41 </property>
41 </property>
42 <property name="topMargin">
42 <property name="topMargin">
43 <number>0</number>
43 <number>0</number>
44 </property>
44 </property>
45 <property name="rightMargin">
45 <property name="rightMargin">
46 <number>0</number>
46 <number>0</number>
47 </property>
47 </property>
48 <property name="bottomMargin">
48 <property name="bottomMargin">
49 <number>0</number>
49 <number>0</number>
50 </property>
50 </property>
51 <item>
51 <item>
52 <widget class="QSplitter" name="splitter">
52 <widget class="QSplitter" name="splitter">
53 <property name="orientation">
53 <property name="orientation">
54 <enum>Qt::Horizontal</enum>
54 <enum>Qt::Horizontal</enum>
55 </property>
55 </property>
56 <widget class="QWidget" name="leftMainInspectorWidget" native="true">
56 <widget class="QWidget" name="leftMainInspectorWidget" native="true">
57 <layout class="QVBoxLayout" name="verticalLayout">
57 <layout class="QVBoxLayout" name="verticalLayout">
58 <property name="spacing">
58 <property name="spacing">
59 <number>0</number>
59 <number>0</number>
60 </property>
60 </property>
61 <property name="leftMargin">
61 <property name="leftMargin">
62 <number>0</number>
62 <number>0</number>
63 </property>
63 </property>
64 <property name="topMargin">
64 <property name="topMargin">
65 <number>0</number>
65 <number>0</number>
66 </property>
66 </property>
67 <property name="rightMargin">
67 <property name="rightMargin">
68 <number>0</number>
68 <number>0</number>
69 </property>
69 </property>
70 <property name="bottomMargin">
70 <property name="bottomMargin">
71 <number>0</number>
71 <number>0</number>
72 </property>
72 </property>
73 <item>
73 <item>
74 <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/>
74 <widget class="DataSourceWidget" name="dataSourceWidget" native="true"/>
75 </item>
75 </item>
76 <item>
76 <item>
77 <widget class="QWidget" name="dateTimeWidget" native="true"/>
77 <widget class="QWidget" name="dateTimeWidget" native="true"/>
78 </item>
78 </item>
79 <item>
79 <item>
80 <widget class="VariableInspectorWidget" name="variableInspectorWidget" native="true"/>
80 <widget class="VariableInspectorWidget" name="variableInspectorWidget" native="true"/>
81 </item>
81 </item>
82 </layout>
82 </layout>
83 </widget>
83 </widget>
84 <widget class="SqpSidePane" name="leftInspectorSidePane" native="true"/>
85 <widget class="VisualizationWidget" name="view" native="true">
84 <widget class="VisualizationWidget" name="view" native="true">
86 <property name="sizePolicy">
85 <property name="sizePolicy">
87 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
86 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
88 <horstretch>0</horstretch>
87 <horstretch>0</horstretch>
89 <verstretch>0</verstretch>
88 <verstretch>0</verstretch>
90 </sizepolicy>
89 </sizepolicy>
91 </property>
90 </property>
92 </widget>
91 </widget>
93 <widget class="SqpSidePane" name="rightInspectorSidePane" native="true"/>
94 <widget class="QWidget" name="rightMainInspectorWidget" native="true">
92 <widget class="QWidget" name="rightMainInspectorWidget" native="true">
95 <layout class="QVBoxLayout" name="verticalLayout_3">
93 <layout class="QVBoxLayout" name="verticalLayout_3">
96 <property name="spacing">
94 <property name="spacing">
97 <number>0</number>
95 <number>0</number>
98 </property>
96 </property>
99 <property name="leftMargin">
97 <property name="leftMargin">
100 <number>0</number>
98 <number>0</number>
101 </property>
99 </property>
102 <property name="topMargin">
100 <property name="topMargin">
103 <number>0</number>
101 <number>0</number>
104 </property>
102 </property>
105 <property name="rightMargin">
103 <property name="rightMargin">
106 <number>0</number>
104 <number>0</number>
107 </property>
105 </property>
108 <property name="bottomMargin">
106 <property name="bottomMargin">
109 <number>0</number>
107 <number>0</number>
110 </property>
108 </property>
111 <item>
109 <item>
112 <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/>
110 <widget class="QWidget" name="commonPropertyInspectorWidget" native="true"/>
113 </item>
111 </item>
114 <item>
112 <item>
115 <widget class="QTreeWidget" name="catalogWidget">
113 <widget class="QTreeWidget" name="catalogWidget">
116 <column>
114 <column>
117 <property name="text">
115 <property name="text">
118 <string notr="true">Name</string>
116 <string notr="true">Name</string>
119 </property>
117 </property>
120 </column>
118 </column>
121 </widget>
119 </widget>
122 </item>
120 </item>
123 </layout>
121 </layout>
124 </widget>
122 </widget>
125 </widget>
123 </widget>
126 </item>
124 </item>
127 </layout>
125 </layout>
128 </widget>
126 </widget>
129 <widget class="QMenuBar" name="menuBar">
127 <widget class="QMenuBar" name="menuBar">
130 <property name="geometry">
128 <property name="geometry">
131 <rect>
129 <rect>
132 <x>0</x>
130 <x>0</x>
133 <y>0</y>
131 <y>0</y>
134 <width>800</width>
132 <width>800</width>
135 <height>21</height>
133 <height>41</height>
136 </rect>
134 </rect>
137 </property>
135 </property>
138 </widget>
136 </widget>
139 <widget class="QStatusBar" name="statusBar"/>
137 <widget class="QStatusBar" name="statusBar"/>
140 </widget>
138 </widget>
141 <layoutdefault spacing="6" margin="11"/>
139 <layoutdefault spacing="6" margin="11"/>
142 <customwidgets>
140 <customwidgets>
143 <customwidget>
141 <customwidget>
144 <class>VisualizationWidget</class>
142 <class>VisualizationWidget</class>
145 <extends>QWidget</extends>
143 <extends>QWidget</extends>
146 <header location="global">Visualization/VisualizationWidget.h</header>
144 <header location="global">Visualization/VisualizationWidget.h</header>
147 <container>1</container>
145 <container>1</container>
148 </customwidget>
146 </customwidget>
149 <customwidget>
147 <customwidget>
150 <class>SqpSidePane</class>
151 <extends>QWidget</extends>
152 <header location="global">SidePane/SqpSidePane.h</header>
153 <container>1</container>
154 </customwidget>
155 <customwidget>
156 <class>DataSourceWidget</class>
148 <class>DataSourceWidget</class>
157 <extends>QWidget</extends>
149 <extends>QWidget</extends>
158 <header location="global">DataSource/DataSourceWidget.h</header>
150 <header location="global">DataSource/DataSourceWidget.h</header>
159 <container>1</container>
151 <container>1</container>
160 </customwidget>
152 </customwidget>
161 <customwidget>
153 <customwidget>
162 <class>VariableInspectorWidget</class>
154 <class>VariableInspectorWidget</class>
163 <extends>QWidget</extends>
155 <extends>QWidget</extends>
164 <header location="global">Variable/VariableInspectorWidget.h</header>
156 <header location="global">Variable/VariableInspectorWidget.h</header>
165 <container>1</container>
157 <container>1</container>
166 </customwidget>
158 </customwidget>
167 </customwidgets>
159 </customwidgets>
168 <resources/>
160 <resources/>
169 <connections/>
161 <connections/>
170 </ui>
162 </ui>
General Comments 0
You need to be logged in to leave comments. Login now