##// END OF EJS Templates
Creates settings dialog and adds it to a new menu in MainWindow...
Alexandre Leroux -
r463:6a4aa86600f2
parent child
Show More
@@ -0,0 +1,27
1 #ifndef SCIQLOP_SQPSETTINGSDIALOG_H
2 #define SCIQLOP_SQPSETTINGSDIALOG_H
3
4 #include "Settings/ISqpSettingsBindable.h"
5
6 #include <QDialog>
7
8 namespace Ui {
9 class SqpSettingsDialog;
10 } // Ui
11
12 /**
13 * @brief The SqpSettingsDialog class represents the dialog in which the parameters of SciQlop are
14 * set
15 */
16 class SqpSettingsDialog : public QDialog {
17 Q_OBJECT
18
19 public:
20 explicit SqpSettingsDialog(QWidget *parent = 0);
21 virtual ~SqpSettingsDialog() noexcept;
22
23 private:
24 Ui::SqpSettingsDialog *ui;
25 };
26
27 #endif // SCIQLOP_SQPSETTINGSDIALOG_H
@@ -0,0 +1,17
1 #include "Settings/SqpSettingsDialog.h"
2 #include "ui_SqpSettingsDialog.h"
3
4 SqpSettingsDialog::SqpSettingsDialog(QWidget *parent)
5 : QDialog{parent}, ui{new Ui::SqpSettingsDialog}
6 {
7 ui->setupUi(this);
8
9 // Connection to change the current page to the selection of an entry in the list
10 connect(ui->listWidget, &QListWidget::currentRowChanged, ui->stackedWidget,
11 &QStackedWidget::setCurrentIndex);
12 }
13
14 SqpSettingsDialog::~SqpSettingsDialog() noexcept
15 {
16 delete ui;
17 }
@@ -0,0 +1,84
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
3 <class>SqpSettingsDialog</class>
4 <widget class="QDialog" name="SqpSettingsDialog">
5 <property name="geometry">
6 <rect>
7 <x>0</x>
8 <y>0</y>
9 <width>572</width>
10 <height>394</height>
11 </rect>
12 </property>
13 <property name="windowTitle">
14 <string>SciQlop Settings</string>
15 </property>
16 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
18 <widget class="QListWidget" name="listWidget">
19 <property name="sizePolicy">
20 <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
21 <horstretch>0</horstretch>
22 <verstretch>0</verstretch>
23 </sizepolicy>
24 </property>
25 </widget>
26 </item>
27 <item row="0" column="1">
28 <widget class="QStackedWidget" name="stackedWidget">
29 <property name="sizePolicy">
30 <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
31 <horstretch>0</horstretch>
32 <verstretch>0</verstretch>
33 </sizepolicy>
34 </property>
35 </widget>
36 </item>
37 <item row="1" column="0" colspan="2">
38 <widget class="QDialogButtonBox" name="buttonBox">
39 <property name="orientation">
40 <enum>Qt::Horizontal</enum>
41 </property>
42 <property name="standardButtons">
43 <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
44 </property>
45 </widget>
46 </item>
47 </layout>
48 </widget>
49 <resources/>
50 <connections>
51 <connection>
52 <sender>buttonBox</sender>
53 <signal>accepted()</signal>
54 <receiver>SqpSettingsDialog</receiver>
55 <slot>accept()</slot>
56 <hints>
57 <hint type="sourcelabel">
58 <x>248</x>
59 <y>254</y>
60 </hint>
61 <hint type="destinationlabel">
62 <x>157</x>
63 <y>274</y>
64 </hint>
65 </hints>
66 </connection>
67 <connection>
68 <sender>buttonBox</sender>
69 <signal>rejected()</signal>
70 <receiver>SqpSettingsDialog</receiver>
71 <slot>reject()</slot>
72 <hints>
73 <hint type="sourcelabel">
74 <x>316</x>
75 <y>260</y>
76 </hint>
77 <hint type="destinationlabel">
78 <x>286</x>
79 <y>274</y>
80 </hint>
81 </hints>
82 </connection>
83 </connections>
84 </ui>
@@ -1,214 +1,236
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 <DataSource/DataSourceController.h>
25 #include <DataSource/DataSourceController.h>
26 #include <DataSource/DataSourceWidget.h>
26 #include <DataSource/DataSourceWidget.h>
27 #include <Settings/SqpSettingsDialog.h>
27 #include <SidePane/SqpSidePane.h>
28 #include <SidePane/SqpSidePane.h>
28 #include <SqpApplication.h>
29 #include <SqpApplication.h>
29 #include <Time/TimeController.h>
30 #include <Time/TimeController.h>
30 #include <TimeWidget/TimeWidget.h>
31 #include <TimeWidget/TimeWidget.h>
31 #include <Variable/Variable.h>
32 #include <Variable/Variable.h>
32 #include <Variable/VariableController.h>
33 #include <Variable/VariableController.h>
33 #include <Visualization/VisualizationController.h>
34 #include <Visualization/VisualizationController.h>
34
35
35 #include <QAction>
36 #include <QAction>
36 #include <QDate>
37 #include <QDate>
37 #include <QDateTime>
38 #include <QDateTime>
38 #include <QDir>
39 #include <QDir>
39 #include <QFileDialog>
40 #include <QFileDialog>
40 #include <QToolBar>
41 #include <QToolBar>
41 #include <QToolButton>
42 #include <QToolButton>
42 #include <memory.h>
43 #include <memory.h>
43
44
44 #include "iostream"
45 #include "iostream"
45
46
46 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
47 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
47
48
48 namespace {
49 namespace {
49 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
50 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
50 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
51 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
51 const auto VIEWPLITTERINDEX = 2;
52 const auto VIEWPLITTERINDEX = 2;
52 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
53 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
53 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
54 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
54 }
55 }
55
56
56 class MainWindow::MainWindowPrivate {
57 class MainWindow::MainWindowPrivate {
57 public:
58 public:
59 explicit MainWindowPrivate(MainWindow *mainWindow)
60 : m_LastOpenLeftInspectorSize{},
61 m_LastOpenRightInspectorSize{},
62 m_SettingsDialog{new SqpSettingsDialog{mainWindow}}
63 {
64 }
65
58 QSize m_LastOpenLeftInspectorSize;
66 QSize m_LastOpenLeftInspectorSize;
59 QSize m_LastOpenRightInspectorSize;
67 QSize m_LastOpenRightInspectorSize;
68 /// Settings dialog. MainWindow has the ownership
69 SqpSettingsDialog *m_SettingsDialog;
60 };
70 };
61
71
62 MainWindow::MainWindow(QWidget *parent)
72 MainWindow::MainWindow(QWidget *parent)
63 : QMainWindow{parent},
73 : QMainWindow{parent},
64 m_Ui{new Ui::MainWindow},
74 m_Ui{new Ui::MainWindow},
65 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
75 impl{spimpl::make_unique_impl<MainWindowPrivate>(this)}
66 {
76 {
67 m_Ui->setupUi(this);
77 m_Ui->setupUi(this);
68
78
69 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
79 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
70 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
80 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
71
81
72
82
73 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
83 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
74 auto openLeftInspectorAction = new QAction{QIcon{
84 auto openLeftInspectorAction = new QAction{QIcon{
75 ":/icones/previous.png",
85 ":/icones/previous.png",
76 },
86 },
77 tr("Show/hide the left inspector"), this};
87 tr("Show/hide the left inspector"), this};
78
88
79
89
80 auto spacerLeftTop = new QWidget{};
90 auto spacerLeftTop = new QWidget{};
81 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
91 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
82
92
83 auto spacerLeftBottom = new QWidget{};
93 auto spacerLeftBottom = new QWidget{};
84 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
94 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
85
95
86 leftSidePane->addWidget(spacerLeftTop);
96 leftSidePane->addWidget(spacerLeftTop);
87 leftSidePane->addAction(openLeftInspectorAction);
97 leftSidePane->addAction(openLeftInspectorAction);
88 leftSidePane->addWidget(spacerLeftBottom);
98 leftSidePane->addWidget(spacerLeftBottom);
89
99
90
100
91 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
101 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
92 auto openRightInspectorAction = new QAction{QIcon{
102 auto openRightInspectorAction = new QAction{QIcon{
93 ":/icones/next.png",
103 ":/icones/next.png",
94 },
104 },
95 tr("Show/hide the right inspector"), this};
105 tr("Show/hide the right inspector"), this};
96
106
97 auto spacerRightTop = new QWidget{};
107 auto spacerRightTop = new QWidget{};
98 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
108 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
99
109
100 auto spacerRightBottom = new QWidget{};
110 auto spacerRightBottom = new QWidget{};
101 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
111 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
102
112
103 rightSidePane->addWidget(spacerRightTop);
113 rightSidePane->addWidget(spacerRightTop);
104 rightSidePane->addAction(openRightInspectorAction);
114 rightSidePane->addAction(openRightInspectorAction);
105 rightSidePane->addWidget(spacerRightBottom);
115 rightSidePane->addWidget(spacerRightBottom);
106
116
107 openLeftInspectorAction->setCheckable(true);
117 openLeftInspectorAction->setCheckable(true);
108 openRightInspectorAction->setCheckable(true);
118 openRightInspectorAction->setCheckable(true);
109
119
110 auto openInspector = [this](bool checked, bool right, auto action) {
120 auto openInspector = [this](bool checked, bool right, auto action) {
111
121
112 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
122 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
113
123
114 auto &lastInspectorSize
124 auto &lastInspectorSize
115 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
125 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
116
126
117 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
127 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
118 : m_Ui->leftMainInspectorWidget->size();
128 : m_Ui->leftMainInspectorWidget->size();
119
129
120 // Update of the last opened geometry
130 // Update of the last opened geometry
121 if (checked) {
131 if (checked) {
122 lastInspectorSize = nextInspectorSize;
132 lastInspectorSize = nextInspectorSize;
123 }
133 }
124
134
125 auto startSize = lastInspectorSize;
135 auto startSize = lastInspectorSize;
126 auto endSize = startSize;
136 auto endSize = startSize;
127 endSize.setWidth(0);
137 endSize.setWidth(0);
128
138
129 auto splitterInspectorIndex
139 auto splitterInspectorIndex
130 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
140 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
131
141
132 auto currentSizes = m_Ui->splitter->sizes();
142 auto currentSizes = m_Ui->splitter->sizes();
133 if (checked) {
143 if (checked) {
134 // adjust sizes individually here, e.g.
144 // adjust sizes individually here, e.g.
135 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
145 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
136 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
146 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
137 m_Ui->splitter->setSizes(currentSizes);
147 m_Ui->splitter->setSizes(currentSizes);
138 }
148 }
139 else {
149 else {
140 // adjust sizes individually here, e.g.
150 // adjust sizes individually here, e.g.
141 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
151 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
142 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
152 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
143 m_Ui->splitter->setSizes(currentSizes);
153 m_Ui->splitter->setSizes(currentSizes);
144 }
154 }
145
155
146 };
156 };
147
157
148
158
149 connect(openLeftInspectorAction, &QAction::triggered,
159 connect(openLeftInspectorAction, &QAction::triggered,
150 [openInspector, openLeftInspectorAction](bool checked) {
160 [openInspector, openLeftInspectorAction](bool checked) {
151 openInspector(checked, false, openLeftInspectorAction);
161 openInspector(checked, false, openLeftInspectorAction);
152 });
162 });
153 connect(openRightInspectorAction, &QAction::triggered,
163 connect(openRightInspectorAction, &QAction::triggered,
154 [openInspector, openRightInspectorAction](bool checked) {
164 [openInspector, openRightInspectorAction](bool checked) {
155 openInspector(checked, true, openRightInspectorAction);
165 openInspector(checked, true, openRightInspectorAction);
156 });
166 });
157
167
168 // //// //
169 // Menu //
170 // //// //
158 this->menuBar()->addAction(tr("File"));
171 this->menuBar()->addAction(tr("File"));
172 auto toolsMenu = this->menuBar()->addMenu(tr("Tools"));
173 toolsMenu->addAction(tr("Settings..."), [this]() {
174 impl->m_SettingsDialog->exec();
175 });
176
159 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
177 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
160
178
161 auto timeWidget = new TimeWidget{};
179 auto timeWidget = new TimeWidget{};
162 mainToolBar->addWidget(timeWidget);
180 mainToolBar->addWidget(timeWidget);
163
181
182 // /////////// //
183 // Connections //
184 // /////////// //
185
164 // Controllers / controllers connections
186 // Controllers / controllers connections
165 connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)),
187 connect(&sqpApp->timeController(), SIGNAL(timeUpdated(SqpDateTime)),
166 &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime)));
188 &sqpApp->variableController(), SLOT(onDateTimeOnSelection(SqpDateTime)));
167
189
168 // Widgets / controllers connections
190 // Widgets / controllers connections
169
191
170 // DataSource
192 // DataSource
171 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
193 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
172 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
194 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
173
195
174 // Time
196 // Time
175 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
197 connect(timeWidget, SIGNAL(timeUpdated(SqpDateTime)), &sqpApp->timeController(),
176 SLOT(onTimeToUpdate(SqpDateTime)));
198 SLOT(onTimeToUpdate(SqpDateTime)));
177
199
178 // Visualization
200 // Visualization
179 connect(&sqpApp->visualizationController(),
201 connect(&sqpApp->visualizationController(),
180 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view,
202 SIGNAL(variableAboutToBeDeleted(std::shared_ptr<Variable>)), m_Ui->view,
181 SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>)));
203 SLOT(onVariableAboutToBeDeleted(std::shared_ptr<Variable>)));
182
204
183 connect(&sqpApp->visualizationController(),
205 connect(&sqpApp->visualizationController(),
184 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpDateTime &)), m_Ui->view,
206 SIGNAL(rangeChanged(std::shared_ptr<Variable>, const SqpDateTime &)), m_Ui->view,
185 SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpDateTime &)));
207 SLOT(onRangeChanged(std::shared_ptr<Variable>, const SqpDateTime &)));
186
208
187 // Widgets / widgets connections
209 // Widgets / widgets connections
188
210
189 // For the following connections, we use DirectConnection to allow each widget that can
211 // For the following connections, we use DirectConnection to allow each widget that can
190 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
212 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
191 // The order of connections is also important, since it determines the order in which each
213 // The order of connections is also important, since it determines the order in which each
192 // widget will attach its menu
214 // widget will attach its menu
193 connect(
215 connect(
194 m_Ui->variableInspectorWidget,
216 m_Ui->variableInspectorWidget,
195 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
217 SIGNAL(tableMenuAboutToBeDisplayed(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
196 m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
218 m_Ui->view, SLOT(attachVariableMenu(QMenu *, const QVector<std::shared_ptr<Variable> > &)),
197 Qt::DirectConnection);
219 Qt::DirectConnection);
198 }
220 }
199
221
200 MainWindow::~MainWindow()
222 MainWindow::~MainWindow()
201 {
223 {
202 }
224 }
203
225
204 void MainWindow::changeEvent(QEvent *e)
226 void MainWindow::changeEvent(QEvent *e)
205 {
227 {
206 QMainWindow::changeEvent(e);
228 QMainWindow::changeEvent(e);
207 switch (e->type()) {
229 switch (e->type()) {
208 case QEvent::LanguageChange:
230 case QEvent::LanguageChange:
209 m_Ui->retranslateUi(this);
231 m_Ui->retranslateUi(this);
210 break;
232 break;
211 default:
233 default:
212 break;
234 break;
213 }
235 }
214 }
236 }
General Comments 0
You need to be logged in to leave comments. Login now