##// END OF EJS Templates
Sync
Jeandet Alexis -
r95:083d612a5a2d default
parent child
Show More
@@ -1,301 +1,321
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) 2012, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "socexplorersettings.h"
22 #include "socexplorersettings.h"
23
23
24 SocExplorerSettings* SocExplorerSettings::_self=NULL;
24 SocExplorerSettings* SocExplorerSettings::_self=NULL;
25 QSettings* SocExplorerSettings::m_settings=NULL;
25 QSettings* SocExplorerSettings::m_settings=NULL;
26 QSettings* SocExplorerSettings::m_sessionSettings=NULL;
26 QSettings* SocExplorerSettings::m_sessionSettings=NULL;
27 SocExplorerSettingsDialog* SocExplorerSettings::m_configDialog = NULL;
27 SocExplorerSettingsDialog* SocExplorerSettings::m_configDialog = NULL;
28 #include <socexplorergui.h>
28 #include <socexplorergui.h>
29 #include <QFile>
29 #include <QFile>
30 #include <QFileInfo>
30 #include <QFileInfo>
31 #include <QDir>
31 #include <QDir>
32 #include <QDebug>
32 #include <QDebug>
33
33
34 #define INIT() \
34 #define INIT() \
35 if(Q_UNLIKELY(_self==NULL))\
35 if(Q_UNLIKELY(_self==NULL))\
36 {\
36 {\
37 init();\
37 init();\
38 }
38 }
39
39
40
40
41 SocExplorerSettings::SocExplorerSettings(QObject *parent) : QObject(parent)
41 SocExplorerSettings::SocExplorerSettings(QObject *parent) : QObject(parent)
42 {
42 {
43 m_settings = new QSettings();
43 m_settings = new QSettings();
44 m_configDialog = new SocExplorerSettingsDialog();
44 m_configDialog = new SocExplorerSettingsDialog();
45 QAction* trigerGUI = new QAction(tr("Settings"),this);
45 QAction* trigerGUI = new QAction(tr("Settings"),this);
46 connect(trigerGUI,SIGNAL(triggered()),this,SLOT(popConfigDialog()));
46 connect(trigerGUI,SIGNAL(triggered()),this,SLOT(popConfigDialog()));
47 SocExplorerGUI::addSettingsAction(trigerGUI);
47 SocExplorerGUI::addSettingsAction(trigerGUI);
48 }
48 }
49
49
50 SocExplorerSettings::~SocExplorerSettings()
50 SocExplorerSettings::~SocExplorerSettings()
51 {
51 {
52 if(m_settings)
52 if(m_settings)
53 {
53 {
54 m_settings->sync();
54 m_settings->sync();
55 delete m_settings;
55 delete m_settings;
56 }
56 }
57 if(m_sessionSettings)
57 if(m_sessionSettings)
58 {
58 {
59 m_sessionSettings->sync();
59 m_sessionSettings->sync();
60 delete m_sessionSettings;
60 delete m_sessionSettings;
61 }
61 }
62 }
62 }
63
63
64 void SocExplorerSettings::init()
64 void SocExplorerSettings::init()
65 {
65 {
66 if(!_self)
66 if(!_self)
67 {
67 {
68 _self= new SocExplorerSettings();
68 _self= new SocExplorerSettings();
69 }
69 }
70 }
70 }
71
71
72 void SocExplorerSettings::setValue(QObject *object, const QString &key, const QVariant &value, SettingScope Sscope)
72 void SocExplorerSettings::setValue(QObject *object, const QString &key, const QVariant &value, SettingScope Sscope)
73 {
73 {
74 INIT();
74 INIT();
75 setValue(object->metaObject()->className(),key,value,Sscope);
75 setValue(object->metaObject()->className(),key,value,Sscope);
76 }
76 }
77
77
78 QVariant SocExplorerSettings::value(QObject *object, const QString &key, const QVariant &defaultValue, SettingScope Sscope)
78 QVariant SocExplorerSettings::value(QObject *object, const QString &key, const QVariant &defaultValue, SettingScope Sscope)
79 {
79 {
80 INIT();
80 INIT();
81 return value(object->metaObject()->className(),key,defaultValue,Sscope);
81 return value(object->metaObject()->className(),key,defaultValue,Sscope);
82 }
82 }
83
83
84 void SocExplorerSettings::setValue(const QString scope, const QString &key, const QVariant &value, SettingScope Sscope)
84 void SocExplorerSettings::setValue(const QString scope, const QString &key, const QVariant &value, SettingScope Sscope)
85 {
85 {
86 INIT();
86 INIT();
87 switch (Sscope)
87 switch (Sscope)
88 {
88 {
89 case SystemWide:
89 case SystemWide:
90 if(m_settings)
90 if(m_settings)
91 m_settings->setValue(scope+"/"+key,value);
91 m_settings->setValue(scope+"/"+key,value);
92 break;
92 break;
93 case Session:
93 case Session:
94 if(m_sessionSettings)
94 if(m_sessionSettings)
95 m_sessionSettings->setValue(scope+"/"+key,value);
95 m_sessionSettings->setValue(scope+"/"+key,value);
96 break;
96 break;
97 default:
97 default:
98 break;
98 break;
99 }
99 }
100 }
100 }
101
101
102 QVariant SocExplorerSettings::value(const QString scope, const QString &key, const QVariant &defaultValue, SettingScope Sscope)
102 QVariant SocExplorerSettings::value(const QString scope, const QString &key, const QVariant &defaultValue, SettingScope Sscope)
103 {
103 {
104 INIT();
104 INIT();
105 switch (Sscope)
105 switch (Sscope)
106 {
106 {
107 case SystemWide:
107 case SystemWide:
108 if(m_settings)
108 if(m_settings)
109 return m_settings->value(scope+"/"+key,defaultValue);
109 return m_settings->value(scope+"/"+key,defaultValue);
110 break;
110 break;
111 case Session:
111 case Session:
112 if(m_sessionSettings)
112 if(m_sessionSettings)
113 return m_sessionSettings->value(scope+"/"+key,defaultValue);
113 return m_sessionSettings->value(scope+"/"+key,defaultValue);
114 break;
114 break;
115 default:
115 default:
116 break;
116 break;
117 }
117 }
118 return defaultValue;
118 return defaultValue;
119 }
119 }
120
120
121 QList<QList<QVariant> > SocExplorerSettings::arrays(const QString &prefix, QStringList keys, SocExplorerSettings::SettingScope Sscope)
121 QList<QList<QVariant> > SocExplorerSettings::arrays(const QString &prefix, QStringList keys, SocExplorerSettings::SettingScope Sscope)
122 {
122 {
123 INIT();
123 INIT();
124 QList<QList<QVariant> > defaultValue;
124 QList<QList<QVariant> > defaultValue;
125 switch (Sscope)
125 switch (Sscope)
126 {
126 {
127 case SystemWide:
127 case SystemWide:
128 if(m_settings)
128 if(m_settings)
129 return arrays(prefix,keys,m_settings);
129 return arrays(prefix,keys,m_settings);
130 break;
130 break;
131 case Session:
131 case Session:
132 if(m_sessionSettings)
132 if(m_sessionSettings)
133 return arrays(prefix,keys,m_sessionSettings);
133 return arrays(prefix,keys,m_sessionSettings);
134 break;
134 break;
135 default:
135 default:
136 break;
136 break;
137 }
137 }
138 return defaultValue;
138 return defaultValue;
139 }
139 }
140
140
141 void SocExplorerSettings::setArrays(const QString &prefix, QStringList keys, QList<QList<QVariant> > values, SocExplorerSettings::SettingScope Sscope)
141 void SocExplorerSettings::setArrays(const QString &prefix, QStringList keys, QList<QList<QVariant> > values, SocExplorerSettings::SettingScope Sscope)
142 {
142 {
143 INIT();
143 INIT();
144 switch (Sscope)
144 switch (Sscope)
145 {
145 {
146 case SystemWide:
146 case SystemWide:
147 if(m_settings)
147 if(m_settings)
148 return setArrays(prefix,keys,values,m_settings);
148 return setArrays(prefix,keys,values,m_settings);
149 break;
149 break;
150 case Session:
150 case Session:
151 if(m_sessionSettings)
151 if(m_sessionSettings)
152 return setArrays(prefix,keys,values,m_sessionSettings);
152 return setArrays(prefix,keys,values,m_sessionSettings);
153 break;
153 break;
154 default:
154 default:
155 break;
155 break;
156 }
156 }
157
157
158 }
158 }
159
159
160 void SocExplorerSettings::sync()
160 void SocExplorerSettings::sync()
161 {
161 {
162 INIT();
162 INIT();
163 if(m_settings)
163 if(m_settings)
164 {
164 {
165 m_settings->sync();
165 m_settings->sync();
166 }
166 }
167 if(m_sessionSettings)
167 if(m_sessionSettings)
168 {
168 {
169 m_sessionSettings->sync();
169 m_sessionSettings->sync();
170 }
170 }
171 }
171 }
172
172
173 bool SocExplorerSettings::registerConfigEntry(SocExplorerSettingsItem *configEntry, QIcon icon, QString text)
173 bool SocExplorerSettings::registerConfigEntry(SocExplorerSettingsItem *configEntry, QIcon icon, QString text)
174 {
174 {
175 INIT();
175 INIT();
176 return m_configDialog->registerConfigEntry(configEntry,icon,text);
176 return m_configDialog->registerConfigEntry(configEntry,icon,text);
177 }
177 }
178
178
179 bool SocExplorerSettings::loadSession(const QString &session)
179 bool SocExplorerSettings::loadSession(const QString &session)
180 {
180 {
181 INIT();
181 INIT();
182 QFileInfo sessionInfo(m_settings->fileName());
182 QFileInfo sessionInfo(m_settings->fileName());
183 QString fullpath=sessionInfo.absoluteDir().absolutePath() +"/"+session+".conf";
183 QString fullpath=sessionInfo.absoluteDir().absolutePath() +"/"+session+".conf";
184 if(m_sessionSettings)
184 if(m_sessionSettings)
185 {
185 {
186 delete m_sessionSettings;
186 delete m_sessionSettings;
187 m_sessionSettings = NULL;
187 m_sessionSettings = NULL;
188 }
188 }
189 m_sessionSettings = new QSettings(fullpath,QSettings::NativeFormat,self());
189 m_sessionSettings = new QSettings(fullpath,QSettings::NativeFormat,self());
190 qDebug()<< m_sessionSettings->fileName();
190 qDebug()<< m_sessionSettings->fileName();
191 if(m_sessionSettings->status()==QSettings::NoError)
191 if(m_sessionSettings->status()==QSettings::NoError)
192 {
192 {
193 return true;
193 return true;
194 }
194 }
195 delete m_sessionSettings;
195 delete m_sessionSettings;
196 m_sessionSettings = NULL;
196 m_sessionSettings = NULL;
197 return false;
197 return false;
198 }
198 }
199
199
200 bool SocExplorerSettings::renameSession(const QString &session, const QString &newName)
201 {
202 INIT();
203 sync();
204 QFileInfo sessionInfo(m_settings->fileName());
205 QString fullpath=sessionInfo.absoluteDir().absolutePath() +"/"+session+".conf";
206 QString newFullpath=sessionInfo.absoluteDir().absolutePath() +"/"+newName+".conf";
207 if(m_sessionSettings && m_sessionSettings->fileName()==fullpath)
208 {
209 delete m_sessionSettings;
210 QFile::rename(fullpath,newFullpath);
211 m_sessionSettings = new QSettings(newFullpath,QSettings::NativeFormat,self());
212 }
213 else
214 {
215 QFile::rename(fullpath,newFullpath);
216 }
217 return true;
218 }
219
200 bool SocExplorerSettings::deleteSession()
220 bool SocExplorerSettings::deleteSession()
201 {
221 {
202 INIT();
222 INIT();
203 if(m_sessionSettings)
223 if(m_sessionSettings)
204 {
224 {
205 m_sessionSettings->clear();
225 m_sessionSettings->clear();
206 QString filename= m_sessionSettings->fileName();
226 QString filename= m_sessionSettings->fileName();
207 if(QFile::exists(filename))
227 if(QFile::exists(filename))
208 {
228 {
209 delete m_sessionSettings;
229 delete m_sessionSettings;
210 QFile::remove(filename);
230 QFile::remove(filename);
211 }
231 }
212 else
232 else
213 delete m_sessionSettings;
233 delete m_sessionSettings;
214 m_sessionSettings = NULL;
234 m_sessionSettings = NULL;
215 return true;
235 return true;
216 }
236 }
217 return false;
237 return false;
218 }
238 }
219
239
220 bool SocExplorerSettings::deleteSession(const QString &session)
240 bool SocExplorerSettings::deleteSession(const QString &session)
221 {
241 {
222 QFileInfo sessionInfo(m_settings->fileName());
242 QFileInfo sessionInfo(m_settings->fileName());
223 QString fullpath=sessionInfo.absoluteDir().absolutePath() +"/"+session+".conf";
243 QString fullpath=sessionInfo.absoluteDir().absolutePath() +"/"+session+".conf";
224 if(m_sessionSettings)
244 if(m_sessionSettings)
225 {
245 {
226 if(m_sessionSettings->fileName()==fullpath)
246 if(m_sessionSettings->fileName()==fullpath)
227 {
247 {
228 deleteSession();
248 deleteSession();
229 return true;
249 return true;
230 }
250 }
231 }
251 }
232 QSettings* sessionSettings = new QSettings(fullpath,QSettings::NativeFormat,self());
252 QSettings* sessionSettings = new QSettings(fullpath,QSettings::NativeFormat,self());
233 if(sessionSettings)
253 if(sessionSettings)
234 {
254 {
235 if(sessionSettings->status()==QSettings::NoError)
255 if(sessionSettings->status()==QSettings::NoError)
236 {
256 {
237 sessionSettings->clear();
257 sessionSettings->clear();
238 QString filename= m_sessionSettings->fileName();
258 QString filename= m_sessionSettings->fileName();
239 if(QFile::exists(filename))
259 if(QFile::exists(filename))
240 {
260 {
241 delete sessionSettings;
261 delete sessionSettings;
242 QFile::remove(filename);
262 QFile::remove(filename);
243 }
263 }
244 else
264 else
245 delete sessionSettings;
265 delete sessionSettings;
246 return true;
266 return true;
247 }
267 }
248 delete sessionSettings;
268 delete sessionSettings;
249 }
269 }
250 return false;
270 return false;
251 }
271 }
252
272
253 void SocExplorerSettings::popConfigDialog()
273 void SocExplorerSettings::popConfigDialog()
254 {
274 {
255 m_configDialog->popConfigDialog(NULL);
275 m_configDialog->popConfigDialog(NULL);
256 }
276 }
257
277
258 QList<QList<QVariant> > SocExplorerSettings::arrays(const QString &prefix, QStringList keys, QSettings *settings)
278 QList<QList<QVariant> > SocExplorerSettings::arrays(const QString &prefix, QStringList keys, QSettings *settings)
259 {
279 {
260 QList<QList<QVariant> > result;
280 QList<QList<QVariant> > result;
261 if(settings)
281 if(settings)
262 {
282 {
263 int size = settings->beginReadArray(prefix);
283 int size = settings->beginReadArray(prefix);
264 for (int i = 0; i < size; ++i)
284 for (int i = 0; i < size; ++i)
265 {
285 {
266 result.append(QList<QVariant>());
286 result.append(QList<QVariant>());
267 settings->setArrayIndex(i);
287 settings->setArrayIndex(i);
268 for(int l=0;l<keys.count();l++)
288 for(int l=0;l<keys.count();l++)
269 {
289 {
270 result[i].append(settings->value(keys.at(l)));
290 result[i].append(settings->value(keys.at(l)));
271 }
291 }
272 }
292 }
273 settings->endArray();
293 settings->endArray();
274 }
294 }
275 return result;
295 return result;
276 }
296 }
277
297
278 void SocExplorerSettings::setArrays(const QString &prefix, QStringList keys, QList<QList<QVariant> > values, QSettings *settings)
298 void SocExplorerSettings::setArrays(const QString &prefix, QStringList keys, QList<QList<QVariant> > values, QSettings *settings)
279 {
299 {
280 if(settings)
300 if(settings)
281 {
301 {
282 QString key;
302 QString key;
283 foreach (key, keys)
303 foreach (key, keys)
284 {
304 {
285
305
286 settings->remove(prefix+"/"+key);
306 settings->remove(prefix+"/"+key);
287 }
307 }
288 settings->beginWriteArray(prefix);
308 settings->beginWriteArray(prefix);
289 for (int i = 0; i < values.size(); ++i)
309 for (int i = 0; i < values.size(); ++i)
290 {
310 {
291 settings->setArrayIndex(i);
311 settings->setArrayIndex(i);
292 for(int l=0;l<keys.count();l++)
312 for(int l=0;l<keys.count();l++)
293 {
313 {
294 settings->setValue(keys[l], values.at(i).at(l));
314 settings->setValue(keys[l], values.at(i).at(l));
295 }
315 }
296 }
316 }
297 settings->endArray();
317 settings->endArray();
298
318
299 }
319 }
300 }
320 }
301
321
@@ -1,70 +1,71
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) 2012, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef SOCEXPLORERSETTINGS_H
22 #ifndef SOCEXPLORERSETTINGS_H
23 #define SOCEXPLORERSETTINGS_H
23 #define SOCEXPLORERSETTINGS_H
24
24
25 #include <QObject>
25 #include <QObject>
26 #include <QWidget>
26 #include <QWidget>
27 #include <QSettings>
27 #include <QSettings>
28 #include <socexplorersettingsdialog.h>
28 #include <socexplorersettingsdialog.h>
29
29
30 class SocExplorerSettings : public QObject
30 class SocExplorerSettings : public QObject
31 {
31 {
32 Q_OBJECT
32 Q_OBJECT
33 private:
33 private:
34 static SocExplorerSettings* _self;
34 static SocExplorerSettings* _self;
35 static QSettings* m_settings;
35 static QSettings* m_settings;
36 static QSettings* m_sessionSettings;
36 static QSettings* m_sessionSettings;
37 static SocExplorerSettingsDialog* m_configDialog;
37 static SocExplorerSettingsDialog* m_configDialog;
38 SocExplorerSettings(QObject *parent = 0);
38 SocExplorerSettings(QObject *parent = 0);
39 ~SocExplorerSettings();
39 ~SocExplorerSettings();
40 public:
40 public:
41 enum SettingScope {
41 enum SettingScope {
42 SystemWide = 0,
42 SystemWide = 0,
43 Session
43 Session
44 };
44 };
45 static void init();
45 static void init();
46 static SocExplorerSettings* self(){ if(!_self){_self= new SocExplorerSettings;}return _self;}
46 static SocExplorerSettings* self(){ if(!_self){_self= new SocExplorerSettings;}return _self;}
47 static void setValue(QObject* object,const QString & key, const QVariant & value,SettingScope Sscope =SystemWide);
47 static void setValue(QObject* object,const QString & key, const QVariant & value,SettingScope Sscope =SystemWide);
48 static QVariant value(QObject* object, const QString & key, const QVariant & defaultValue = QVariant(),SettingScope Sscope=SystemWide);
48 static QVariant value(QObject* object, const QString & key, const QVariant & defaultValue = QVariant(),SettingScope Sscope=SystemWide);
49 static void setValue(const QString scope,const QString & key, const QVariant & value,SettingScope Sscope= SystemWide);
49 static void setValue(const QString scope,const QString & key, const QVariant & value,SettingScope Sscope= SystemWide);
50 static QVariant value(const QString scope, const QString & key, const QVariant & defaultValue = QVariant(),SettingScope Sscope =SystemWide);
50 static QVariant value(const QString scope, const QString & key, const QVariant & defaultValue = QVariant(),SettingScope Sscope =SystemWide);
51 static QList<QList<QVariant> > arrays(const QString & prefix, QStringList keys,SettingScope Sscope =SystemWide);
51 static QList<QList<QVariant> > arrays(const QString & prefix, QStringList keys,SettingScope Sscope =SystemWide);
52 static void setArrays(const QString & prefix, QStringList keys,QList<QList<QVariant> > values,SettingScope Sscope =SystemWide);
52 static void setArrays(const QString & prefix, QStringList keys,QList<QList<QVariant> > values,SettingScope Sscope =SystemWide);
53 static void sync();
53 static void sync();
54 static bool registerConfigEntry(SocExplorerSettingsItem* configEntry,QIcon icon, QString text);
54 static bool registerConfigEntry(SocExplorerSettingsItem* configEntry,QIcon icon, QString text);
55 //! Loads the given session, or sreate it if doesn't exists.
55 //! Loads the given session, or sreate it if doesn't exists.
56 //! \param session Session name.
56 //! \param session Session name.
57 //! \return true if success or false if fails to create session config file.
57 //! \return true if success or false if fails to create session config file.
58 static bool loadSession(const QString& session);
58 static bool loadSession(const QString& session);
59 static bool renameSession(const QString& session,const QString& newName);
59 static bool deleteSession();
60 static bool deleteSession();
60 static bool deleteSession(const QString& session);
61 static bool deleteSession(const QString& session);
61 signals:
62 signals:
62
63
63 public slots:
64 public slots:
64 void popConfigDialog();
65 void popConfigDialog();
65 private:
66 private:
66 static QList<QList<QVariant> > arrays(const QString & prefix, QStringList keys,QSettings* settings);
67 static QList<QList<QVariant> > arrays(const QString & prefix, QStringList keys,QSettings* settings);
67 static void setArrays(const QString & prefix, QStringList keys,QList<QList<QVariant> > values,QSettings* settings);
68 static void setArrays(const QString & prefix, QStringList keys,QList<QList<QVariant> > values,QSettings* settings);
68 };
69 };
69
70
70 #endif // SOCEXPLORERSETTINGS_H
71 #endif // SOCEXPLORERSETTINGS_H
@@ -1,264 +1,265
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) 2014, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2014, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22
22
23 #include <socexplorerplugin.h>
23 #include <socexplorerplugin.h>
24 #include <abstractbinfile.h>
24 #include <abstractbinfile.h>
25 #include <srec/srecfile.h>
25 #include <srec/srecfile.h>
26 #include <BinFile/binaryfile.h>
26 #include <BinFile/binaryfile.h>
27
27
28 int socexplorerplugin::isConnected(){return this->Connected;}
28 int socexplorerplugin::isConnected(){return this->Connected;}
29
29
30 QString socexplorerplugin::baseName(){return *_Name;}
30 QString socexplorerplugin::baseName(){return *_Name;}
31
31
32 int socexplorerplugin::baseAddress(){return this->BaseAddress;}
32 int socexplorerplugin::baseAddress(){return this->BaseAddress;}
33
33
34 void socexplorerplugin::setBaseAddress(unsigned int baseAddress){this->BaseAddress = baseAddress;}
34 void socexplorerplugin::setBaseAddress(unsigned int baseAddress){this->BaseAddress = baseAddress;}
35
35
36 QString socexplorerplugin::instanceName()
36 QString socexplorerplugin::instanceName()
37 {
37 {
38 return this->_instanceName;
38 return this->_instanceName;
39 }
39 }
40
40
41 int socexplorerplugin::registermenu(QMenu *menu)
41 int socexplorerplugin::registermenu(QMenu *menu)
42 {
42 {
43 this->menu = menu->addMenu(this->_instanceName);
43 this->menu = menu->addMenu(this->_instanceName);
44 this->closeAction = this->menu->addAction(tr("Close plugin"));
44 this->closeAction = this->menu->addAction(tr("Close plugin"));
45 QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe()));
45 QObject::connect(this->closeAction,SIGNAL(triggered()),this,SLOT(closeMe()));
46 this->ChildsMenu = this->menu->addMenu(QString("Childs"));
46 this->ChildsMenu = this->menu->addMenu(QString("Childs"));
47 for(int i=0;i<this->childs.count();i++)
47 for(int i=0;i<this->childs.count();i++)
48 {
48 {
49 this->childs.at(i)->registermenu(this->ChildsMenu);
49 this->childs.at(i)->registermenu(this->ChildsMenu);
50 }
50 }
51 emit this->registerObject((QObject*)this,this->instanceName());
51 emit this->registerObject((QObject*)this,this->instanceName());
52 return 0;
52 return 0;
53 }
53 }
54
54
55 void socexplorerplugin::postInstantiationTrigger()
55 void socexplorerplugin::postInstantiationTrigger()
56 {
56 {
57 return;
57 return;
58 }
58 }
59
59
60 unsigned int socexplorerplugin::Write(unsigned int *Value, unsigned int count, unsigned int address)
60 unsigned int socexplorerplugin::Write(unsigned int *Value, unsigned int count, unsigned int address)
61 {
61 {
62 if(parent!=NULL)
62 if(parent!=NULL)
63 {
63 {
64 return parent->Write(Value,count,address);
64 return parent->Write(Value,count,address);
65 }
65 }
66 return 0;
66 return 0;
67 }
67 }
68
68
69 unsigned int socexplorerplugin::Read(unsigned int *Value, unsigned int count, unsigned int address)
69 unsigned int socexplorerplugin::Read(unsigned int *Value, unsigned int count, unsigned int address)
70 {
70 {
71 if(parent!=NULL)
71 if(parent!=NULL)
72 {
72 {
73 return parent->Read(Value,count,address);
73 return parent->Read(Value,count,address);
74 }
74 }
75 return 0;
75 return 0;
76 }
76 }
77
77
78 QVariantList socexplorerplugin::Read(unsigned int address,unsigned int count)
78 QVariantList socexplorerplugin::Read(unsigned int address,unsigned int count)
79 {
79 {
80 unsigned int data[count];
80 unsigned int data[count];
81 QVariantList result;
81 QVariantList result;
82 Read(data,count,address);
82 Read(data,count,address);
83 for(unsigned int i = 0;i<count;i++)
83 for(unsigned int i = 0;i<count;i++)
84 {
84 {
85 result.append(QVariant((int)data[i]));
85 result.append(QVariant((int)data[i]));
86 }
86 }
87 return result;
87 return result;
88 }
88 }
89 void socexplorerplugin::Write(unsigned int address,QList<QVariant> dataList)
89 void socexplorerplugin::Write(unsigned int address,QList<QVariant> dataList)
90 {
90 {
91 unsigned int data[dataList.count()];
91 unsigned int data[dataList.count()];
92 for(int i = 0;i<dataList.count();i++)
92 for(int i = 0;i<dataList.count();i++)
93 {
93 {
94 data[i] = (unsigned int)dataList.at(i).toUInt();
94 data[i] = (unsigned int)dataList.at(i).toUInt();
95 }
95 }
96 Write(data,dataList.count(),address);
96 Write(data,dataList.count(),address);
97 }
97 }
98
98
99
99
100
100
101 void socexplorerplugin::closeMe(){emit this->closePlugin(this);}
101 void socexplorerplugin::closeMe(){emit this->closePlugin(this);}
102
102
103 void socexplorerplugin::activate(bool flag){this->setEnabled(flag);emit this->activateSig(flag);}
103 void socexplorerplugin::activate(bool flag){this->setEnabled(flag);emit this->activateSig(flag);}
104
104
105 void socexplorerplugin::setInstanceName(const QString &newName)
105 void socexplorerplugin::setInstanceName(const QString &newName)
106 {
106 {
107 this->_instanceName = newName;
107 this->_instanceName = newName;
108 if(this->menu)
108 if(this->menu)
109 this->menu->setTitle(this->_instanceName);
109 this->menu->setTitle(this->_instanceName);
110 this->setWindowTitle(newName);
110 this->setWindowTitle(newName);
111 this->setObjectName(newName);
111 }
112 }
112
113
113 bool socexplorerplugin::dumpMemory(unsigned int address, unsigned int count, QString file)
114 bool socexplorerplugin::dumpMemory(unsigned int address, unsigned int count, QString file)
114 {
115 {
115 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
116 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
116 if(buffer!=NULL)
117 if(buffer!=NULL)
117 {
118 {
118 this->Read(buffer,count,address);
119 this->Read(buffer,count,address);
119 QFile outfile(file);
120 QFile outfile(file);
120 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
121 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
121 return false;
122 return false;
122 QTextStream out(&outfile);
123 QTextStream out(&outfile);
123 for(int i=0;(unsigned int)i<count;i++)
124 for(int i=0;(unsigned int)i<count;i++)
124 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
125 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
125 free(buffer);
126 free(buffer);
126 out.flush();
127 out.flush();
127 outfile.close();
128 outfile.close();
128 return true;
129 return true;
129 }
130 }
130 return false;
131 return false;
131 }
132 }
132
133
133 bool socexplorerplugin::memSet(unsigned int address, int value, unsigned int count)
134 bool socexplorerplugin::memSet(unsigned int address, int value, unsigned int count)
134 {
135 {
135 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
136 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
136 if(buffer!=NULL)
137 if(buffer!=NULL)
137 {
138 {
138 memset((void*)buffer,value,count*sizeof(unsigned int));
139 memset((void*)buffer,value,count*sizeof(unsigned int));
139 this->Write(buffer,count,address);
140 this->Write(buffer,count,address);
140 free(buffer );
141 free(buffer );
141 return true;
142 return true;
142 }
143 }
143 return false;
144 return false;
144 }
145 }
145
146
146 bool socexplorerplugin::loadbin(unsigned int address, QString file)
147 bool socexplorerplugin::loadbin(unsigned int address, QString file)
147 {
148 {
148 QFile infile(file);
149 QFile infile(file);
149 if (!infile.open(QIODevice::ReadOnly))
150 if (!infile.open(QIODevice::ReadOnly))
150 return false;
151 return false;
151 uint32_t* buffer = (uint32_t*)malloc(infile.size());
152 uint32_t* buffer = (uint32_t*)malloc(infile.size());
152 if(buffer!=NULL)
153 if(buffer!=NULL)
153 {
154 {
154 infile.read((char*)buffer,infile.size());
155 infile.read((char*)buffer,infile.size());
155 for(int i=0;i<(infile.size()/4);i++)
156 for(int i=0;i<(infile.size()/4);i++)
156 {
157 {
157 buffer[i] = socexplorerBswap32(buffer[i]);
158 buffer[i] = socexplorerBswap32(buffer[i]);
158 }
159 }
159 this->Write(buffer,infile.size()/4,address);
160 this->Write(buffer,infile.size()/4,address);
160 free(buffer);
161 free(buffer);
161 return true;
162 return true;
162 }
163 }
163 return false;
164 return false;
164
165
165 }
166 }
166
167
167 bool socexplorerplugin::loadfile(abstractBinFile *file)
168 bool socexplorerplugin::loadfile(abstractBinFile *file)
168 {
169 {
169 if(file->isopened())
170 if(file->isopened())
170 {
171 {
171 QList<codeFragment*> fragments= file->getFragments();
172 QList<codeFragment*> fragments= file->getFragments();
172 for(int i=0;i<fragments.count();i++)
173 for(int i=0;i<fragments.count();i++)
173 {
174 {
174 int size = fragments.at(i)->size/4;
175 int size = fragments.at(i)->size/4;
175 // TODO fixme, should be the oposite
176 // TODO fixme, should be the oposite
176 #if __BYTE_ORDER == __LITTLE_ENDIAN
177 #if __BYTE_ORDER == __LITTLE_ENDIAN
177 if(!file->litleendian)
178 if(!file->litleendian)
178 {
179 {
179 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
180 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
180 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
181 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
181 if(buffer!=NULL)
182 if(buffer!=NULL)
182 {
183 {
183 for(int l=0;l<(size);l++)
184 for(int l=0;l<(size);l++)
184 {
185 {
185 buffer[l] = socexplorerBswap32(buffer[l]);
186 buffer[l] = socexplorerBswap32(buffer[l]);
186 }
187 }
187 this->Write(buffer,size,fragments.at(i)->address);
188 this->Write(buffer,size,fragments.at(i)->address);
188 free(buffer);
189 free(buffer);
189 }
190 }
190 }
191 }
191 else
192 else
192 {
193 {
193 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
194 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
194 }
195 }
195 #elif __BYTE_ORDER == __BIG_ENDIAN
196 #elif __BYTE_ORDER == __BIG_ENDIAN
196 if(file->litleendian)
197 if(file->litleendian)
197 {
198 {
198 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
199 uint32_t* buffer = (uint32_t*)malloc(fragments.at(i)->size);
199 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
200 memcpy(buffer,fragments.at(i)->data,fragments.at(i)->size);
200 if(buffer!=NULL)
201 if(buffer!=NULL)
201 {
202 {
202 for(int l=0;l<(size);l++)
203 for(int l=0;l<(size);l++)
203 {
204 {
204 buffer[l] = socexplorerBswap32(buffer[l]);
205 buffer[l] = socexplorerBswap32(buffer[l]);
205 }
206 }
206 this->Write(buffer,size,fragments.at(i)->address);
207 this->Write(buffer,size,fragments.at(i)->address);
207 free(buffer);
208 free(buffer);
208 }
209 }
209 }
210 }
210 else
211 else
211 {
212 {
212 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
213 this->Write((uint32_t*) fragments.at(i)->data,size,fragments.at(i)->address);
213 }
214 }
214 #endif
215 #endif
215 }
216 }
216 }
217 }
217 return true;
218 return true;
218 }
219 }
219
220
220 bool socexplorerplugin::dumpMemory(unsigned int address, unsigned int count, QString file, const QString &format)
221 bool socexplorerplugin::dumpMemory(unsigned int address, unsigned int count, QString file, const QString &format)
221 {
222 {
222 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
223 unsigned int* buffer = (unsigned int*)malloc(count*sizeof(unsigned int));
223 if(buffer!=NULL)
224 if(buffer!=NULL)
224 {
225 {
225 this->Read(buffer,count,address);
226 this->Read(buffer,count,address);
226 if(!format.compare("srec",Qt::CaseInsensitive))
227 if(!format.compare("srec",Qt::CaseInsensitive))
227 {
228 {
228 //need to convert from in memory endianness to file endianness
229 //need to convert from in memory endianness to file endianness
229 //SREC is always big endian
230 //SREC is always big endian
230 #if __BYTE_ORDER == __LITTLE_ENDIAN
231 #if __BYTE_ORDER == __LITTLE_ENDIAN
231 for(int l=0;l<(count);l++)
232 for(int l=0;l<(count);l++)
232 {
233 {
233 buffer[l] = socexplorerBswap32(buffer[l]);
234 buffer[l] = socexplorerBswap32(buffer[l]);
234 }
235 }
235 #elif __BYTE_ORDER == __BIG_ENDIAN
236 #elif __BYTE_ORDER == __BIG_ENDIAN
236
237
237 #endif
238 #endif
238 codeFragment fragment((char*)buffer,count*4,address);
239 codeFragment fragment((char*)buffer,count*4,address);
239 srecFile::toSrec(QList<codeFragment*>()<<&fragment,file);
240 srecFile::toSrec(QList<codeFragment*>()<<&fragment,file);
240 }
241 }
241 if(!format.compare("bin",Qt::CaseInsensitive))
242 if(!format.compare("bin",Qt::CaseInsensitive))
242 {
243 {
243 //beware this format is not portable from a big endian host to a litle endian one
244 //beware this format is not portable from a big endian host to a litle endian one
244 codeFragment fragment((char*)buffer,count*4,address);
245 codeFragment fragment((char*)buffer,count*4,address);
245 binaryFile::toBinary(QList<codeFragment*>()<<&fragment,file);
246 binaryFile::toBinary(QList<codeFragment*>()<<&fragment,file);
246 }
247 }
247 if(!format.compare("hexa",Qt::CaseInsensitive))
248 if(!format.compare("hexa",Qt::CaseInsensitive))
248 {
249 {
249 QFile outfile(file);
250 QFile outfile(file);
250 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
251 if (!outfile.open(QIODevice::ReadWrite | QIODevice::Text))
251 return false;
252 return false;
252 QTextStream out(&outfile);
253 QTextStream out(&outfile);
253 for(int i=0;(unsigned int)i<count;i++)
254 for(int i=0;(unsigned int)i<count;i++)
254 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
255 out << "0x"+QString::number(address+(i*4),16) + ": 0x" + QString::number(buffer[i],16) + "\n";
255 free(buffer);
256 free(buffer);
256 out.flush();
257 out.flush();
257 outfile.close();
258 outfile.close();
258 }
259 }
259 return true;
260 return true;
260 }
261 }
261 return false;
262 return false;
262 }
263 }
263
264
264
265
@@ -1,328 +1,339
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-2015, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011-2015, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@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 #include <socexplorersettings.h>
24 #include <socexplorersettings.h>
25 #include <socexplorerconfigkeys.h>
25 #include <socexplorerconfigkeys.h>
26
26
27 SocExplorerMainWindow::SocExplorerMainWindow(QString ScriptToEval, QWidget *parent)
27 SocExplorerMainWindow::SocExplorerMainWindow(QString ScriptToEval, QWidget *parent)
28 : QMainWindow(parent)
28 : QMainWindow(parent)
29 {
29 {
30 QCoreApplication::setApplicationName("SocExplorer");
30 QCoreApplication::setApplicationName("SocExplorer");
31 QCoreApplication::setOrganizationName("LPP");
31 QCoreApplication::setOrganizationName("LPP");
32 QCoreApplication::setOrganizationDomain("lpp.fr");
32 QCoreApplication::setOrganizationDomain("lpp.fr");
33 this->makeObjects(ScriptToEval);
33 this->makeObjects(ScriptToEval);
34 this->makeLayout();
34 this->makeLayout();
35 this->makeMenu();
35 this->makeMenu();
36 SocExplorerSettings::init();
36 SocExplorerSettings::init();
37 this->makeConnections();
37 this->makeConnections();
38 this->setWindowIcon(QIcon(":/images/icon.png"));
38 this->setWindowIcon(QIcon(":/images/icon.png"));
39 this->setAcceptDrops(true);
39 this->setAcceptDrops(true);
40 this->pluginManager->setRootLoadable(true);
40 this->pluginManager->setRootLoadable(true);
41 this->PythonConsoleInst->pyConsoleRunFile(ScriptToEval);
41 this->PythonConsoleInst->pyConsoleRunFile(ScriptToEval);
42 QFile file(":/styles/SocExplorer.css");
42 QFile file(":/styles/SocExplorer.css");
43 if(file.open(QIODevice::ReadOnly | QIODevice::Text))
43 if(file.open(QIODevice::ReadOnly | QIODevice::Text))
44 {
44 {
45 qApp->setStyleSheet(file.readAll());
45 qApp->setStyleSheet(file.readAll());
46 file.close();
46 file.close();
47 }
47 }
48 }
48 }
49
49
50
50
51 void SocExplorerMainWindow::makeObjects(QString ScriptToEval)
51 void SocExplorerMainWindow::makeObjects(QString ScriptToEval)
52 {
52 {
53 Q_UNUSED(ScriptToEval)
53 Q_UNUSED(ScriptToEval)
54 this->p_pluginGUIlist = new QList<QDockWidget*>();
54 this->p_pluginGUIlist = new QList<QDockWidget*>();
55 pluginsDockContainer = new QMainWindow;
55 pluginsDockContainer = new QMainWindow;
56 pluginsDockContainer->setObjectName("pluginsDockContainer");
56 pluginsDockContainer->setObjectName("pluginsDockContainer");
57 pluginsDockContainer->setWindowFlags(Qt::Widget);
57 pluginsDockContainer->setWindowFlags(Qt::Widget);
58 pluginsDockContainer->setDockNestingEnabled(true);
58 pluginsDockContainer->setDockNestingEnabled(true);
59 this->sessionsActions = new QActionGroup(this);
60 this->sessionManagerAction =new QAction(tr("&Session manager"),this);
59 this->mainWidget = new QSplitter(Qt::Vertical);
61 this->mainWidget = new QSplitter(Qt::Vertical);
60 this->appTranslator = new QTranslator;
62 this->appTranslator = new QTranslator;
61 this->Quit = new QAction(tr("&Quit"),this);
63 this->Quit = new QAction(tr("&Quit"),this);
62 this->Quit->setShortcut(tr("CTRL+Q"));
64 this->Quit->setShortcut(tr("CTRL+Q"));
63 this->ManagePlugins = new QAction(tr("&Manage Plugins"),this);
65 this->ManagePlugins = new QAction(tr("&Manage Plugins"),this);
64 this->ManagePlugins->setShortcut(tr("CTRL+P"));
66 this->ManagePlugins->setShortcut(tr("CTRL+P"));
65 this->regsManager = new QAction(tr("&Manage registers"),this);
67 this->regsManager = new QAction(tr("&Manage registers"),this);
66 this->exploreRegs = new QAction(tr("&Explore registers"),this);
68 this->exploreRegs = new QAction(tr("&Explore registers"),this);
67 this->help = new QAction(tr("&Help"),this);
69 this->help = new QAction(tr("&Help"),this);
68 this->help->setShortcut(tr("CTRL+H"));
70 this->help->setShortcut(tr("CTRL+H"));
69 this->about = new QAction(tr("&About"),this);
71 this->about = new QAction(tr("&About"),this);
70 this->p_SessionManagerDialog = new SessionManagerDialog();
72 this->p_SessionManagerDialog = new SessionManagerDialog();
71 socexplorerproxy::setMainWindow(this);
73 socexplorerproxy::setMainWindow(this);
72 SocExplorerEngine::setMainWindow(this);
74 SocExplorerEngine::setMainWindow(this);
73 SocExplorerEngine::xmlModel()->scanXmlFiles();
75 SocExplorerEngine::xmlModel()->scanXmlFiles();
74 this->regExplorer = new RegsExplorer();
76 this->regExplorer = new RegsExplorer();
75 this->regExplorer->setAllowedAreas(Qt::AllDockWidgetAreas);
77 this->regExplorer->setAllowedAreas(Qt::AllDockWidgetAreas);
76 this->regExplorer->setObjectName("regExplorer");
78 this->regExplorer->setObjectName("regExplorer");
77 this->addPluginInterface(this->regExplorer);
79 this->addPluginInterface(this->regExplorer);
78 this->PythonConsoleInst = new PythonConsole(socexplorerproxy::self());
80 this->PythonConsoleInst = new PythonConsole(socexplorerproxy::self());
79 this->PythonConsoleInst->addObject("SocExplorerEngine",SocExplorerEngine::self());
81 this->PythonConsoleInst->addObject("SocExplorerEngine",SocExplorerEngine::self());
80 this->pluginManager = new dockablePluginManager();
82 this->pluginManager = new dockablePluginManager();
81 this->toolpane = new toolBar;
83 this->toolpane = new toolBar;
82 this->toolpane->setObjectName("toolpane");
84 this->toolpane->setObjectName("toolpane");
83 this->p_about = new aboutsocexplorer();
85 this->p_about = new aboutsocexplorer();
84 }
86 }
85
87
86 void SocExplorerMainWindow::makeLayout()
88 void SocExplorerMainWindow::makeLayout()
87 {
89 {
88 this->mainWidget->addWidget(pluginsDockContainer);
90 this->mainWidget->addWidget(pluginsDockContainer);
89 this->mainWidget->addWidget(this->PythonConsoleInst);
91 this->mainWidget->addWidget(this->PythonConsoleInst);
90 this->toolpane->setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea);
92 this->toolpane->setAllowedAreas(Qt::RightDockWidgetArea|Qt::LeftDockWidgetArea);
91 this->addDockWidget(Qt::LeftDockWidgetArea,this->toolpane);
93 this->addDockWidget(Qt::LeftDockWidgetArea,this->toolpane);
92 this->toolpane->addTool(this->pluginManager);
94 this->toolpane->addTool(this->pluginManager);
93 this->setCentralWidget(this->mainWidget);
95 this->setCentralWidget(this->mainWidget);
94 }
96 }
95
97
96
98
97 void SocExplorerMainWindow::makeConnections()
99 void SocExplorerMainWindow::makeConnections()
98 {
100 {
99 connect(socexplorerproxy::self(),SIGNAL(clearMenu()),this,SLOT(clearMenu()));
101 connect(socexplorerproxy::self(),SIGNAL(clearMenu()),this,SLOT(clearMenu()));
100 connect(this,SIGNAL(translateSig()),socexplorerproxy::self(),SLOT(updateText()));
102 connect(this,SIGNAL(translateSig()),socexplorerproxy::self(),SLOT(updateText()));
101 connect(socexplorerproxy::self(),SIGNAL(addPluginGUI(QDockWidget*)),this,SLOT(addPluginInterface(QDockWidget*)));
103 connect(socexplorerproxy::self(),SIGNAL(addPluginGUI(QDockWidget*)),this,SLOT(addPluginInterface(QDockWidget*)));
102 connect(socexplorerproxy::self(),SIGNAL(removePluginGUI(QDockWidget*)),this,SLOT(removePluginInterface(QDockWidget*)));
104 connect(socexplorerproxy::self(),SIGNAL(removePluginGUI(QDockWidget*)),this,SLOT(removePluginInterface(QDockWidget*)));
103 connect(this->ManagePlugins,SIGNAL(triggered()),this,SLOT(launchPluginManager()));
105 connect(this->ManagePlugins,SIGNAL(triggered()),this,SLOT(launchPluginManager()));
104 connect(this->Quit,SIGNAL(triggered()),qApp,SLOT(quit()));
106 connect(this->Quit,SIGNAL(triggered()),qApp,SLOT(quit()));
105 connect(this,SIGNAL(registerObject(QObject*,QString)),this->PythonConsoleInst,SLOT(registerObject(QObject*,QString)));
107 connect(this,SIGNAL(registerObject(QObject*,QString)),this->PythonConsoleInst,SLOT(registerObject(QObject*,QString)));
106 connect(socexplorerproxy::self(),SIGNAL(registerObject(QObject*,QString)),this,SIGNAL(registerObject(QObject*,QString)));
108 connect(socexplorerproxy::self(),SIGNAL(registerObject(QObject*,QString)),this,SIGNAL(registerObject(QObject*,QString)));
107 connect(this->pluginManager,SIGNAL(geteplugintree()),socexplorerproxy::self(),SLOT(geteplugintree()));
109 connect(this->pluginManager,SIGNAL(geteplugintree()),socexplorerproxy::self(),SLOT(geteplugintree()));
108 connect(socexplorerproxy::self(),SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->pluginManager,SIGNAL(treeChanged(QList<socexplorerplugin*>)));
110 connect(socexplorerproxy::self(),SIGNAL(treeChanged(QList<socexplorerplugin*>)),this->pluginManager,SIGNAL(treeChanged(QList<socexplorerplugin*>)));
109 connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),socexplorerproxy::self(),SLOT(changeSysDriverInstName(QString,QString)));
111 connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),socexplorerproxy::self(),SLOT(changeSysDriverInstName(QString,QString)));
110 connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),this->PythonConsoleInst,SLOT(changeSysDriverInstName(QString,QString)));
112 connect(this->pluginManager,SIGNAL(changeSysDriverInstName(QString,QString)),this->PythonConsoleInst,SLOT(changeSysDriverInstName(QString,QString)));
111 connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),socexplorerproxy::self(),SLOT(closeSysDriver(QString)));
113 connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),socexplorerproxy::self(),SLOT(closeSysDriver(QString)));
112 connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),this->PythonConsoleInst,SLOT(removeDriver(QString)));
114 connect(this->pluginManager,SIGNAL(closeSysDriver(QString)),this->PythonConsoleInst,SLOT(removeDriver(QString)));
113 connect(this->pluginManager,SIGNAL(pluginselected(QString)),this,SLOT(pluginselected(QString)));
115 connect(this->pluginManager,SIGNAL(pluginselected(QString)),this,SLOT(pluginselected(QString)));
114 connect(this->about,SIGNAL(triggered()),this,SLOT(showAboutBox()));
116 connect(this->about,SIGNAL(triggered()),this,SLOT(showAboutBox()));
115 connect(this->exploreRegs,SIGNAL(triggered()),this->regExplorer,SLOT(show()));
117 connect(this->exploreRegs,SIGNAL(triggered()),this->regExplorer,SLOT(show()));
116
118
117 connect(this->sessionManagerAction, SIGNAL(triggered(bool)),this,SLOT(showSessionManager(bool)));
119 connect(this->sessionManagerAction, SIGNAL(triggered(bool)),this,SLOT(showSessionManager(bool)));
118 connect(this->p_SessionManagerDialog, SIGNAL(switchSession(QString)),this,SLOT(setActiveSession(QString)));
120 connect(this->p_SessionManagerDialog, SIGNAL(switchSession(QString)),this,SLOT(setActiveSession(QString)));
121 connect(this->sessionsActions,SIGNAL(triggered(QAction*)),this,SLOT(setActiveSession(QAction*)));
119
122
120 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString)));
123 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString)));
121 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDriverToParent(QString,QString)),socexplorerproxy::self(),SLOT(loadSysDriverToParent(QString,QString)));
124 this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDriverToParent(QString,QString)),socexplorerproxy::self(),SLOT(loadSysDriverToParent(QString,QString)));
122
125
123 }
126 }
124
127
125
128
126 void SocExplorerMainWindow::launchPluginManager()
129 void SocExplorerMainWindow::launchPluginManager()
127 {
130 {
128 if(this->pluginManager->isHidden())
131 if(this->pluginManager->isHidden())
129 {
132 {
130 this->pluginManager->setHidden(false);
133 this->pluginManager->setHidden(false);
131 }
134 }
132 }
135 }
133
136
134
137
135 void SocExplorerMainWindow::addPluginInterface(QDockWidget *plugin)
138 void SocExplorerMainWindow::addPluginInterface(QDockWidget *plugin)
136 {
139 {
137 plugin->setAllowedAreas(Qt::AllDockWidgetAreas);
140 plugin->setAllowedAreas(Qt::AllDockWidgetAreas);
138 this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,plugin);
141 this->pluginsDockContainer->addDockWidget(Qt::TopDockWidgetArea,plugin);
139 if(p_pluginGUIlist->count()!=0)
142 if(p_pluginGUIlist->count()!=0)
140 this->pluginsDockContainer->tabifyDockWidget(p_pluginGUIlist->last(),plugin);
143 this->pluginsDockContainer->tabifyDockWidget(p_pluginGUIlist->last(),plugin);
141 p_pluginGUIlist->append(plugin);
144 p_pluginGUIlist->append(plugin);
142 }
145 }
143
146
144 void SocExplorerMainWindow::removePluginInterface(QDockWidget *plugin)
147 void SocExplorerMainWindow::removePluginInterface(QDockWidget *plugin)
145 {
148 {
146 p_pluginGUIlist->removeOne(plugin);
149 p_pluginGUIlist->removeOne(plugin);
147 this->pluginsDockContainer->removeDockWidget(plugin);
150 this->pluginsDockContainer->removeDockWidget(plugin);
148 }
151 }
149
152
150
153
151 void SocExplorerMainWindow::clearMenu()
154 void SocExplorerMainWindow::clearMenu()
152 {
155 {
153 this->menuBar()->clear();
156 this->menuBar()->clear();
154 this->makeMenu();
157 this->makeMenu();
155 }
158 }
156
159
157
160
158 void SocExplorerMainWindow::makeMenu()
161 void SocExplorerMainWindow::makeMenu()
159 {
162 {
160 this->FileMenu = menuBar()->addMenu(tr("&File"));
163 this->FileMenu = menuBar()->addMenu(tr("&File"));
161 this->SessionsMenu = this->FileMenu->addMenu(tr("&Sessions"));
164 this->SessionsMenu = this->FileMenu->addMenu(tr("&Sessions"));
162 this->loadSessions();
165 this->loadSessions();
163 this->sessionManagerAction = this->FileMenu->addAction(tr("&Session manager..."));
166 this->FileMenu->addAction(this->sessionManagerAction);
164 this->SettingsMenu = menuBar()->addMenu(tr("&Settings"));
167 this->SettingsMenu = menuBar()->addMenu(tr("&Settings"));
165 SocExplorerGUI::registerMenuBar(menuBar(),this->FileMenu,this->SettingsMenu);
168 SocExplorerGUI::registerMenuBar(menuBar(),this->FileMenu,this->SettingsMenu);
166 this->PluginsMenu = menuBar()->addMenu(tr("&Plugins"));
169 this->PluginsMenu = menuBar()->addMenu(tr("&Plugins"));
167 this->ToolsMenu = menuBar()->addMenu(tr("&Tools"));
170 this->ToolsMenu = menuBar()->addMenu(tr("&Tools"));
168 this->ToolsMenu->addAction(this->exploreRegs);
171 this->ToolsMenu->addAction(this->exploreRegs);
169 this->FileMenu->addAction(this->Quit);
172 this->FileMenu->addAction(this->Quit);
170 socexplorerproxy::self()->makeMenu(this->PluginsMenu);
173 socexplorerproxy::self()->makeMenu(this->PluginsMenu);
171 this->PluginsMenu->addAction(this->ManagePlugins);
174 this->PluginsMenu->addAction(this->ManagePlugins);
172
175
173 this->helpMenu = menuBar()->addMenu(tr("Help"));
176 this->helpMenu = menuBar()->addMenu(tr("Help"));
174 this->helpMenu->addAction(this->help);
177 this->helpMenu->addAction(this->help);
175 this->helpMenu->addAction(this->about);
178 this->helpMenu->addAction(this->about);
176
179
177 }
180 }
178
181
179 void SocExplorerMainWindow::loadSessions()
182 void SocExplorerMainWindow::loadSessions()
180 {
183 {
181 p_Sessions=this->p_SessionManagerDialog->getSessionsList();
184 p_Sessions=this->p_SessionManagerDialog->getSessionsList();
182 sessionsActions_t* sact;
185 QAction* sact;
183 QString stext;
186 QString stext;
184 foreach (sact, sessionsActions)
187 QList<QAction*> sessions=sessionsActions->actions();
188 foreach (sact, sessions)
185 {
189 {
186 sessionsActions.removeAll(sact);
190 sessionsActions->removeAction(sact);
187 SessionsMenu->removeAction(sact);
191 SessionsMenu->removeAction(sact);
188 disconnect(sact);
189 delete sact;
192 delete sact;
190 }
193 }
191 foreach (stext, p_Sessions)
194 foreach (stext, p_Sessions)
192 {
195 {
193 sact = new sessionsActions_t(stext,this);
196 sact = new QAction(stext,this);
194 sact->setCheckable(true);
197 sact->setCheckable(true);
195 connect(sact,SIGNAL(triggered(QString)),this,SLOT(setActiveSession(QString)));
198 sact->setData(stext);
196 sessionsActions.append(sact);
199 if(p_currentSession==stext)
200 sact->setChecked(true);
201 sessionsActions->addAction(sact);
197 SessionsMenu->addAction(sact);
202 SessionsMenu->addAction(sact);
198 }
203 }
199 }
204 }
200
205
201 void SocExplorerMainWindow::savePlugins()
206 void SocExplorerMainWindow::savePlugins()
202 {
207 {
203
208
204 }
209 }
205
210
206 void SocExplorerMainWindow::saveCurrentSession()
211 void SocExplorerMainWindow::saveCurrentSession()
207 {
212 {
208 if(p_currentSession.isEmpty())
213 if(p_currentSession.isEmpty())
209 {
214 {
210 SocExplorerSettings::loadSession("default");
215 SocExplorerSettings::loadSession("default");
211 }
216 }
212 SocExplorerSettings::setValue("GLOBAL","LastModified",QDate::currentDate().toString(),SocExplorerSettings::Session);
217 SocExplorerSettings::setValue("GLOBAL","LastModified",QDate::currentDate().toString(),SocExplorerSettings::Session);
213 SocExplorerSettings::setValue(this,"DOCK_LOCATIONS",this->saveState(0),SocExplorerSettings::Session);
218 SocExplorerSettings::setValue(this,"DOCK_LOCATIONS",this->saveState(0),SocExplorerSettings::Session);
219 SocExplorerSettings::setValue(this,"PLUGINS_DOCK_LOCATIONS",this->pluginsDockContainer->saveState(0),SocExplorerSettings::Session);
214 SocExplorerSettings::setValue(this,"MAIN_WINDOW_GEOMETRY",this->saveGeometry(),SocExplorerSettings::Session);
220 SocExplorerSettings::setValue(this,"MAIN_WINDOW_GEOMETRY",this->saveGeometry(),SocExplorerSettings::Session);
215 QStringList plugins = socexplorerproxy::getPluginsList();
221 QStringList plugins = socexplorerproxy::getPluginsList();
216 SocExplorerSettings::setValue(this,"LOADED_PLUGINS",QVariant(plugins),SocExplorerSettings::Session);
222 SocExplorerSettings::setValue(this,"LOADED_PLUGINS",QVariant(plugins),SocExplorerSettings::Session);
217 SocExplorerSettings::sync();
223 SocExplorerSettings::sync();
218 }
224 }
219
225
220 void SocExplorerMainWindow::loadCurrentSession()
226 void SocExplorerMainWindow::loadCurrentSession()
221 {
227 {
222
228
223 QStringList plugins = SocExplorerSettings::value(this,"LOADED_PLUGINS",QVariant(),SocExplorerSettings::Session).toStringList();
229 QStringList plugins = SocExplorerSettings::value(this,"LOADED_PLUGINS",QVariant(),SocExplorerSettings::Session).toStringList();
224 socexplorerproxy::loadPluginsList(plugins);
230 socexplorerproxy::loadPluginsList(plugins);
225 this->restoreGeometry(SocExplorerSettings::value(this,"MAIN_WINDOW_GEOMETRY",QVariant(),SocExplorerSettings::Session).toByteArray());
231 this->restoreGeometry(SocExplorerSettings::value(this,"MAIN_WINDOW_GEOMETRY",QVariant(),SocExplorerSettings::Session).toByteArray());
226 this->restoreState(SocExplorerSettings::value(this,"DOCK_LOCATIONS",QVariant(),SocExplorerSettings::Session).toByteArray());
232 this->restoreState(SocExplorerSettings::value(this,"DOCK_LOCATIONS",QVariant(),SocExplorerSettings::Session).toByteArray());
233 this->pluginsDockContainer->restoreState(SocExplorerSettings::value(this,"PLUGINS_DOCK_LOCATIONS",QVariant(),SocExplorerSettings::Session).toByteArray());
227 }
234 }
228
235
229
236
230 SocExplorerMainWindow::~SocExplorerMainWindow()
237 SocExplorerMainWindow::~SocExplorerMainWindow()
231 {
238 {
232
239
233 }
240 }
234
241
235
242
236 void SocExplorerMainWindow::setLangage(QAction *action)
243 void SocExplorerMainWindow::setLangage(QAction *action)
237 {
244 {
238 QString local = action->data().toString();
245 QString local = action->data().toString();
239 QString qmPath = QDir(QString("translations")).absolutePath();
246 QString qmPath = QDir(QString("translations")).absolutePath();
240 appTranslator->load(qmPath+"/socexplorer_"+local+".qm");
247 appTranslator->load(qmPath+"/socexplorer_"+local+".qm");
241 qApp->installTranslator(appTranslator);
248 qApp->installTranslator(appTranslator);
242 emit this->translateSig();
249 emit this->translateSig();
243 }
250 }
244
251
245
252
246 void SocExplorerMainWindow::createLangMenu()
253 void SocExplorerMainWindow::createLangMenu()
247 {
254 {
248 this->langMenu = menuBar()->addMenu(tr("&Langue"));
255 this->langMenu = menuBar()->addMenu(tr("&Langue"));
249 this->langActionGrp = new QActionGroup(this);
256 this->langActionGrp = new QActionGroup(this);
250 connect(this->langActionGrp,SIGNAL(triggered(QAction*)),this,SLOT(setLangage(QAction*)));
257 connect(this->langActionGrp,SIGNAL(triggered(QAction*)),this,SLOT(setLangage(QAction*)));
251 QDir* qmDir = new QDir(QString("translations"));
258 QDir* qmDir = new QDir(QString("translations"));
252 QStringList LangFiles = qmDir->entryList(QStringList("socexplorer_*.qm"));
259 QStringList LangFiles = qmDir->entryList(QStringList("socexplorer_*.qm"));
253 for(int i=0;i<LangFiles.size();++i)
260 for(int i=0;i<LangFiles.size();++i)
254 {
261 {
255 QString Local = LangFiles[i];
262 QString Local = LangFiles[i];
256 Local.remove(0,Local.indexOf('_')+1);
263 Local.remove(0,Local.indexOf('_')+1);
257 Local.chop(3);
264 Local.chop(3);
258 QTranslator translator;
265 QTranslator translator;
259 translator.load(LangFiles[i],qmDir->absolutePath());
266 translator.load(LangFiles[i],qmDir->absolutePath());
260 QString langage = translator.translate("MainWindow","English");
267 QString langage = translator.translate("MainWindow","English");
261 QAction *action = new QAction(tr("&%1 %2").arg(i+1).arg(langage),this);
268 QAction *action = new QAction(tr("&%1 %2").arg(i+1).arg(langage),this);
262 action->setCheckable(true);
269 action->setCheckable(true);
263 action->setData(Local);
270 action->setData(Local);
264 langMenu->addAction(action);
271 langMenu->addAction(action);
265 langActionGrp->addAction(action);
272 langActionGrp->addAction(action);
266 if(langage==tr("English"))
273 if(langage==tr("English"))
267 action->setChecked(true);
274 action->setChecked(true);
268 }
275 }
269 }
276 }
270
277
271
278
272 void SocExplorerMainWindow::updateText()
279 void SocExplorerMainWindow::updateText()
273 {
280 {
274 emit this->translateSig();
281 emit this->translateSig();
275 }
282 }
276
283
277
284
278
285
279 void SocExplorerMainWindow::showAboutBox()
286 void SocExplorerMainWindow::showAboutBox()
280 {
287 {
281 p_about->show();
288 p_about->show();
282 }
289 }
283
290
284 void SocExplorerMainWindow::pluginselected(const QString &instanceName)
291 void SocExplorerMainWindow::pluginselected(const QString &instanceName)
285 {
292 {
286 socexplorerplugin* drv=socexplorerproxy::self()->getSysDriver(instanceName);
293 socexplorerplugin* drv=socexplorerproxy::self()->getSysDriver(instanceName);
287 if(drv)
294 if(drv)
288 drv->raise();
295 drv->raise();
289 }
296 }
290
297
291 void SocExplorerMainWindow::setActiveSession(const QString &session)
298 void SocExplorerMainWindow::setActiveSession(const QString &session)
292 {
299 {
293 if(!(p_currentSession.isNull() && session=="default"))
300 if(!(p_currentSession.isNull() && session=="default"))
294 saveCurrentSession();
301 saveCurrentSession();
295 socexplorerproxy::self()->close();
302 socexplorerproxy::self()->close();
296 this->p_currentSession = session;
303 this->p_currentSession = session;
297 sessionsActions_t* sact;
298 SocExplorerSettings::loadSession(session);
304 SocExplorerSettings::loadSession(session);
299 loadCurrentSession();
305 loadCurrentSession();
300 foreach (sact, sessionsActions)
306
301 {
307 }
302 if(sact->text().compare(session))
308
303 sact->setChecked(false);
309 void SocExplorerMainWindow::setActiveSession(QAction *session)
304 else
310 {
305 sact->setChecked(true);
311 this->setActiveSession(session->text());
306 }
307 }
312 }
308
313
309 void SocExplorerMainWindow::showSessionManager(bool)
314 void SocExplorerMainWindow::showSessionManager(bool)
310 {
315 {
311 this->p_SessionManagerDialog->show();
316 this->p_SessionManagerDialog->show();
312 }
317 }
313
318
319 //TODO handle rename
320 void SocExplorerMainWindow::sessionListChanged()
321 {
322
323 }
324
314
325
315
326
316 void SocExplorerMainWindow::closeEvent(QCloseEvent *event)
327 void SocExplorerMainWindow::closeEvent(QCloseEvent *event)
317 {
328 {
318 saveCurrentSession();
329 saveCurrentSession();
319 socexplorerproxy::self()->close();
330 socexplorerproxy::self()->close();
320 qApp->closeAllWindows();
331 qApp->closeAllWindows();
321 event->accept();
332 event->accept();
322 }
333 }
323
334
324
335
325
336
326
337
327
338
328
339
@@ -1,116 +1,100
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, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2011, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@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 #include "socexplorergui.h"
41 #include "socexplorergui.h"
42 #include "sessionmanagerdialog.h"
42 #include "sessionmanagerdialog.h"
43 class sessionsActions_t: public QAction
44 {
45 Q_OBJECT
46 public:
47 sessionsActions_t(const QString &text, QObject* parent)
48 : QAction(text,parent)
49 {
50 connect(this,SIGNAL(triggered(bool)),this,SLOT(p_triggered(bool)));
51 }
52 signals:
53 void triggered(const QString & session);
54 private slots:
55 void p_triggered(bool checked = false)
56 {
57 Q_UNUSED(checked)
58 emit triggered(this->text());
59 }
60 };
61
43
62 class SocExplorerMainWindow : public QMainWindow
44 class SocExplorerMainWindow : public QMainWindow
63 {
45 {
64 Q_OBJECT
46 Q_OBJECT
65
47
66
48
67 public:
49 public:
68 SocExplorerMainWindow(QString ScriptToEval,QWidget *parent = 0);
50 SocExplorerMainWindow(QString ScriptToEval,QWidget *parent = 0);
69 ~SocExplorerMainWindow();
51 ~SocExplorerMainWindow();
70 QAction* Quit,*LoadPlugin,*ManagePlugins,*help,*regsManager,*exploreRegs,*about,*translateAction,*sessionManagerAction;
52 QAction* Quit,*LoadPlugin,*ManagePlugins,*help,*regsManager,*exploreRegs,*about,*translateAction,*sessionManagerAction;
71 QList<sessionsActions_t*> sessionsActions;
53 QActionGroup*sessionsActions;
72 QActionGroup*langActionGrp;
54 QActionGroup*langActionGrp;
73 QMenu* FileMenu,*SettingsMenu,*PluginsMenu,*ToolsMenu,*langMenu,*helpMenu,*SessionsMenu;
55 QMenu* FileMenu,*SettingsMenu,*PluginsMenu,*ToolsMenu,*langMenu,*helpMenu,*SessionsMenu;
74 QTranslator* appTranslator;
56 QTranslator* appTranslator;
75 void createLangMenu();
57 void createLangMenu();
76 void closeEvent(QCloseEvent *event);
58 void closeEvent(QCloseEvent *event);
77 toolBar* toolpane;
59 toolBar* toolpane;
78
60
79
61
80 public slots:
62 public slots:
81 void launchPluginManager();
63 void launchPluginManager();
82 void addPluginInterface(QDockWidget* plugin);
64 void addPluginInterface(QDockWidget* plugin);
83 void removePluginInterface(QDockWidget* plugin);
65 void removePluginInterface(QDockWidget* plugin);
84 void clearMenu();
66 void clearMenu();
85 void updateText();
67 void updateText();
86 void setLangage(QAction* action);
68 void setLangage(QAction* action);
87 void showAboutBox();
69 void showAboutBox();
88 void pluginselected(const QString& instanceName);
70 void pluginselected(const QString& instanceName);
89 void setActiveSession(const QString & session);
71 void setActiveSession(const QString & session);
72 void setActiveSession(QAction* session);
90 void showSessionManager(bool);
73 void showSessionManager(bool);
74 void sessionListChanged();
91 signals:
75 signals:
92 void translateSig();
76 void translateSig();
93 void registerObject(QObject* object,const QString& instanceName);
77 void registerObject(QObject* object,const QString& instanceName);
94
78
95 private:
79 private:
96 void makeObjects(QString ScriptToEval);
80 void makeObjects(QString ScriptToEval);
97 void makeLayout();
81 void makeLayout();
98 void makeConnections();
82 void makeConnections();
99 void makeMenu();
83 void makeMenu();
100 void loadSessions();
84 void loadSessions();
101 void savePlugins();
85 void savePlugins();
102 void saveCurrentSession();
86 void saveCurrentSession();
103 void loadCurrentSession();
87 void loadCurrentSession();
104 QMainWindow* pluginsDockContainer;
88 QMainWindow* pluginsDockContainer;
105 QSplitter* mainWidget;
89 QSplitter* mainWidget;
106 PythonConsole* PythonConsoleInst;
90 PythonConsole* PythonConsoleInst;
107 dockablePluginManager* pluginManager;
91 dockablePluginManager* pluginManager;
108 RegsExplorer* regExplorer;
92 RegsExplorer* regExplorer;
109 aboutsocexplorer* p_about;
93 aboutsocexplorer* p_about;
110 QList<QDockWidget*>* p_pluginGUIlist;
94 QList<QDockWidget*>* p_pluginGUIlist;
111 QStringList p_Sessions;
95 QStringList p_Sessions;
112 QString p_currentSession;
96 QString p_currentSession;
113 SessionManagerDialog* p_SessionManagerDialog;
97 SessionManagerDialog* p_SessionManagerDialog;
114 };
98 };
115
99
116 #endif // MAINWINDOW_H
100 #endif // MAINWINDOW_H
@@ -1,174 +1,178
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) 2015, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #include "sessionmanagerdialog.h"
22 #include "sessionmanagerdialog.h"
23 #include "ui_sessionmanagerdialog.h"
23 #include "ui_sessionmanagerdialog.h"
24 #include <socexplorersettings.h>
24 #include <socexplorersettings.h>
25 #include <socexplorerconfigkeys.h>
25 #include <socexplorerconfigkeys.h>
26 #include <QInputDialog>
26 #include <QInputDialog>
27 #include <QMessageBox>
27 #include <QMessageBox>
28
28
29 SessionManagerDialog::SessionManagerDialog(QWidget *parent) :
29 SessionManagerDialog::SessionManagerDialog(QWidget *parent) :
30 QDialog(parent),
30 QDialog(parent),
31 ui(new Ui::SessionManagerDialog)
31 ui(new Ui::SessionManagerDialog)
32 {
32 {
33 ui->setupUi(this);
33 ui->setupUi(this);
34 connect(this->ui->NewQPB,SIGNAL(clicked(bool)),this,SLOT(newSession()));
34 connect(this->ui->NewQPB,SIGNAL(clicked(bool)),this,SLOT(newSession()));
35 connect(this->ui->DeleteQPB,SIGNAL(clicked(bool)),this,SLOT(deleteSession()));
35 connect(this->ui->DeleteQPB,SIGNAL(clicked(bool)),this,SLOT(deleteSession()));
36 connect(this->ui->RenameQPB,SIGNAL(clicked(bool)),this,SLOT(renameSession()));
36 connect(this->ui->RenameQPB,SIGNAL(clicked(bool)),this,SLOT(renameSession()));
37 connect(this->ui->SwitchToQPB,SIGNAL(clicked(bool)),this,SLOT(switchSession()));
37 connect(this->ui->SwitchToQPB,SIGNAL(clicked(bool)),this,SLOT(switchSession()));
38 }
38 }
39
39
40 SessionManagerDialog::~SessionManagerDialog()
40 SessionManagerDialog::~SessionManagerDialog()
41 {
41 {
42 delete ui;
42 delete ui;
43 }
43 }
44
44
45
45
46 QStringList SessionManagerDialog::getSessionsList()
46 QStringList SessionManagerDialog::getSessionsList()
47 {
47 {
48 QStringList result;
48 QStringList result;
49 QList<QList<QVariant> > sessions = SocExplorerSettings::arrays(SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_SCOPE,QStringList()<<SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_NAME);
49 QList<QList<QVariant> > sessions = SocExplorerSettings::arrays(SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_SCOPE,QStringList()<<SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_NAME);
50 for(int i=0;i<sessions.count();i++)
50 for(int i=0;i<sessions.count();i++)
51 {
51 {
52 if(sessions.at(i).count()>=1)
52 if(sessions.at(i).count()>=1)
53 {
53 {
54 result.append(sessions.at(i).at(0).toString());
54 result.append(sessions.at(i).at(0).toString());
55 }
55 }
56 }
56 }
57 // May always return at least default session
57 // May always return at least default session
58 if(result.count()==0)
58 if(result.count()==0)
59 {
59 {
60 result.append("default");
60 result.append("default");
61 }
61 }
62 return result;
62 return result;
63 }
63 }
64
64
65 void SessionManagerDialog::show()
65 void SessionManagerDialog::show()
66 {
66 {
67 QStringList sessions = getSessionsList();
67 QStringList sessions = getSessionsList();
68 this->ui->listWidget->clear();
68 this->ui->listWidget->clear();
69 this->ui->listWidget->addItems(sessions);
69 this->ui->listWidget->addItems(sessions);
70 QDialog::show();
70 QDialog::show();
71 }
71 }
72
72
73 void SessionManagerDialog::newSession()
73 void SessionManagerDialog::newSession()
74 {
74 {
75 bool ok=true,exists=false;
75 bool ok=true,exists=false;
76 QString text;
76 QString text;
77 do
77 do
78 {
78 {
79 text = QInputDialog::getText(this, tr("SocExplorer Session Manager"),
79 text = QInputDialog::getText(this, tr("SocExplorer Session Manager"),
80 tr("Session name:"), QLineEdit::Normal,
80 tr("Session name:"), QLineEdit::Normal,
81 "New Session", &ok);
81 "New Session", &ok);
82 exists = sessionExists(text);
82 exists = sessionExists(text);
83 if(exists && ok)
83 if(exists && ok)
84 {
84 {
85 QMessageBox::warning(this, tr("SocExplorer Session Manager"),
85 QMessageBox::warning(this, tr("SocExplorer Session Manager"),
86 tr("The session ")+text+tr(" already exists."),
86 tr("The session ")+text+tr(" already exists."),
87 QMessageBox::Ok);
87 QMessageBox::Ok);
88 }
88 }
89 }while(ok && (text.isEmpty() || exists));
89 }while(ok && (text.isEmpty() || exists));
90
90
91 if (ok && !text.isEmpty())
91 if (ok && !text.isEmpty())
92 {
92 {
93 this->newSession(text);
93 this->newSession(text);
94 }
94 }
95 }
95 }
96
96
97 void SessionManagerDialog::newSession(QString session)
97 void SessionManagerDialog::newSession(QString session)
98 {
98 {
99 if (!session.isEmpty())
99 if (!session.isEmpty())
100 {
100 {
101 this->ui->listWidget->addItem(session);
101 this->ui->listWidget->addItem(session);
102 updateSessionList();
102 updateSessionList();
103 }
103 }
104 }
104 }
105
105
106 void SessionManagerDialog::renameSession()
106 void SessionManagerDialog::renameSession()
107 {
107 {
108 bool ok=true;
108 bool ok=true;
109 int exists=0;
109 int exists=0;
110 QListWidgetItem* item = this->ui->listWidget->currentItem();
110 QListWidgetItem* item = this->ui->listWidget->currentItem();
111 QString text= item->text();
111 QString text= item->text();
112 QString OldText= item->text();
112 do
113 do
113 {
114 {
114 text = QInputDialog::getText(this, tr("SocExplorer Session Manager"),
115 text = QInputDialog::getText(this, tr("SocExplorer Session Manager"),
115 tr("New session name:"), QLineEdit::Normal,
116 tr("New session name:"), QLineEdit::Normal,
116 text, &ok);
117 text, &ok);
117 exists = sessionExists(text);
118 exists = sessionExists(text);
118 if(exists&& ok)
119 if(exists&& ok)
119 {
120 {
120 QMessageBox::warning(this, tr("SocExplorer Session Manager"),
121 QMessageBox::warning(this, tr("SocExplorer Session Manager"),
121 tr("The session ")+text+tr(" already exists."),
122 tr("The session ")+text+tr(" already exists."),
122 QMessageBox::Ok);
123 QMessageBox::Ok);
123 }
124 }
124 }while(ok && text.isEmpty());
125 }while(ok && text.isEmpty());
125
126
126 if (ok && !text.isEmpty())
127 if (ok && !text.isEmpty())
127 {
128 {
128 item->setText(text);
129 item->setText(text);
130 SocExplorerSettings::renameSession(text,OldText);
131 updateSessionList();
132 emit sessionListChanged();
129 }
133 }
130 }
134 }
131
135
132 void SessionManagerDialog::deleteSession()
136 void SessionManagerDialog::deleteSession()
133 {
137 {
134 if(this->ui->listWidget->selectedItems().count())
138 if(this->ui->listWidget->selectedItems().count())
135 {
139 {
136 QListWidgetItem* item = this->ui->listWidget->currentItem();
140 QListWidgetItem* item = this->ui->listWidget->currentItem();
137 if(item && item->text().compare("default"))
141 if(item && item->text().compare("default"))
138 {
142 {
139 this->ui->listWidget->removeItemWidget(item);
143 this->ui->listWidget->removeItemWidget(item);
140 SocExplorerSettings::deleteSession(item->text());
144 SocExplorerSettings::deleteSession(item->text());
141 delete item;
145 delete item;
142 updateSessionList();
146 updateSessionList();
143 }
147 }
144 }
148 }
145 }
149 }
146
150
147 void SessionManagerDialog::switchSession()
151 void SessionManagerDialog::switchSession()
148 {
152 {
149 QListWidgetItem* item = this->ui->listWidget->currentItem();
153 QListWidgetItem* item = this->ui->listWidget->currentItem();
150 if(item)
154 if(item)
151 emit switchSession(item->text());
155 emit switchSession(item->text());
152 }
156 }
153
157
154 int SessionManagerDialog::sessionExists(QString session)
158 int SessionManagerDialog::sessionExists(QString session)
155 {
159 {
156 int exists=0;
160 int exists=0;
157 for(int i=0;i< this->ui->listWidget->count();i++)
161 for(int i=0;i< this->ui->listWidget->count();i++)
158 {
162 {
159 exists += (this->ui->listWidget->item(i)->text().compare(session)==0);
163 exists += (this->ui->listWidget->item(i)->text().compare(session)==0);
160 }
164 }
161 return exists;
165 return exists;
162 }
166 }
163
167
164 void SessionManagerDialog::updateSessionList()
168 void SessionManagerDialog::updateSessionList()
165 {
169 {
166 QList<QList<QVariant> > sessions;
170 QList<QList<QVariant> > sessions;
167 for(int i=0;i< this->ui->listWidget->count();i++)
171 for(int i=0;i< this->ui->listWidget->count();i++)
168 {
172 {
169 QList<QVariant> sess;
173 QList<QVariant> sess;
170 sess.append(this->ui->listWidget->item(i)->text());
174 sess.append(this->ui->listWidget->item(i)->text());
171 sessions.append(sess);
175 sessions.append(sess);
172 }
176 }
173 SocExplorerSettings::setArrays(SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_SCOPE,QStringList()<<SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_NAME,sessions);
177 SocExplorerSettings::setArrays(SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_SCOPE,QStringList()<<SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_NAME,sessions);
174 }
178 }
@@ -1,57 +1,58
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) 2015, Plasma Physics Laboratory - CNRS
3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
4 --
4 --
5 -- This program is free software; you can redistribute it and/or modify
5 -- This program is free software; you can redistribute it and/or modify
6 -- it under the terms of the GNU General Public License as published by
6 -- it under the terms of the GNU General Public License as published by
7 -- the Free Software Foundation; either version 2 of the License, or
7 -- the Free Software Foundation; either version 2 of the License, or
8 -- (at your option) any later version.
8 -- (at your option) any later version.
9 --
9 --
10 -- This program is distributed in the hope that it will be useful,
10 -- This program is distributed in the hope that it will be useful,
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 -- GNU General Public License for more details.
13 -- GNU General Public License for more details.
14 --
14 --
15 -- You should have received a copy of the GNU General Public License
15 -- You should have received a copy of the GNU General Public License
16 -- along with this program; if not, write to the Free Software
16 -- along with this program; if not, write to the Free Software
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 -------------------------------------------------------------------------------*/
18 -------------------------------------------------------------------------------*/
19 /*-- Author : Alexis Jeandet
19 /*-- Author : Alexis Jeandet
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
20 -- Mail : alexis.jeandet@lpp.polytechnique.fr
21 ----------------------------------------------------------------------------*/
21 ----------------------------------------------------------------------------*/
22 #ifndef SESSIONMANAGERDIALOG_H
22 #ifndef SESSIONMANAGERDIALOG_H
23 #define SESSIONMANAGERDIALOG_H
23 #define SESSIONMANAGERDIALOG_H
24
24
25 #include <QDialog>
25 #include <QDialog>
26
26
27 namespace Ui {
27 namespace Ui {
28 class SessionManagerDialog;
28 class SessionManagerDialog;
29 }
29 }
30
30
31 class SessionManagerDialog : public QDialog
31 class SessionManagerDialog : public QDialog
32 {
32 {
33 Q_OBJECT
33 Q_OBJECT
34
34
35 public:
35 public:
36 explicit SessionManagerDialog(QWidget *parent = 0);
36 explicit SessionManagerDialog(QWidget *parent = 0);
37 ~SessionManagerDialog();
37 ~SessionManagerDialog();
38
38
39 QStringList getSessionsList();
39 QStringList getSessionsList();
40 public slots:
40 public slots:
41 void show();
41 void show();
42 void newSession(QString session);
42 void newSession(QString session);
43 int sessionExists(QString session);
43 int sessionExists(QString session);
44 private slots:
44 private slots:
45 void newSession();
45 void newSession();
46 void renameSession();
46 void renameSession();
47 void deleteSession();
47 void deleteSession();
48 void switchSession();
48 void switchSession();
49 signals:
49 signals:
50 void switchSession(QString session);
50 void switchSession(QString session);
51 void sessionListChanged();
51
52
52 private:
53 private:
53 void updateSessionList();
54 void updateSessionList();
54 Ui::SessionManagerDialog *ui;
55 Ui::SessionManagerDialog *ui;
55 };
56 };
56
57
57 #endif // SESSIONMANAGERDIALOG_H
58 #endif // SESSIONMANAGERDIALOG_H
@@ -1,121 +1,127
1 <?xml version="1.0" encoding="UTF-8"?>
1 <?xml version="1.0" encoding="UTF-8"?>
2 <ui version="4.0">
2 <ui version="4.0">
3 <class>SessionManagerDialog</class>
3 <class>SessionManagerDialog</class>
4 <widget class="QDialog" name="SessionManagerDialog">
4 <widget class="QDialog" name="SessionManagerDialog">
5 <property name="windowModality">
6 <enum>Qt::ApplicationModal</enum>
7 </property>
5 <property name="geometry">
8 <property name="geometry">
6 <rect>
9 <rect>
7 <x>0</x>
10 <x>0</x>
8 <y>0</y>
11 <y>0</y>
9 <width>553</width>
12 <width>553</width>
10 <height>275</height>
13 <height>275</height>
11 </rect>
14 </rect>
12 </property>
15 </property>
13 <property name="windowTitle">
16 <property name="windowTitle">
14 <string>SocExplorer Session Manager</string>
17 <string>SocExplorer Session Manager</string>
15 </property>
18 </property>
19 <property name="modal">
20 <bool>true</bool>
21 </property>
16 <layout class="QGridLayout" name="gridLayout">
22 <layout class="QGridLayout" name="gridLayout">
17 <item row="0" column="0">
23 <item row="0" column="0">
18 <widget class="QListWidget" name="listWidget"/>
24 <widget class="QListWidget" name="listWidget"/>
19 </item>
25 </item>
20 <item row="0" column="1">
26 <item row="0" column="1">
21 <widget class="QWidget" name="widget" native="true">
27 <widget class="QWidget" name="widget" native="true">
22 <layout class="QVBoxLayout" name="verticalLayout">
28 <layout class="QVBoxLayout" name="verticalLayout">
23 <item>
29 <item>
24 <widget class="QPushButton" name="NewQPB">
30 <widget class="QPushButton" name="NewQPB">
25 <property name="text">
31 <property name="text">
26 <string>New</string>
32 <string>New</string>
27 </property>
33 </property>
28 </widget>
34 </widget>
29 </item>
35 </item>
30 <item>
36 <item>
31 <widget class="QPushButton" name="RenameQPB">
37 <widget class="QPushButton" name="RenameQPB">
32 <property name="text">
38 <property name="text">
33 <string>Rename</string>
39 <string>Rename</string>
34 </property>
40 </property>
35 </widget>
41 </widget>
36 </item>
42 </item>
37 <item>
43 <item>
38 <widget class="QPushButton" name="CloneQPB">
44 <widget class="QPushButton" name="CloneQPB">
39 <property name="text">
45 <property name="text">
40 <string>Clone</string>
46 <string>Clone</string>
41 </property>
47 </property>
42 </widget>
48 </widget>
43 </item>
49 </item>
44 <item>
50 <item>
45 <widget class="QPushButton" name="DeleteQPB">
51 <widget class="QPushButton" name="DeleteQPB">
46 <property name="text">
52 <property name="text">
47 <string>Delete</string>
53 <string>Delete</string>
48 </property>
54 </property>
49 </widget>
55 </widget>
50 </item>
56 </item>
51 <item>
57 <item>
52 <widget class="QPushButton" name="SwitchToQPB">
58 <widget class="QPushButton" name="SwitchToQPB">
53 <property name="text">
59 <property name="text">
54 <string>Switch to</string>
60 <string>Switch to</string>
55 </property>
61 </property>
56 </widget>
62 </widget>
57 </item>
63 </item>
58 <item>
64 <item>
59 <spacer name="verticalSpacer">
65 <spacer name="verticalSpacer">
60 <property name="orientation">
66 <property name="orientation">
61 <enum>Qt::Vertical</enum>
67 <enum>Qt::Vertical</enum>
62 </property>
68 </property>
63 <property name="sizeHint" stdset="0">
69 <property name="sizeHint" stdset="0">
64 <size>
70 <size>
65 <width>20</width>
71 <width>20</width>
66 <height>40</height>
72 <height>40</height>
67 </size>
73 </size>
68 </property>
74 </property>
69 </spacer>
75 </spacer>
70 </item>
76 </item>
71 </layout>
77 </layout>
72 </widget>
78 </widget>
73 </item>
79 </item>
74 <item row="1" column="0" colspan="2">
80 <item row="1" column="0" colspan="2">
75 <widget class="QDialogButtonBox" name="buttonBox">
81 <widget class="QDialogButtonBox" name="buttonBox">
76 <property name="orientation">
82 <property name="orientation">
77 <enum>Qt::Horizontal</enum>
83 <enum>Qt::Horizontal</enum>
78 </property>
84 </property>
79 <property name="standardButtons">
85 <property name="standardButtons">
80 <set>QDialogButtonBox::Close</set>
86 <set>QDialogButtonBox::Close</set>
81 </property>
87 </property>
82 </widget>
88 </widget>
83 </item>
89 </item>
84 </layout>
90 </layout>
85 </widget>
91 </widget>
86 <resources/>
92 <resources/>
87 <connections>
93 <connections>
88 <connection>
94 <connection>
89 <sender>buttonBox</sender>
95 <sender>buttonBox</sender>
90 <signal>accepted()</signal>
96 <signal>accepted()</signal>
91 <receiver>SessionManagerDialog</receiver>
97 <receiver>SessionManagerDialog</receiver>
92 <slot>accept()</slot>
98 <slot>accept()</slot>
93 <hints>
99 <hints>
94 <hint type="sourcelabel">
100 <hint type="sourcelabel">
95 <x>248</x>
101 <x>248</x>
96 <y>254</y>
102 <y>254</y>
97 </hint>
103 </hint>
98 <hint type="destinationlabel">
104 <hint type="destinationlabel">
99 <x>157</x>
105 <x>157</x>
100 <y>274</y>
106 <y>274</y>
101 </hint>
107 </hint>
102 </hints>
108 </hints>
103 </connection>
109 </connection>
104 <connection>
110 <connection>
105 <sender>buttonBox</sender>
111 <sender>buttonBox</sender>
106 <signal>rejected()</signal>
112 <signal>rejected()</signal>
107 <receiver>SessionManagerDialog</receiver>
113 <receiver>SessionManagerDialog</receiver>
108 <slot>reject()</slot>
114 <slot>reject()</slot>
109 <hints>
115 <hints>
110 <hint type="sourcelabel">
116 <hint type="sourcelabel">
111 <x>316</x>
117 <x>316</x>
112 <y>260</y>
118 <y>260</y>
113 </hint>
119 </hint>
114 <hint type="destinationlabel">
120 <hint type="destinationlabel">
115 <x>286</x>
121 <x>286</x>
116 <y>274</y>
122 <y>274</y>
117 </hint>
123 </hint>
118 </hints>
124 </hints>
119 </connection>
125 </connection>
120 </connections>
126 </connections>
121 </ui>
127 </ui>
General Comments 0
You need to be logged in to leave comments. Login now