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