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