##// END OF EJS Templates
Modificaiton of the sidepane :...
perrinel -
r125:3457b4e96a14
parent child
Show More
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -1,224 +1,276
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 <SidePane/SqpSidePane.h>
27 #include <SidePane/SqpSidePane.h>
28 #include <SqpApplication.h>
28 #include <SqpApplication.h>
29 #include <TimeWidget/TimeWidget.h>
29
30
30 #include <QAction>
31 #include <QAction>
31 #include <QDate>
32 #include <QDate>
32 #include <QDateTime>
33 #include <QDateTime>
33 #include <QDir>
34 #include <QDir>
34 #include <QFileDialog>
35 #include <QFileDialog>
35 #include <QToolBar>
36 #include <QToolBar>
36 #include <memory.h>
37 #include <memory.h>
37
38
38 //#include <omp.h>
39 //#include <omp.h>
39 //#include <network/filedownloader.h>
40 //#include <network/filedownloader.h>
40 //#include <qlopdatabase.h>
41 //#include <qlopdatabase.h>
41 //#include <qlopsettings.h>
42 //#include <qlopsettings.h>
42 //#include <qlopgui.h>
43 //#include <qlopgui.h>
43 //#include <spacedata.h>
44 //#include <spacedata.h>
44 //#include "qlopcore.h"
45 //#include "qlopcore.h"
45 //#include "qlopcodecmanager.h"
46 //#include "qlopcodecmanager.h"
46 //#include "cdfcodec.h"
47 //#include "cdfcodec.h"
47 //#include "amdatxtcodec.h"
48 //#include "amdatxtcodec.h"
48 //#include <qlopplotmanager.h>
49 //#include <qlopplotmanager.h>
49
50
50 #include "iostream"
51 #include "iostream"
51
52
52 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
53 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
53
54
54 namespace {
55 namespace {
55 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
56 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
56 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
57 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
57 const auto VIEWPLITTERINDEX = 2;
58 const auto VIEWPLITTERINDEX = 2;
58 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
59 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
59 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
60 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
60 }
61 }
61
62
62 class MainWindow::MainWindowPrivate {
63 class MainWindow::MainWindowPrivate {
63 public:
64 public:
64 QSize m_LastOpenLeftInspectorSize;
65 QSize m_LastOpenLeftInspectorSize;
65 QSize m_LastOpenRightInspectorSize;
66 QSize m_LastOpenRightInspectorSize;
66 };
67 };
67
68
68 MainWindow::MainWindow(QWidget *parent)
69 MainWindow::MainWindow(QWidget *parent)
69 : QMainWindow{parent},
70 : QMainWindow{parent},
70 m_Ui{new Ui::MainWindow},
71 m_Ui{new Ui::MainWindow},
71 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
72 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
72 {
73 {
73 m_Ui->setupUi(this);
74 m_Ui->setupUi(this);
74
75
75 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
76 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
76 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
77 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
77
78
79
80 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
81 auto openLeftInspectorAction = new QAction(
note

ok

82 QIcon{
83 ":/icones/previous.png",
84 },
85 tr("Show/hide the left inspector"), this);
86
87
88 QWidget *spacerLeftTop = new QWidget();
89 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
90
91 QWidget *spacerLeftBottom = new QWidget();
92 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
93
94 leftSidePane->addWidget(spacerLeftTop);
95 leftSidePane->addAction(openLeftInspectorAction);
96 leftSidePane->addWidget(spacerLeftBottom);
97
98
99 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
100 auto openRightInspectorAction = new QAction(
101 QIcon{
102 ":/icones/next.png",
103 },
104 tr("Show/hide the right inspector"), this);
105
106 QWidget *spacerRightTop = new QWidget();
107 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
108
109 QWidget *spacerRightBottom = new QWidget();
note

ok

110 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
111
112 rightSidePane->addWidget(spacerRightTop);
113 rightSidePane->addAction(openRightInspectorAction);
114 rightSidePane->addWidget(spacerRightBottom);
115
116 openLeftInspectorAction->setCheckable(true);
117 openRightInspectorAction->setCheckable(true);
118
119
78 // NOTE: These lambda could be factorized. Be careful of theirs parameters
120 // NOTE: These lambda could be factorized. Be careful of theirs parameters
79 // Lambda that defines what's happened when clicking on the leftSidePaneInspector open button
121 // Lambda that defines what's happened when clicking on the leftSidePaneInspector open button
80 auto openLeftInspector = [this](bool checked) {
122 auto openLeftInspector = [this, openLeftInspectorAction](bool checked) {
123
124 if (checked) {
125 openLeftInspectorAction->setIcon(QIcon{
126 ":/icones/next.png",
127 });
128 }
129 else {
130 openLeftInspectorAction->setIcon(QIcon{
131 ":/icones/previous.png",
132 });
133 }
81
134
82 // Update of the last opened geometry
135 // Update of the last opened geometry
83 if (checked) {
136 if (checked) {
84 impl->m_LastOpenLeftInspectorSize = m_Ui->leftMainInspectorWidget->size();
137 impl->m_LastOpenLeftInspectorSize = m_Ui->leftMainInspectorWidget->size();
85 }
138 }
86
139
87 auto startSize = impl->m_LastOpenLeftInspectorSize;
140 auto startSize = impl->m_LastOpenLeftInspectorSize;
88 auto endSize = startSize;
141 auto endSize = startSize;
89 endSize.setWidth(0);
142 endSize.setWidth(0);
90
143
91 auto currentSizes = m_Ui->splitter->sizes();
144 auto currentSizes = m_Ui->splitter->sizes();
92 if (checked) {
145 if (checked) {
93 // adjust sizes individually here, e.g.
146 // adjust sizes individually here, e.g.
94 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
147 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
95 -= impl->m_LastOpenLeftInspectorSize.width();
148 -= impl->m_LastOpenLeftInspectorSize.width();
96 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenLeftInspectorSize.width();
149 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenLeftInspectorSize.width();
97 m_Ui->splitter->setSizes(currentSizes);
150 m_Ui->splitter->setSizes(currentSizes);
98 }
151 }
99 else {
152 else {
100 // adjust sizes individually here, e.g.
153 // adjust sizes individually here, e.g.
101 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
154 currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX]
102 += impl->m_LastOpenLeftInspectorSize.width();
155 += impl->m_LastOpenLeftInspectorSize.width();
103 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenLeftInspectorSize.width();
156 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenLeftInspectorSize.width();
104 m_Ui->splitter->setSizes(currentSizes);
157 m_Ui->splitter->setSizes(currentSizes);
105 }
158 }
106
159
107 };
160 };
108
161
109 // Lambda that defines what's happened when clicking on the SidePaneInspector open button
162 // Lambda that defines what's happened when clicking on the SidePaneInspector open button
110 auto openRightInspector = [this](bool checked) {
163 auto openRightInspector = [this, openRightInspectorAction](bool checked) {
164
165 if (checked) {
166 openRightInspectorAction->setIcon(QIcon{
167 ":/icones/previous.png",
168 });
169 }
170 else {
171 openRightInspectorAction->setIcon(QIcon{
172 ":/icones/next.png",
173 });
174 }
175
111
176
112 // Update of the last opened geometry
177 // Update of the last opened geometry
113 if (checked) {
178 if (checked) {
114 impl->m_LastOpenRightInspectorSize = m_Ui->rightMainInspectorWidget->size();
179 impl->m_LastOpenRightInspectorSize = m_Ui->rightMainInspectorWidget->size();
115 }
180 }
116
181
117 auto startSize = impl->m_LastOpenRightInspectorSize;
182 auto startSize = impl->m_LastOpenRightInspectorSize;
118 auto endSize = startSize;
183 auto endSize = startSize;
119 endSize.setWidth(0);
184 endSize.setWidth(0);
120
185
121 auto currentSizes = m_Ui->splitter->sizes();
186 auto currentSizes = m_Ui->splitter->sizes();
122 if (checked) {
187 if (checked) {
123 // adjust sizes individually here, e.g.
188 // adjust sizes individually here, e.g.
124 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
189 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
125 -= impl->m_LastOpenRightInspectorSize.width();
190 -= impl->m_LastOpenRightInspectorSize.width();
126 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenRightInspectorSize.width();
191 currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenRightInspectorSize.width();
127 m_Ui->splitter->setSizes(currentSizes);
192 m_Ui->splitter->setSizes(currentSizes);
128 }
193 }
129 else {
194 else {
130 // adjust sizes individually here, e.g.
195 // adjust sizes individually here, e.g.
131 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
196 currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX]
132 += impl->m_LastOpenRightInspectorSize.width();
197 += impl->m_LastOpenRightInspectorSize.width();
133 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenRightInspectorSize.width();
198 currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenRightInspectorSize.width();
134 m_Ui->splitter->setSizes(currentSizes);
199 m_Ui->splitter->setSizes(currentSizes);
135 }
200 }
136
201
137 };
202 };
138
203
139
204
140 QToolBar *leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
205 connect(openLeftInspectorAction, &QAction::triggered, openLeftInspector);
141 auto openLeftInspectorAction = leftSidePane->addAction(
206 connect(openRightInspectorAction, &QAction::triggered, openRightInspector);
142 QIcon{
143 ":/icones/openInspector.png",
144 },
145 tr("Show/hide the left inspector"), openLeftInspector);
146
147 openLeftInspectorAction->setCheckable(true);
148
149 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
150 auto openRightInspectorAction = rightSidePane->addAction(
151 QIcon{
152 ":/icones/openInspector.png",
153 },
154 tr("Show/hide the right inspector"), openRightInspector);
155
207
156 openRightInspectorAction->setCheckable(true);
157
208
158 this->menuBar()->addAction(tr("File"));
209 this->menuBar()->addAction(tr("File"));
159 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
210 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
160 mainToolBar->addAction(QStringLiteral("A1"));
211
212 mainToolBar->addWidget(new TimeWidget());
note

