##// END OF EJS Templates
Sync
Jeandet Alexis -
r95:083d612a5a2d default
parent child
Show More
@@ -197,6 +197,26 bool SocExplorerSettings::loadSession(co
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();
@@ -56,6 +56,7 public:
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:
@@ -108,6 +108,7 void socexplorerplugin::setInstanceName(
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)
@@ -56,6 +56,8 void SocExplorerMainWindow::makeObjects(
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);
@@ -116,6 +118,7 void SocExplorerMainWindow::makeConnecti
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)));
@@ -160,7 +163,7 void SocExplorerMainWindow::makeMenu()
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"));
@@ -179,21 +182,23 void SocExplorerMainWindow::makeMenu()
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 }
@@ -211,6 +216,7 void SocExplorerMainWindow::saveCurrentS
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);
@@ -224,6 +230,7 void SocExplorerMainWindow::loadCurrentS
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
@@ -294,16 +301,14 void SocExplorerMainWindow::setActiveSes
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
307 }
308
309 void SocExplorerMainWindow::setActiveSession(QAction *session)
301 {
310 {
302 if(sact->text().compare(session))
311 this->setActiveSession(session->text());
303 sact->setChecked(false);
304 else
305 sact->setChecked(true);
306 }
307 }
312 }
308
313
309 void SocExplorerMainWindow::showSessionManager(bool)
314 void SocExplorerMainWindow::showSessionManager(bool)
@@ -311,6 +316,12 void SocExplorerMainWindow::showSessionM
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)
@@ -40,24 +40,6
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 {
@@ -68,7 +50,7 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;
@@ -87,7 +69,9 public slots:
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);
@@ -109,6 +109,7 void SessionManagerDialog::renameSession
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"),
@@ -126,6 +127,9 void SessionManagerDialog::renameSession
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
@@ -48,6 +48,7 private slots:
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();
@@ -2,6 +2,9
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>
@@ -13,6 +16,9
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"/>
General Comments 0
You need to be logged in to leave comments. Login now