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