diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-06-15 06:54:58 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-06-15 06:54:58 +0000 |
commit | 2e320f66f4f3c831dcfd232b33da0e6ab6dd7dd0 (patch) | |
tree | a6ef8001d797213e9dd81cd41c48f5065c33f3f0 /utils/themeeditor | |
parent | 1d4dc9b3b0f094a70463395138fc920e5107eabc (diff) | |
download | rockbox-2e320f66f4f3c831dcfd232b33da0e6ab6dd7dd0.tar.gz rockbox-2e320f66f4f3c831dcfd232b33da0e6ab6dd7dd0.zip |
Theme Editor: Changed color to colour in preferences. Made parse tree viewer alternate line colors and auto-scroll/expand with cursor in editor window. Implemented TabContent abstract class so that more than just skin documents can be loaded in tabs. Made SkinDocument implement TabContent. Began implementing ConfigDocument for editing configuration files.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26851 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor')
-rw-r--r-- | utils/themeeditor/configdocument.cpp | 125 | ||||
-rw-r--r-- | utils/themeeditor/configdocument.h | 54 | ||||
-rw-r--r-- | utils/themeeditor/configdocument.ui | 79 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.cpp | 94 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.h | 16 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.ui | 8 | ||||
-rw-r--r-- | utils/themeeditor/preferencesdialog.ui | 6 | ||||
-rw-r--r-- | utils/themeeditor/projectmodel.cpp | 10 | ||||
-rw-r--r-- | utils/themeeditor/projectmodel.h | 2 | ||||
-rw-r--r-- | utils/themeeditor/skindocument.cpp | 30 | ||||
-rw-r--r-- | utils/themeeditor/skindocument.h | 12 | ||||
-rw-r--r-- | utils/themeeditor/tabcontent.h | 35 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 10 |
13 files changed, 435 insertions, 46 deletions
diff --git a/utils/themeeditor/configdocument.cpp b/utils/themeeditor/configdocument.cpp new file mode 100644 index 0000000000..95daec0b60 --- /dev/null +++ b/utils/themeeditor/configdocument.cpp | |||
@@ -0,0 +1,125 @@ | |||
1 | #include "configdocument.h" | ||
2 | #include "ui_configdocument.h" | ||
3 | |||
4 | ConfigDocument::ConfigDocument(QMap<QString, QString>& settings, QString file, | ||
5 | QWidget *parent) | ||
6 | : TabContent(parent), | ||
7 | ui(new Ui::ConfigDocument), | ||
8 | filePath(file) | ||
9 | { | ||
10 | ui->setupUi(this); | ||
11 | |||
12 | QMap<QString, QString>::iterator i; | ||
13 | for(i = settings.begin(); i != settings.end(); i++) | ||
14 | addRow(i.key(), i.value()); | ||
15 | |||
16 | saved = toPlainText(); | ||
17 | |||
18 | QObject::connect(ui->addKeyButton, SIGNAL(pressed()), | ||
19 | this, SLOT(addClicked())); | ||
20 | } | ||
21 | |||
22 | ConfigDocument::~ConfigDocument() | ||
23 | { | ||
24 | delete ui; | ||
25 | } | ||
26 | |||
27 | void ConfigDocument::changeEvent(QEvent *e) | ||
28 | { | ||
29 | QWidget::changeEvent(e); | ||
30 | switch (e->type()) { | ||
31 | case QEvent::LanguageChange: | ||
32 | ui->retranslateUi(this); | ||
33 | break; | ||
34 | default: | ||
35 | break; | ||
36 | } | ||
37 | } | ||
38 | |||
39 | QString ConfigDocument::title() const | ||
40 | { | ||
41 | QStringList decompose = filePath.split("/"); | ||
42 | return decompose.last(); | ||
43 | } | ||
44 | |||
45 | void ConfigDocument::save() | ||
46 | { | ||
47 | |||
48 | } | ||
49 | |||
50 | void ConfigDocument::saveAs() | ||
51 | { | ||
52 | |||
53 | } | ||
54 | |||
55 | bool ConfigDocument::requestClose() | ||
56 | { | ||
57 | |||
58 | } | ||
59 | |||
60 | QString ConfigDocument::toPlainText() const | ||
61 | { | ||
62 | QString buffer = ""; | ||
63 | |||
64 | for(int i = 0; i < keys.count(); i++) | ||
65 | { | ||
66 | buffer += keys[i]->text(); | ||
67 | buffer += ":"; | ||
68 | buffer += values[i]->text(); | ||
69 | buffer += "\n"; | ||
70 | } | ||
71 | |||
72 | return buffer; | ||
73 | } | ||
74 | |||
75 | void ConfigDocument::addRow(QString key, QString value) | ||
76 | { | ||
77 | QHBoxLayout* layout = new QHBoxLayout(); | ||
78 | QLineEdit* keyEdit = new QLineEdit(key, this); | ||
79 | QLineEdit* valueEdit = new QLineEdit(value, this); | ||
80 | QPushButton* delButton = new QPushButton(tr("-"), this); | ||
81 | |||
82 | layout->addWidget(keyEdit); | ||
83 | layout->addWidget(valueEdit); | ||
84 | layout->addWidget(delButton); | ||
85 | |||
86 | delButton->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); | ||
87 | delButton->setMaximumWidth(35); | ||
88 | |||
89 | QObject::connect(delButton, SIGNAL(clicked()), | ||
90 | this, SLOT(deleteClicked())); | ||
91 | |||
92 | ui->configBoxes->addLayout(layout); | ||
93 | |||
94 | containers.append(layout); | ||
95 | keys.append(keyEdit); | ||
96 | values.append(valueEdit); | ||
97 | deleteButtons.append(delButton); | ||
98 | |||
99 | } | ||
100 | |||
101 | void ConfigDocument::deleteClicked() | ||
102 | { | ||
103 | QPushButton* button = dynamic_cast<QPushButton*>(sender()); | ||
104 | int row = deleteButtons.indexOf(button); | ||
105 | |||
106 | deleteButtons[row]->deleteLater(); | ||
107 | keys[row]->deleteLater(); | ||
108 | values[row]->deleteLater(); | ||
109 | containers[row]->deleteLater(); | ||
110 | |||
111 | deleteButtons.removeAt(row); | ||
112 | keys.removeAt(row); | ||
113 | values.removeAt(row); | ||
114 | containers.removeAt(row); | ||
115 | |||
116 | if(saved != toPlainText()) | ||
117 | emit titleChanged(title() + "*"); | ||
118 | else | ||
119 | emit titleChanged(title()); | ||
120 | } | ||
121 | |||
122 | void ConfigDocument::addClicked() | ||
123 | { | ||
124 | addRow(tr("Key"), tr("Value")); | ||
125 | } | ||
diff --git a/utils/themeeditor/configdocument.h b/utils/themeeditor/configdocument.h new file mode 100644 index 0000000000..2f4c2501a1 --- /dev/null +++ b/utils/themeeditor/configdocument.h | |||
@@ -0,0 +1,54 @@ | |||
1 | #ifndef CONFIGDOCUMENT_H | ||
2 | #define CONFIGDOCUMENT_H | ||
3 | |||
4 | #include <QHBoxLayout> | ||
5 | #include <QLineEdit> | ||
6 | #include <QPushButton> | ||
7 | #include <QWidget> | ||
8 | #include <QMap> | ||
9 | |||
10 | #include "tabcontent.h" | ||
11 | |||
12 | namespace Ui { | ||
13 | class ConfigDocument; | ||
14 | } | ||
15 | |||
16 | class ConfigDocument : public TabContent { | ||
17 | Q_OBJECT | ||
18 | public: | ||
19 | ConfigDocument(QMap<QString, QString>& settings, QString file, | ||
20 | QWidget *parent = 0); | ||
21 | virtual ~ConfigDocument(); | ||
22 | |||
23 | TabType type() const{ return TabContent::Config; } | ||
24 | QString file() const{ return filePath; } | ||
25 | QString title() const; | ||
26 | |||
27 | QString toPlainText() const; | ||
28 | |||
29 | void save(); | ||
30 | void saveAs(); | ||
31 | |||
32 | bool requestClose(); | ||
33 | |||
34 | protected: | ||
35 | void changeEvent(QEvent *e); | ||
36 | |||
37 | private: | ||
38 | Ui::ConfigDocument *ui; | ||
39 | QList<QHBoxLayout*> containers; | ||
40 | QList<QLineEdit*> keys; | ||
41 | QList<QLineEdit*> values; | ||
42 | QList<QPushButton*> deleteButtons; | ||
43 | |||
44 | QString filePath; | ||
45 | QString saved; | ||
46 | |||
47 | void addRow(QString key, QString value); | ||
48 | |||
49 | private slots: | ||
50 | void deleteClicked(); | ||
51 | void addClicked(); | ||
52 | }; | ||
53 | |||
54 | #endif // CONFIGDOCUMENT_H | ||
diff --git a/utils/themeeditor/configdocument.ui b/utils/themeeditor/configdocument.ui new file mode 100644 index 0000000000..e2f9e7fb21 --- /dev/null +++ b/utils/themeeditor/configdocument.ui | |||
@@ -0,0 +1,79 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>ConfigDocument</class> | ||
4 | <widget class="QWidget" name="ConfigDocument"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>422</width> | ||
10 | <height>299</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="QScrollArea" name="scrollArea"> | ||
19 | <property name="widgetResizable"> | ||
20 | <bool>true</bool> | ||
21 | </property> | ||
22 | <widget class="QWidget" name="scrollAreaWidgetContents"> | ||
23 | <property name="geometry"> | ||
24 | <rect> | ||
25 | <x>0</x> | ||
26 | <y>0</y> | ||
27 | <width>402</width> | ||
28 | <height>244</height> | ||
29 | </rect> | ||
30 | </property> | ||
31 | <layout class="QVBoxLayout" name="verticalLayout_3"> | ||
32 | <item> | ||
33 | <layout class="QVBoxLayout" name="configBoxes"/> | ||
34 | </item> | ||
35 | </layout> | ||
36 | </widget> | ||
37 | </widget> | ||
38 | </item> | ||
39 | <item> | ||
40 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
41 | <item> | ||
42 | <spacer name="horizontalSpacer"> | ||
43 | <property name="orientation"> | ||
44 | <enum>Qt::Horizontal</enum> | ||
45 | </property> | ||
46 | <property name="sizeHint" stdset="0"> | ||
47 | <size> | ||
48 | <width>40</width> | ||
49 | <height>20</height> | ||
50 | </size> | ||
51 | </property> | ||
52 | </spacer> | ||
53 | </item> | ||
54 | <item> | ||
55 | <widget class="QPushButton" name="addKeyButton"> | ||
56 | <property name="sizePolicy"> | ||
57 | <sizepolicy hsizetype="Maximum" vsizetype="Fixed"> | ||
58 | <horstretch>0</horstretch> | ||
59 | <verstretch>0</verstretch> | ||
60 | </sizepolicy> | ||
61 | </property> | ||
62 | <property name="maximumSize"> | ||
63 | <size> | ||
64 | <width>35</width> | ||
65 | <height>16777215</height> | ||
66 | </size> | ||
67 | </property> | ||
68 | <property name="text"> | ||
69 | <string>+</string> | ||
70 | </property> | ||
71 | </widget> | ||
72 | </item> | ||
73 | </layout> | ||
74 | </item> | ||
75 | </layout> | ||
76 | </widget> | ||
77 | <resources/> | ||
78 | <connections/> | ||
79 | </ui> | ||
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp index 93cf3641f0..3603b24af1 100644 --- a/utils/themeeditor/editorwindow.cpp +++ b/utils/themeeditor/editorwindow.cpp | |||
@@ -40,14 +40,14 @@ EditorWindow::EditorWindow(QWidget *parent) : | |||
40 | setupMenus(); | 40 | setupMenus(); |
41 | } | 41 | } |
42 | 42 | ||
43 | void EditorWindow::loadTabFromFile(QString fileName) | 43 | void EditorWindow::loadTabFromSkinFile(QString fileName) |
44 | { | 44 | { |
45 | /* Checking to see if the file is already open */ | 45 | /* Checking to see if the file is already open */ |
46 | for(int i = 0; i < ui->editorTabs->count(); i++) | 46 | for(int i = 0; i < ui->editorTabs->count(); i++) |
47 | { | 47 | { |
48 | SkinDocument* current = dynamic_cast<SkinDocument*> | 48 | TabContent* current = dynamic_cast<TabContent*> |
49 | (ui->editorTabs->widget(i)); | 49 | (ui->editorTabs->widget(i)); |
50 | if(current->getFile() == fileName) | 50 | if(current->file() == fileName) |
51 | { | 51 | { |
52 | ui->editorTabs->setCurrentIndex(i); | 52 | ui->editorTabs->setCurrentIndex(i); |
53 | return; | 53 | return; |
@@ -61,6 +61,27 @@ void EditorWindow::loadTabFromFile(QString fileName) | |||
61 | 61 | ||
62 | } | 62 | } |
63 | 63 | ||
64 | void EditorWindow::loadConfigTab(ConfigDocument* doc) | ||
65 | { | ||
66 | for(int i = 0; i < ui->editorTabs->count(); i++) | ||
67 | { | ||
68 | TabContent* current = dynamic_cast<TabContent*> | ||
69 | (ui->editorTabs->widget(i)); | ||
70 | if(current->file() == doc->file()) | ||
71 | { | ||
72 | ui->editorTabs->setCurrentIndex(i); | ||
73 | doc->deleteLater(); | ||
74 | return; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | addTab(doc); | ||
79 | ui->editorTabs->setCurrentWidget(doc); | ||
80 | |||
81 | QObject::connect(doc, SIGNAL(titleChanged(QString)), | ||
82 | this, SLOT(tabTitleChanged(QString))); | ||
83 | } | ||
84 | |||
64 | void EditorWindow::loadSettings() | 85 | void EditorWindow::loadSettings() |
65 | { | 86 | { |
66 | 87 | ||
@@ -153,16 +174,19 @@ void EditorWindow::setupMenus() | |||
153 | this, SLOT(openProject())); | 174 | this, SLOT(openProject())); |
154 | } | 175 | } |
155 | 176 | ||
156 | void EditorWindow::addTab(SkinDocument *doc) | 177 | void EditorWindow::addTab(TabContent *doc) |
157 | { | 178 | { |
158 | ui->editorTabs->addTab(doc, doc->getTitle()); | 179 | ui->editorTabs->addTab(doc, doc->title()); |
159 | 180 | ||
160 | /* Connecting to title change events */ | 181 | /* Connecting to title change events */ |
161 | QObject::connect(doc, SIGNAL(titleChanged(QString)), | 182 | QObject::connect(doc, SIGNAL(titleChanged(QString)), |
162 | this, SLOT(tabTitleChanged(QString))); | 183 | this, SLOT(tabTitleChanged(QString))); |
184 | QObject::connect(doc, SIGNAL(lineChanged(int)), | ||
185 | this, SLOT(lineChanged(int))); | ||
163 | 186 | ||
164 | /* Connecting to settings change events */ | 187 | /* Connecting to settings change events */ |
165 | doc->connectPrefs(prefs); | 188 | if(doc->type() == TabContent::Skin) |
189 | dynamic_cast<SkinDocument*>(doc)->connectPrefs(prefs); | ||
166 | } | 190 | } |
167 | 191 | ||
168 | 192 | ||
@@ -175,7 +199,9 @@ void EditorWindow::newTab() | |||
175 | 199 | ||
176 | void EditorWindow::shiftTab(int index) | 200 | void EditorWindow::shiftTab(int index) |
177 | { | 201 | { |
178 | if(index < 0) | 202 | TabContent* widget = dynamic_cast<TabContent*> |
203 | (ui->editorTabs->currentWidget()); | ||
204 | if(index < 0 || widget->type() != TabContent::Skin) | ||
179 | { | 205 | { |
180 | ui->parseTree->setModel(0); | 206 | ui->parseTree->setModel(0); |
181 | ui->actionSave_Document->setEnabled(false); | 207 | ui->actionSave_Document->setEnabled(false); |
@@ -187,8 +213,7 @@ void EditorWindow::shiftTab(int index) | |||
187 | else | 213 | else |
188 | { | 214 | { |
189 | /* Syncing the tree view and the status bar */ | 215 | /* Syncing the tree view and the status bar */ |
190 | SkinDocument* doc = dynamic_cast<SkinDocument*> | 216 | SkinDocument* doc = dynamic_cast<SkinDocument*>(widget); |
191 | (ui->editorTabs->currentWidget()); | ||
192 | ui->parseTree->setModel(doc->getModel()); | 217 | ui->parseTree->setModel(doc->getModel()); |
193 | parseStatus->setText(doc->getStatus()); | 218 | parseStatus->setText(doc->getStatus()); |
194 | 219 | ||
@@ -197,12 +222,15 @@ void EditorWindow::shiftTab(int index) | |||
197 | ui->actionClose_Document->setEnabled(true); | 222 | ui->actionClose_Document->setEnabled(true); |
198 | ui->actionToolbarSave->setEnabled(true); | 223 | ui->actionToolbarSave->setEnabled(true); |
199 | ui->fromTree->setEnabled(true); | 224 | ui->fromTree->setEnabled(true); |
225 | |||
226 | sizeColumns(); | ||
227 | |||
200 | } | 228 | } |
201 | } | 229 | } |
202 | 230 | ||
203 | bool EditorWindow::closeTab(int index) | 231 | bool EditorWindow::closeTab(int index) |
204 | { | 232 | { |
205 | SkinDocument* widget = dynamic_cast<SkinDocument*> | 233 | TabContent* widget = dynamic_cast<TabContent*> |
206 | (ui->editorTabs->widget(index)); | 234 | (ui->editorTabs->widget(index)); |
207 | if(widget->requestClose()) | 235 | if(widget->requestClose()) |
208 | { | 236 | { |
@@ -222,13 +250,13 @@ void EditorWindow::closeCurrent() | |||
222 | void EditorWindow::saveCurrent() | 250 | void EditorWindow::saveCurrent() |
223 | { | 251 | { |
224 | if(ui->editorTabs->currentIndex() >= 0) | 252 | if(ui->editorTabs->currentIndex() >= 0) |
225 | dynamic_cast<SkinDocument*>(ui->editorTabs->currentWidget())->save(); | 253 | dynamic_cast<TabContent*>(ui->editorTabs->currentWidget())->save(); |
226 | } | 254 | } |
227 | 255 | ||
228 | void EditorWindow::saveCurrentAs() | 256 | void EditorWindow::saveCurrentAs() |
229 | { | 257 | { |
230 | if(ui->editorTabs->currentIndex() >= 0) | 258 | if(ui->editorTabs->currentIndex() >= 0) |
231 | dynamic_cast<SkinDocument*>(ui->editorTabs->currentWidget())->saveAs(); | 259 | dynamic_cast<TabContent*>(ui->editorTabs->currentWidget())->saveAs(); |
232 | } | 260 | } |
233 | 261 | ||
234 | void EditorWindow::openFile() | 262 | void EditorWindow::openFile() |
@@ -248,7 +276,7 @@ void EditorWindow::openFile() | |||
248 | 276 | ||
249 | QString current = fileNames[i]; | 277 | QString current = fileNames[i]; |
250 | 278 | ||
251 | loadTabFromFile(current); | 279 | loadTabFromSkinFile(current); |
252 | 280 | ||
253 | /* And setting the new default directory */ | 281 | /* And setting the new default directory */ |
254 | current.chop(current.length() - current.lastIndexOf('/') - 1); | 282 | current.chop(current.length() - current.lastIndexOf('/') - 1); |
@@ -292,7 +320,7 @@ void EditorWindow::openProject() | |||
292 | 320 | ||
293 | void EditorWindow::tabTitleChanged(QString title) | 321 | void EditorWindow::tabTitleChanged(QString title) |
294 | { | 322 | { |
295 | SkinDocument* sender = dynamic_cast<SkinDocument*>(QObject::sender()); | 323 | TabContent* sender = dynamic_cast<TabContent*>(QObject::sender()); |
296 | ui->editorTabs->setTabText(ui->editorTabs->indexOf(sender), title); | 324 | ui->editorTabs->setTabText(ui->editorTabs->indexOf(sender), title); |
297 | } | 325 | } |
298 | 326 | ||
@@ -334,6 +362,44 @@ void EditorWindow::updateCurrent() | |||
334 | (ui->editorTabs->currentWidget())->genCode(); | 362 | (ui->editorTabs->currentWidget())->genCode(); |
335 | } | 363 | } |
336 | 364 | ||
365 | void EditorWindow::lineChanged(int line) | ||
366 | { | ||
367 | ui->parseTree->collapseAll(); | ||
368 | ParseTreeModel* model = dynamic_cast<ParseTreeModel*> | ||
369 | (ui->parseTree->model()); | ||
370 | expandLine(model, QModelIndex(), line); | ||
371 | sizeColumns(); | ||
372 | |||
373 | } | ||
374 | |||
375 | void EditorWindow::expandLine(ParseTreeModel* model, QModelIndex parent, | ||
376 | int line) | ||
377 | { | ||
378 | for(int i = 0; i < model->rowCount(parent); i++) | ||
379 | { | ||
380 | QModelIndex data = model->index(i, ParseTreeModel::lineColumn, parent); | ||
381 | QModelIndex recurse = model->index(i, 0, parent); | ||
382 | |||
383 | expandLine(model, recurse, line); | ||
384 | |||
385 | if(model->data(data, Qt::DisplayRole) == line) | ||
386 | { | ||
387 | ui->parseTree->expand(parent); | ||
388 | ui->parseTree->expand(data); | ||
389 | ui->parseTree->scrollTo(parent, QAbstractItemView::PositionAtTop); | ||
390 | } | ||
391 | |||
392 | } | ||
393 | } | ||
394 | |||
395 | void EditorWindow::sizeColumns() | ||
396 | { | ||
397 | /* Setting the column widths */ | ||
398 | ui->parseTree->resizeColumnToContents(ParseTreeModel::lineColumn); | ||
399 | ui->parseTree->resizeColumnToContents(ParseTreeModel::typeColumn); | ||
400 | ui->parseTree->resizeColumnToContents(ParseTreeModel::valueColumn); | ||
401 | } | ||
402 | |||
337 | EditorWindow::~EditorWindow() | 403 | EditorWindow::~EditorWindow() |
338 | { | 404 | { |
339 | delete ui; | 405 | delete ui; |
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h index 32c7d0a057..7e62caadf2 100644 --- a/utils/themeeditor/editorwindow.h +++ b/utils/themeeditor/editorwindow.h | |||
@@ -28,22 +28,27 @@ | |||
28 | #include "parsetreemodel.h" | 28 | #include "parsetreemodel.h" |
29 | #include "skinhighlighter.h" | 29 | #include "skinhighlighter.h" |
30 | #include "skindocument.h" | 30 | #include "skindocument.h" |
31 | #include "configdocument.h" | ||
31 | #include "preferencesdialog.h" | 32 | #include "preferencesdialog.h" |
32 | 33 | ||
33 | class ProjectModel; | 34 | class ProjectModel; |
35 | class TabContent; | ||
34 | 36 | ||
35 | namespace Ui { | 37 | namespace Ui |
38 | { | ||
36 | class EditorWindow; | 39 | class EditorWindow; |
37 | } | 40 | } |
38 | 41 | ||
39 | class EditorWindow : public QMainWindow { | 42 | class EditorWindow : public QMainWindow |
43 | { | ||
40 | Q_OBJECT | 44 | Q_OBJECT |
41 | public: | 45 | public: |
42 | EditorWindow(QWidget *parent = 0); | 46 | EditorWindow(QWidget *parent = 0); |
43 | ~EditorWindow(); | 47 | ~EditorWindow(); |
44 | 48 | ||
45 | /* A public function so external widgets can load files */ | 49 | /* A public function so external widgets can load files */ |
46 | void loadTabFromFile(QString fileName); | 50 | void loadTabFromSkinFile(QString fileName); |
51 | void loadConfigTab(ConfigDocument* doc); | ||
47 | 52 | ||
48 | protected: | 53 | protected: |
49 | virtual void closeEvent(QCloseEvent* event); | 54 | virtual void closeEvent(QCloseEvent* event); |
@@ -60,6 +65,7 @@ private slots: | |||
60 | void openProject(); | 65 | void openProject(); |
61 | void tabTitleChanged(QString title); | 66 | void tabTitleChanged(QString title); |
62 | void updateCurrent(); /* Generates code in the current tab */ | 67 | void updateCurrent(); /* Generates code in the current tab */ |
68 | void lineChanged(int line); /* Used for auto-expand */ | ||
63 | 69 | ||
64 | private: | 70 | private: |
65 | /* Setup functions */ | 71 | /* Setup functions */ |
@@ -67,7 +73,9 @@ private: | |||
67 | void saveSettings(); | 73 | void saveSettings(); |
68 | void setupUI(); | 74 | void setupUI(); |
69 | void setupMenus(); | 75 | void setupMenus(); |
70 | void addTab(SkinDocument* doc); | 76 | void addTab(TabContent* doc); |
77 | void expandLine(ParseTreeModel* model, QModelIndex parent, int line); | ||
78 | void sizeColumns(); | ||
71 | 79 | ||
72 | Ui::EditorWindow *ui; | 80 | Ui::EditorWindow *ui; |
73 | PreferencesDialog* prefs; | 81 | PreferencesDialog* prefs; |
diff --git a/utils/themeeditor/editorwindow.ui b/utils/themeeditor/editorwindow.ui index 61b5f222a5..06c7d422bd 100644 --- a/utils/themeeditor/editorwindow.ui +++ b/utils/themeeditor/editorwindow.ui | |||
@@ -40,7 +40,7 @@ | |||
40 | <x>0</x> | 40 | <x>0</x> |
41 | <y>0</y> | 41 | <y>0</y> |
42 | <width>628</width> | 42 | <width>628</width> |
43 | <height>27</height> | 43 | <height>25</height> |
44 | </rect> | 44 | </rect> |
45 | </property> | 45 | </property> |
46 | <widget class="QMenu" name="menuFile"> | 46 | <widget class="QMenu" name="menuFile"> |
@@ -126,7 +126,11 @@ | |||
126 | <widget class="QWidget" name="dockWidgetContents_3"> | 126 | <widget class="QWidget" name="dockWidgetContents_3"> |
127 | <layout class="QVBoxLayout" name="verticalLayout_3"> | 127 | <layout class="QVBoxLayout" name="verticalLayout_3"> |
128 | <item> | 128 | <item> |
129 | <widget class="QTreeView" name="parseTree"/> | 129 | <widget class="QTreeView" name="parseTree"> |
130 | <property name="alternatingRowColors"> | ||
131 | <bool>true</bool> | ||
132 | </property> | ||
133 | </widget> | ||
130 | </item> | 134 | </item> |
131 | <item> | 135 | <item> |
132 | <widget class="QPushButton" name="fromTree"> | 136 | <widget class="QPushButton" name="fromTree"> |
diff --git a/utils/themeeditor/preferencesdialog.ui b/utils/themeeditor/preferencesdialog.ui index c6594caa41..1da7811b62 100644 --- a/utils/themeeditor/preferencesdialog.ui +++ b/utils/themeeditor/preferencesdialog.ui | |||
@@ -64,7 +64,7 @@ | |||
64 | <item> | 64 | <item> |
65 | <widget class="QLabel" name="label_2"> | 65 | <widget class="QLabel" name="label_2"> |
66 | <property name="text"> | 66 | <property name="text"> |
67 | <string>Foreground Color</string> | 67 | <string>Foreground Colour</string> |
68 | </property> | 68 | </property> |
69 | <property name="alignment"> | 69 | <property name="alignment"> |
70 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> | 70 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> |
@@ -91,7 +91,7 @@ | |||
91 | <item> | 91 | <item> |
92 | <widget class="QLabel" name="label_3"> | 92 | <widget class="QLabel" name="label_3"> |
93 | <property name="text"> | 93 | <property name="text"> |
94 | <string>Background Color</string> | 94 | <string>Background Colour</string> |
95 | </property> | 95 | </property> |
96 | <property name="alignment"> | 96 | <property name="alignment"> |
97 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> | 97 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> |
@@ -118,7 +118,7 @@ | |||
118 | <item> | 118 | <item> |
119 | <widget class="QLabel" name="label_9"> | 119 | <widget class="QLabel" name="label_9"> |
120 | <property name="text"> | 120 | <property name="text"> |
121 | <string>Error Color</string> | 121 | <string>Error Colour</string> |
122 | </property> | 122 | </property> |
123 | <property name="buddy"> | 123 | <property name="buddy"> |
124 | <cstring>errorButton</cstring> | 124 | <cstring>errorButton</cstring> |
diff --git a/utils/themeeditor/projectmodel.cpp b/utils/themeeditor/projectmodel.cpp index 925be81950..2df4c0af00 100644 --- a/utils/themeeditor/projectmodel.cpp +++ b/utils/themeeditor/projectmodel.cpp | |||
@@ -113,6 +113,12 @@ QVariant ProjectModel::data(const QModelIndex &index, int role) const | |||
113 | 113 | ||
114 | void ProjectModel::activated(const QModelIndex &index) | 114 | void ProjectModel::activated(const QModelIndex &index) |
115 | { | 115 | { |
116 | mainWindow->loadTabFromFile(settings.value("themebase", "") | 116 | if(index.row() == 0) |
117 | + "/" + files[index.row()]); | 117 | mainWindow->loadConfigTab(new ConfigDocument(settings, |
118 | settings.value("themebase", | ||
119 | "") + "/" + | ||
120 | files[index.row()])); | ||
121 | else | ||
122 | mainWindow->loadTabFromSkinFile(settings.value("themebase", "") | ||
123 | + "/" + files[index.row()]); | ||
118 | } | 124 | } |
diff --git a/utils/themeeditor/projectmodel.h b/utils/themeeditor/projectmodel.h index d577f00a69..6623917420 100644 --- a/utils/themeeditor/projectmodel.h +++ b/utils/themeeditor/projectmodel.h | |||
@@ -44,6 +44,8 @@ public: | |||
44 | int rowCount(const QModelIndex& parent) const; | 44 | int rowCount(const QModelIndex& parent) const; |
45 | QVariant data(const QModelIndex &index, int role) const; | 45 | QVariant data(const QModelIndex &index, int role) const; |
46 | 46 | ||
47 | QString getSetting(QString key){ return settings.value(key, ""); } | ||
48 | |||
47 | signals: | 49 | signals: |
48 | 50 | ||
49 | public slots: | 51 | public slots: |
diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp index 9a9bf5c85f..82c7106051 100644 --- a/utils/themeeditor/skindocument.cpp +++ b/utils/themeeditor/skindocument.cpp | |||
@@ -9,10 +9,10 @@ | |||
9 | * | 9 | * |
10 | * Copyright (C) 2010 Robert Bieber | 10 | * Copyright (C) 2010 Robert Bieber |
11 | * | 11 | * |
12 | * This program is free software; you can redistribute it and/or | 12 | * This program is free software; can redistribute it and/or |
13 | * modify it under the terms of the GNU General Public License | 13 | * modify it under the terms of the GNU General Public License |
14 | * as published by the Free Software Foundation; either version 2 | 14 | * as published by the Free Software Foundation; either version 2 |
15 | * of the License, or (at your option) any later version. | 15 | * of the License, or (at your optiyouon) any later version. |
16 | * | 16 | * |
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | 17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY |
18 | * KIND, either express or implied. | 18 | * KIND, either express or implied. |
@@ -30,11 +30,11 @@ | |||
30 | #include <iostream> | 30 | #include <iostream> |
31 | 31 | ||
32 | SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) : | 32 | SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) : |
33 | QWidget(parent), statusLabel(statusLabel) | 33 | TabContent(parent), statusLabel(statusLabel) |
34 | { | 34 | { |
35 | setupUI(); | 35 | setupUI(); |
36 | 36 | ||
37 | title = "Untitled"; | 37 | titleText = "Untitled"; |
38 | fileName = ""; | 38 | fileName = ""; |
39 | saved = ""; | 39 | saved = ""; |
40 | parseStatus = tr("Empty document"); | 40 | parseStatus = tr("Empty document"); |
@@ -42,7 +42,7 @@ SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) : | |||
42 | } | 42 | } |
43 | 43 | ||
44 | SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent): | 44 | SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent): |
45 | QWidget(parent), fileName(file), statusLabel(statusLabel) | 45 | TabContent(parent), fileName(file), statusLabel(statusLabel) |
46 | { | 46 | { |
47 | setupUI(); | 47 | setupUI(); |
48 | blockUpdate = false; | 48 | blockUpdate = false; |
@@ -60,7 +60,7 @@ SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent): | |||
60 | 60 | ||
61 | /* Setting the title */ | 61 | /* Setting the title */ |
62 | QStringList decomposed = fileName.split('/'); | 62 | QStringList decomposed = fileName.split('/'); |
63 | title = decomposed.last(); | 63 | titleText = decomposed.last(); |
64 | } | 64 | } |
65 | 65 | ||
66 | SkinDocument::~SkinDocument() | 66 | SkinDocument::~SkinDocument() |
@@ -86,7 +86,7 @@ bool SkinDocument::requestClose() | |||
86 | /* Spawning the "Are you sure?" dialog */ | 86 | /* Spawning the "Are you sure?" dialog */ |
87 | QMessageBox confirm(this); | 87 | QMessageBox confirm(this); |
88 | confirm.setWindowTitle(tr("Confirm Close")); | 88 | confirm.setWindowTitle(tr("Confirm Close")); |
89 | confirm.setText(title + tr(" has been modified.")); | 89 | confirm.setText(titleText + tr(" has been modified.")); |
90 | confirm.setInformativeText(tr("Do you want to save your changes?")); | 90 | confirm.setInformativeText(tr("Do you want to save your changes?")); |
91 | confirm.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | 91 | confirm.setStandardButtons(QMessageBox::Save | QMessageBox::Discard |
92 | | QMessageBox::Cancel); | 92 | | QMessageBox::Cancel); |
@@ -192,6 +192,10 @@ void SkinDocument::cursorChanged() | |||
192 | parseStatus = tr("Errors in document"); | 192 | parseStatus = tr("Errors in document"); |
193 | statusLabel->setText(parseStatus); | 193 | statusLabel->setText(parseStatus); |
194 | } | 194 | } |
195 | else | ||
196 | { | ||
197 | emit lineChanged(editor->textCursor().blockNumber() + 1); | ||
198 | } | ||
195 | 199 | ||
196 | } | 200 | } |
197 | 201 | ||
@@ -245,9 +249,9 @@ void SkinDocument::codeChanged() | |||
245 | } | 249 | } |
246 | 250 | ||
247 | if(editor->document()->toPlainText() != saved) | 251 | if(editor->document()->toPlainText() != saved) |
248 | emit titleChanged(title + QChar('*')); | 252 | emit titleChanged(titleText + QChar('*')); |
249 | else | 253 | else |
250 | emit titleChanged(title); | 254 | emit titleChanged(titleText); |
251 | 255 | ||
252 | cursorChanged(); | 256 | cursorChanged(); |
253 | 257 | ||
@@ -269,8 +273,8 @@ void SkinDocument::save() | |||
269 | 273 | ||
270 | saved = editor->document()->toPlainText(); | 274 | saved = editor->document()->toPlainText(); |
271 | QStringList decompose = fileName.split('/'); | 275 | QStringList decompose = fileName.split('/'); |
272 | title = decompose.last(); | 276 | titleText = decompose.last(); |
273 | emit titleChanged(title); | 277 | emit titleChanged(titleText); |
274 | 278 | ||
275 | } | 279 | } |
276 | 280 | ||
@@ -301,7 +305,7 @@ void SkinDocument::saveAs() | |||
301 | 305 | ||
302 | saved = editor->document()->toPlainText(); | 306 | saved = editor->document()->toPlainText(); |
303 | QStringList decompose = fileName.split('/'); | 307 | QStringList decompose = fileName.split('/'); |
304 | title = decompose[decompose.count() - 1]; | 308 | titleText = decompose[decompose.count() - 1]; |
305 | emit titleChanged(title); | 309 | emit titleChanged(titleText); |
306 | 310 | ||
307 | } | 311 | } |
diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h index 79db8b648a..c6449ca627 100644 --- a/utils/themeeditor/skindocument.h +++ b/utils/themeeditor/skindocument.h | |||
@@ -30,8 +30,9 @@ | |||
30 | #include "parsetreemodel.h" | 30 | #include "parsetreemodel.h" |
31 | #include "preferencesdialog.h" | 31 | #include "preferencesdialog.h" |
32 | #include "codeeditor.h" | 32 | #include "codeeditor.h" |
33 | #include "tabcontent.h" | ||
33 | 34 | ||
34 | class SkinDocument : public QWidget | 35 | class SkinDocument : public TabContent |
35 | { | 36 | { |
36 | Q_OBJECT | 37 | Q_OBJECT |
37 | public: | 38 | public: |
@@ -52,8 +53,8 @@ public: | |||
52 | void connectPrefs(PreferencesDialog* prefs); | 53 | void connectPrefs(PreferencesDialog* prefs); |
53 | 54 | ||
54 | ParseTreeModel* getModel(){ return model; } | 55 | ParseTreeModel* getModel(){ return model; } |
55 | QString getFile(){ return fileName; } | 56 | QString file() const{ return fileName; } |
56 | QString getTitle(){ return title; } | 57 | QString title() const{ return titleText; } |
57 | QString getStatus(){ return parseStatus; } | 58 | QString getStatus(){ return parseStatus; } |
58 | void genCode(){ editor->document()->setPlainText(model->genCode()); } | 59 | void genCode(){ editor->document()->setPlainText(model->genCode()); } |
59 | 60 | ||
@@ -62,8 +63,9 @@ public: | |||
62 | 63 | ||
63 | bool requestClose(); | 64 | bool requestClose(); |
64 | 65 | ||
66 | TabType type() const{ return Skin; } | ||
67 | |||
65 | signals: | 68 | signals: |
66 | void titleChanged(QString); | ||
67 | 69 | ||
68 | public slots: | 70 | public slots: |
69 | void settingsChanged(); | 71 | void settingsChanged(); |
@@ -75,7 +77,7 @@ private slots: | |||
75 | private: | 77 | private: |
76 | void setupUI(); | 78 | void setupUI(); |
77 | 79 | ||
78 | QString title; | 80 | QString titleText; |
79 | QString fileName; | 81 | QString fileName; |
80 | QString saved; | 82 | QString saved; |
81 | QString parseStatus; | 83 | QString parseStatus; |
diff --git a/utils/themeeditor/tabcontent.h b/utils/themeeditor/tabcontent.h new file mode 100644 index 0000000000..1b153f7df5 --- /dev/null +++ b/utils/themeeditor/tabcontent.h | |||
@@ -0,0 +1,35 @@ | |||
1 | #ifndef TABCONTENT_H | ||
2 | #define TABCONTENT_H | ||
3 | |||
4 | #include <QWidget> | ||
5 | |||
6 | class TabContent : public QWidget | ||
7 | { | ||
8 | Q_OBJECT | ||
9 | public: | ||
10 | enum TabType | ||
11 | { | ||
12 | Skin, | ||
13 | Config | ||
14 | }; | ||
15 | |||
16 | TabContent(QWidget *parent = 0): QWidget(parent){ } | ||
17 | |||
18 | virtual TabType type() const = 0; | ||
19 | virtual QString title() const = 0; | ||
20 | virtual QString file() const = 0; | ||
21 | |||
22 | virtual void save() = 0; | ||
23 | virtual void saveAs() = 0; | ||
24 | |||
25 | virtual bool requestClose() = 0; | ||
26 | |||
27 | signals: | ||
28 | void titleChanged(QString); | ||
29 | void lineChanged(int); | ||
30 | |||
31 | public slots: | ||
32 | |||
33 | }; | ||
34 | |||
35 | #endif // TABCONTENT_H | ||
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index 128f56996d..c336edf2f5 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro | |||
@@ -16,7 +16,9 @@ HEADERS += tag_table.h \ | |||
16 | skindocument.h \ | 16 | skindocument.h \ |
17 | preferencesdialog.h \ | 17 | preferencesdialog.h \ |
18 | codeeditor.h \ | 18 | codeeditor.h \ |
19 | projectmodel.h | 19 | projectmodel.h \ |
20 | tabcontent.h \ | ||
21 | configdocument.h | ||
20 | SOURCES += tag_table.c \ | 22 | SOURCES += tag_table.c \ |
21 | skin_parser.c \ | 23 | skin_parser.c \ |
22 | skin_scan.c \ | 24 | skin_scan.c \ |
@@ -29,7 +31,8 @@ SOURCES += tag_table.c \ | |||
29 | skindocument.cpp \ | 31 | skindocument.cpp \ |
30 | preferencesdialog.cpp \ | 32 | preferencesdialog.cpp \ |
31 | codeeditor.cpp \ | 33 | codeeditor.cpp \ |
32 | projectmodel.cpp | 34 | projectmodel.cpp \ |
35 | configdocument.cpp | ||
33 | OTHER_FILES += README \ | 36 | OTHER_FILES += README \ |
34 | resources/windowicon.png \ | 37 | resources/windowicon.png \ |
35 | resources/appicon.xcf \ | 38 | resources/appicon.xcf \ |
@@ -38,5 +41,6 @@ OTHER_FILES += README \ | |||
38 | resources/document-open.png \ | 41 | resources/document-open.png \ |
39 | resources/document-new.png | 42 | resources/document-new.png |
40 | FORMS += editorwindow.ui \ | 43 | FORMS += editorwindow.ui \ |
41 | preferencesdialog.ui | 44 | preferencesdialog.ui \ |
45 | configdocument.ui | ||
42 | RESOURCES += resources.qrc | 46 | RESOURCES += resources.qrc |