@@ -197,6 +197,26 bool SocExplorerSettings::loadSession(co | |||
|
197 | 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 | 220 | bool SocExplorerSettings::deleteSession() |
|
201 | 221 | { |
|
202 | 222 | INIT(); |
@@ -56,6 +56,7 public: | |||
|
56 | 56 | //! \param session Session name. |
|
57 | 57 | //! \return true if success or false if fails to create session config file. |
|
58 | 58 | static bool loadSession(const QString& session); |
|
59 | static bool renameSession(const QString& session,const QString& newName); | |
|
59 | 60 | static bool deleteSession(); |
|
60 | 61 | static bool deleteSession(const QString& session); |
|
61 | 62 | signals: |
@@ -108,6 +108,7 void socexplorerplugin::setInstanceName( | |||
|
108 | 108 | if(this->menu) |
|
109 | 109 | this->menu->setTitle(this->_instanceName); |
|
110 | 110 | this->setWindowTitle(newName); |
|
111 | this->setObjectName(newName); | |
|
111 | 112 | } |
|
112 | 113 | |
|
113 | 114 | bool socexplorerplugin::dumpMemory(unsigned int address, unsigned int count, QString file) |
@@ -56,6 +56,8 void SocExplorerMainWindow::makeObjects( | |||
|
56 | 56 | pluginsDockContainer->setObjectName("pluginsDockContainer"); |
|
57 | 57 | pluginsDockContainer->setWindowFlags(Qt::Widget); |
|
58 | 58 | pluginsDockContainer->setDockNestingEnabled(true); |
|
59 | this->sessionsActions = new QActionGroup(this); | |
|
60 | this->sessionManagerAction =new QAction(tr("&Session manager"),this); | |
|
59 | 61 | this->mainWidget = new QSplitter(Qt::Vertical); |
|
60 | 62 | this->appTranslator = new QTranslator; |
|
61 | 63 | this->Quit = new QAction(tr("&Quit"),this); |
@@ -116,6 +118,7 void SocExplorerMainWindow::makeConnecti | |||
|
116 | 118 | |
|
117 | 119 | connect(this->sessionManagerAction, SIGNAL(triggered(bool)),this,SLOT(showSessionManager(bool))); |
|
118 | 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 | 123 | this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDrviver(QString)),socexplorerproxy::self(),SLOT(loadSysDriver(QString))); |
|
121 | 124 | this->pluginManager->connect(this->pluginManager,SIGNAL(loadSysDriverToParent(QString,QString)),socexplorerproxy::self(),SLOT(loadSysDriverToParent(QString,QString))); |
@@ -160,7 +163,7 void SocExplorerMainWindow::makeMenu() | |||
|
160 | 163 | this->FileMenu = menuBar()->addMenu(tr("&File")); |
|
161 | 164 | this->SessionsMenu = this->FileMenu->addMenu(tr("&Sessions")); |
|
162 | 165 | this->loadSessions(); |
|
163 |
|
|
|
166 | this->FileMenu->addAction(this->sessionManagerAction); | |
|
164 | 167 | this->SettingsMenu = menuBar()->addMenu(tr("&Settings")); |
|
165 | 168 | SocExplorerGUI::registerMenuBar(menuBar(),this->FileMenu,this->SettingsMenu); |
|
166 | 169 | this->PluginsMenu = menuBar()->addMenu(tr("&Plugins")); |
@@ -179,21 +182,23 void SocExplorerMainWindow::makeMenu() | |||
|
179 | 182 | void SocExplorerMainWindow::loadSessions() |
|
180 | 183 | { |
|
181 | 184 | p_Sessions=this->p_SessionManagerDialog->getSessionsList(); |
|
182 |
|
|
|
185 | QAction* sact; | |
|
183 | 186 | QString stext; |
|
184 | foreach (sact, sessionsActions) | |
|
187 | QList<QAction*> sessions=sessionsActions->actions(); | |
|
188 | foreach (sact, sessions) | |
|
185 | 189 | { |
|
186 |
sessionsActions |
|
|
190 | sessionsActions->removeAction(sact); | |
|
187 | 191 | SessionsMenu->removeAction(sact); |
|
188 | disconnect(sact); | |
|
189 | 192 | delete sact; |
|
190 | 193 | } |
|
191 | 194 | foreach (stext, p_Sessions) |
|
192 | 195 | { |
|
193 |
sact = new |
|
|
196 | sact = new QAction(stext,this); | |
|
194 | 197 | sact->setCheckable(true); |
|
195 | connect(sact,SIGNAL(triggered(QString)),this,SLOT(setActiveSession(QString))); | |
|
196 | sessionsActions.append(sact); | |
|
198 | sact->setData(stext); | |
|
199 | if(p_currentSession==stext) | |
|
200 | sact->setChecked(true); | |
|
201 | sessionsActions->addAction(sact); | |
|
197 | 202 | SessionsMenu->addAction(sact); |
|
198 | 203 | } |
|
199 | 204 | } |
@@ -211,6 +216,7 void SocExplorerMainWindow::saveCurrentS | |||
|
211 | 216 | } |
|
212 | 217 | SocExplorerSettings::setValue("GLOBAL","LastModified",QDate::currentDate().toString(),SocExplorerSettings::Session); |
|
213 | 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 | 220 | SocExplorerSettings::setValue(this,"MAIN_WINDOW_GEOMETRY",this->saveGeometry(),SocExplorerSettings::Session); |
|
215 | 221 | QStringList plugins = socexplorerproxy::getPluginsList(); |
|
216 | 222 | SocExplorerSettings::setValue(this,"LOADED_PLUGINS",QVariant(plugins),SocExplorerSettings::Session); |
@@ -224,6 +230,7 void SocExplorerMainWindow::loadCurrentS | |||
|
224 | 230 | socexplorerproxy::loadPluginsList(plugins); |
|
225 | 231 | this->restoreGeometry(SocExplorerSettings::value(this,"MAIN_WINDOW_GEOMETRY",QVariant(),SocExplorerSettings::Session).toByteArray()); |
|
226 | 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 | 301 | saveCurrentSession(); |
|
295 | 302 | socexplorerproxy::self()->close(); |
|
296 | 303 | this->p_currentSession = session; |
|
297 | sessionsActions_t* sact; | |
|
298 | 304 | SocExplorerSettings::loadSession(session); |
|
299 | 305 | loadCurrentSession(); |
|
300 | foreach (sact, sessionsActions) | |
|
306 | ||
|
307 | } | |
|
308 | ||
|
309 | void SocExplorerMainWindow::setActiveSession(QAction *session) | |
|
301 | 310 | { |
|
302 | if(sact->text().compare(session)) | |
|
303 | sact->setChecked(false); | |
|
304 | else | |
|
305 | sact->setChecked(true); | |
|
306 | } | |
|
311 | this->setActiveSession(session->text()); | |
|
307 | 312 | } |
|
308 | 313 | |
|
309 | 314 | void SocExplorerMainWindow::showSessionManager(bool) |
@@ -311,6 +316,12 void SocExplorerMainWindow::showSessionM | |||
|
311 | 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 | 327 | void SocExplorerMainWindow::closeEvent(QCloseEvent *event) |
@@ -40,24 +40,6 | |||
|
40 | 40 | #include "regsExplorer/regsexplorer.h" |
|
41 | 41 | #include "socexplorergui.h" |
|
42 | 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 | 44 | class SocExplorerMainWindow : public QMainWindow |
|
63 | 45 | { |
@@ -68,7 +50,7 public: | |||
|
68 | 50 | SocExplorerMainWindow(QString ScriptToEval,QWidget *parent = 0); |
|
69 | 51 | ~SocExplorerMainWindow(); |
|
70 | 52 | QAction* Quit,*LoadPlugin,*ManagePlugins,*help,*regsManager,*exploreRegs,*about,*translateAction,*sessionManagerAction; |
|
71 |
Q |
|
|
53 | QActionGroup*sessionsActions; | |
|
72 | 54 | QActionGroup*langActionGrp; |
|
73 | 55 | QMenu* FileMenu,*SettingsMenu,*PluginsMenu,*ToolsMenu,*langMenu,*helpMenu,*SessionsMenu; |
|
74 | 56 | QTranslator* appTranslator; |
@@ -87,7 +69,9 public slots: | |||
|
87 | 69 | void showAboutBox(); |
|
88 | 70 | void pluginselected(const QString& instanceName); |
|
89 | 71 | void setActiveSession(const QString & session); |
|
72 | void setActiveSession(QAction* session); | |
|
90 | 73 | void showSessionManager(bool); |
|
74 | void sessionListChanged(); | |
|
91 | 75 | signals: |
|
92 | 76 | void translateSig(); |
|
93 | 77 | void registerObject(QObject* object,const QString& instanceName); |
@@ -109,6 +109,7 void SessionManagerDialog::renameSession | |||
|
109 | 109 | int exists=0; |
|
110 | 110 | QListWidgetItem* item = this->ui->listWidget->currentItem(); |
|
111 | 111 | QString text= item->text(); |
|
112 | QString OldText= item->text(); | |
|
112 | 113 | do |
|
113 | 114 | { |
|
114 | 115 | text = QInputDialog::getText(this, tr("SocExplorer Session Manager"), |
@@ -126,6 +127,9 void SessionManagerDialog::renameSession | |||
|
126 | 127 | if (ok && !text.isEmpty()) |
|
127 | 128 | { |
|
128 | 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 | 48 | void switchSession(); |
|
49 | 49 | signals: |
|
50 | 50 | void switchSession(QString session); |
|
51 | void sessionListChanged(); | |
|
51 | 52 | |
|
52 | 53 | private: |
|
53 | 54 | void updateSessionList(); |
@@ -2,6 +2,9 | |||
|
2 | 2 | <ui version="4.0"> |
|
3 | 3 | <class>SessionManagerDialog</class> |
|
4 | 4 | <widget class="QDialog" name="SessionManagerDialog"> |
|
5 | <property name="windowModality"> | |
|
6 | <enum>Qt::ApplicationModal</enum> | |
|
7 | </property> | |
|
5 | 8 | <property name="geometry"> |
|
6 | 9 | <rect> |
|
7 | 10 | <x>0</x> |
@@ -13,6 +16,9 | |||
|
13 | 16 | <property name="windowTitle"> |
|
14 | 17 | <string>SocExplorer Session Manager</string> |
|
15 | 18 | </property> |
|
19 | <property name="modal"> | |
|
20 | <bool>true</bool> | |
|
21 | </property> | |
|
16 | 22 | <layout class="QGridLayout" name="gridLayout"> |
|
17 | 23 | <item row="0" column="0"> |
|
18 | 24 | <widget class="QListWidget" name="listWidget"/> |
General Comments 0
You need to be logged in to leave comments.
Login now