diff options
Diffstat (limited to 'utils/themeeditor/gui')
-rw-r--r-- | utils/themeeditor/gui/configdocument.cpp | 2 | ||||
-rw-r--r-- | utils/themeeditor/gui/editorwindow.cpp | 50 | ||||
-rw-r--r-- | utils/themeeditor/gui/skindocument.cpp | 24 | ||||
-rw-r--r-- | utils/themeeditor/gui/skindocument.h | 14 | ||||
-rw-r--r-- | utils/themeeditor/gui/skinviewer.ui | 19 |
5 files changed, 85 insertions, 24 deletions
diff --git a/utils/themeeditor/gui/configdocument.cpp b/utils/themeeditor/gui/configdocument.cpp index a897d3b9e3..cfdd8c5c62 100644 --- a/utils/themeeditor/gui/configdocument.cpp +++ b/utils/themeeditor/gui/configdocument.cpp | |||
@@ -100,7 +100,7 @@ void ConfigDocument::save() | |||
100 | 100 | ||
101 | saved = toPlainText(); | 101 | saved = toPlainText(); |
102 | emit titleChanged(title()); | 102 | emit titleChanged(title()); |
103 | 103 | emit configFileChanged(file()); | |
104 | } | 104 | } |
105 | 105 | ||
106 | void ConfigDocument::saveAs() | 106 | void ConfigDocument::saveAs() |
diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp index 675520dc28..c40a420e98 100644 --- a/utils/themeeditor/gui/editorwindow.cpp +++ b/utils/themeeditor/gui/editorwindow.cpp | |||
@@ -56,7 +56,7 @@ void EditorWindow::loadTabFromSkinFile(QString fileName) | |||
56 | } | 56 | } |
57 | 57 | ||
58 | /* Adding a new document*/ | 58 | /* Adding a new document*/ |
59 | SkinDocument* doc = new SkinDocument(parseStatus, fileName); | 59 | SkinDocument* doc = new SkinDocument(parseStatus, fileName, project); |
60 | addTab(doc); | 60 | addTab(doc); |
61 | ui->editorTabs->setCurrentWidget(doc); | 61 | ui->editorTabs->setCurrentWidget(doc); |
62 | 62 | ||
@@ -144,11 +144,6 @@ void EditorWindow::setupUI() | |||
144 | viewer = new SkinViewer(this); | 144 | viewer = new SkinViewer(this); |
145 | ui->skinPreviewLayout->addWidget(viewer); | 145 | ui->skinPreviewLayout->addWidget(viewer); |
146 | 146 | ||
147 | //TODO: Remove this test code | ||
148 | QGraphicsScene* test = new QGraphicsScene(); | ||
149 | test->addRect(0,0,50,50); | ||
150 | |||
151 | viewer->setScene(test); | ||
152 | } | 147 | } |
153 | 148 | ||
154 | void EditorWindow::setupMenus() | 149 | void EditorWindow::setupMenus() |
@@ -204,7 +199,7 @@ void EditorWindow::addTab(TabContent *doc) | |||
204 | 199 | ||
205 | void EditorWindow::newTab() | 200 | void EditorWindow::newTab() |
206 | { | 201 | { |
207 | SkinDocument* doc = new SkinDocument(parseStatus); | 202 | SkinDocument* doc = new SkinDocument(parseStatus, project); |
208 | addTab(doc); | 203 | addTab(doc); |
209 | ui->editorTabs->setCurrentWidget(doc); | 204 | ui->editorTabs->setCurrentWidget(doc); |
210 | } | 205 | } |
@@ -221,6 +216,7 @@ void EditorWindow::shiftTab(int index) | |||
221 | ui->actionClose_Document->setEnabled(false); | 216 | ui->actionClose_Document->setEnabled(false); |
222 | ui->actionToolbarSave->setEnabled(false); | 217 | ui->actionToolbarSave->setEnabled(false); |
223 | ui->fromTree->setEnabled(false); | 218 | ui->fromTree->setEnabled(false); |
219 | viewer->setScene(0); | ||
224 | } | 220 | } |
225 | else if(widget->type() == TabContent::Config) | 221 | else if(widget->type() == TabContent::Config) |
226 | { | 222 | { |
@@ -228,8 +224,9 @@ void EditorWindow::shiftTab(int index) | |||
228 | ui->actionSave_Document_As->setEnabled(true); | 224 | ui->actionSave_Document_As->setEnabled(true); |
229 | ui->actionClose_Document->setEnabled(true); | 225 | ui->actionClose_Document->setEnabled(true); |
230 | ui->actionToolbarSave->setEnabled(true); | 226 | ui->actionToolbarSave->setEnabled(true); |
227 | viewer->setScene(0); | ||
231 | } | 228 | } |
232 | else | 229 | else if(widget->type() == TabContent::Skin) |
233 | { | 230 | { |
234 | /* Syncing the tree view and the status bar */ | 231 | /* Syncing the tree view and the status bar */ |
235 | SkinDocument* doc = dynamic_cast<SkinDocument*>(widget); | 232 | SkinDocument* doc = dynamic_cast<SkinDocument*>(widget); |
@@ -244,6 +241,9 @@ void EditorWindow::shiftTab(int index) | |||
244 | 241 | ||
245 | sizeColumns(); | 242 | sizeColumns(); |
246 | 243 | ||
244 | /* Syncing the preview */ | ||
245 | viewer->setScene(doc->scene()); | ||
246 | |||
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
@@ -331,6 +331,20 @@ void EditorWindow::openProject() | |||
331 | fileName.chop(fileName.length() - fileName.lastIndexOf('/') - 1); | 331 | fileName.chop(fileName.length() - fileName.lastIndexOf('/') - 1); |
332 | settings.setValue("defaultDirectory", fileName); | 332 | settings.setValue("defaultDirectory", fileName); |
333 | 333 | ||
334 | for(int i = 0; i < ui->editorTabs->count(); i++) | ||
335 | { | ||
336 | TabContent* doc = dynamic_cast<TabContent*> | ||
337 | (ui->editorTabs->widget(i)); | ||
338 | if(doc->type() == TabContent::Skin) | ||
339 | { | ||
340 | dynamic_cast<SkinDocument*>(doc)->setProject(project); | ||
341 | if(i == ui->editorTabs->currentIndex()) | ||
342 | { | ||
343 | viewer->setScene(dynamic_cast<SkinDocument*>(doc)->scene()); | ||
344 | } | ||
345 | } | ||
346 | } | ||
347 | |||
334 | } | 348 | } |
335 | 349 | ||
336 | settings.endGroup(); | 350 | settings.endGroup(); |
@@ -340,10 +354,6 @@ void EditorWindow::openProject() | |||
340 | void EditorWindow::configFileChanged(QString configFile) | 354 | void EditorWindow::configFileChanged(QString configFile) |
341 | { | 355 | { |
342 | 356 | ||
343 | QSettings settings; | ||
344 | |||
345 | settings.beginGroup("ProjectModel"); | ||
346 | |||
347 | if(QFile::exists(configFile)) | 357 | if(QFile::exists(configFile)) |
348 | { | 358 | { |
349 | 359 | ||
@@ -356,12 +366,22 @@ void EditorWindow::configFileChanged(QString configFile) | |||
356 | QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)), | 366 | QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)), |
357 | project, SLOT(activated(QModelIndex))); | 367 | project, SLOT(activated(QModelIndex))); |
358 | 368 | ||
359 | configFile.chop(configFile.length() - configFile.lastIndexOf('/') - 1); | 369 | for(int i = 0; i < ui->editorTabs->count(); i++) |
360 | settings.setValue("defaultDirectory", configFile); | 370 | { |
371 | TabContent* doc = dynamic_cast<TabContent*> | ||
372 | (ui->editorTabs->widget(i)); | ||
373 | if(doc->type() == TabContent::Skin) | ||
374 | { | ||
375 | dynamic_cast<SkinDocument*>(doc)->setProject(project); | ||
376 | if(i == ui->editorTabs->currentIndex()) | ||
377 | { | ||
378 | viewer->setScene(dynamic_cast<SkinDocument*>(doc)->scene()); | ||
379 | } | ||
380 | } | ||
381 | } | ||
361 | 382 | ||
362 | } | 383 | } |
363 | 384 | ||
364 | settings.endGroup(); | ||
365 | 385 | ||
366 | } | 386 | } |
367 | 387 | ||
diff --git a/utils/themeeditor/gui/skindocument.cpp b/utils/themeeditor/gui/skindocument.cpp index 82c7106051..aeefcc38f4 100644 --- a/utils/themeeditor/gui/skindocument.cpp +++ b/utils/themeeditor/gui/skindocument.cpp | |||
@@ -29,8 +29,10 @@ | |||
29 | 29 | ||
30 | #include <iostream> | 30 | #include <iostream> |
31 | 31 | ||
32 | SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) : | 32 | SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project, |
33 | TabContent(parent), statusLabel(statusLabel) | 33 | QWidget *parent) |
34 | :TabContent(parent), statusLabel(statusLabel), | ||
35 | project(project) | ||
34 | { | 36 | { |
35 | setupUI(); | 37 | setupUI(); |
36 | 38 | ||
@@ -41,8 +43,10 @@ SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) : | |||
41 | blockUpdate = false; | 43 | blockUpdate = false; |
42 | } | 44 | } |
43 | 45 | ||
44 | SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent): | 46 | SkinDocument::SkinDocument(QLabel* statusLabel, QString file, |
45 | TabContent(parent), fileName(file), statusLabel(statusLabel) | 47 | ProjectModel* project, QWidget *parent) |
48 | :TabContent(parent), fileName(file), | ||
49 | statusLabel(statusLabel), project(project) | ||
46 | { | 50 | { |
47 | setupUI(); | 51 | setupUI(); |
48 | blockUpdate = false; | 52 | blockUpdate = false; |
@@ -65,8 +69,8 @@ SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent): | |||
65 | 69 | ||
66 | SkinDocument::~SkinDocument() | 70 | SkinDocument::~SkinDocument() |
67 | { | 71 | { |
68 | delete highlighter; | 72 | highlighter->deleteLater(); |
69 | delete model; | 73 | model->deleteLater(); |
70 | } | 74 | } |
71 | 75 | ||
72 | void SkinDocument::connectPrefs(PreferencesDialog* prefs) | 76 | void SkinDocument::connectPrefs(PreferencesDialog* prefs) |
@@ -309,3 +313,11 @@ void SkinDocument::saveAs() | |||
309 | emit titleChanged(titleText); | 313 | emit titleChanged(titleText); |
310 | 314 | ||
311 | } | 315 | } |
316 | |||
317 | QString SkinDocument::findSetting(QString key, QString fallback) | ||
318 | { | ||
319 | if(!project) | ||
320 | return fallback; | ||
321 | else | ||
322 | return project->getSetting(key, fallback); | ||
323 | } | ||
diff --git a/utils/themeeditor/gui/skindocument.h b/utils/themeeditor/gui/skindocument.h index c6449ca627..68bec43913 100644 --- a/utils/themeeditor/gui/skindocument.h +++ b/utils/themeeditor/gui/skindocument.h | |||
@@ -25,12 +25,14 @@ | |||
25 | #include <QWidget> | 25 | #include <QWidget> |
26 | #include <QLabel> | 26 | #include <QLabel> |
27 | #include <QHBoxLayout> | 27 | #include <QHBoxLayout> |
28 | #include <QGraphicsScene> | ||
28 | 29 | ||
29 | #include "skinhighlighter.h" | 30 | #include "skinhighlighter.h" |
30 | #include "parsetreemodel.h" | 31 | #include "parsetreemodel.h" |
31 | #include "preferencesdialog.h" | 32 | #include "preferencesdialog.h" |
32 | #include "codeeditor.h" | 33 | #include "codeeditor.h" |
33 | #include "tabcontent.h" | 34 | #include "tabcontent.h" |
35 | #include "projectmodel.h" | ||
34 | 36 | ||
35 | class SkinDocument : public TabContent | 37 | class SkinDocument : public TabContent |
36 | { | 38 | { |
@@ -46,8 +48,10 @@ public: | |||
46 | "All Files (*.*)"); | 48 | "All Files (*.*)"); |
47 | } | 49 | } |
48 | 50 | ||
49 | SkinDocument(QLabel* statusLabel, QWidget *parent = 0); | 51 | SkinDocument(QLabel* statusLabel, ProjectModel* project = 0, |
50 | SkinDocument(QLabel* statusLabel, QString file, QWidget* parent = 0); | 52 | QWidget *parent = 0); |
53 | SkinDocument(QLabel* statusLabel, QString file, ProjectModel* project = 0, | ||
54 | QWidget* parent = 0); | ||
51 | virtual ~SkinDocument(); | 55 | virtual ~SkinDocument(); |
52 | 56 | ||
53 | void connectPrefs(PreferencesDialog* prefs); | 57 | void connectPrefs(PreferencesDialog* prefs); |
@@ -57,6 +61,7 @@ public: | |||
57 | QString title() const{ return titleText; } | 61 | QString title() const{ return titleText; } |
58 | QString getStatus(){ return parseStatus; } | 62 | QString getStatus(){ return parseStatus; } |
59 | void genCode(){ editor->document()->setPlainText(model->genCode()); } | 63 | void genCode(){ editor->document()->setPlainText(model->genCode()); } |
64 | void setProject(ProjectModel* project){ this->project = project; } | ||
60 | 65 | ||
61 | void save(); | 66 | void save(); |
62 | void saveAs(); | 67 | void saveAs(); |
@@ -65,6 +70,8 @@ public: | |||
65 | 70 | ||
66 | TabType type() const{ return Skin; } | 71 | TabType type() const{ return Skin; } |
67 | 72 | ||
73 | QGraphicsScene* scene(){ return model->render(project); } | ||
74 | |||
68 | signals: | 75 | signals: |
69 | 76 | ||
70 | public slots: | 77 | public slots: |
@@ -76,6 +83,7 @@ private slots: | |||
76 | 83 | ||
77 | private: | 84 | private: |
78 | void setupUI(); | 85 | void setupUI(); |
86 | QString findSetting(QString key, QString fallback); | ||
79 | 87 | ||
80 | QString titleText; | 88 | QString titleText; |
81 | QString fileName; | 89 | QString fileName; |
@@ -91,6 +99,8 @@ private: | |||
91 | QLabel* statusLabel; | 99 | QLabel* statusLabel; |
92 | 100 | ||
93 | bool blockUpdate; | 101 | bool blockUpdate; |
102 | |||
103 | ProjectModel* project; | ||
94 | }; | 104 | }; |
95 | 105 | ||
96 | #endif // SKINDOCUMENT_H | 106 | #endif // SKINDOCUMENT_H |
diff --git a/utils/themeeditor/gui/skinviewer.ui b/utils/themeeditor/gui/skinviewer.ui index ed260d0650..a5373de160 100644 --- a/utils/themeeditor/gui/skinviewer.ui +++ b/utils/themeeditor/gui/skinviewer.ui | |||
@@ -20,10 +20,26 @@ | |||
20 | <item> | 20 | <item> |
21 | <layout class="QHBoxLayout" name="horizontalLayout"> | 21 | <layout class="QHBoxLayout" name="horizontalLayout"> |
22 | <item> | 22 | <item> |
23 | <spacer name="horizontalSpacer"> | ||
24 | <property name="orientation"> | ||
25 | <enum>Qt::Horizontal</enum> | ||
26 | </property> | ||
27 | <property name="sizeHint" stdset="0"> | ||
28 | <size> | ||
29 | <width>40</width> | ||
30 | <height>20</height> | ||
31 | </size> | ||
32 | </property> | ||
33 | </spacer> | ||
34 | </item> | ||
35 | <item> | ||
23 | <widget class="QToolButton" name="zoomInButton"> | 36 | <widget class="QToolButton" name="zoomInButton"> |
24 | <property name="text"> | 37 | <property name="text"> |
25 | <string>Zoom In</string> | 38 | <string>Zoom In</string> |
26 | </property> | 39 | </property> |
40 | <property name="autoRepeat"> | ||
41 | <bool>true</bool> | ||
42 | </property> | ||
27 | </widget> | 43 | </widget> |
28 | </item> | 44 | </item> |
29 | <item> | 45 | <item> |
@@ -31,6 +47,9 @@ | |||
31 | <property name="text"> | 47 | <property name="text"> |
32 | <string>Zoom Out</string> | 48 | <string>Zoom Out</string> |
33 | </property> | 49 | </property> |
50 | <property name="autoRepeat"> | ||
51 | <bool>true</bool> | ||
52 | </property> | ||
34 | </widget> | 53 | </widget> |
35 | </item> | 54 | </item> |
36 | </layout> | 55 | </layout> |