##// END OF EJS Templates
Removed annoying GUI bug with dock widget handling:...
Jeandet Alexis -
r12:a31c7daed0d6 default
parent child
Show More
@@ -1,36 +1,37
1 1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 2 <html>
3 3 <head>
4 4 </head>
5 5 <body style="background-color : #dbdbdb;">
6 6
7 7 <div align="center">
8 8 <a href="http://www.cnrs.fr/"> <IMG src=":/images/logocnrs.png" alt="CNRS" width="47" height="47" align="top" border="0" ></a>
9 9 <a href="http://www.lpp.fr/"> <IMG src=":/images/logolpp.png" width="158" height="47" align="top" border="0" ></a>
10 10 <a href="http://www.solarorbiter.org/"> <IMG src=":/images/logoso.png" width="64" height="47" align="top" border="0" ></a>
11 11 </div>
12 12 <hr>
13 13 <div align="center">
14 14 <B style="font-size : 150%;">About SocExplorer</B>
15 15 </div>
16 16 <hr>
17 17 <div align="center">
18 18 <B>SocExplorer Version $VERSION$.</B><BR><BR>
19 <B> Changeset $Changeset$.</B><BR><BR>
20 <B> Branch $Branch$.</B><BR><BR>
19 <B> Build from Changeset $Changeset$.</B><BR><BR>
20 <B> Branch $Branch$.</B><BR><BR>
21 21 Copyright (C) 2011-2014 Plasmas Physic Laboratory.<BR>
22 22 This is free software; licenced under the terms of the GPLV2 license.<BR><BR>
23 23 This program uses:
24 24 <div align="left" style="margin-left : 50%;">
25 25 <ul>
26 26 <LI><a href="http://qt.nokia.com" title="Qt">Qt</a> (Copyright 2008-2013 Digia Plc).</LI>
27 27 <LI><a href="http://pythonqt.sourceforge.net" title="PythonQt">PythonQt</a> </LI>
28 <LI><a href="http://commons.wikimedia.org/wiki/GNOME_Desktop_icons" title="Gnome Icons">Gnome Icons</a> </LI>
28 29 <LI><a href="http://nsis.sourceforge.net/Main_Page" title="NSIS">NSIS</a> (Nullsoft Scriptable Install System) </LI>
29 <LI>LppSerial</LI>
30 <LI><a href="https://hephaistos.lpp.polytechnique.fr/rhodecode/HG_REPOSITORIES/LPP/INSTRUMENTATION/lppserial" title="LppSerial">LppSerial</a></LI>
30 31 <LI><a href="http://www.qcustomplot.com/index.php/introduction" title="qhexedit">QCustomPlot</a></LI>
31 32 <LI><a href="http://code.google.com/p/qhexedit2/" title="qhexedit">QHexEdit</a></LI>
32 33 </ul>
33 34 </div>
34 35 </div>
35 36 </body>
36 37 </html>
@@ -1,379 +1,380
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "socexplorerproxy.h"
23 23 #include <pluginmanagerWDGT.h>
24 24 #include <socexplorerengine.h>
25 25 #include <pluginloader.h>
26 26 #include <socexplorerplugin.h>
27 27
28 28 socexplorerproxy* socexplorerproxy::_self=NULL;
29 29 QMainWindow* socexplorerproxy::mainWindow=NULL;
30 30 QList<socexplorerplugin*>* socexplorerproxy::drivers=NULL;
31 31 QList<socexplorerplugin*>* socexplorerproxy::linearDriverList=NULL;
32 32 socexplorerplugin* socexplorerproxy::root=NULL;
33 33 socexplorerplugin* socexplorerproxy::parent=NULL;
34 34 PluginsCache* socexplorerproxy::cache=NULL;
35 35
36 36 socexplorerproxy::socexplorerproxy(QObject *parent) :
37 37 QObject(parent)
38 38 {
39 39 cache = new PluginsCache;
40 40 drivers = new QList<socexplorerplugin*>;
41 41 linearDriverList=new QList<socexplorerplugin*>;
42 42 root = NULL;
43 43 }
44 44
45 45
46 46 socexplorerproxy::socexplorerproxy(QMainWindow *Mainwindow, QObject *parent):
47 47 QObject(parent)
48 48 {
49 49 mainWindow = Mainwindow;
50 50 cache = new PluginsCache;
51 51 drivers = new QList<socexplorerplugin*>;
52 52 linearDriverList=new QList<socexplorerplugin*>;
53 53 root = NULL;
54 54 }
55 55
56 56
57 57 void socexplorerproxy::init()
58 58 {
59 59 if(!_self)
60 60 {
61 61 _self = new socexplorerproxy();
62 62 mainWindow = NULL;
63 63 }
64 64
65 65 }
66 66
67 67 void socexplorerproxy::setMainWindow(QMainWindow *Mainwindow)
68 68 {
69 69 if(!_self)init();
70 70 mainWindow=Mainwindow;
71 71 }
72 72
73 73 void socexplorerproxy::loadSysDriver(const QString name)
74 74 {
75 75 if(!_self)init();
76 76 if(pluginloader::libcanberoot(name))
77 77 {
78 78 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name);
79 79 QString driverName = _self->getinstanceName(driver->baseName());
80 80 loadSysDriver(driver,driverName);
81 81 }
82 82 }
83 83
84 84 void socexplorerproxy::loadSysDriver(const QString name, const QString instanceName)
85 85 {
86 86 if(!_self)init();
87 87 if(pluginloader::libcanberoot(name) && !_self->instanceExists(instanceName))
88 88 {
89 89 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name);
90 90 loadSysDriver(driver,instanceName);
91 91 }
92 92 }
93 93
94 94
95 95 void socexplorerproxy::loadSysDriver(socexplorerplugin *driver, const QString instanceName)
96 96 {
97 97 if(!_self)init();
98 98 driver->setInstanceName(instanceName);
99 99 driver->parent = NULL;
100 100 drivers->append(driver);
101 101 linearDriverList->append(driver);
102 102 connectChildToProxy(driver);
103 103 emit _self->addPluginGUI(driver);
104 104 emit _self->clearMenu();
105 105 emit _self->treeChanged(QList<socexplorerplugin*>(*drivers));
106 106 SocExplorerEngine::addSOC(driver);
107 107 }
108 108
109 109 void socexplorerproxy::loadChildSysDriver(socexplorerplugin *parent, const QString child)
110 110 {
111 111 if(!_self)init();
112 112 if(pluginloader::libcanbechild(child))
113 113 {
114 114 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(child);
115 115 QString driverName = _self->getinstanceName(driver->baseName());
116 116 bool ok=true;
117 117 if(ok)
118 118 {
119 119 if(parent!=NULL)_self->loadSysDriverToParent(driver,parent,driverName);
120 120 }
121 121 }
122 122 }
123 123
124 124 void socexplorerproxy::loadSysDriverToParent(const QString name,const QString ParentInst)
125 125 {
126 126 if(!_self)init();
127 127 if(pluginloader::libcanbechild(name))
128 128 {
129 129 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name);
130 130 QString driverName = _self->getinstanceName(driver->baseName());
131 131 bool ok=true;
132 132 if(ok)
133 133 {
134 134 socexplorerplugin* parent=_self->getSysDriver(ParentInst);
135 135 if(parent!=NULL)loadSysDriverToParent(driver,parent,driverName);
136 136 }
137 137 }
138 138 }
139 139
140 140
141 141 void socexplorerproxy::loadSysDriverToParent(const QString name,const QString instanceName,const QString ParentInst)
142 142 {
143 143 if(!_self)init();
144 144 if(pluginloader::libcanbechild(name) && !_self->instanceExists(instanceName))
145 145 {
146 146 socexplorerplugin* driver = pluginloader::newsocexplorerplugin(name);
147 147 bool ok=true;
148 148 if(ok)
149 149 {
150 150 socexplorerplugin* parent=_self->getSysDriver(ParentInst);
151 151 if(parent!=NULL)loadSysDriverToParent(driver,parent,instanceName);
152 152 }
153 153 }
154 154 }
155 155
156 156 void socexplorerproxy::loadSysDriverToParent(socexplorerplugin *driver,socexplorerplugin *parent, const QString instanceName)
157 157 {
158 158 if(!_self)init();
159 159 linearDriverList->append(driver);
160 160 driver->parent = parent;
161 161 driver->setInstanceName(instanceName);
162 162 parent->childs.append(driver);
163 163 connectChildToProxy(driver);
164 164 connectChildToParent(parent,driver);
165 165 emit _self->clearMenu();
166 166 emit _self->addPluginGUI(driver);
167 167 emit _self->treeChanged(QList<socexplorerplugin*>(*drivers));
168 168 driver->postInstantiationTrigger();
169 169 }
170 170
171 171
172 172 void socexplorerproxy::changeSysDriverInstName(const QString instanceName)
173 173 {
174 174 Q_UNUSED(instanceName)
175 175 }
176 176
177 177 void socexplorerproxy::changeSysDriverInstName(const QString newinstanceName, const QString previnstanceName)
178 178 {
179 179 if(!_self)init();
180 180 socexplorerplugin*temp=_self->getSysDriver(previnstanceName);
181 181 if(temp!=NULL)
182 182 {
183 183 if(NULL!=_self->getSysDriver(newinstanceName))
184 184 {
185 185 emit _self->treeChanged(QList<socexplorerplugin*>(*drivers));
186 186 return;
187 187 }
188 188 temp->setInstanceName(newinstanceName);
189 189 }
190 190 emit _self->treeChanged(QList<socexplorerplugin*>(*drivers));
191 191 }
192 192
193 void socexplorerproxy::loadChild(socexplorerplugin *parent)
194 {
195 if(!_self)init();
196 parent = parent;
197 pluginmanagerWDGT* pluginmanager0 = new pluginmanagerWDGT;
198 pluginmanager0->setChildLoadable(true);
199 pluginmanager0->connect(pluginmanager0,SIGNAL(loadSysDrviver(QString)),_self,SLOT(loadSysDriverToParent(QString)));
200 pluginmanager0->show();
201 }
193 //void socexplorerproxy::loadChild(socexplorerplugin *parent)
194 //{
195 // if(!_self)init();
196 // parent = parent;
197 // pluginmanagerWDGT* pluginmanager0 = new pluginmanagerWDGT;
198 // pluginmanager0->setChildLoadable(true);
199 // pluginmanager0->connect(pluginmanager0,SIGNAL(loadSysDrviver(QString)),_self,SLOT(loadSysDriverToParent(QString)));
200 // pluginmanager0->show();
201 //}
202 202
203 203
204 204 void socexplorerproxy::connectChildToParent(socexplorerplugin *parent, socexplorerplugin *child)
205 205 {
206 206 if(!_self)init();
207 207 connect(parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool)));
208 208 child->activate(parent->isConnected());
209 209 }
210 210
211 211 void socexplorerproxy::disconnectChildToParent(socexplorerplugin *child)
212 212 {
213 213 if(!_self)init();
214 214 disconnect(child->parent,SIGNAL(activateSig(bool)),child,SLOT(activate(bool)));
215 215 }
216 216
217 217
218 218 void socexplorerproxy::connectChildToProxy(socexplorerplugin *child)
219 219 {
220 220 if(!_self)init();
221 221 connect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString)));
222 222 connect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriver(socexplorerplugin*)));
223 223 }
224 224
225 225 void socexplorerproxy::disconnectChildToProxy(socexplorerplugin *child)
226 226 {
227 227 if(!_self)init();
228 228 disconnect(child,SIGNAL(registerObject(QObject*,QString)),_self,SIGNAL(registerObject(QObject*,QString)));
229 229 disconnect(child,SIGNAL(closePlugin(socexplorerplugin*)),_self,SLOT(closeSysDriverFromDriver(socexplorerplugin*)));
230 230 }
231 231
232 232 QString socexplorerproxy::getinstanceName(const QString& baseName)
233 233 {
234 234 if(!_self)init();
235 235 int i=0;
236 236 QString name;
237 237 bool validName = false;
238 238 while(!validName)
239 239 {
240 240 name.clear();
241 241 name.append(baseName+QString::number(i));
242 242 validName = instanceNameIsValid(name);
243 243 i++;
244 244 }
245 245 return name;
246 246 }
247 247
248 248 void socexplorerproxy::changeSysDriverInstName(socexplorerplugin* driver)
249 249 {
250 250 if(!_self)init();
251 251 QString prevName(driver->instanceName());
252 252 }
253 253
254 254 bool socexplorerproxy::instanceNameIsValid(const QString& instanceName)
255 255 {
256 256 if(!_self)init();
257 257 for(int k=0;k<linearDriverList->count();k++)
258 258 {
259 259 if(!linearDriverList->at(k)->instanceName().compare(instanceName))
260 260 return false;
261 261 }
262 262 return true;
263 263 }
264 264
265 265 socexplorerplugin *socexplorerproxy::findPlugin(const QString &instanceName)
266 266 {
267 267 if(!_self)init();
268 268 for(int k=0;k<linearDriverList->count();k++)
269 269 {
270 270 if(linearDriverList->at(k)->instanceName().compare(instanceName))
271 271 return linearDriverList->at(k);
272 272 }
273 273 return NULL;
274 274 }
275 275
276 276 bool socexplorerproxy::instanceExists(const QString &instanceName)
277 277 {
278 278 return !socexplorerproxy::instanceNameIsValid(instanceName);
279 279 }
280 280
281 281 void socexplorerproxy::close()
282 282 {
283 283 if(!_self)init();
284 284 socexplorerplugin* tmpPtr;
285 285 while(drivers->count()>0)
286 286 {
287 287 tmpPtr = drivers->last();
288 288 drivers->removeLast();
289 289 _self->closeSysDriver(tmpPtr);
290 290 }
291 291 if(root!=NULL)
292 292 {
293 293 _self->closeSysDriver(root);
294 294 }
295 295
296 296 }
297 297
298 298 socexplorerplugin* socexplorerproxy::getSysDriver(const QString instanceName)
299 299 {
300 300 if(!_self)init();
301 301 for(int i=0;i<linearDriverList->count();i++)
302 302 {
303 303 if(!linearDriverList->at(i)->instanceName().compare(instanceName))
304 304 return linearDriverList->at(i);
305 305 }
306 306 return NULL;
307 307 }
308 308
309 309
310 310 void socexplorerproxy::closeSysDriver(const QString instanceName)
311 311 {
312 312 if(!_self)init();
313 313 closeSysDriver(getSysDriver(instanceName),false);
314 314 }
315 315
316 316 void socexplorerproxy::closeSysDriver(socexplorerplugin *driver, bool recursive)
317 317 {
318 318 if(!_self)init();
319 319 if(driver!=NULL)
320 320 {
321 emit _self->removePluginGUI(driver);
321 322 if(driver->parent==NULL)SocExplorerEngine::removeSOC(driver);
322 323 while(driver->childs.count()!=0)closeSysDriver(driver->childs.first());
323 324 linearDriverList->removeOne(driver);
324 325 if(driver->parent!= NULL)
325 326 {
326 327 driver->parent->childs.removeOne(driver); //Have parent so it's a child
327 328 disconnectChildToParent(driver);
328 329 disconnectChildToProxy(driver);
329 330 delete driver;
330 331 }
331 332 else
332 333 {
333 334 drivers->removeOne(driver);
334 335 disconnectChildToProxy(driver);
335 336 delete driver;
336 337 }
337 338 if(!recursive)
338 339 {
339 340 emit _self->clearMenu();
340 emit _self->registermenu(mainWindow);
341 emit _self->registermenu(mainWindow);
341 342 emit _self->treeChanged(QList<socexplorerplugin*>(*drivers));
342 343 }
343 344 }
344 345
345 346 }
346 347
347 348 void socexplorerproxy::geteplugintree()
348 349 {
349 350 if(!_self)init();
350 351 emit _self->treeChanged(QList<socexplorerplugin*>(*drivers));
351 352 }
352 353
353 354 void socexplorerproxy::closeSysDriverFromDriver(socexplorerplugin *driver)
354 355 {
355 356 if(!_self)init();
356 357 emit _self->closeSysDriverSig(driver);
357 358 }
358 359
359 360 void socexplorerproxy::updateText()
360 361 {
361 362 if(!_self)init();
362 363 emit _self->clearMenu();
363 364 emit _self->registermenu(mainWindow);
364 365 }
365 366
366 367
367 368
368 369
369 370
370 371 void socexplorerproxy::makeMenu(QMenu* menu)
371 372 {
372 373 if(!_self)init();
373 374 for(int i=0;i<drivers->count();i++)
374 375 {
375 376 drivers->at(i)->registermenu(menu);
376 377 }
377 378 }
378 379
379 380
@@ -1,102 +1,103
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef SOCEXPLORERPROXY_H
23 23 #define SOCEXPLORERPROXY_H
24 24
25 25 #include <QObject>
26 26 #include <QString>
27 27 #include <QList>
28 28 #include "pluginscache.h"
29 29 #include <socexplorerplugin.h>
30 30 #include <socexplorerplugininterface.h>
31 31 #include <QInputDialog>
32 32 #include <QtGlobal>
33 33
34 34 #if defined(SOCEXPLORER_SDK_BUILD)
35 35 # define SOCEXPLORER_SDK_EXPORT Q_DECL_EXPORT
36 36 #else
37 37 # define SOCEXPLORER_SDK_EXPORT Q_DECL_IMPORT
38 38 #endif
39 39
40 40 class SOCEXPLORER_SDK_EXPORT socexplorerproxy : public QObject
41 41 {
42 42 Q_OBJECT
43 43 private:
44 44 socexplorerproxy(QObject *parent = 0);
45 45 socexplorerproxy(QMainWindow* Mainwindow,QObject *parent = 0);
46 46 static socexplorerproxy* _self;
47 47 public:
48 48 static socexplorerproxy* self(){if(!_self)init(); return _self;}
49 49 static void init();
50 50 static void setMainWindow(QMainWindow* Mainwindow);
51 51 static void connectChildToParent(socexplorerplugin* parent, socexplorerplugin* child);
52 52 static void connectChildToProxy(socexplorerplugin* child);
53 53 static void disconnectChildToParent(socexplorerplugin* child);
54 54 static void disconnectChildToProxy(socexplorerplugin* child);
55 55 static bool instanceNameIsValid(const QString& instanceName);
56 56 static socexplorerplugin* findPlugin(const QString &instanceName);
57 57
58 58 QT_ENSURE_STACK_ALIGNED_FOR_SSE static void loadChildSysDriver(socexplorerplugin* parent,const QString child);
59 59
60 60 signals:
61 61 void addPluginGUI(QDockWidget* plugin);
62 void removePluginGUI(QDockWidget* plugin);
62 63 int registermenu(QMainWindow* menuHolder);
63 64 void clearMenu();
64 65 QStringList findDrivers(int VID,int PID);
65 66 void rootDriverAdded(socexplorerplugin* driver);
66 67 void rootDriverRemoved();
67 68 void closeSysDriverSig(socexplorerplugin* driver);
68 69 void registerObject(QObject* object,const QString& instanceName);
69 70 void treeChanged(const QList<socexplorerplugin*>& drivers);
70 71
71 72 public slots:
72 73 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(const QString name);
73 74 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(const QString name,const QString instanceName);
74 75 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriver(socexplorerplugin* driver,const QString instanceName);
75 76 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(const QString name,const QString ParentInst);
76 77 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(const QString name,const QString instanceName,const QString ParentInst);
77 78 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadSysDriverToParent(socexplorerplugin *driver,socexplorerplugin *parent, const QString instanceName);
78 79 QT_ENSURE_STACK_ALIGNED_FOR_SSE void changeSysDriverInstName(const QString instanceName);
79 80 QT_ENSURE_STACK_ALIGNED_FOR_SSE void changeSysDriverInstName(const QString newinstanceName,const QString previnstanceName);
80 QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadChild(socexplorerplugin* parent);
81 // QT_ENSURE_STACK_ALIGNED_FOR_SSE void loadChild(socexplorerplugin* parent);
81 82 void updateText();
82 83 QT_ENSURE_STACK_ALIGNED_FOR_SSE void closeSysDriverFromDriver(socexplorerplugin* driver);
83 84 QT_ENSURE_STACK_ALIGNED_FOR_SSE void closeSysDriver(socexplorerplugin* driver,bool recursive=false);
84 85 QT_ENSURE_STACK_ALIGNED_FOR_SSE void closeSysDriver(const QString instanceName);
85 86 void makeMenu(QMenu* menu);
86 87 void close();
87 88 QString getinstanceName(const QString& baseName);
88 89 void geteplugintree();
89 90 QT_ENSURE_STACK_ALIGNED_FOR_SSE socexplorerplugin* getSysDriver(const QString instanceName);
90 91 bool instanceExists(const QString& instanceName);
91 92 private:
92 93
93 94 static void changeSysDriverInstName(socexplorerplugin* driver);
94 95 static QMainWindow* mainWindow;
95 96 static QList<socexplorerplugin*>* drivers;
96 97 static QList<socexplorerplugin*>* linearDriverList;
97 98 static socexplorerplugin* root;
98 99 static socexplorerplugin* parent;
99 100 static PluginsCache* cache;
100 101 };
101 102
102 103 #endif // SOCEXPLORERPROXY_H
@@ -1,234 +1,238
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #include "mainwindow.h"
23 23 #include <QDockWidget>
24 24
25 25 LPMONMainWindow::LPMONMainWindow(QString ScriptToEval, QWidget *parent)
26 26 : QMainWindow(parent)
27 27 {
28 28 QCoreApplication::setApplicationName("SocExplorer");
29 29 QCoreApplication::setOrganizationName("LPP");
30 30 QCoreApplication::setOrganizationDomain("lpp.fr");
31 31 this->makeObjects(ScriptToEval);
32 32 this->makeLayout();
33 33 this->makeMenu();
34 34 this->makeConnections();
35 35 this->setWindowIcon(QIcon(tr(":/images/logolppcutted.png")));
36 36 this->setAcceptDrops(true);
37 37 this->pluginManager->setRootLoadable(true);
38 38 this->PythonConsoleInst->pyConsoleRunFile(ScriptToEval);
39 // QProgressBar* test = SocExplorerEngine::getProgressBar("test",10);
40 // statusBar()->setFixedHeight(statusBar()->height());
41 // SocExplorerEngine::deleteProgressBar(test);
42 39 }
43 40
44 41
45 42 void LPMONMainWindow::makeObjects(QString ScriptToEval)
46 43 {
47 44 Q_UNUSED(ScriptToEval)
45 this->p_pluginGUIlist = new QList<QDockWidget*>();
48 46 pluginsDockContainer = new QMainWindow;
49 47 pluginsDockContainer->setWindowFlags(Qt::Widget);
50 48 pluginsDockContainer->setDockNestingEnabled(true);
51 49 this->mainWidget = new QSplitter(Qt::Vertical);
52 50 this->appTranslator = new QTranslator;
53 51 this->Quit = new QAction(tr("&Quit"),this);
54 52 this->Quit->setShortcut(tr("CTRL+Q"));
55 53 this->ManagePlugins = new QAction(tr("&Manage Plugins"),this);
56 54 this->ManagePlugins->setShortcut(tr("CTRL+P"));
57 55 this->regsManager = new QAction(tr("&Manage registers"),this);
58 56 this->exploreRegs = new QAction(tr("&Explore registers"),this);
59 57 this->help = new QAction(tr("&Help"),this);
60 58 this->help->setShortcut(tr("CTRL+H"));
61 59 this->about = new QAction(tr("&About"),this);
62 60 socexplorerproxy::setMainWindow(this);
63 61 SocExplorerEngine::setMainWindow(this);
64 62 SocExplorerEngine::xmlModel()->scanXmlFiles();
65 63 this->regExplorer = new regsExplorer();
66 64 this->regExplorer->setAllowedAreas(Qt::AllDockWidgetAreas);
67 // this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,this->regExplorer);
68 65 this->addPluginInterface(this->regExplorer);
69 66 this->PythonConsoleInst = new PythonConsole(socexplorerproxy::self());
70 67 this->PythonConsoleInst->addObject("SocExplorerEngine",SocExplorerEngine::self());
71 68 this->pluginManager = new dockablePluginManager();
72 69 this->toolpane = new toolBar;
73 70 this->p_about = new aboutsocexplorer();
71
74 72 }
75 73
76 74 void LPMONMainWindow::makeLayout()
77 75 {
78 76 this->mainWidget->addWidget(pluginsDockContainer);
79 77 this->mainWidget->addWidget(this->PythonConsoleInst);
80 78 this->toolpane->setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea);
81 79 this->addDockWidget(Qt::LeftDockWidgetArea,this->toolpane);
82 80 this->toolpane->addTool(this->pluginManager);
83 81 this->setCentralWidget(this->mainWidget);
84 82 }
85 83
86 84
87 85 void LPMONMainWindow::makeConnections()
88 86 {
89 87 connect(socexplorerproxy::self(),SIGNAL(clearMenu()),this,SLOT(clearMenu()));
90 88 connect(this,SIGNAL(translateSig()),socexplorerproxy::self(),SLOT(updateText()));
91 89 connect(socexplorerproxy::self(),SIGNAL(addPluginGUI(QDockWidget*)),this,SLOT(addPluginInterface(QDockWidget*)));
90 connect(socexplorerproxy::self(),SIGNAL(removePluginGUI(QDockWidget*)),this,SLOT(removePluginInterface(QDockWidget*)));
92 91 connect(this->ManagePlugins,SIGNAL(triggered()),this,SLOT(launchPluginManager()));
93 92 connect(this->Quit,SIGNAL(triggered()),qApp,SLOT(quit()));
94 93 connect(this,SIGNAL(registerObject(QObject*,QString)),this->PythonConsoleInst,SLOT(registerObject(QObject*,QString)));
95 94 connect(socexplorerproxy::self(),SIGNAL(registerObject(QObject*,QString)),this,SIGNAL(registerObject(QObject*,QString)));
96 95 connect(this->pluginManager,SIGNAL(geteplugintree()),socexplorerproxy::self(),SLOT(geteplugintree()));
97 96 connect(socexplorerproxy::self(),SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->pluginManager,SIGNAL(treeChanged(QList<socexplorerplugin*>)));
98 97 connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),socexplorerproxy::self(),SLOT(changeSysDriverInstName(QString,QString)));
99 98 connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),this->PythonConsoleInst,SLOT(changeSysDriverInstName(QString,QString)));
100 99 connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),socexplorerproxy::self(),SLOT(closeSysDriver(QString)));
101 100 connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),this->PythonConsoleInst,SLOT(removeDriver(QString)));
102 101 connect(this->pluginManager,SIGNAL(pluginselected(QString)),this,SLOT(pluginselected(QString)));
103 102 connect(this->about,SIGNAL(triggered()),this,SLOT(showAboutBox()));
104 103 connect(this->exploreRegs,SIGNAL(triggered()),this->regExplorer,SLOT(show()));
105 104
106 105 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString)));
107 106 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDriverToParent(QString,QString)),socexplorerproxy::self(),SLOT(loadSysDriverToParent(QString,QString)));
108 107
109 108 }
110 109
111 110
112 111 void LPMONMainWindow::launchPluginManager()
113 112 {
114 113
115 114 if(this->pluginManager->isHidden())
116 115 {
117 116 this->pluginManager->setHidden(false);
118 117 }
119 118
120 119 }
121 120
122 121
123 122 void LPMONMainWindow::addPluginInterface(QDockWidget *plugin)
124 123 {
125 static QDockWidget* last=NULL;
126 124 plugin->setAllowedAreas(Qt::AllDockWidgetAreas);
127 125 this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,plugin);
128 if(last!=NULL)
129 this->pluginsDockContainer->tabifyDockWidget(last,plugin);
130 last = plugin;
126 if(p_pluginGUIlist->count()!=0)
127 this->pluginsDockContainer->tabifyDockWidget(p_pluginGUIlist->last(),plugin);
128 p_pluginGUIlist->append(plugin);
131 129
132 130 }
133 131
132 void LPMONMainWindow::removePluginInterface(QDockWidget *plugin)
133 {
134 p_pluginGUIlist->removeOne(plugin);
135 this->pluginsDockContainer->removeDockWidget(plugin);
136 }
137
134 138
135 139 void LPMONMainWindow::clearMenu()
136 140 {
137 141 this->menuBar()->clear();
138 142 this->makeMenu();
139 143 }
140 144
141 145
142 146 void LPMONMainWindow::makeMenu()
143 147 {
144 148 this->FileMenu = menuBar()->addMenu(tr("&File"));
145 149 this->PluginsMenu = menuBar()->addMenu(tr("&Plugins"));
146 150 this->ToolsMenu = menuBar()->addMenu(tr("&Tools"));
147 151 this->ToolsMenu->addAction(this->exploreRegs);
148 152 this->FileMenu->addAction(this->Quit);
149 153 socexplorerproxy::self()->makeMenu(this->PluginsMenu);
150 154 this->PluginsMenu->addAction(this->ManagePlugins);
151 155
152 156 this->helpMenu = menuBar()->addMenu(tr("Help"));
153 157 this->helpMenu->addAction(this->help);
154 158 this->helpMenu->addAction(this->about);
155 159
156 160 }
157 161
158 162
159 163 LPMONMainWindow::~LPMONMainWindow()
160 164 {
161 165 delete this->p_about;
166 delete this->p_pluginGUIlist;
162 167 }
163 168
164 169
165 170 void LPMONMainWindow::setLangage(QAction *action)
166 171 {
167 172 QString local = action->data().toString();
168 173 QString qmPath = QDir(QString("translations")).absolutePath();
169 174 appTranslator->load(qmPath+"/socexplorer_"+local+".qm");
170 175 qApp->installTranslator(appTranslator);
171 176 emit this->translateSig();
172 177 }
173 178
174 179
175 180 void LPMONMainWindow::createLangMenu()
176 181 {
177 182 this->langMenu = menuBar()->addMenu(tr("&Langue"));
178 183 this->langActionGrp = new QActionGroup(this);
179 184 connect(this->langActionGrp,SIGNAL(triggered(QAction*)),this,SLOT(setLangage(QAction*)));
180 185 QDir* qmDir = new QDir(QString("translations"));
181 186 QStringList LangFiles = qmDir->entryList(QStringList("socexplorer_*.qm"));
182 187 for(int i=0;i<LangFiles.size();++i)
183 188 {
184 189 QString Local = LangFiles[i];
185 190 Local.remove(0,Local.indexOf('_')+1);
186 191 Local.chop(3);
187 192 QTranslator translator;
188 193 translator.load(LangFiles[i],qmDir->absolutePath());
189 194 QString langage = translator.translate("MainWindow","English");
190 195 QAction *action = new QAction(tr("&%1 %2").arg(i+1).arg(langage),this);
191 196 action->setCheckable(true);
192 197 action->setData(Local);
193 198 langMenu->addAction(action);
194 199 langActionGrp->addAction(action);
195 200 if(langage==tr("English"))
196 201 action->setChecked(true);
197 202 }
198 203 }
199 204
200 205
201 206 void LPMONMainWindow::updateText()
202 207 {
203 208 emit this->translateSig();
204 209 }
205 210
206 211
207 212
208 213 void LPMONMainWindow::showAboutBox()
209 214 {
210 215 p_about->show();
211 216 }
212 217
213 218 void LPMONMainWindow::pluginselected(const QString &instanceName)
214 219 {
215 220 socexplorerplugin* drv=socexplorerproxy::self()->getSysDriver(instanceName);
216 221 if(drv)
217 222 drv->raise();
218 // TODO add plugin widget auto focus
219 223 }
220 224
221 225
222 226
223 227 void LPMONMainWindow::closeEvent(QCloseEvent *event)
224 228 {
225 229 socexplorerproxy::self()->close();
226 230 qApp->closeAllWindows();
227 231 event->accept();
228 232 }
229 233
230 234
231 235
232 236
233 237
234 238
@@ -1,85 +1,86
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the SocExplorer Software
3 3 -- Copyright (C) 2011, Laboratory of Plasmas Physic - 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@lpp.polytechnique.fr
21 21 ----------------------------------------------------------------------------*/
22 22 #ifndef MAINWINDOW_H
23 23 #define MAINWINDOW_H
24 24
25 25 #include <QMainWindow>
26 26 #include <QApplication>
27 27 #include <QVBoxLayout>
28 28 #include <QIcon>
29 29 #include <QMenuBar>
30 30 #include <QMenu>
31 31 #include <QAction>
32 32 #include <QDockWidget>
33 33 #include <QTranslator>
34 34 #include <QSplitter>
35 35 #include "dockablepluginmanager.h"
36 36 #include <socexplorerproxy.h>
37 37 #include "PyWdgt/pythonconsole.h"
38 38 #include "aboutsocexplorer.h"
39 39 #include "toolbar.h"
40 40 #include "regsExplorer/regsexplorer.h"
41 41
42 42 class LPMONMainWindow : public QMainWindow
43 43 {
44 44 Q_OBJECT
45 45
46 46 public:
47 47 LPMONMainWindow(QString ScriptToEval,QWidget *parent = 0);
48 48 ~LPMONMainWindow();
49 49 QAction* Quit,*LoadPlugin,*ManagePlugins,*help,*regsManager,*exploreRegs,*about,*translateAction;
50 50 QActionGroup*langActionGrp;
51 51 QMenu* FileMenu,*PluginsMenu,*ToolsMenu,*langMenu,*helpMenu;
52 52 QTranslator* appTranslator;
53 53 void createLangMenu();
54 54 void closeEvent(QCloseEvent *event);
55 55 toolBar* toolpane;
56 56
57 57
58 58 public slots:
59 59 void launchPluginManager();
60 60 void addPluginInterface(QDockWidget* plugin);
61 void removePluginInterface(QDockWidget* plugin);
61 62 void clearMenu();
62 63 void updateText();
63 64 void setLangage(QAction* action);
64 65 void showAboutBox();
65 66 void pluginselected(const QString& instanceName);
66 67
67 68 signals:
68 69 void translateSig();
69 70 void registerObject(QObject* object,const QString& instanceName);
70 71
71 72 private:
72 73 void makeObjects(QString ScriptToEval);
73 74 void makeLayout();
74 75 void makeConnections();
75 76 void makeMenu();
76 77 QMainWindow* pluginsDockContainer;
77 78 QSplitter* mainWidget;
78 79 PythonConsole* PythonConsoleInst;
79 80 dockablePluginManager* pluginManager;
80 81 regsExplorer* regExplorer;
81 82 aboutsocexplorer* p_about;
82
83 QList<QDockWidget*>* p_pluginGUIlist;
83 84 };
84 85
85 86 #endif // MAINWINDOW_H
General Comments 0
You need to be logged in to leave comments. Login now