|
1 | NO CONTENT: new file 100644, binary diff hidden |
|
1 | NO CONTENT: new file 100644, binary diff hidden |
@@ -1,224 +1,276 | |||
|
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 <SidePane/SqpSidePane.h> |
|
28 | 28 | #include <SqpApplication.h> |
|
29 | #include <TimeWidget/TimeWidget.h> | |
|
29 | 30 | |
|
30 | 31 | #include <QAction> |
|
31 | 32 | #include <QDate> |
|
32 | 33 | #include <QDateTime> |
|
33 | 34 | #include <QDir> |
|
34 | 35 | #include <QFileDialog> |
|
35 | 36 | #include <QToolBar> |
|
36 | 37 | #include <memory.h> |
|
37 | 38 | |
|
38 | 39 | //#include <omp.h> |
|
39 | 40 | //#include <network/filedownloader.h> |
|
40 | 41 | //#include <qlopdatabase.h> |
|
41 | 42 | //#include <qlopsettings.h> |
|
42 | 43 | //#include <qlopgui.h> |
|
43 | 44 | //#include <spacedata.h> |
|
44 | 45 | //#include "qlopcore.h" |
|
45 | 46 | //#include "qlopcodecmanager.h" |
|
46 | 47 | //#include "cdfcodec.h" |
|
47 | 48 | //#include "amdatxtcodec.h" |
|
48 | 49 | //#include <qlopplotmanager.h> |
|
49 | 50 | |
|
50 | 51 | #include "iostream" |
|
51 | 52 | |
|
52 | 53 | Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow") |
|
53 | 54 | |
|
54 | 55 | namespace { |
|
55 | 56 | const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0; |
|
56 | 57 | const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1; |
|
57 | 58 | const auto VIEWPLITTERINDEX = 2; |
|
58 | 59 | const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3; |
|
59 | 60 | const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4; |
|
60 | 61 | } |
|
61 | 62 | |
|
62 | 63 | class MainWindow::MainWindowPrivate { |
|
63 | 64 | public: |
|
64 | 65 | QSize m_LastOpenLeftInspectorSize; |
|
65 | 66 | QSize m_LastOpenRightInspectorSize; |
|
66 | 67 | }; |
|
67 | 68 | |
|
68 | 69 | MainWindow::MainWindow(QWidget *parent) |
|
69 | 70 | : QMainWindow{parent}, |
|
70 | 71 | m_Ui{new Ui::MainWindow}, |
|
71 | 72 | impl{spimpl::make_unique_impl<MainWindowPrivate>()} |
|
72 | 73 | { |
|
73 | 74 | m_Ui->setupUi(this); |
|
74 | 75 | |
|
75 | 76 | m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
76 | 77 | m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false); |
|
77 | 78 | |
|
79 | ||
|
80 | auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); | |
|
81 | auto openLeftInspectorAction = new QAction( | |
|
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(); | |
|
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 | 120 | // NOTE: These lambda could be factorized. Be careful of theirs parameters |
|
79 | 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 | 135 | // Update of the last opened geometry |
|
83 | 136 | if (checked) { |
|
84 | 137 | impl->m_LastOpenLeftInspectorSize = m_Ui->leftMainInspectorWidget->size(); |
|
85 | 138 | } |
|
86 | 139 | |
|
87 | 140 | auto startSize = impl->m_LastOpenLeftInspectorSize; |
|
88 | 141 | auto endSize = startSize; |
|
89 | 142 | endSize.setWidth(0); |
|
90 | 143 | |
|
91 | 144 | auto currentSizes = m_Ui->splitter->sizes(); |
|
92 | 145 | if (checked) { |
|
93 | 146 | // adjust sizes individually here, e.g. |
|
94 | 147 | currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX] |
|
95 | 148 | -= impl->m_LastOpenLeftInspectorSize.width(); |
|
96 | 149 | currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenLeftInspectorSize.width(); |
|
97 | 150 | m_Ui->splitter->setSizes(currentSizes); |
|
98 | 151 | } |
|
99 | 152 | else { |
|
100 | 153 | // adjust sizes individually here, e.g. |
|
101 | 154 | currentSizes[LEFTMAININSPECTORWIDGETSPLITTERINDEX] |
|
102 | 155 | += impl->m_LastOpenLeftInspectorSize.width(); |
|
103 | 156 | currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenLeftInspectorSize.width(); |
|
104 | 157 | m_Ui->splitter->setSizes(currentSizes); |
|
105 | 158 | } |
|
106 | 159 | |
|
107 | 160 | }; |
|
108 | 161 | |
|
109 | 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 | 177 | // Update of the last opened geometry |
|
113 | 178 | if (checked) { |
|
114 | 179 | impl->m_LastOpenRightInspectorSize = m_Ui->rightMainInspectorWidget->size(); |
|
115 | 180 | } |
|
116 | 181 | |
|
117 | 182 | auto startSize = impl->m_LastOpenRightInspectorSize; |
|
118 | 183 | auto endSize = startSize; |
|
119 | 184 | endSize.setWidth(0); |
|
120 | 185 | |
|
121 | 186 | auto currentSizes = m_Ui->splitter->sizes(); |
|
122 | 187 | if (checked) { |
|
123 | 188 | // adjust sizes individually here, e.g. |
|
124 | 189 | currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX] |
|
125 | 190 | -= impl->m_LastOpenRightInspectorSize.width(); |
|
126 | 191 | currentSizes[VIEWPLITTERINDEX] += impl->m_LastOpenRightInspectorSize.width(); |
|
127 | 192 | m_Ui->splitter->setSizes(currentSizes); |
|
128 | 193 | } |
|
129 | 194 | else { |
|
130 | 195 | // adjust sizes individually here, e.g. |
|
131 | 196 | currentSizes[RIGHTMAININSPECTORWIDGETSPLITTERINDEX] |
|
132 | 197 | += impl->m_LastOpenRightInspectorSize.width(); |
|
133 | 198 | currentSizes[VIEWPLITTERINDEX] -= impl->m_LastOpenRightInspectorSize.width(); |
|
134 | 199 | m_Ui->splitter->setSizes(currentSizes); |
|
135 | 200 | } |
|
136 | 201 | |
|
137 | 202 | }; |
|
138 | 203 | |
|
139 | 204 | |
|
140 | QToolBar *leftSidePane = m_Ui->leftInspectorSidePane->sidePane(); | |
|
141 | auto openLeftInspectorAction = leftSidePane->addAction( | |
|
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); | |
|
205 | connect(openLeftInspectorAction, &QAction::triggered, openLeftInspector); | |
|
206 | connect(openRightInspectorAction, &QAction::triggered, openRightInspector); | |
|
155 | 207 | |
|
156 | openRightInspectorAction->setCheckable(true); | |
|
157 | 208 | |
|
158 | 209 | this->menuBar()->addAction(tr("File")); |
|
159 | 210 | auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar")); |
|
160 | mainToolBar->addAction(QStringLiteral("A1")); | |
|
211 | ||
|
212 | mainToolBar->addWidget(new TimeWidget()); | |
|
161 | 213 | |
|
162 | 214 | // Widgets / controllers connections |
|
163 | 215 | connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)), |
|
164 | 216 | m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *))); |
|
165 | 217 | |
|
166 | 218 | /* QLopGUI::registerMenuBar(menuBar()); |
|
167 | 219 | this->setWindowIcon(QIcon(":/sciqlopLOGO.svg")); |
|
168 | 220 | this->m_progressWidget = new QWidget(); |
|
169 | 221 | this->m_progressLayout = new QVBoxLayout(this->m_progressWidget); |
|
170 | 222 | this->m_progressWidget->setLayout(this->m_progressLayout); |
|
171 | 223 | this->m_progressWidget->setWindowModality(Qt::WindowModal); |
|
172 | 224 | m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int)); |
|
173 | 225 | for(int i=0;i<OMP_THREADS;i++) |
|
174 | 226 | { |
|
175 | 227 | this->m_progress.append(new QProgressBar(this->m_progressWidget)); |
|
176 | 228 | this->m_progress.last()->setMinimum(0); |
|
177 | 229 | this->m_progress.last()->setMaximum(100); |
|
178 | 230 | this->m_progressLayout->addWidget(this->m_progress.last()); |
|
179 | 231 | this->m_progressWidget->hide(); |
|
180 | 232 | this->m_progressThreadIds[i] = -1; |
|
181 | 233 | } |
|
182 | 234 | this->m_progressWidget->setWindowTitle("Loading File"); |
|
183 | 235 | const QList<QLopService*>ServicesToLoad=QList<QLopService*>() |
|
184 | 236 | << QLopCore::self() |
|
185 | 237 | << QLopPlotManager::self() |
|
186 | 238 | << QLopCodecManager::self() |
|
187 | 239 | << FileDownloader::self() |
|
188 | 240 | << QLopDataBase::self() |
|
189 | 241 | << SpaceData::self(); |
|
190 | 242 | |
|
191 | 243 | CDFCodec::registerToManager(); |
|
192 | 244 | AMDATXTCodec::registerToManager(); |
|
193 | 245 | |
|
194 | 246 | |
|
195 | 247 | for(int i=0;i<ServicesToLoad.count();i++) |
|
196 | 248 | { |
|
197 | 249 | qDebug()<<ServicesToLoad.at(i)->serviceName(); |
|
198 | 250 | ServicesToLoad.at(i)->initialize(); //must be called before getGUI |
|
199 | 251 | QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI(); |
|
200 | 252 | if(wdgt) |
|
201 | 253 | { |
|
202 | 254 | wdgt->setAllowedAreas(Qt::AllDockWidgetAreas); |
|
203 | 255 | this->addDockWidget(Qt::TopDockWidgetArea,wdgt); |
|
204 | 256 | } |
|
205 | 257 | PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i)); |
|
206 | 258 | }*/ |
|
207 | 259 | } |
|
208 | 260 | |
|
209 | 261 | MainWindow::~MainWindow() |
|
210 | 262 | { |
|
211 | 263 | } |
|
212 | 264 | |
|
213 | 265 | |
|
214 | 266 | void MainWindow::changeEvent(QEvent *e) |
|
215 | 267 | { |
|
216 | 268 | QMainWindow::changeEvent(e); |
|
217 | 269 | switch (e->type()) { |
|
218 | 270 | case QEvent::LanguageChange: |
|
219 | 271 | m_Ui->retranslateUi(this); |
|
220 | 272 | break; |
|
221 | 273 | default: |
|
222 | 274 | break; |
|
223 | 275 | } |
|
224 | 276 | } |
@@ -1,54 +1,47 | |||
|
1 | 1 | #include "SidePane/SqpSidePane.h" |
|
2 | 2 | #include "ui_SqpSidePane.h" |
|
3 | 3 | |
|
4 | 4 | #include <QAction> |
|
5 | 5 | #include <QLayout> |
|
6 | 6 | #include <QToolBar> |
|
7 | 7 | |
|
8 | 8 | namespace { |
|
9 | 9 | static const QString SQPSIDEPANESTYLESHEET |
|
10 | 10 | = "QToolBar {" |
|
11 | 11 | " background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0," |
|
12 | 12 | " stop: 0.0 #5a5a5a," |
|
13 | 13 | " stop: 1.0 #414141);" |
|
14 | 14 | " border: none;" |
|
15 | 15 | " border-left: 1px solid #424242;" |
|
16 | 16 | "border-right: 1px solid #393939;" |
|
17 | 17 | " }" |
|
18 | 18 | |
|
19 | 19 | " QToolButton {" |
|
20 | 20 | "background: none;" |
|
21 | 21 | "border: none;" |
|
22 | 22 | " }"; |
|
23 | 23 | } |
|
24 | 24 | |
|
25 | 25 | SqpSidePane::SqpSidePane(QWidget *parent) : QWidget{parent}, ui{new Ui::SqpSidePane} |
|
26 | 26 | { |
|
27 | 27 | // QVBoxLayout *sidePaneLayout = new QVBoxLayout(this); |
|
28 | 28 | // sidePaneLayout->setContentsMargins(0, 0, 0, 0); |
|
29 | 29 | // this->setLayout(sidePaneLayout); |
|
30 | 30 | |
|
31 | 31 | ui->setupUi(this); |
|
32 | 32 | m_SidePaneToolbar = new QToolBar(); |
|
33 | 33 | m_SidePaneToolbar->setOrientation(Qt::Vertical); |
|
34 | 34 | this->layout()->addWidget(m_SidePaneToolbar); |
|
35 | 35 | |
|
36 | 36 | m_SidePaneToolbar->setStyleSheet(SQPSIDEPANESTYLESHEET); |
|
37 | ||
|
38 | this->setStyleSheet( | |
|
39 | " QWidget {" | |
|
40 | "background: red;" | |
|
41 | ||
|
42 | "border: 1px;" | |
|
43 | " }"); | |
|
44 | 37 | } |
|
45 | 38 | |
|
46 | 39 | SqpSidePane::~SqpSidePane() |
|
47 | 40 | { |
|
48 | 41 | delete ui; |
|
49 | 42 | } |
|
50 | 43 | |
|
51 | 44 | QToolBar *SqpSidePane::sidePane() |
|
52 | 45 | { |
|
53 | 46 | return m_SidePaneToolbar; |
|
54 | 47 | } |
General Comments 0
You need to be logged in to leave comments.
Login now