##// END OF EJS Templates
Can hide all dock widgets and gave main tool bar a name...
jeandet -
r1499:1c0fd6e997a0
parent child
Show More
@@ -1,203 +1,204
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 <Catalogue2/browser.h>
26 #include <Catalogue2/browser.h>
27 #include <DataSource/DataSourceItem.h>
27 #include <DataSource/DataSourceItem.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
35
36 #include "toolbar.h"
36 #include "toolbar.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
48
49 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
49 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
50
50
51 class MainWindow::MainWindowPrivate
51 class MainWindow::MainWindowPrivate
52 {
52 {
53 public:
53 public:
54 explicit MainWindowPrivate(MainWindow* mainWindow)
54 explicit MainWindowPrivate(MainWindow* mainWindow)
55 : m_GeneralSettingsWidget { new SqpSettingsGeneralWidget { mainWindow } }
55 : m_GeneralSettingsWidget { new SqpSettingsGeneralWidget { mainWindow } }
56 , m_SettingsDialog { new SqpSettingsDialog { mainWindow } }
56 , m_SettingsDialog { new SqpSettingsDialog { mainWindow } }
57 , m_CatalogExplorer { new CataloguesBrowser { mainWindow } }
57 , m_CatalogExplorer { new CataloguesBrowser { mainWindow } }
58 {
58 {
59 }
59 }
60
60
61 /// General settings widget. MainWindow has the ownership
61 /// General settings widget. MainWindow has the ownership
62 SqpSettingsGeneralWidget* m_GeneralSettingsWidget;
62 SqpSettingsGeneralWidget* m_GeneralSettingsWidget;
63 /// Settings dialog. MainWindow has the ownership
63 /// Settings dialog. MainWindow has the ownership
64 SqpSettingsDialog* m_SettingsDialog;
64 SqpSettingsDialog* m_SettingsDialog;
65 /// Catalogue dialog. MainWindow has the ownership
65 /// Catalogue dialog. MainWindow has the ownership
66 CataloguesBrowser* m_CatalogExplorer;
66 CataloguesBrowser* m_CatalogExplorer;
67
67
68 bool checkDataToSave(QWidget* parentWidget);
68 bool checkDataToSave(QWidget* parentWidget);
69 };
69 };
70
70
71 MainWindow::MainWindow(QWidget* parent)
71 MainWindow::MainWindow(QWidget* parent)
72 : QMainWindow { parent }
72 : QMainWindow { parent }
73 , m_Ui { new Ui::MainWindow }
73 , m_Ui { new Ui::MainWindow }
74 , impl { spimpl::make_unique_impl<MainWindowPrivate>(this) }
74 , impl { spimpl::make_unique_impl<MainWindowPrivate>(this) }
75 {
75 {
76 m_Ui->setupUi(this);
76 m_Ui->setupUi(this);
77 setWindowTitle(QString("SciQLop v%1").arg(SCIQLOP_VERSION));
77 setWindowTitle(QString("SciQLop v%1").arg(SCIQLOP_VERSION));
78
78
79 // //////////////// //
79 // //////////////// //
80 // Menu and Toolbar //
80 // Menu and Toolbar //
81 // //////////////// //
81 // //////////////// //
82 this->menuBar()->addAction(tr("File"));
82 this->menuBar()->addAction(tr("File"));
83 auto toolsMenu = this->menuBar()->addMenu(tr("Tools"));
83 auto toolsMenu = this->menuBar()->addMenu(tr("Tools"));
84 toolsMenu->addAction(tr("Settings..."), [this]() {
84 toolsMenu->addAction(tr("Settings..."), [this]() {
85 // Loads settings
85 // Loads settings
86 impl->m_SettingsDialog->loadSettings();
86 impl->m_SettingsDialog->loadSettings();
87
87
88 // Open settings dialog and save settings if the dialog is accepted
88 // Open settings dialog and save settings if the dialog is accepted
89 if (impl->m_SettingsDialog->exec() == QDialog::Accepted)
89 if (impl->m_SettingsDialog->exec() == QDialog::Accepted)
90 {
90 {
91 impl->m_SettingsDialog->saveSettings();
91 impl->m_SettingsDialog->saveSettings();
92 }
92 }
93 });
93 });
94 auto mainToolBar = new ToolBar(this);
94 auto mainToolBar = new ToolBar(this);
95 mainToolBar->setWindowTitle("Tool bar");
95 this->addToolBar(mainToolBar);
96 this->addToolBar(mainToolBar);
96 connect(mainToolBar, &ToolBar::setPlotsInteractionMode, sqpApp,
97 connect(mainToolBar, &ToolBar::setPlotsInteractionMode, sqpApp,
97 &SqpApplication::setPlotsInteractionMode);
98 &SqpApplication::setPlotsInteractionMode);
98 connect(mainToolBar, &ToolBar::setPlotsCursorMode, sqpApp, &SqpApplication::setPlotsCursorMode);
99 connect(mainToolBar, &ToolBar::setPlotsCursorMode, sqpApp, &SqpApplication::setPlotsCursorMode);
99 connect(mainToolBar, &ToolBar::showCataloguesBrowser,
100 connect(mainToolBar, &ToolBar::showCataloguesBrowser,
100 [this]() { impl->m_CatalogExplorer->show(); });
101 [this]() { impl->m_CatalogExplorer->show(); });
101
102
102 // //////// //
103 // //////// //
103 // Settings //
104 // Settings //
104 // //////// //
105 // //////// //
105
106
106 // Registers "general settings" widget to the settings dialog
107 // Registers "general settings" widget to the settings dialog
107 impl->m_SettingsDialog->registerWidget(
108 impl->m_SettingsDialog->registerWidget(
108 QStringLiteral("General"), impl->m_GeneralSettingsWidget);
109 QStringLiteral("General"), impl->m_GeneralSettingsWidget);
109
110
110 // /////////// //
111 // /////////// //
111 // Connections //
112 // Connections //
112 // /////////// //
113 // /////////// //
113
114
114 // Widgets / controllers connections
115 // Widgets / controllers connections
115
116
116 // Time
117 // Time
117 // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(),
118 // connect(timeWidget, SIGNAL(timeUpdated(DateTimeRange)), &sqpApp->timeController(),
118 // SLOT(onTimeToUpdate(DateTimeRange)));
119 // SLOT(onTimeToUpdate(DateTimeRange)));
119 connect(mainToolBar, &ToolBar::timeUpdated, &sqpApp->timeController(),
120 connect(mainToolBar, &ToolBar::timeUpdated, &sqpApp->timeController(),
120 &TimeController::setDateTimeRange);
121 &TimeController::setDateTimeRange);
121
122
122 // Widgets / widgets connections
123 // Widgets / widgets connections
123
124
124 // For the following connections, we use DirectConnection to allow each widget that can
125 // For the following connections, we use DirectConnection to allow each widget that can
125 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
126 // potentially attach a menu to the variable's menu to do so before this menu is displayed.
126 // The order of connections is also important, since it determines the order in which each
127 // The order of connections is also important, since it determines the order in which each
127 // widget will attach its menu
128 // widget will attach its menu
128 connect(m_Ui->variableInspectorWidget,
129 connect(m_Ui->variableInspectorWidget,
129 SIGNAL(tableMenuAboutToBeDisplayed(QMenu*, const QVector<std::shared_ptr<Variable>>&)),
130 SIGNAL(tableMenuAboutToBeDisplayed(QMenu*, const QVector<std::shared_ptr<Variable>>&)),
130 m_Ui->view, SLOT(attachVariableMenu(QMenu*, const QVector<std::shared_ptr<Variable>>&)),
131 m_Ui->view, SLOT(attachVariableMenu(QMenu*, const QVector<std::shared_ptr<Variable>>&)),
131 Qt::DirectConnection);
132 Qt::DirectConnection);
132 }
133 }
133
134
134 MainWindow::~MainWindow() {}
135 MainWindow::~MainWindow() {}
135
136
136 void MainWindow::changeEvent(QEvent* e)
137 void MainWindow::changeEvent(QEvent* e)
137 {
138 {
138 QMainWindow::changeEvent(e);
139 QMainWindow::changeEvent(e);
139 switch (e->type())
140 switch (e->type())
140 {
141 {
141 case QEvent::LanguageChange:
142 case QEvent::LanguageChange:
142 m_Ui->retranslateUi(this);
143 m_Ui->retranslateUi(this);
143 break;
144 break;
144 default:
145 default:
145 break;
146 break;
146 }
147 }
147 }
148 }
148
149
149 void MainWindow::closeEvent(QCloseEvent* event)
150 void MainWindow::closeEvent(QCloseEvent* event)
150 {
151 {
151 if (!impl->checkDataToSave(this))
152 if (!impl->checkDataToSave(this))
152 {
153 {
153 event->ignore();
154 event->ignore();
154 }
155 }
155 else
156 else
156 {
157 {
157 event->accept();
158 event->accept();
158 }
159 }
159 }
160 }
160
161
161 void MainWindow::keyPressEvent(QKeyEvent* event)
162 void MainWindow::keyPressEvent(QKeyEvent* event)
162 {
163 {
163 switch (event->key())
164 switch (event->key())
164 {
165 {
165 case Qt::Key_F11:
166 case Qt::Key_F11:
166 if (this->isFullScreen())
167 if (this->isFullScreen())
167 {
168 {
168 this->showNormal();
169 this->showNormal();
169 }
170 }
170 else
171 else
171 {
172 {
172 this->showFullScreen();
173 this->showFullScreen();
173 }
174 }
174 break;
175 break;
175 default:
176 default:
176 break;
177 break;
177 }
178 }
178 }
179 }
179
180
180 bool MainWindow::MainWindowPrivate::checkDataToSave(QWidget* parentWidget)
181 bool MainWindow::MainWindowPrivate::checkDataToSave(QWidget* parentWidget)
181 {
182 {
182 // auto hasChanges = sqpApp->catalogueController().hasChanges();
183 // auto hasChanges = sqpApp->catalogueController().hasChanges();
183 // if (hasChanges)
184 // if (hasChanges)
184 // {
185 // {
185 // // There are some unsaved changes
186 // // There are some unsaved changes
186 // switch (QMessageBox::question(parentWidget, tr("Save changes"),
187 // switch (QMessageBox::question(parentWidget, tr("Save changes"),
187 // tr("The catalogue controller has unsaved changes.\nDo you want to save them ?"),
188 // tr("The catalogue controller has unsaved changes.\nDo you want to save them ?"),
188 // QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel,
189 // QMessageBox::SaveAll | QMessageBox::Discard | QMessageBox::Cancel,
189 // QMessageBox::SaveAll))
190 // QMessageBox::SaveAll))
190 // {
191 // {
191 // case QMessageBox::SaveAll:
192 // case QMessageBox::SaveAll:
192 // sqpApp->catalogueController().saveAll();
193 // sqpApp->catalogueController().saveAll();
193 // break;
194 // break;
194 // case QMessageBox::Discard:
195 // case QMessageBox::Discard:
195 // break;
196 // break;
196 // case QMessageBox::Cancel:
197 // case QMessageBox::Cancel:
197 // default:
198 // default:
198 // return false;
199 // return false;
199 // }
200 // }
200 // }
201 // }
201
202
202 return true;
203 return true;
203 }
204 }
@@ -1,110 +1,113
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</string>
14 <string>SciQlop</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="VisualizationWidget" name="view">
19 <widget class="VisualizationWidget" name="view">
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 </widget>
35 </widget>
36 <widget class="QMenuBar" name="menuBar">
36 <widget class="QMenuBar" name="menuBar">
37 <property name="geometry">
37 <property name="geometry">
38 <rect>
38 <rect>
39 <x>0</x>
39 <x>0</x>
40 <y>0</y>
40 <y>0</y>
41 <width>800</width>
41 <width>800</width>
42 <height>24</height>
42 <height>29</height>
43 </rect>
43 </rect>
44 </property>
44 </property>
45 <property name="sizePolicy">
45 <property name="sizePolicy">
46 <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
46 <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
47 <horstretch>0</horstretch>
47 <horstretch>0</horstretch>
48 <verstretch>0</verstretch>
48 <verstretch>0</verstretch>
49 </sizepolicy>
49 </sizepolicy>
50 </property>
50 </property>
51 <property name="minimumSize">
51 <property name="minimumSize">
52 <size>
52 <size>
53 <width>0</width>
53 <width>0</width>
54 <height>0</height>
54 <height>0</height>
55 </size>
55 </size>
56 </property>
56 </property>
57 <property name="accessibleName">
58 <string/>
59 </property>
57 <property name="nativeMenuBar">
60 <property name="nativeMenuBar">
58 <bool>true</bool>
61 <bool>true</bool>
59 </property>
62 </property>
60 </widget>
63 </widget>
61 <widget class="QStatusBar" name="statusBar"/>
64 <widget class="QStatusBar" name="statusBar"/>
62 <widget class="QDockWidget" name="dockWidget">
65 <widget class="QDockWidget" name="dockWidget">
63 <property name="features">
66 <property name="features">
64 <set>QDockWidget::DockWidgetMovable</set>
67 <set>QDockWidget::AllDockWidgetFeatures</set>
65 </property>
68 </property>
66 <property name="windowTitle">
69 <property name="windowTitle">
67 <string>Products</string>
70 <string>Products</string>
68 </property>
71 </property>
69 <attribute name="dockWidgetArea">
72 <attribute name="dockWidgetArea">
70 <number>1</number>
73 <number>1</number>
71 </attribute>
74 </attribute>
72 <widget class="DataSourceWidget" name="dataSourceWidget"/>
75 <widget class="DataSourceWidget" name="dataSourceWidget"/>
73 </widget>
76 </widget>
74 <widget class="QDockWidget" name="dockWidget_2">
77 <widget class="QDockWidget" name="dockWidget_2">
75 <property name="features">
78 <property name="features">
76 <set>QDockWidget::DockWidgetMovable</set>
79 <set>QDockWidget::AllDockWidgetFeatures</set>
77 </property>
80 </property>
78 <property name="windowTitle">
81 <property name="windowTitle">
79 <string>Variables</string>
82 <string>Variables</string>
80 </property>
83 </property>
81 <attribute name="dockWidgetArea">
84 <attribute name="dockWidgetArea">
82 <number>1</number>
85 <number>1</number>
83 </attribute>
86 </attribute>
84 <widget class="VariableInspectorWidget" name="variableInspectorWidget"/>
87 <widget class="VariableInspectorWidget" name="variableInspectorWidget"/>
85 </widget>
88 </widget>
86 </widget>
89 </widget>
87 <layoutdefault spacing="6" margin="11"/>
90 <layoutdefault spacing="6" margin="11"/>
88 <customwidgets>
91 <customwidgets>
89 <customwidget>
92 <customwidget>
90 <class>VisualizationWidget</class>
93 <class>VisualizationWidget</class>
91 <extends>QWidget</extends>
94 <extends>QWidget</extends>
92 <header location="global">Visualization/VisualizationWidget.h</header>
95 <header location="global">Visualization/VisualizationWidget.h</header>
93 <container>1</container>
96 <container>1</container>
94 </customwidget>
97 </customwidget>
95 <customwidget>
98 <customwidget>
96 <class>DataSourceWidget</class>
99 <class>DataSourceWidget</class>
97 <extends>QWidget</extends>
100 <extends>QWidget</extends>
98 <header location="global">DataSource/DataSourceWidget.h</header>
101 <header location="global">DataSource/DataSourceWidget.h</header>
99 <container>1</container>
102 <container>1</container>
100 </customwidget>
103 </customwidget>
101 <customwidget>
104 <customwidget>
102 <class>VariableInspectorWidget</class>
105 <class>VariableInspectorWidget</class>
103 <extends>QWidget</extends>
106 <extends>QWidget</extends>
104 <header location="global">Variable/VariableInspectorWidget.h</header>
107 <header location="global">Variable/VariableInspectorWidget.h</header>
105 <container>1</container>
108 <container>1</container>
106 </customwidget>
109 </customwidget>
107 </customwidgets>
110 </customwidgets>
108 <resources/>
111 <resources/>
109 <connections/>
112 <connections/>
110 </ui>
113 </ui>
General Comments 0
You need to be logged in to leave comments. Login now