ok

161
213
162 // Widgets / controllers connections
214 // Widgets / controllers connections
163 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
215 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
164 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
216 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
165
217
166 /* QLopGUI::registerMenuBar(menuBar());
218 /* QLopGUI::registerMenuBar(menuBar());
167 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
219 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
168 this->m_progressWidget = new QWidget();
220 this->m_progressWidget = new QWidget();
169 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
221 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
170 this->m_progressWidget->setLayout(this->m_progressLayout);
222 this->m_progressWidget->setLayout(this->m_progressLayout);
171 this->m_progressWidget->setWindowModality(Qt::WindowModal);
223 this->m_progressWidget->setWindowModality(Qt::WindowModal);
172 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
224 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
173 for(int i=0;i<OMP_THREADS;i++)
225 for(int i=0;i<OMP_THREADS;i++)
174 {
226 {
175 this->m_progress.append(new QProgressBar(this->m_progressWidget));
227 this->m_progress.append(new QProgressBar(this->m_progressWidget));
176 this->m_progress.last()->setMinimum(0);
228 this->m_progress.last()->setMinimum(0);
177 this->m_progress.last()->setMaximum(100);
229 this->m_progress.last()->setMaximum(100);
178 this->m_progressLayout->addWidget(this->m_progress.last());
230 this->m_progressLayout->addWidget(this->m_progress.last());
179 this->m_progressWidget->hide();
231 this->m_progressWidget->hide();
180 this->m_progressThreadIds[i] = -1;
232 this->m_progressThreadIds[i] = -1;
181 }
233 }
182 this->m_progressWidget->setWindowTitle("Loading File");
234 this->m_progressWidget->setWindowTitle("Loading File");
183 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
235 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
184 << QLopCore::self()
236 << QLopCore::self()
185 << QLopPlotManager::self()
237 << QLopPlotManager::self()
186 << QLopCodecManager::self()
238 << QLopCodecManager::self()
187 << FileDownloader::self()
239 << FileDownloader::self()
188 << QLopDataBase::self()
240 << QLopDataBase::self()
189 << SpaceData::self();
241 << SpaceData::self();
190
242
191 CDFCodec::registerToManager();
243 CDFCodec::registerToManager();
192 AMDATXTCodec::registerToManager();
244 AMDATXTCodec::registerToManager();
193
245
194
246
195 for(int i=0;i<ServicesToLoad.count();i++)
247 for(int i=0;i<ServicesToLoad.count();i++)
196 {
248 {
197 qDebug()<<ServicesToLoad.at(i)->serviceName();
249 qDebug()<<ServicesToLoad.at(i)->serviceName();
198 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
250 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
199 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
251 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
200 if(wdgt)
252 if(wdgt)
201 {
253 {
202 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
254 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
203 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
255 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
204 }
256 }
205 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
257 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
206 }*/
258 }*/
207 }
259 }
208
260
209 MainWindow::~MainWindow()
261 MainWindow::~MainWindow()
210 {
262 {
211 }
263 }
212
264
213
265
214 void MainWindow::changeEvent(QEvent *e)
266 void MainWindow::changeEvent(QEvent *e)
215 {
267 {
216 QMainWindow::changeEvent(e);
268 QMainWindow::changeEvent(e);
217 switch (e->type()) {
269 switch (e->type()) {
218 case QEvent::LanguageChange:
270 case QEvent::LanguageChange:
219 m_Ui->retranslateUi(this);
271 m_Ui->retranslateUi(this);
220 break;
272 break;
221 default:
273 default:
222 break;
274 break;
223 }
275 }
224 }
276 }
@@ -1,54 +1,47
1 #include "SidePane/SqpSidePane.h"
1 #include "SidePane/SqpSidePane.h"
2 #include "ui_SqpSidePane.h"
2 #include "ui_SqpSidePane.h"
3
3
4 #include <QAction>
4 #include <QAction>
5 #include <QLayout>
5 #include <QLayout>
6 #include <QToolBar>
6 #include <QToolBar>
7
7
8 namespace {
8 namespace {
9 static const QString SQPSIDEPANESTYLESHEET
9 static const QString SQPSIDEPANESTYLESHEET
10 = "QToolBar {"
10 = "QToolBar {"
11 " background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,"
11 " background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,"
12 " stop: 0.0 #5a5a5a,"
12 " stop: 0.0 #5a5a5a,"
13 " stop: 1.0 #414141);"
13 " stop: 1.0 #414141);"
14 " border: none;"
14 " border: none;"
15 " border-left: 1px solid #424242;"
15 " border-left: 1px solid #424242;"
16 "border-right: 1px solid #393939;"
16 "border-right: 1px solid #393939;"
17 " }"
17 " }"
18
18
19 " QToolButton {"
19 " QToolButton {"
20 "background: none;"
20 "background: none;"
21 "border: none;"
21 "border: none;"
22 " }";
22 " }";
23 }
23 }
24
24
25 SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSidePane}
25 SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSidePane}
26 {
26 {
27 // QVBoxLayout *sidePaneLayout = new QVBoxLayout(this);
27 // QVBoxLayout *sidePaneLayout = new QVBoxLayout(this);
28 // sidePaneLayout->setContentsMargins(0, 0, 0, 0);
28 // sidePaneLayout->setContentsMargins(0, 0, 0, 0);
29 // this->setLayout(sidePaneLayout);
29 // this->setLayout(sidePaneLayout);
30
30
31 ui->setupUi(this);
31 ui->setupUi(this);
32 m_SidePaneToolbar = new QToolBar();
32 m_SidePaneToolbar = new QToolBar();
33 m_SidePaneToolbar->setOrientation(Qt::Vertical);
33 m_SidePaneToolbar->setOrientation(Qt::Vertical);
34 this->layout()->addWidget(m_SidePaneToolbar);
34 this->layout()->addWidget(m_SidePaneToolbar);
35
35
36 m_SidePaneToolbar->setStyleSheet(SQPSIDEPANESTYLESHEET);
36 m_SidePaneToolbar->setStyleSheet(SQPSIDEPANESTYLESHEET);
37
38 this->setStyleSheet(
39 " QWidget {"
40 "background: red;"
41
42 "border: 1px;"
43 " }");
44 }
37 }
45
38
46 SqpSidePane::~SqpSidePane()
39 SqpSidePane::~SqpSidePane()
47 {
40 {
48 delete ui;
41 delete ui;
49 }
42 }
50
43
51 QToolBar *SqpSidePane::sidePane()
44 QToolBar *SqpSidePane::sidePane()
52 {
45 {
53 return m_SidePaneToolbar;
46 return m_SidePaneToolbar;
54 }
47 }
General Comments 0
You need to be logged in to leave comments. Login now