diff options
Diffstat (limited to 'utils/themeeditor')
-rw-r--r-- | utils/themeeditor/editorwindow.cpp | 29 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.h | 3 | ||||
-rw-r--r-- | utils/themeeditor/preferencesdialog.cpp | 164 | ||||
-rw-r--r-- | utils/themeeditor/preferencesdialog.h | 69 | ||||
-rw-r--r-- | utils/themeeditor/preferencesdialog.ui | 235 | ||||
-rw-r--r-- | utils/themeeditor/skindocument.cpp | 34 | ||||
-rw-r--r-- | utils/themeeditor/skindocument.h | 6 | ||||
-rw-r--r-- | utils/themeeditor/skinhighlighter.cpp | 31 | ||||
-rw-r--r-- | utils/themeeditor/skinhighlighter.h | 6 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 9 |
10 files changed, 563 insertions, 23 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp index 91e099ebf7..8e81829a41 100644 --- a/utils/themeeditor/editorwindow.cpp +++ b/utils/themeeditor/editorwindow.cpp | |||
@@ -32,6 +32,7 @@ EditorWindow::EditorWindow(QWidget *parent) : | |||
32 | ui(new Ui::EditorWindow) | 32 | ui(new Ui::EditorWindow) |
33 | { | 33 | { |
34 | ui->setupUi(this); | 34 | ui->setupUi(this); |
35 | prefs = new PreferencesDialog(this); | ||
35 | loadSettings(); | 36 | loadSettings(); |
36 | setupUI(); | 37 | setupUI(); |
37 | setupMenus(); | 38 | setupMenus(); |
@@ -43,7 +44,7 @@ void EditorWindow::loadSettings() | |||
43 | QSettings settings; | 44 | QSettings settings; |
44 | 45 | ||
45 | /* Main Window location */ | 46 | /* Main Window location */ |
46 | settings.beginGroup("MainWindow"); | 47 | settings.beginGroup("EditorWindow"); |
47 | QSize size = settings.value("size").toSize(); | 48 | QSize size = settings.value("size").toSize(); |
48 | QPoint pos = settings.value("position").toPoint(); | 49 | QPoint pos = settings.value("position").toPoint(); |
49 | QByteArray state = settings.value("state").toByteArray(); | 50 | QByteArray state = settings.value("state").toByteArray(); |
@@ -65,7 +66,7 @@ void EditorWindow::saveSettings() | |||
65 | QSettings settings; | 66 | QSettings settings; |
66 | 67 | ||
67 | /* Saving window and panel positions */ | 68 | /* Saving window and panel positions */ |
68 | settings.beginGroup("MainWindow"); | 69 | settings.beginGroup("EditorWindow"); |
69 | settings.setValue("position", pos()); | 70 | settings.setValue("position", pos()); |
70 | settings.setValue("size", size()); | 71 | settings.setValue("size", size()); |
71 | settings.setValue("state", saveState()); | 72 | settings.setValue("state", saveState()); |
@@ -89,6 +90,10 @@ void EditorWindow::setupUI() | |||
89 | QObject::connect(ui->fromTree, SIGNAL(pressed()), | 90 | QObject::connect(ui->fromTree, SIGNAL(pressed()), |
90 | this, SLOT(updateCurrent())); | 91 | this, SLOT(updateCurrent())); |
91 | 92 | ||
93 | /* Connecting the preferences dialog */ | ||
94 | QObject::connect(ui->actionPreferences, SIGNAL(triggered()), | ||
95 | prefs, SLOT(exec())); | ||
96 | |||
92 | } | 97 | } |
93 | 98 | ||
94 | void EditorWindow::setupMenus() | 99 | void EditorWindow::setupMenus() |
@@ -124,15 +129,23 @@ void EditorWindow::setupMenus() | |||
124 | 129 | ||
125 | } | 130 | } |
126 | 131 | ||
127 | 132 | void EditorWindow::addTab(SkinDocument *doc) | |
128 | void EditorWindow::newTab() | ||
129 | { | 133 | { |
130 | SkinDocument* doc = new SkinDocument; | ||
131 | ui->editorTabs->addTab(doc, doc->getTitle()); | 134 | ui->editorTabs->addTab(doc, doc->getTitle()); |
132 | 135 | ||
133 | /* Connecting to title change events */ | 136 | /* Connecting to title change events */ |
134 | QObject::connect(doc, SIGNAL(titleChanged(QString)), | 137 | QObject::connect(doc, SIGNAL(titleChanged(QString)), |
135 | this, SLOT(tabTitleChanged(QString))); | 138 | this, SLOT(tabTitleChanged(QString))); |
139 | |||
140 | /* Connecting to settings change events */ | ||
141 | doc->connectPrefs(prefs); | ||
142 | } | ||
143 | |||
144 | |||
145 | void EditorWindow::newTab() | ||
146 | { | ||
147 | SkinDocument* doc = new SkinDocument; | ||
148 | addTab(doc); | ||
136 | } | 149 | } |
137 | 150 | ||
138 | void EditorWindow::shiftTab(int index) | 151 | void EditorWindow::shiftTab(int index) |
@@ -208,10 +221,7 @@ void EditorWindow::openFile() | |||
208 | 221 | ||
209 | /* Adding a new document for each file name */ | 222 | /* Adding a new document for each file name */ |
210 | SkinDocument* doc = new SkinDocument(current); | 223 | SkinDocument* doc = new SkinDocument(current); |
211 | ui->editorTabs->addTab(doc, doc->getTitle()); | 224 | addTab(doc); |
212 | |||
213 | QObject::connect(doc, SIGNAL(titleChanged(QString)), | ||
214 | this, SLOT(tabTitleChanged(QString))); | ||
215 | 225 | ||
216 | /* And setting the new default directory */ | 226 | /* And setting the new default directory */ |
217 | current.chop(current.length() - current.lastIndexOf('/') - 1); | 227 | current.chop(current.length() - current.lastIndexOf('/') - 1); |
@@ -270,4 +280,5 @@ void EditorWindow::updateCurrent() | |||
270 | EditorWindow::~EditorWindow() | 280 | EditorWindow::~EditorWindow() |
271 | { | 281 | { |
272 | delete ui; | 282 | delete ui; |
283 | delete prefs; | ||
273 | } | 284 | } |
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h index e7fd96a548..5f39ed35d6 100644 --- a/utils/themeeditor/editorwindow.h +++ b/utils/themeeditor/editorwindow.h | |||
@@ -27,6 +27,7 @@ | |||
27 | #include "parsetreemodel.h" | 27 | #include "parsetreemodel.h" |
28 | #include "skinhighlighter.h" | 28 | #include "skinhighlighter.h" |
29 | #include "skindocument.h" | 29 | #include "skindocument.h" |
30 | #include "preferencesdialog.h" | ||
30 | 31 | ||
31 | namespace Ui { | 32 | namespace Ui { |
32 | class EditorWindow; | 33 | class EditorWindow; |
@@ -59,8 +60,10 @@ private: | |||
59 | void saveSettings(); | 60 | void saveSettings(); |
60 | void setupUI(); | 61 | void setupUI(); |
61 | void setupMenus(); | 62 | void setupMenus(); |
63 | void addTab(SkinDocument* doc); | ||
62 | 64 | ||
63 | Ui::EditorWindow *ui; | 65 | Ui::EditorWindow *ui; |
66 | PreferencesDialog* prefs; | ||
64 | }; | 67 | }; |
65 | 68 | ||
66 | #endif // EDITORWINDOW_H | 69 | #endif // EDITORWINDOW_H |
diff --git a/utils/themeeditor/preferencesdialog.cpp b/utils/themeeditor/preferencesdialog.cpp new file mode 100644 index 0000000000..4d3ad04495 --- /dev/null +++ b/utils/themeeditor/preferencesdialog.cpp | |||
@@ -0,0 +1,164 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #include "preferencesdialog.h" | ||
23 | #include "ui_preferencesdialog.h" | ||
24 | |||
25 | #include <QSettings> | ||
26 | #include <QColorDialog> | ||
27 | |||
28 | PreferencesDialog::PreferencesDialog(QWidget *parent) : | ||
29 | QDialog(parent), | ||
30 | ui(new Ui::PreferencesDialog) | ||
31 | { | ||
32 | ui->setupUi(this); | ||
33 | setupUI(); | ||
34 | loadSettings(); | ||
35 | } | ||
36 | |||
37 | PreferencesDialog::~PreferencesDialog() | ||
38 | { | ||
39 | delete ui; | ||
40 | } | ||
41 | |||
42 | void PreferencesDialog::loadSettings() | ||
43 | { | ||
44 | loadColors(); | ||
45 | } | ||
46 | |||
47 | void PreferencesDialog::loadColors() | ||
48 | { | ||
49 | |||
50 | QSettings settings; | ||
51 | |||
52 | /* The list of buttons from the SkinHighlighter group */ | ||
53 | |||
54 | settings.beginGroup("SkinHighlighter"); | ||
55 | |||
56 | commentColor = settings.value("commentColor", | ||
57 | QColor(0, 180, 0)).value<QColor>(); | ||
58 | setButtonColor(ui->commentButton, commentColor); | ||
59 | |||
60 | escapedColor = settings.value("escapedColor", | ||
61 | QColor(120,120,120)).value<QColor>(); | ||
62 | setButtonColor(ui->escapedButton, escapedColor); | ||
63 | |||
64 | conditionalColor = settings.value("conditionalColor", | ||
65 | QColor(0, 0, 180)).value<QColor>(); | ||
66 | setButtonColor(ui->conditionalButton, conditionalColor); | ||
67 | |||
68 | tagColor = settings.value("tagColor", | ||
69 | QColor(180, 0, 0)).value<QColor>(); | ||
70 | setButtonColor(ui->tagButton, tagColor); | ||
71 | |||
72 | settings.endGroup(); | ||
73 | |||
74 | /* Buttons from the editor group */ | ||
75 | settings.beginGroup("SkinDocument"); | ||
76 | |||
77 | fgColor = settings.value("fgColor", Qt::black).value<QColor>(); | ||
78 | setButtonColor(ui->fgButton, fgColor); | ||
79 | |||
80 | bgColor = settings.value("bgColor", Qt::white).value<QColor>(); | ||
81 | setButtonColor(ui->bgButton, bgColor); | ||
82 | |||
83 | settings.endGroup(); | ||
84 | } | ||
85 | |||
86 | void PreferencesDialog::saveSettings() | ||
87 | { | ||
88 | saveColors(); | ||
89 | } | ||
90 | |||
91 | void PreferencesDialog::saveColors() | ||
92 | { | ||
93 | QSettings settings; | ||
94 | |||
95 | /* Saving the editor colors */ | ||
96 | settings.beginGroup("SkinDocument"); | ||
97 | |||
98 | settings.setValue("fgColor", fgColor); | ||
99 | settings.setValue("bgColor", bgColor); | ||
100 | |||
101 | settings.endGroup(); | ||
102 | |||
103 | /* Saving the highlighting colors */ | ||
104 | settings.beginGroup("SkinHighlighter"); | ||
105 | |||
106 | settings.setValue("tagColor", tagColor); | ||
107 | settings.setValue("commentColor", commentColor); | ||
108 | settings.setValue("conditionalColor", conditionalColor); | ||
109 | settings.setValue("escapedColor", escapedColor); | ||
110 | |||
111 | settings.endGroup(); | ||
112 | } | ||
113 | |||
114 | void PreferencesDialog::setupUI() | ||
115 | { | ||
116 | /* Connecting color buttons */ | ||
117 | QList<QPushButton*> buttons; | ||
118 | buttons.append(ui->bgButton); | ||
119 | buttons.append(ui->fgButton); | ||
120 | buttons.append(ui->commentButton); | ||
121 | buttons.append(ui->tagButton); | ||
122 | buttons.append(ui->conditionalButton); | ||
123 | buttons.append(ui->escapedButton); | ||
124 | |||
125 | for(int i = 0; i < buttons.count(); i++) | ||
126 | QObject::connect(buttons[i], SIGNAL(pressed()), | ||
127 | this, SLOT(colorClicked())); | ||
128 | } | ||
129 | |||
130 | void PreferencesDialog::colorClicked() | ||
131 | { | ||
132 | QColor* toEdit = 0; | ||
133 | |||
134 | if(QObject::sender() == ui->bgButton) | ||
135 | toEdit = &bgColor; | ||
136 | else if(QObject::sender() == ui->fgButton) | ||
137 | toEdit = &fgColor; | ||
138 | else if(QObject::sender() == ui->commentButton) | ||
139 | toEdit = &commentColor; | ||
140 | else if(QObject::sender() == ui->tagButton) | ||
141 | toEdit = &tagColor; | ||
142 | else if(QObject::sender() == ui->conditionalButton) | ||
143 | toEdit = &conditionalColor; | ||
144 | else if(QObject::sender() == ui->escapedButton) | ||
145 | toEdit = &escapedColor; | ||
146 | |||
147 | if(!toEdit) | ||
148 | return; | ||
149 | |||
150 | *toEdit = QColorDialog::getColor(*toEdit, this); | ||
151 | setButtonColor(dynamic_cast<QPushButton*>(QObject::sender()), *toEdit); | ||
152 | } | ||
153 | |||
154 | void PreferencesDialog::accept() | ||
155 | { | ||
156 | saveSettings(); | ||
157 | QDialog::accept(); | ||
158 | } | ||
159 | |||
160 | void PreferencesDialog::reject() | ||
161 | { | ||
162 | loadSettings(); | ||
163 | QDialog::reject(); | ||
164 | } | ||
diff --git a/utils/themeeditor/preferencesdialog.h b/utils/themeeditor/preferencesdialog.h new file mode 100644 index 0000000000..a4adda47d1 --- /dev/null +++ b/utils/themeeditor/preferencesdialog.h | |||
@@ -0,0 +1,69 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * $Id$ | ||
9 | * | ||
10 | * Copyright (C) 2010 Robert Bieber | ||
11 | * | ||
12 | * This program is free software; you can redistribute it and/or | ||
13 | * modify it under the terms of the GNU General Public License | ||
14 | * as published by the Free Software Foundation; either version 2 | ||
15 | * of the License, or (at your option) any later version. | ||
16 | * | ||
17 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
18 | * KIND, either express or implied. | ||
19 | * | ||
20 | ****************************************************************************/ | ||
21 | |||
22 | #ifndef PREFERENCESDIALOG_H | ||
23 | #define PREFERENCESDIALOG_H | ||
24 | |||
25 | #include <QDialog> | ||
26 | #include <QPushButton> | ||
27 | |||
28 | namespace Ui { | ||
29 | class PreferencesDialog; | ||
30 | } | ||
31 | |||
32 | class PreferencesDialog : public QDialog { | ||
33 | Q_OBJECT | ||
34 | public: | ||
35 | PreferencesDialog(QWidget *parent = 0); | ||
36 | ~PreferencesDialog(); | ||
37 | |||
38 | static void setButtonColor(QPushButton* button, QColor color) | ||
39 | { | ||
40 | QString style = "* { background:" + color.name() + "}"; | ||
41 | button->setStyleSheet(style); | ||
42 | } | ||
43 | |||
44 | public slots: | ||
45 | void accept(); | ||
46 | void reject(); | ||
47 | |||
48 | private slots: | ||
49 | void colorClicked(); | ||
50 | |||
51 | private: | ||
52 | Ui::PreferencesDialog *ui; | ||
53 | |||
54 | void loadSettings(); | ||
55 | void loadColors(); | ||
56 | void saveSettings(); | ||
57 | void saveColors(); | ||
58 | |||
59 | void setupUI(); | ||
60 | |||
61 | QColor fgColor; | ||
62 | QColor bgColor; | ||
63 | QColor commentColor; | ||
64 | QColor escapedColor; | ||
65 | QColor tagColor; | ||
66 | QColor conditionalColor; | ||
67 | }; | ||
68 | |||
69 | #endif // PREFERENCESDIALOG_H | ||
diff --git a/utils/themeeditor/preferencesdialog.ui b/utils/themeeditor/preferencesdialog.ui new file mode 100644 index 0000000000..017e69dd01 --- /dev/null +++ b/utils/themeeditor/preferencesdialog.ui | |||
@@ -0,0 +1,235 @@ | |||
1 | <?xml version="1.0" encoding="UTF-8"?> | ||
2 | <ui version="4.0"> | ||
3 | <class>PreferencesDialog</class> | ||
4 | <widget class="QDialog" name="PreferencesDialog"> | ||
5 | <property name="geometry"> | ||
6 | <rect> | ||
7 | <x>0</x> | ||
8 | <y>0</y> | ||
9 | <width>370</width> | ||
10 | <height>370</height> | ||
11 | </rect> | ||
12 | </property> | ||
13 | <property name="windowTitle"> | ||
14 | <string>Dialog</string> | ||
15 | </property> | ||
16 | <layout class="QVBoxLayout" name="verticalLayout"> | ||
17 | <item> | ||
18 | <widget class="QToolBox" name="prefsGroups"> | ||
19 | <property name="currentIndex"> | ||
20 | <number>0</number> | ||
21 | </property> | ||
22 | <widget class="QWidget" name="highlighting"> | ||
23 | <property name="geometry"> | ||
24 | <rect> | ||
25 | <x>0</x> | ||
26 | <y>0</y> | ||
27 | <width>352</width> | ||
28 | <height>288</height> | ||
29 | </rect> | ||
30 | </property> | ||
31 | <attribute name="label"> | ||
32 | <string>Editor Colors</string> | ||
33 | </attribute> | ||
34 | <layout class="QHBoxLayout" name="horizontalLayout"> | ||
35 | <item> | ||
36 | <layout class="QVBoxLayout" name="verticalLayout_3"> | ||
37 | <item> | ||
38 | <widget class="QLabel" name="label_2"> | ||
39 | <property name="text"> | ||
40 | <string>Foreground</string> | ||
41 | </property> | ||
42 | <property name="alignment"> | ||
43 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> | ||
44 | </property> | ||
45 | <property name="buddy"> | ||
46 | <cstring>fgButton</cstring> | ||
47 | </property> | ||
48 | </widget> | ||
49 | </item> | ||
50 | <item> | ||
51 | <widget class="QLabel" name="label_3"> | ||
52 | <property name="text"> | ||
53 | <string>Background</string> | ||
54 | </property> | ||
55 | <property name="alignment"> | ||
56 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> | ||
57 | </property> | ||
58 | <property name="buddy"> | ||
59 | <cstring>bgButton</cstring> | ||
60 | </property> | ||
61 | </widget> | ||
62 | </item> | ||
63 | <item> | ||
64 | <widget class="QLabel" name="label_4"> | ||
65 | <property name="text"> | ||
66 | <string>Comment</string> | ||
67 | </property> | ||
68 | <property name="alignment"> | ||
69 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> | ||
70 | </property> | ||
71 | <property name="buddy"> | ||
72 | <cstring>commentButton</cstring> | ||
73 | </property> | ||
74 | </widget> | ||
75 | </item> | ||
76 | <item> | ||
77 | <widget class="QLabel" name="label_5"> | ||
78 | <property name="text"> | ||
79 | <string>Escaped Character</string> | ||
80 | </property> | ||
81 | <property name="alignment"> | ||
82 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> | ||
83 | </property> | ||
84 | <property name="buddy"> | ||
85 | <cstring>escapedButton</cstring> | ||
86 | </property> | ||
87 | </widget> | ||
88 | </item> | ||
89 | <item> | ||
90 | <widget class="QLabel" name="label_6"> | ||
91 | <property name="text"> | ||
92 | <string>Conditional</string> | ||
93 | </property> | ||
94 | <property name="alignment"> | ||
95 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> | ||
96 | </property> | ||
97 | <property name="buddy"> | ||
98 | <cstring>conditionalButton</cstring> | ||
99 | </property> | ||
100 | </widget> | ||
101 | </item> | ||
102 | <item> | ||
103 | <widget class="QLabel" name="label"> | ||
104 | <property name="text"> | ||
105 | <string>Tag</string> | ||
106 | </property> | ||
107 | <property name="alignment"> | ||
108 | <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set> | ||
109 | </property> | ||
110 | <property name="buddy"> | ||
111 | <cstring>tagButton</cstring> | ||
112 | </property> | ||
113 | </widget> | ||
114 | </item> | ||
115 | </layout> | ||
116 | </item> | ||
117 | <item> | ||
118 | <layout class="QVBoxLayout" name="verticalLayout_2"> | ||
119 | <item> | ||
120 | <widget class="QPushButton" name="fgButton"> | ||
121 | <property name="autoFillBackground"> | ||
122 | <bool>false</bool> | ||
123 | </property> | ||
124 | <property name="text"> | ||
125 | <string>Click To Change</string> | ||
126 | </property> | ||
127 | </widget> | ||
128 | </item> | ||
129 | <item> | ||
130 | <widget class="QPushButton" name="bgButton"> | ||
131 | <property name="autoFillBackground"> | ||
132 | <bool>false</bool> | ||
133 | </property> | ||
134 | <property name="text"> | ||
135 | <string>Click To Change</string> | ||
136 | </property> | ||
137 | </widget> | ||
138 | </item> | ||
139 | <item> | ||
140 | <widget class="QPushButton" name="commentButton"> | ||
141 | <property name="autoFillBackground"> | ||
142 | <bool>false</bool> | ||
143 | </property> | ||
144 | <property name="text"> | ||
145 | <string>Click To Change</string> | ||
146 | </property> | ||
147 | <property name="flat"> | ||
148 | <bool>false</bool> | ||
149 | </property> | ||
150 | </widget> | ||
151 | </item> | ||
152 | <item> | ||
153 | <widget class="QPushButton" name="escapedButton"> | ||
154 | <property name="autoFillBackground"> | ||
155 | <bool>false</bool> | ||
156 | </property> | ||
157 | <property name="text"> | ||
158 | <string>Click To Change</string> | ||
159 | </property> | ||
160 | </widget> | ||
161 | </item> | ||
162 | <item> | ||
163 | <widget class="QPushButton" name="conditionalButton"> | ||
164 | <property name="autoFillBackground"> | ||
165 | <bool>false</bool> | ||
166 | </property> | ||
167 | <property name="text"> | ||
168 | <string>Click To Change</string> | ||
169 | </property> | ||
170 | </widget> | ||
171 | </item> | ||
172 | <item> | ||
173 | <widget class="QPushButton" name="tagButton"> | ||
174 | <property name="autoFillBackground"> | ||
175 | <bool>false</bool> | ||
176 | </property> | ||
177 | <property name="text"> | ||
178 | <string>Click To Change</string> | ||
179 | </property> | ||
180 | </widget> | ||
181 | </item> | ||
182 | </layout> | ||
183 | </item> | ||
184 | </layout> | ||
185 | </widget> | ||
186 | </widget> | ||
187 | </item> | ||
188 | <item> | ||
189 | <widget class="QDialogButtonBox" name="buttonBox"> | ||
190 | <property name="orientation"> | ||
191 | <enum>Qt::Horizontal</enum> | ||
192 | </property> | ||
193 | <property name="standardButtons"> | ||
194 | <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> | ||
195 | </property> | ||
196 | </widget> | ||
197 | </item> | ||
198 | </layout> | ||
199 | </widget> | ||
200 | <resources/> | ||
201 | <connections> | ||
202 | <connection> | ||
203 | <sender>buttonBox</sender> | ||
204 | <signal>accepted()</signal> | ||
205 | <receiver>PreferencesDialog</receiver> | ||
206 | <slot>accept()</slot> | ||
207 | <hints> | ||
208 | <hint type="sourcelabel"> | ||
209 | <x>248</x> | ||
210 | <y>254</y> | ||
211 | </hint> | ||
212 | <hint type="destinationlabel"> | ||
213 | <x>157</x> | ||
214 | <y>274</y> | ||
215 | </hint> | ||
216 | </hints> | ||
217 | </connection> | ||
218 | <connection> | ||
219 | <sender>buttonBox</sender> | ||
220 | <signal>rejected()</signal> | ||
221 | <receiver>PreferencesDialog</receiver> | ||
222 | <slot>reject()</slot> | ||
223 | <hints> | ||
224 | <hint type="sourcelabel"> | ||
225 | <x>316</x> | ||
226 | <y>260</y> | ||
227 | </hint> | ||
228 | <hint type="destinationlabel"> | ||
229 | <x>286</x> | ||
230 | <y>274</y> | ||
231 | </hint> | ||
232 | </hints> | ||
233 | </connection> | ||
234 | </connections> | ||
235 | </ui> | ||
diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp index efb16eeae1..fbb33cc366 100644 --- a/utils/themeeditor/skindocument.cpp +++ b/utils/themeeditor/skindocument.cpp | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <QFile> | 24 | #include <QFile> |
25 | #include <QSettings> | 25 | #include <QSettings> |
26 | #include <QColor> | ||
26 | #include <QMessageBox> | 27 | #include <QMessageBox> |
27 | #include <QFileDialog> | 28 | #include <QFileDialog> |
28 | 29 | ||
@@ -61,6 +62,14 @@ SkinDocument::~SkinDocument() | |||
61 | delete model; | 62 | delete model; |
62 | } | 63 | } |
63 | 64 | ||
65 | void SkinDocument::connectPrefs(PreferencesDialog* prefs) | ||
66 | { | ||
67 | QObject::connect(prefs, SIGNAL(accepted()), | ||
68 | this, SLOT(colorsChanged())); | ||
69 | QObject::connect(prefs, SIGNAL(accepted()), | ||
70 | highlighter, SLOT(loadSettings())); | ||
71 | } | ||
72 | |||
64 | bool SkinDocument::requestClose() | 73 | bool SkinDocument::requestClose() |
65 | { | 74 | { |
66 | if(editor->document()->toPlainText() != saved) | 75 | if(editor->document()->toPlainText() != saved) |
@@ -106,9 +115,7 @@ void SkinDocument::setupUI() | |||
106 | setLayout(layout); | 115 | setLayout(layout); |
107 | 116 | ||
108 | /* Attaching the syntax highlighter */ | 117 | /* Attaching the syntax highlighter */ |
109 | highlighter = new SkinHighlighter(QColor(0,180,0), QColor(255,0,0), | 118 | highlighter = new SkinHighlighter(editor->document()); |
110 | QColor(0,0,255), QColor(120,120,120), | ||
111 | editor->document()); | ||
112 | 119 | ||
113 | /* Setting up the model */ | 120 | /* Setting up the model */ |
114 | model = new ParseTreeModel(""); | 121 | model = new ParseTreeModel(""); |
@@ -116,6 +123,27 @@ void SkinDocument::setupUI() | |||
116 | /* Connecting the editor's signal */ | 123 | /* Connecting the editor's signal */ |
117 | QObject::connect(editor, SIGNAL(textChanged()), | 124 | QObject::connect(editor, SIGNAL(textChanged()), |
118 | this, SLOT(codeChanged())); | 125 | this, SLOT(codeChanged())); |
126 | |||
127 | colorsChanged(); | ||
128 | } | ||
129 | |||
130 | void SkinDocument::colorsChanged() | ||
131 | { | ||
132 | /* Setting the editor colors */ | ||
133 | QSettings settings; | ||
134 | settings.beginGroup("SkinDocument"); | ||
135 | |||
136 | QColor fg = settings.value("fgColor", Qt::black).value<QColor>(); | ||
137 | QColor bg = settings.value("bgColor", Qt::white).value<QColor>(); | ||
138 | QPalette palette; | ||
139 | palette.setColor(QPalette::All, QPalette::Base, bg); | ||
140 | palette.setColor(QPalette::All, QPalette::Text, fg); | ||
141 | |||
142 | editor->setPalette(palette); | ||
143 | editor->repaint(); | ||
144 | |||
145 | settings.endGroup(); | ||
146 | |||
119 | } | 147 | } |
120 | 148 | ||
121 | void SkinDocument::codeChanged() | 149 | void SkinDocument::codeChanged() |
diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h index 84d12df6a9..14a71e02a1 100644 --- a/utils/themeeditor/skindocument.h +++ b/utils/themeeditor/skindocument.h | |||
@@ -28,6 +28,7 @@ | |||
28 | 28 | ||
29 | #include "skinhighlighter.h" | 29 | #include "skinhighlighter.h" |
30 | #include "parsetreemodel.h" | 30 | #include "parsetreemodel.h" |
31 | #include "preferencesdialog.h" | ||
31 | 32 | ||
32 | class SkinDocument : public QWidget | 33 | class SkinDocument : public QWidget |
33 | { | 34 | { |
@@ -47,6 +48,8 @@ public: | |||
47 | SkinDocument(QString file, QWidget* parent = 0); | 48 | SkinDocument(QString file, QWidget* parent = 0); |
48 | virtual ~SkinDocument(); | 49 | virtual ~SkinDocument(); |
49 | 50 | ||
51 | void connectPrefs(PreferencesDialog* prefs); | ||
52 | |||
50 | ParseTreeModel* getModel(){ return model; } | 53 | ParseTreeModel* getModel(){ return model; } |
51 | QString getTitle(){ return title; } | 54 | QString getTitle(){ return title; } |
52 | void genCode(){ editor->document()->setPlainText(model->genCode()); } | 55 | void genCode(){ editor->document()->setPlainText(model->genCode()); } |
@@ -59,6 +62,9 @@ public: | |||
59 | signals: | 62 | signals: |
60 | void titleChanged(QString); | 63 | void titleChanged(QString); |
61 | 64 | ||
65 | public slots: | ||
66 | void colorsChanged(); | ||
67 | |||
62 | private slots: | 68 | private slots: |
63 | void codeChanged(); | 69 | void codeChanged(); |
64 | 70 | ||
diff --git a/utils/themeeditor/skinhighlighter.cpp b/utils/themeeditor/skinhighlighter.cpp index 8289c38a1d..25a479f815 100644 --- a/utils/themeeditor/skinhighlighter.cpp +++ b/utils/themeeditor/skinhighlighter.cpp | |||
@@ -21,13 +21,12 @@ | |||
21 | 21 | ||
22 | #include "skinhighlighter.h" | 22 | #include "skinhighlighter.h" |
23 | 23 | ||
24 | SkinHighlighter::SkinHighlighter(QColor comment, QColor tag, QColor conditional, | 24 | #include <QSettings> |
25 | QColor escaped, QTextDocument* doc) | ||
26 | :QSyntaxHighlighter(doc), | ||
27 | escaped(escaped), tag(tag), | ||
28 | conditional(conditional), comment(comment) | ||
29 | { | ||
30 | 25 | ||
26 | SkinHighlighter::SkinHighlighter(QTextDocument* doc) | ||
27 | :QSyntaxHighlighter(doc) | ||
28 | { | ||
29 | loadSettings(); | ||
31 | } | 30 | } |
32 | 31 | ||
33 | SkinHighlighter::~SkinHighlighter() | 32 | SkinHighlighter::~SkinHighlighter() |
@@ -151,3 +150,23 @@ void SkinHighlighter::highlightBlock(const QString& text) | |||
151 | } | 150 | } |
152 | } | 151 | } |
153 | } | 152 | } |
153 | |||
154 | void SkinHighlighter::loadSettings() | ||
155 | { | ||
156 | QSettings settings; | ||
157 | |||
158 | settings.beginGroup("SkinHighlighter"); | ||
159 | |||
160 | /* Loading the highlighting colors */ | ||
161 | tag = settings.value("tagColor", QColor(180,0,0)).value<QColor>(); | ||
162 | conditional = settings.value("conditionalColor", | ||
163 | QColor(0, 0, 180)).value<QColor>(); | ||
164 | escaped = settings.value("escapedColor", | ||
165 | QColor(120,120,120)).value<QColor>(); | ||
166 | comment = settings.value("commentColor", | ||
167 | QColor(0, 180, 0)).value<QColor>(); | ||
168 | |||
169 | settings.endGroup(); | ||
170 | |||
171 | rehighlight(); | ||
172 | } | ||
diff --git a/utils/themeeditor/skinhighlighter.h b/utils/themeeditor/skinhighlighter.h index 6baa699871..4d5c68ba52 100644 --- a/utils/themeeditor/skinhighlighter.h +++ b/utils/themeeditor/skinhighlighter.h | |||
@@ -40,12 +40,14 @@ public: | |||
40 | * conditional - The color for conditionals and their delimiters | 40 | * conditional - The color for conditionals and their delimiters |
41 | * | 41 | * |
42 | */ | 42 | */ |
43 | SkinHighlighter(QColor comment, QColor tag, QColor conditional, | 43 | SkinHighlighter(QTextDocument* doc); |
44 | QColor escaped, QTextDocument* doc); | ||
45 | virtual ~SkinHighlighter(); | 44 | virtual ~SkinHighlighter(); |
46 | 45 | ||
47 | void highlightBlock(const QString& text); | 46 | void highlightBlock(const QString& text); |
48 | 47 | ||
48 | public slots: | ||
49 | void loadSettings(); | ||
50 | |||
49 | private: | 51 | private: |
50 | QColor escaped; | 52 | QColor escaped; |
51 | QColor tag; | 53 | QColor tag; |
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index ef32a3e56e..fe83d6bbf5 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro | |||
@@ -13,7 +13,8 @@ HEADERS += tag_table.h \ | |||
13 | parsetreenode.h \ | 13 | parsetreenode.h \ |
14 | editorwindow.h \ | 14 | editorwindow.h \ |
15 | skinhighlighter.h \ | 15 | skinhighlighter.h \ |
16 | skindocument.h | 16 | skindocument.h \ |
17 | preferencesdialog.h | ||
17 | SOURCES += tag_table.c \ | 18 | SOURCES += tag_table.c \ |
18 | skin_parser.c \ | 19 | skin_parser.c \ |
19 | skin_scan.c \ | 20 | skin_scan.c \ |
@@ -23,7 +24,8 @@ SOURCES += tag_table.c \ | |||
23 | parsetreenode.cpp \ | 24 | parsetreenode.cpp \ |
24 | editorwindow.cpp \ | 25 | editorwindow.cpp \ |
25 | skinhighlighter.cpp \ | 26 | skinhighlighter.cpp \ |
26 | skindocument.cpp | 27 | skindocument.cpp \ |
28 | preferencesdialog.cpp | ||
27 | OTHER_FILES += README \ | 29 | OTHER_FILES += README \ |
28 | resources/windowicon.png \ | 30 | resources/windowicon.png \ |
29 | resources/appicon.xcf \ | 31 | resources/appicon.xcf \ |
@@ -31,5 +33,6 @@ OTHER_FILES += README \ | |||
31 | resources/document-save.png \ | 33 | resources/document-save.png \ |
32 | resources/document-open.png \ | 34 | resources/document-open.png \ |
33 | resources/document-new.png | 35 | resources/document-new.png |
34 | FORMS += editorwindow.ui | 36 | FORMS += editorwindow.ui \ |
37 | preferencesdialog.ui | ||
35 | RESOURCES += resources.qrc | 38 | RESOURCES += resources.qrc |