@@ -0,0 +1,34 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
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 | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
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 | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | #ifndef SOCEXPLORERCONFIGKEYS | |||
|
23 | #define SOCEXPLORERCONFIGKEYS | |||
|
24 | ||||
|
25 | #define SOCEXPLORERENGINE_SETTINGS_SCOPE "SocExplorerEngine" | |||
|
26 | #define SOCEXPLORERENGINE_SETTINGS_PLUGINS_LOOKUP_PATH "plugins-lookup-path" | |||
|
27 | #define SOCEXPLORERENGINE_SETTINGS_SOC_REGS_LOOKUP_PATH "soc-registers-lookup-path" | |||
|
28 | ||||
|
29 | #define SOCEXPLORERGLOBAL_SETTINGS_SCOPE "GLOBAL" | |||
|
30 | #define SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_SCOPE "SESSIONS" | |||
|
31 | #define SOCEXPLORERGLOBAL_SETTINGS_SESSIONS_NAME "NAME" | |||
|
32 | ||||
|
33 | #endif // SOCEXPLORERCONFIGKEYS | |||
|
34 |
@@ -0,0 +1,93 | |||||
|
1 | #include "socexplorergui.h" | |||
|
2 | ||||
|
3 | SocExplorerGUI* SocExplorerGUI::_self=NULL; | |||
|
4 | QMenuBar* SocExplorerGUI::m_mainMenuBar=NULL; | |||
|
5 | QMenu* SocExplorerGUI::m_fileMenu=NULL; | |||
|
6 | QMenu* SocExplorerGUI::m_SettingsMenu=NULL; | |||
|
7 | QList<QAction*>* SocExplorerGUI::m_queuedSettingActions=NULL; | |||
|
8 | QList<QAction*>* SocExplorerGUI::m_queuedFileMenuActions=NULL; | |||
|
9 | ||||
|
10 | #define INIT() \ | |||
|
11 | if(Q_UNLIKELY(_self==NULL))\ | |||
|
12 | {\ | |||
|
13 | init();\ | |||
|
14 | } | |||
|
15 | ||||
|
16 | SocExplorerGUI::SocExplorerGUI(QObject *parent) : QObject(parent) | |||
|
17 | { | |||
|
18 | m_queuedFileMenuActions = new QList<QAction*>(); | |||
|
19 | m_queuedSettingActions = new QList<QAction*>(); | |||
|
20 | } | |||
|
21 | ||||
|
22 | void SocExplorerGUI::init() | |||
|
23 | { | |||
|
24 | _self=new SocExplorerGUI(); | |||
|
25 | } | |||
|
26 | ||||
|
27 | void SocExplorerGUI::registerMenuBar(QMenuBar *menuBar, QMenu *fileMenu, QMenu *SettingsMenu) | |||
|
28 | { | |||
|
29 | INIT(); | |||
|
30 | m_mainMenuBar = menuBar; | |||
|
31 | if(m_mainMenuBar) | |||
|
32 | { | |||
|
33 | if(fileMenu==NULL) | |||
|
34 | m_fileMenu = m_mainMenuBar->addMenu(tr("File")); | |||
|
35 | else | |||
|
36 | m_fileMenu = fileMenu; | |||
|
37 | if(SettingsMenu==NULL) | |||
|
38 | m_SettingsMenu = m_mainMenuBar->addMenu(tr("Settings")); | |||
|
39 | else | |||
|
40 | m_SettingsMenu = SettingsMenu; | |||
|
41 | } | |||
|
42 | ||||
|
43 | QAction* action; | |||
|
44 | foreach (action, *m_queuedSettingActions) | |||
|
45 | { | |||
|
46 | m_SettingsMenu->addAction(action); | |||
|
47 | } | |||
|
48 | foreach (action, *m_queuedFileMenuActions) | |||
|
49 | { | |||
|
50 | m_fileMenu->addAction(action); | |||
|
51 | } | |||
|
52 | } | |||
|
53 | ||||
|
54 | QMenu *SocExplorerGUI::addMenu(const QString &title) | |||
|
55 | { | |||
|
56 | INIT(); | |||
|
57 | if(m_mainMenuBar) | |||
|
58 | { | |||
|
59 | return m_mainMenuBar->addMenu(title); | |||
|
60 | } | |||
|
61 | return NULL; | |||
|
62 | } | |||
|
63 | ||||
|
64 | bool SocExplorerGUI::addFileAction(QAction *action) | |||
|
65 | { | |||
|
66 | INIT(); | |||
|
67 | if(m_fileMenu) | |||
|
68 | { | |||
|
69 | m_fileMenu->addAction(action); | |||
|
70 | return true; | |||
|
71 | } | |||
|
72 | else | |||
|
73 | { | |||
|
74 | m_queuedFileMenuActions->append(action); | |||
|
75 | } | |||
|
76 | return false; | |||
|
77 | } | |||
|
78 | ||||
|
79 | bool SocExplorerGUI::addSettingsAction(QAction *action) | |||
|
80 | { | |||
|
81 | INIT(); | |||
|
82 | if(m_SettingsMenu) | |||
|
83 | { | |||
|
84 | m_SettingsMenu->addAction(action); | |||
|
85 | return true; | |||
|
86 | } | |||
|
87 | else | |||
|
88 | { | |||
|
89 | m_queuedSettingActions->append(action); | |||
|
90 | } | |||
|
91 | return false; | |||
|
92 | } | |||
|
93 |
@@ -0,0 +1,32 | |||||
|
1 | #ifndef SOCEXPLORERGUI_H | |||
|
2 | #define SOCEXPLORERGUI_H | |||
|
3 | ||||
|
4 | #include <QObject> | |||
|
5 | #include <QWidget> | |||
|
6 | #include <QMenu> | |||
|
7 | #include <QMenuBar> | |||
|
8 | #include <QAction> | |||
|
9 | ||||
|
10 | class SocExplorerGUI : public QObject | |||
|
11 | { | |||
|
12 | Q_OBJECT | |||
|
13 | static SocExplorerGUI* _self; | |||
|
14 | static QMenuBar* m_mainMenuBar; | |||
|
15 | static QMenu* m_fileMenu; | |||
|
16 | static QMenu* m_SettingsMenu; | |||
|
17 | static QList<QAction*>* m_queuedSettingActions; | |||
|
18 | static QList<QAction*>* m_queuedFileMenuActions; | |||
|
19 | SocExplorerGUI(QObject *parent = 0); | |||
|
20 | static void init(); | |||
|
21 | public: | |||
|
22 | static SocExplorerGUI* self(){ if(!_self){_self= new SocExplorerGUI;}return _self;} | |||
|
23 | static void registerMenuBar(QMenuBar* menuBar, QMenu* fileMenu=NULL, QMenu* SettingsMenu=NULL); | |||
|
24 | static QMenu* addMenu(const QString & title); | |||
|
25 | static bool addFileAction(QAction * action); | |||
|
26 | static bool addSettingsAction(QAction * action); | |||
|
27 | signals: | |||
|
28 | ||||
|
29 | public slots: | |||
|
30 | }; | |||
|
31 | ||||
|
32 | #endif // SOCEXPLORERGUI_H |
@@ -0,0 +1,205 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
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 | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
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 | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | #include "socexplorersettings.h" | |||
|
23 | ||||
|
24 | SocExplorerSettings* SocExplorerSettings::_self=NULL; | |||
|
25 | QSettings* SocExplorerSettings::m_settings=NULL; | |||
|
26 | QSettings* SocExplorerSettings::m_sessionSettings=NULL; | |||
|
27 | SocExplorerSettingsDialog* SocExplorerSettings::m_configDialog = NULL; | |||
|
28 | #include <socexplorergui.h> | |||
|
29 | #include <QFile> | |||
|
30 | #include <QFileInfo> | |||
|
31 | #include <QDir> | |||
|
32 | #include <QDebug> | |||
|
33 | ||||
|
34 | #define INIT() \ | |||
|
35 | if(Q_UNLIKELY(_self==NULL))\ | |||
|
36 | {\ | |||
|
37 | init();\ | |||
|
38 | } | |||
|
39 | ||||
|
40 | ||||
|
41 | SocExplorerSettings::SocExplorerSettings(QObject *parent) : QObject(parent) | |||
|
42 | { | |||
|
43 | m_settings = new QSettings(); | |||
|
44 | m_configDialog = new SocExplorerSettingsDialog(); | |||
|
45 | QAction* trigerGUI = new QAction(tr("Settings"),this); | |||
|
46 | connect(trigerGUI,SIGNAL(triggered()),this,SLOT(popConfigDialog())); | |||
|
47 | SocExplorerGUI::addSettingsAction(trigerGUI); | |||
|
48 | } | |||
|
49 | ||||
|
50 | SocExplorerSettings::~SocExplorerSettings() | |||
|
51 | { | |||
|
52 | if(m_settings) | |||
|
53 | { | |||
|
54 | m_settings->sync(); | |||
|
55 | delete m_settings; | |||
|
56 | } | |||
|
57 | if(m_sessionSettings) | |||
|
58 | { | |||
|
59 | m_sessionSettings->sync(); | |||
|
60 | delete m_sessionSettings; | |||
|
61 | } | |||
|
62 | } | |||
|
63 | ||||
|
64 | void SocExplorerSettings::init() | |||
|
65 | { | |||
|
66 | if(!_self) | |||
|
67 | { | |||
|
68 | _self= new SocExplorerSettings(); | |||
|
69 | } | |||
|
70 | } | |||
|
71 | ||||
|
72 | void SocExplorerSettings::setValue(QObject *object, const QString &key, const QVariant &value, SettingScope Sscope) | |||
|
73 | { | |||
|
74 | INIT(); | |||
|
75 | setValue(object->metaObject()->className(),key,value,Sscope); | |||
|
76 | } | |||
|
77 | ||||
|
78 | QVariant SocExplorerSettings::value(QObject *object, const QString &key, const QVariant &defaultValue, SettingScope Sscope) | |||
|
79 | { | |||
|
80 | INIT(); | |||
|
81 | return value(object->metaObject()->className(),key,defaultValue,Sscope); | |||
|
82 | } | |||
|
83 | ||||
|
84 | void SocExplorerSettings::setValue(const QString scope, const QString &key, const QVariant &value, SettingScope Sscope) | |||
|
85 | { | |||
|
86 | INIT(); | |||
|
87 | switch (Sscope) | |||
|
88 | { | |||
|
89 | case SystemWide: | |||
|
90 | if(m_settings) | |||
|
91 | m_settings->setValue(scope+"/"+key,value); | |||
|
92 | break; | |||
|
93 | case Session: | |||
|
94 | if(m_sessionSettings) | |||
|
95 | m_sessionSettings->setValue(scope+"/"+key,value); | |||
|
96 | break; | |||
|
97 | default: | |||
|
98 | break; | |||
|
99 | } | |||
|
100 | } | |||
|
101 | ||||
|
102 | QVariant SocExplorerSettings::value(const QString scope, const QString &key, const QVariant &defaultValue, SettingScope Sscope) | |||
|
103 | { | |||
|
104 | INIT(); | |||
|
105 | switch (Sscope) | |||
|
106 | { | |||
|
107 | case SystemWide: | |||
|
108 | if(m_settings) | |||
|
109 | return m_settings->value(scope+"/"+key,defaultValue); | |||
|
110 | break; | |||
|
111 | case Session: | |||
|
112 | if(m_sessionSettings) | |||
|
113 | return m_sessionSettings->value(scope+"/"+key,defaultValue); | |||
|
114 | break; | |||
|
115 | default: | |||
|
116 | break; | |||
|
117 | } | |||
|
118 | return defaultValue; | |||
|
119 | } | |||
|
120 | ||||
|
121 | QList<QList<QVariant> > SocExplorerSettings::arrays(const QString &prefix, QStringList keys, SocExplorerSettings::SettingScope Sscope) | |||
|
122 | { | |||
|
123 | INIT(); | |||
|
124 | QList<QList<QVariant> > defaultValue; | |||
|
125 | switch (Sscope) | |||
|
126 | { | |||
|
127 | case SystemWide: | |||
|
128 | if(m_settings) | |||
|
129 | return arrays(prefix,keys,m_settings); | |||
|
130 | break; | |||
|
131 | case Session: | |||
|
132 | if(m_sessionSettings) | |||
|
133 | return arrays(prefix,keys,m_sessionSettings); | |||
|
134 | break; | |||
|
135 | default: | |||
|
136 | break; | |||
|
137 | } | |||
|
138 | return defaultValue; | |||
|
139 | } | |||
|
140 | ||||
|
141 | void SocExplorerSettings::sync() | |||
|
142 | { | |||
|
143 | INIT(); | |||
|
144 | if(m_settings) | |||
|
145 | { | |||
|
146 | m_settings->sync(); | |||
|
147 | } | |||
|
148 | if(m_sessionSettings) | |||
|
149 | { | |||
|
150 | m_sessionSettings->sync(); | |||
|
151 | } | |||
|
152 | } | |||
|
153 | ||||
|
154 | bool SocExplorerSettings::registerConfigEntry(SocExplorerSettingsItem *configEntry, QIcon icon, QString text) | |||
|
155 | { | |||
|
156 | INIT(); | |||
|
157 | return m_configDialog->registerConfigEntry(configEntry,icon,text); | |||
|
158 | } | |||
|
159 | ||||
|
160 | bool SocExplorerSettings::loadSession(const QString &session) | |||
|
161 | { | |||
|
162 | INIT(); | |||
|
163 | QFileInfo sessionInfo(m_settings->fileName()); | |||
|
164 | QString fullpath=sessionInfo.absoluteDir().absolutePath() +"/"+session+".conf"; | |||
|
165 | if(m_sessionSettings) | |||
|
166 | { | |||
|
167 | delete m_sessionSettings; | |||
|
168 | m_sessionSettings = NULL; | |||
|
169 | } | |||
|
170 | m_sessionSettings = new QSettings(fullpath,QSettings::NativeFormat,self()); | |||
|
171 | qDebug()<< m_sessionSettings->fileName(); | |||
|
172 | if(m_sessionSettings->status()==QSettings::NoError) | |||
|
173 | { | |||
|
174 | return true; | |||
|
175 | } | |||
|
176 | delete m_sessionSettings; | |||
|
177 | m_sessionSettings = NULL; | |||
|
178 | return false; | |||
|
179 | } | |||
|
180 | ||||
|
181 | void SocExplorerSettings::popConfigDialog() | |||
|
182 | { | |||
|
183 | m_configDialog->popConfigDialog(NULL); | |||
|
184 | } | |||
|
185 | ||||
|
186 | QList<QList<QVariant> > SocExplorerSettings::arrays(const QString &prefix, QStringList keys, QSettings *settings) | |||
|
187 | { | |||
|
188 | QList<QList<QVariant> > result; | |||
|
189 | if(settings) | |||
|
190 | { | |||
|
191 | int size = settings->beginReadArray(prefix); | |||
|
192 | for (int i = 0; i < size; ++i) | |||
|
193 | { | |||
|
194 | result.append(QList<QVariant>()); | |||
|
195 | settings->setArrayIndex(i); | |||
|
196 | for(int l=0;l<keys.count();l++) | |||
|
197 | { | |||
|
198 | result[i].append(settings->value(keys.at(i))); | |||
|
199 | } | |||
|
200 | } | |||
|
201 | settings->endArray(); | |||
|
202 | } | |||
|
203 | return result; | |||
|
204 | } | |||
|
205 |
@@ -0,0 +1,66 | |||||
|
1 | /*------------------------------------------------------------------------------ | |||
|
2 | -- This file is a part of the SocExplorer Software | |||
|
3 | -- Copyright (C) 2012, Plasma Physics Laboratory - CNRS | |||
|
4 | -- | |||
|
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 | |||
|
7 | -- the Free Software Foundation; either version 2 of the License, or | |||
|
8 | -- (at your option) any later version. | |||
|
9 | -- | |||
|
10 | -- This program is distributed in the hope that it will be useful, | |||
|
11 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
12 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
13 | -- GNU General Public License for more details. | |||
|
14 | -- | |||
|
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 | |||
|
17 | -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |||
|
18 | -------------------------------------------------------------------------------*/ | |||
|
19 | /*-- Author : Alexis Jeandet | |||
|
20 | -- Mail : alexis.jeandet@lpp.polytechnique.fr | |||
|
21 | ----------------------------------------------------------------------------*/ | |||
|
22 | #ifndef SOCEXPLORERSETTINGS_H | |||
|
23 | #define SOCEXPLORERSETTINGS_H | |||
|
24 | ||||
|
25 | #include <QObject> | |||
|
26 | #include <QWidget> | |||
|
27 | #include <QSettings> | |||
|
28 | #include <socexplorersettingsdialog.h> | |||
|
29 | ||||
|
30 | class SocExplorerSettings : public QObject | |||
|
31 | { | |||
|
32 | Q_OBJECT | |||
|
33 | private: | |||
|
34 | static SocExplorerSettings* _self; | |||
|
35 | static QSettings* m_settings; | |||
|
36 | static QSettings* m_sessionSettings; | |||
|
37 | static SocExplorerSettingsDialog* m_configDialog; | |||
|
38 | SocExplorerSettings(QObject *parent = 0); | |||
|
39 | ~SocExplorerSettings(); | |||
|
40 | public: | |||
|
41 | enum SettingScope { | |||
|
42 | SystemWide = 0, | |||
|
43 | Session | |||
|
44 | }; | |||
|
45 | static void init(); | |||
|
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); | |||
|
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); | |||
|
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); | |||
|
52 | static void sync(); | |||
|
53 | static bool registerConfigEntry(SocExplorerSettingsItem* configEntry,QIcon icon, QString text); | |||
|
54 | //! Loads the given session, or sreate it if doesn't exists. | |||
|
55 | //! \param session Session name. | |||
|
56 | //! \return true if success or false if fails to create session config file. | |||
|
57 | static bool loadSession(const QString& session); | |||
|
58 | signals: | |||
|
59 | ||||
|
60 | public slots: | |||
|
61 | void popConfigDialog(); | |||
|
62 | private: | |||
|
63 | static QList<QList<QVariant> > arrays(const QString & prefix, QStringList keys,QSettings* settings); | |||
|
64 | }; | |||
|
65 | ||||
|
66 | #endif // SOCEXPLORERSETTINGS_H |
@@ -0,0 +1,69 | |||||
|
1 | #include "socexplorersettingsdialog.h" | |||
|
2 | #include "ui_socexplorersettingsdialog.h" | |||
|
3 | ||||
|
4 | SocExplorerSettingsDialog::SocExplorerSettingsDialog(QWidget *parent) : | |||
|
5 | QDialog(parent), | |||
|
6 | ui(new Ui::SocExplorerSettingsDialog) | |||
|
7 | { | |||
|
8 | ui->setupUi(this); | |||
|
9 | connect(ui->contentsWidget, SIGNAL(currentItemChanged(QListWidgetItem*,QListWidgetItem*)),this, SLOT(changePage(QListWidgetItem*,QListWidgetItem*))); | |||
|
10 | ui->contentsWidget->setViewMode(QListView::IconMode); | |||
|
11 | ui->contentsWidget->setIconSize(QSize(96, 84)); | |||
|
12 | ui->contentsWidget->setMovement(QListView::Static); | |||
|
13 | ui->contentsWidget->setSpacing(12); | |||
|
14 | } | |||
|
15 | ||||
|
16 | SocExplorerSettingsDialog::~SocExplorerSettingsDialog() | |||
|
17 | { | |||
|
18 | delete ui; | |||
|
19 | } | |||
|
20 | ||||
|
21 | void SocExplorerSettingsDialog::changePage(QListWidgetItem *current, QListWidgetItem *previous) | |||
|
22 | { | |||
|
23 | if (!current) | |||
|
24 | current = previous; | |||
|
25 | ui->pagesWidget->setCurrentIndex(ui->contentsWidget->row(current)); | |||
|
26 | } | |||
|
27 | ||||
|
28 | bool SocExplorerSettingsDialog::registerConfigEntry(SocExplorerSettingsItem *configEntry, QIcon icon, QString text) | |||
|
29 | { | |||
|
30 | if(configEntry!=NULL) | |||
|
31 | { | |||
|
32 | ui->pagesWidget->addWidget(configEntry); | |||
|
33 | QListWidgetItem *configButton = new QListWidgetItem(ui->contentsWidget); | |||
|
34 | configButton->setIcon(icon); | |||
|
35 | configButton->setText(text); | |||
|
36 | configButton->setTextAlignment(Qt::AlignHCenter); | |||
|
37 | configButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); | |||
|
38 | connect(this,SIGNAL(accepted()),configEntry,SLOT(accept())); | |||
|
39 | return true; | |||
|
40 | } | |||
|
41 | return false; | |||
|
42 | } | |||
|
43 | ||||
|
44 | void SocExplorerSettingsDialog::popConfigDialog(SocExplorerSettingsItem *selectedConfigEntry) | |||
|
45 | { | |||
|
46 | if(selectedConfigEntry!=NULL) | |||
|
47 | { | |||
|
48 | for(int i=0;i<ui->pagesWidget->count();i++) | |||
|
49 | { | |||
|
50 | if(ui->pagesWidget->widget(i)==selectedConfigEntry) | |||
|
51 | { | |||
|
52 | ui->pagesWidget->setCurrentIndex(i); | |||
|
53 | } | |||
|
54 | } | |||
|
55 | } | |||
|
56 | this->show(); | |||
|
57 | } | |||
|
58 | ||||
|
59 | void SocExplorerSettingsDialog::changeEvent(QEvent *e) | |||
|
60 | { | |||
|
61 | QDialog::changeEvent(e); | |||
|
62 | switch (e->type()) { | |||
|
63 | case QEvent::LanguageChange: | |||
|
64 | ui->retranslateUi(this); | |||
|
65 | break; | |||
|
66 | default: | |||
|
67 | break; | |||
|
68 | } | |||
|
69 | } |
@@ -0,0 +1,41 | |||||
|
1 | #ifndef SOCEXPLORERSETTINGSDIALOG_H | |||
|
2 | #define SOCEXPLORERSETTINGSDIALOG_H | |||
|
3 | ||||
|
4 | #include <QDialog> | |||
|
5 | ||||
|
6 | namespace Ui { | |||
|
7 | class SocExplorerSettingsDialog; | |||
|
8 | } | |||
|
9 | #include <QListWidgetItem> | |||
|
10 | ||||
|
11 | class SocExplorerSettingsItem : public QWidget | |||
|
12 | { | |||
|
13 | Q_OBJECT | |||
|
14 | public: | |||
|
15 | SocExplorerSettingsItem(QWidget *parent = 0):QWidget(parent) {} | |||
|
16 | ~SocExplorerSettingsItem() {} | |||
|
17 | public slots: | |||
|
18 | virtual void accept()=0; | |||
|
19 | }; | |||
|
20 | ||||
|
21 | class SocExplorerSettingsDialog : public QDialog | |||
|
22 | { | |||
|
23 | Q_OBJECT | |||
|
24 | ||||
|
25 | public: | |||
|
26 | explicit SocExplorerSettingsDialog(QWidget *parent = 0); | |||
|
27 | ~SocExplorerSettingsDialog(); | |||
|
28 | ||||
|
29 | public slots: | |||
|
30 | void changePage(QListWidgetItem *current, QListWidgetItem *previous); | |||
|
31 | bool registerConfigEntry(SocExplorerSettingsItem* configEntry, QIcon icon, QString text); | |||
|
32 | void popConfigDialog(SocExplorerSettingsItem* selectedConfigEntry=0); | |||
|
33 | ||||
|
34 | protected: | |||
|
35 | void changeEvent(QEvent *e); | |||
|
36 | ||||
|
37 | private: | |||
|
38 | Ui::SocExplorerSettingsDialog *ui; | |||
|
39 | }; | |||
|
40 | ||||
|
41 | #endif // SOCEXPLORERSETTINGSDIALOG_H |
@@ -0,0 +1,102 | |||||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |||
|
2 | <ui version="4.0"> | |||
|
3 | <class>SocExplorerSettingsDialog</class> | |||
|
4 | <widget class="QDialog" name="SocExplorerSettingsDialog"> | |||
|
5 | <property name="geometry"> | |||
|
6 | <rect> | |||
|
7 | <x>0</x> | |||
|
8 | <y>0</y> | |||
|
9 | <width>555</width> | |||
|
10 | <height>329</height> | |||
|
11 | </rect> | |||
|
12 | </property> | |||
|
13 | <property name="windowTitle"> | |||
|
14 | <string>Dialog</string> | |||
|
15 | </property> | |||
|
16 | <layout class="QGridLayout" name="gridLayout"> | |||
|
17 | <item row="0" column="1"> | |||
|
18 | <widget class="QListWidget" name="contentsWidget"> | |||
|
19 | <property name="sizePolicy"> | |||
|
20 | <sizepolicy hsizetype="Maximum" vsizetype="Expanding"> | |||
|
21 | <horstretch>0</horstretch> | |||
|
22 | <verstretch>0</verstretch> | |||
|
23 | </sizepolicy> | |||
|
24 | </property> | |||
|
25 | <property name="minimumSize"> | |||
|
26 | <size> | |||
|
27 | <width>100</width> | |||
|
28 | <height>0</height> | |||
|
29 | </size> | |||
|
30 | </property> | |||
|
31 | <property name="maximumSize"> | |||
|
32 | <size> | |||
|
33 | <width>16777215</width> | |||
|
34 | <height>16777215</height> | |||
|
35 | </size> | |||
|
36 | </property> | |||
|
37 | </widget> | |||
|
38 | </item> | |||
|
39 | <item row="0" column="2"> | |||
|
40 | <widget class="QStackedWidget" name="pagesWidget"> | |||
|
41 | <property name="sizePolicy"> | |||
|
42 | <sizepolicy hsizetype="Minimum" vsizetype="Preferred"> | |||
|
43 | <horstretch>0</horstretch> | |||
|
44 | <verstretch>0</verstretch> | |||
|
45 | </sizepolicy> | |||
|
46 | </property> | |||
|
47 | <property name="minimumSize"> | |||
|
48 | <size> | |||
|
49 | <width>100</width> | |||
|
50 | <height>0</height> | |||
|
51 | </size> | |||
|
52 | </property> | |||
|
53 | </widget> | |||
|
54 | </item> | |||
|
55 | <item row="2" column="1" colspan="2"> | |||
|
56 | <widget class="QDialogButtonBox" name="buttonBox"> | |||
|
57 | <property name="orientation"> | |||
|
58 | <enum>Qt::Horizontal</enum> | |||
|
59 | </property> | |||
|
60 | <property name="standardButtons"> | |||
|
61 | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | |||
|
62 | </property> | |||
|
63 | </widget> | |||
|
64 | </item> | |||
|
65 | </layout> | |||
|
66 | </widget> | |||
|
67 | <resources/> | |||
|
68 | <connections> | |||
|
69 | <connection> | |||
|
70 | <sender>buttonBox</sender> | |||
|
71 | <signal>accepted()</signal> | |||
|
72 | <receiver>SocExplorerSettingsDialog</receiver> | |||
|
73 | <slot>accept()</slot> | |||
|
74 | <hints> | |||
|
75 | <hint type="sourcelabel"> | |||
|
76 | <x>277</x> | |||
|
77 | <y>304</y> | |||
|
78 | </hint> | |||
|
79 | <hint type="destinationlabel"> | |||
|
80 | <x>277</x> | |||
|
81 | <y>164</y> | |||
|
82 | </hint> | |||
|
83 | </hints> | |||
|
84 | </connection> | |||
|
85 | <connection> | |||
|
86 | <sender>buttonBox</sender> | |||
|
87 | <signal>rejected()</signal> | |||
|
88 | <receiver>SocExplorerSettingsDialog</receiver> | |||
|
89 | <slot>reject()</slot> | |||
|
90 | <hints> | |||
|
91 | <hint type="sourcelabel"> | |||
|
92 | <x>277</x> | |||
|
93 | <y>304</y> | |||
|
94 | </hint> | |||
|
95 | <hint type="destinationlabel"> | |||
|
96 | <x>277</x> | |||
|
97 | <y>164</y> | |||
|
98 | </hint> | |||
|
99 | </hints> | |||
|
100 | </connection> | |||
|
101 | </connections> | |||
|
102 | </ui> |
@@ -0,0 +1,37 | |||||
|
1 | #include "socexplorercoresettingsgui.h" | |||
|
2 | #include "ui_socexplorercoresettingsgui.h" | |||
|
3 | #include <socexplorersettings.h> | |||
|
4 | #include <socexplorerengine.h> | |||
|
5 | #include <socexplorerconfigkeys.h> | |||
|
6 | ||||
|
7 | SocExplorerCoreSettingsGUI::SocExplorerCoreSettingsGUI(QWidget *parent) : | |||
|
8 | SocExplorerSettingsItem(parent), | |||
|
9 | ui(new Ui::SocExplorerCoreSettingsGUI) | |||
|
10 | { | |||
|
11 | ui->setupUi(this); | |||
|
12 | this->ui->PluginsLookupPath->setText(SocExplorerSettings::value(SOCEXPLORERENGINE_SETTINGS_SCOPE,SOCEXPLORERENGINE_SETTINGS_PLUGINS_LOOKUP_PATH,"").toString()); | |||
|
13 | this->ui->SOCregsLookupPath->setText(SocExplorerSettings::value(SOCEXPLORERENGINE_SETTINGS_SCOPE,SOCEXPLORERENGINE_SETTINGS_SOC_REGS_LOOKUP_PATH,"").toString()); | |||
|
14 | } | |||
|
15 | ||||
|
16 | SocExplorerCoreSettingsGUI::~SocExplorerCoreSettingsGUI() | |||
|
17 | { | |||
|
18 | delete ui; | |||
|
19 | } | |||
|
20 | ||||
|
21 | void SocExplorerCoreSettingsGUI::changeEvent(QEvent *e) | |||
|
22 | { | |||
|
23 | QWidget::changeEvent(e); | |||
|
24 | switch (e->type()) { | |||
|
25 | case QEvent::LanguageChange: | |||
|
26 | ui->retranslateUi(this); | |||
|
27 | break; | |||
|
28 | default: | |||
|
29 | break; | |||
|
30 | } | |||
|
31 | } | |||
|
32 | ||||
|
33 | void SocExplorerCoreSettingsGUI::accept() | |||
|
34 | { | |||
|
35 | SocExplorerSettings::setValue(SOCEXPLORERENGINE_SETTINGS_SCOPE,SOCEXPLORERENGINE_SETTINGS_PLUGINS_LOOKUP_PATH,this->ui->PluginsLookupPath->text()); | |||
|
36 | SocExplorerSettings::setValue(SOCEXPLORERENGINE_SETTINGS_SCOPE,SOCEXPLORERENGINE_SETTINGS_SOC_REGS_LOOKUP_PATH,this->ui->SOCregsLookupPath->text()); | |||
|
37 | } |
@@ -0,0 +1,27 | |||||
|
1 | #ifndef SOCEXPLORERCORESETTINGSGUI_H | |||
|
2 | #define SOCEXPLORERCORESETTINGSGUI_H | |||
|
3 | ||||
|
4 | #include <QWidget> | |||
|
5 | #include <socexplorersettingsdialog.h> | |||
|
6 | ||||
|
7 | namespace Ui { | |||
|
8 | class SocExplorerCoreSettingsGUI; | |||
|
9 | } | |||
|
10 | ||||
|
11 | class SocExplorerCoreSettingsGUI : public SocExplorerSettingsItem | |||
|
12 | { | |||
|
13 | Q_OBJECT | |||
|
14 | ||||
|
15 | public: | |||
|
16 | explicit SocExplorerCoreSettingsGUI(QWidget *parent = 0); | |||
|
17 | ~SocExplorerCoreSettingsGUI(); | |||
|
18 | ||||
|
19 | protected: | |||
|
20 | void changeEvent(QEvent *e); | |||
|
21 | public slots: | |||
|
22 | void accept(); | |||
|
23 | private: | |||
|
24 | Ui::SocExplorerCoreSettingsGUI *ui; | |||
|
25 | }; | |||
|
26 | ||||
|
27 | #endif // SOCEXPLORERCORESETTINGSGUI_H |
@@ -0,0 +1,80 | |||||
|
1 | <?xml version="1.0" encoding="UTF-8"?> | |||
|
2 | <ui version="4.0"> | |||
|
3 | <class>SocExplorerCoreSettingsGUI</class> | |||
|
4 | <widget class="QWidget" name="SocExplorerCoreSettingsGUI"> | |||
|
5 | <property name="geometry"> | |||
|
6 | <rect> | |||
|
7 | <x>0</x> | |||
|
8 | <y>0</y> | |||
|
9 | <width>573</width> | |||
|
10 | <height>274</height> | |||
|
11 | </rect> | |||
|
12 | </property> | |||
|
13 | <property name="windowTitle"> | |||
|
14 | <string>Form</string> | |||
|
15 | </property> | |||
|
16 | <layout class="QVBoxLayout" name="verticalLayout"> | |||
|
17 | <item> | |||
|
18 | <widget class="QGroupBox" name="groupBox"> | |||
|
19 | <property name="title"> | |||
|
20 | <string>Plugins</string> | |||
|
21 | </property> | |||
|
22 | <layout class="QFormLayout" name="formLayout"> | |||
|
23 | <item row="0" column="0"> | |||
|
24 | <widget class="QLabel" name="label"> | |||
|
25 | <property name="text"> | |||
|
26 | <string>Lookup path</string> | |||
|
27 | </property> | |||
|
28 | </widget> | |||
|
29 | </item> | |||
|
30 | <item row="0" column="1"> | |||
|
31 | <widget class="QLineEdit" name="PluginsLookupPath"> | |||
|
32 | <property name="toolTip"> | |||
|
33 | <string><html><head/><body><p><span style=" font-weight:600;">Semicolon </span>separated list of path.</p></body></html></string> | |||
|
34 | </property> | |||
|
35 | </widget> | |||
|
36 | </item> | |||
|
37 | </layout> | |||
|
38 | </widget> | |||
|
39 | </item> | |||
|
40 | <item> | |||
|
41 | <widget class="QGroupBox" name="groupBox_2"> | |||
|
42 | <property name="title"> | |||
|
43 | <string>SOC registers description</string> | |||
|
44 | </property> | |||
|
45 | <layout class="QFormLayout" name="formLayout_2"> | |||
|
46 | <item row="0" column="0"> | |||
|
47 | <widget class="QLabel" name="label_2"> | |||
|
48 | <property name="text"> | |||
|
49 | <string>Lookup path</string> | |||
|
50 | </property> | |||
|
51 | </widget> | |||
|
52 | </item> | |||
|
53 | <item row="0" column="1"> | |||
|
54 | <widget class="QLineEdit" name="SOCregsLookupPath"> | |||
|
55 | <property name="toolTip"> | |||
|
56 | <string><html><head/><body><p><span style=" font-weight:600;">Semicolon </span>separated list of path.</p></body></html></string> | |||
|
57 | </property> | |||
|
58 | </widget> | |||
|
59 | </item> | |||
|
60 | </layout> | |||
|
61 | </widget> | |||
|
62 | </item> | |||
|
63 | <item> | |||
|