##// END OF EJS Templates
Correction MR
perrinel -
r131:94f8c05d7495
parent child
Show More
@@ -1,235 +1,233
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 29 #include <TimeWidget/TimeWidget.h>
30 30
31 31 #include <QAction>
32 32 #include <QDate>
33 33 #include <QDateTime>
34 34 #include <QDir>
35 35 #include <QFileDialog>
36 36 #include <QToolBar>
37 37 #include <QToolButton>
38 38 #include <memory.h>
39 39
40 40 //#include <omp.h>
41 41 //#include <network/filedownloader.h>
42 42 //#include <qlopdatabase.h>
43 43 //#include <qlopsettings.h>
44 44 //#include <qlopgui.h>
45 45 //#include <spacedata.h>
46 46 //#include "qlopcore.h"
47 47 //#include "qlopcodecmanager.h"
48 48 //#include "cdfcodec.h"
49 49 //#include "amdatxtcodec.h"
50 50 //#include <qlopplotmanager.h>
51 51
52 52 #include "iostream"
53 53
54 54 Q_LOGGING_CATEGORY(LOG_MainWindow, "MainWindow")
55 55
56 56 namespace {
57 57 const auto LEFTMAININSPECTORWIDGETSPLITTERINDEX = 0;
58 58 const auto LEFTINSPECTORSIDEPANESPLITTERINDEX = 1;
59 59 const auto VIEWPLITTERINDEX = 2;
60 60 const auto RIGHTINSPECTORSIDEPANESPLITTERINDEX = 3;
61 61 const auto RIGHTMAININSPECTORWIDGETSPLITTERINDEX = 4;
62 62 }
63 63
64 64 class MainWindow::MainWindowPrivate {
65 65 public:
66 66 QSize m_LastOpenLeftInspectorSize;
67 67 QSize m_LastOpenRightInspectorSize;
68 68 };
69 69
70 70 MainWindow::MainWindow(QWidget *parent)
71 71 : QMainWindow{parent},
72 72 m_Ui{new Ui::MainWindow},
73 73 impl{spimpl::make_unique_impl<MainWindowPrivate>()}
74 74 {
75 75 m_Ui->setupUi(this);
76 76
77 77 m_Ui->splitter->setCollapsible(LEFTINSPECTORSIDEPANESPLITTERINDEX, false);
78 78 m_Ui->splitter->setCollapsible(RIGHTINSPECTORSIDEPANESPLITTERINDEX, false);
79 79
80 80
81 81 auto leftSidePane = m_Ui->leftInspectorSidePane->sidePane();
82 auto openLeftInspectorAction = new QAction(
83 QIcon{
84 ":/icones/previous.png",
85 },
86 tr("Show/hide the left inspector"), this);
82 auto openLeftInspectorAction = new QAction{QIcon{
83 ":/icones/previous.png",
84 },
85 tr("Show/hide the left inspector"), this};
87 86
88 87
89 QWidget *spacerLeftTop = new QWidget();
88 auto spacerLeftTop = new QWidget{};
90 89 spacerLeftTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
91 90
92 QWidget *spacerLeftBottom = new QWidget();
91 auto spacerLeftBottom = new QWidget{};
93 92 spacerLeftBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
94 93
95 94 leftSidePane->addWidget(spacerLeftTop);
96 95 leftSidePane->addAction(openLeftInspectorAction);
97 96 leftSidePane->addWidget(spacerLeftBottom);
98 97
99 98
100 99 auto rightSidePane = m_Ui->rightInspectorSidePane->sidePane();
101 auto openRightInspectorAction = new QAction(
102 QIcon{
103 ":/icones/next.png",
104 },
105 tr("Show/hide the right inspector"), this);
100 auto openRightInspectorAction = new QAction{QIcon{
101 ":/icones/next.png",
102 },
103 tr("Show/hide the right inspector"), this};
106 104
107 QWidget *spacerRightTop = new QWidget();
105 auto spacerRightTop = new QWidget{};
108 106 spacerRightTop->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
109 107
110 QWidget *spacerRightBottom = new QWidget();
108 auto spacerRightBottom = new QWidget{};
111 109 spacerRightBottom->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
112 110
113 111 rightSidePane->addWidget(spacerRightTop);
114 112 rightSidePane->addAction(openRightInspectorAction);
115 113 rightSidePane->addWidget(spacerRightBottom);
116 114
117 115 openLeftInspectorAction->setCheckable(true);
118 116 openRightInspectorAction->setCheckable(true);
119 117
120 118 auto openInspector = [this](bool checked, bool right, auto action) {
121 119
122 120 action->setIcon(QIcon{(checked xor right) ? ":/icones/next.png" : ":/icones/previous.png"});
123 121
124 122 auto &lastInspectorSize
125 123 = right ? impl->m_LastOpenRightInspectorSize : impl->m_LastOpenLeftInspectorSize;
126 124
127 125 auto nextInspectorSize = right ? m_Ui->rightMainInspectorWidget->size()
128 126 : m_Ui->leftMainInspectorWidget->size();
129 127
130 128 // Update of the last opened geometry
131 129 if (checked) {
132 130 lastInspectorSize = nextInspectorSize;
133 131 }
134 132
135 133 auto startSize = lastInspectorSize;
136 134 auto endSize = startSize;
137 135 endSize.setWidth(0);
138 136
139 137 auto splitterInspectorIndex
140 138 = right ? RIGHTMAININSPECTORWIDGETSPLITTERINDEX : LEFTMAININSPECTORWIDGETSPLITTERINDEX;
141 139
142 140 auto currentSizes = m_Ui->splitter->sizes();
143 141 if (checked) {
144 142 // adjust sizes individually here, e.g.
145 143 currentSizes[splitterInspectorIndex] -= lastInspectorSize.width();
146 144 currentSizes[VIEWPLITTERINDEX] += lastInspectorSize.width();
147 145 m_Ui->splitter->setSizes(currentSizes);
148 146 }
149 147 else {
150 148 // adjust sizes individually here, e.g.
151 149 currentSizes[splitterInspectorIndex] += lastInspectorSize.width();
152 150 currentSizes[VIEWPLITTERINDEX] -= lastInspectorSize.width();
153 151 m_Ui->splitter->setSizes(currentSizes);
154 152 }
155 153
156 154 };
157 155
158 156
159 157 connect(openLeftInspectorAction, &QAction::triggered,
160 158 [openInspector, openLeftInspectorAction](bool checked) {
161 159 openInspector(checked, false, openLeftInspectorAction);
162 160 });
163 161 connect(openRightInspectorAction, &QAction::triggered,
164 162 [openInspector, openRightInspectorAction](bool checked) {
165 163 openInspector(checked, true, openRightInspectorAction);
166 164 });
167 165
168 166 this->menuBar()->addAction(tr("File"));
169 167 auto mainToolBar = this->addToolBar(QStringLiteral("MainToolBar"));
170 168
171 mainToolBar->addWidget(new TimeWidget());
169 mainToolBar->addWidget(new TimeWidget{});
172 170
173 171 // Widgets / controllers connections
174 172 connect(&sqpApp->dataSourceController(), SIGNAL(dataSourceItemSet(DataSourceItem *)),
175 173 m_Ui->dataSourceWidget, SLOT(addDataSource(DataSourceItem *)));
176 174
177 175 /* QLopGUI::registerMenuBar(menuBar());
178 176 this->setWindowIcon(QIcon(":/sciqlopLOGO.svg"));
179 177 this->m_progressWidget = new QWidget();
180 178 this->m_progressLayout = new QVBoxLayout(this->m_progressWidget);
181 179 this->m_progressWidget->setLayout(this->m_progressLayout);
182 180 this->m_progressWidget->setWindowModality(Qt::WindowModal);
183 181 m_progressThreadIds = (int*) malloc(OMP_THREADS*sizeof(int));
184 182 for(int i=0;i<OMP_THREADS;i++)
185 183 {
186 184 this->m_progress.append(new QProgressBar(this->m_progressWidget));
187 185 this->m_progress.last()->setMinimum(0);
188 186 this->m_progress.last()->setMaximum(100);
189 187 this->m_progressLayout->addWidget(this->m_progress.last());
190 188 this->m_progressWidget->hide();
191 189 this->m_progressThreadIds[i] = -1;
192 190 }
193 191 this->m_progressWidget->setWindowTitle("Loading File");
194 192 const QList<QLopService*>ServicesToLoad=QList<QLopService*>()
195 193 << QLopCore::self()
196 194 << QLopPlotManager::self()
197 195 << QLopCodecManager::self()
198 196 << FileDownloader::self()
199 197 << QLopDataBase::self()
200 198 << SpaceData::self();
201 199
202 200 CDFCodec::registerToManager();
203 201 AMDATXTCodec::registerToManager();
204 202
205 203
206 204 for(int i=0;i<ServicesToLoad.count();i++)
207 205 {
208 206 qDebug()<<ServicesToLoad.at(i)->serviceName();
209 207 ServicesToLoad.at(i)->initialize(); //must be called before getGUI
210 208 QDockWidget* wdgt=ServicesToLoad.at(i)->getGUI();
211 209 if(wdgt)
212 210 {
213 211 wdgt->setAllowedAreas(Qt::AllDockWidgetAreas);
214 212 this->addDockWidget(Qt::TopDockWidgetArea,wdgt);
215 213 }
216 214 PythonQt::self()->getMainModule().addObject(ServicesToLoad.at(i)->serviceName(),(QObject*)ServicesToLoad.at(i));
217 215 }*/
218 216 }
219 217
220 218 MainWindow::~MainWindow()
221 219 {
222 220 }
223 221
224 222
225 223 void MainWindow::changeEvent(QEvent *e)
226 224 {
227 225 QMainWindow::changeEvent(e);
228 226 switch (e->type()) {
229 227 case QEvent::LanguageChange:
230 228 m_Ui->retranslateUi(this);
231 229 break;
232 230 default:
233 231 break;
234 232 }
235 233 }
@@ -1,23 +1,21
1 1 #ifndef SCIQLOP_TIMEWIDGET_H
2 2 #define SCIQLOP_TIMEWIDGET_H
3 3
4 4 #include <QWidget>
5 5
6 6 namespace Ui {
7 7 class TimeWidget;
8 8 } // Ui
9 9
10 class TimeWidget;
11
12 10 class TimeWidget : public QWidget {
13 11 Q_OBJECT
14 12
15 13 public:
16 14 explicit TimeWidget(QWidget *parent = 0);
17 15 virtual ~TimeWidget();
18 16
19 17 private:
20 18 Ui::TimeWidget *ui;
21 19 };
22 20
23 21 #endif // SCIQLOP_ SQPSIDEPANE_H
General Comments 0
You need to be logged in to leave comments. Login now