diff options
Diffstat (limited to 'utils/themeeditor')
-rw-r--r-- | utils/themeeditor/configdocument.cpp | 16 | ||||
-rw-r--r-- | utils/themeeditor/configdocument.h | 4 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.cpp | 39 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.h | 3 | ||||
-rw-r--r-- | utils/themeeditor/projectmodel.cpp | 15 |
5 files changed, 70 insertions, 7 deletions
diff --git a/utils/themeeditor/configdocument.cpp b/utils/themeeditor/configdocument.cpp index c212cc52ce..5bc4b77504 100644 --- a/utils/themeeditor/configdocument.cpp +++ b/utils/themeeditor/configdocument.cpp | |||
@@ -116,6 +116,7 @@ void ConfigDocument::saveAs() | |||
116 | 116 | ||
117 | saved = toPlainText(); | 117 | saved = toPlainText(); |
118 | emit titleChanged(title()); | 118 | emit titleChanged(title()); |
119 | emit configFileChanged(file()); | ||
119 | 120 | ||
120 | } | 121 | } |
121 | 122 | ||
@@ -150,7 +151,7 @@ bool ConfigDocument::requestClose() | |||
150 | return false; | 151 | return false; |
151 | } | 152 | } |
152 | } | 153 | } |
153 | return false; | 154 | return true; |
154 | } | 155 | } |
155 | 156 | ||
156 | QString ConfigDocument::toPlainText() const | 157 | QString ConfigDocument::toPlainText() const |
@@ -185,6 +186,11 @@ void ConfigDocument::addRow(QString key, QString value) | |||
185 | QObject::connect(delButton, SIGNAL(clicked()), | 186 | QObject::connect(delButton, SIGNAL(clicked()), |
186 | this, SLOT(deleteClicked())); | 187 | this, SLOT(deleteClicked())); |
187 | 188 | ||
189 | QObject::connect(keyEdit, SIGNAL(textChanged(QString)), | ||
190 | this, SLOT(textChanged())); | ||
191 | QObject::connect(valueEdit, SIGNAL(textChanged(QString)), | ||
192 | this, SLOT(textChanged())); | ||
193 | |||
188 | ui->configBoxes->addLayout(layout); | 194 | ui->configBoxes->addLayout(layout); |
189 | 195 | ||
190 | containers.append(layout); | 196 | containers.append(layout); |
@@ -219,3 +225,11 @@ void ConfigDocument::addClicked() | |||
219 | { | 225 | { |
220 | addRow(tr("Key"), tr("Value")); | 226 | addRow(tr("Key"), tr("Value")); |
221 | } | 227 | } |
228 | |||
229 | void ConfigDocument::textChanged() | ||
230 | { | ||
231 | if(toPlainText() != saved) | ||
232 | emit titleChanged(title() + "*"); | ||
233 | else | ||
234 | emit titleChanged(title()); | ||
235 | } | ||
diff --git a/utils/themeeditor/configdocument.h b/utils/themeeditor/configdocument.h index 9aa1a63da5..114cb5bbfc 100644 --- a/utils/themeeditor/configdocument.h +++ b/utils/themeeditor/configdocument.h | |||
@@ -67,9 +67,13 @@ private: | |||
67 | 67 | ||
68 | void addRow(QString key, QString value); | 68 | void addRow(QString key, QString value); |
69 | 69 | ||
70 | signals: | ||
71 | void configFileChanged(QString); | ||
72 | |||
70 | private slots: | 73 | private slots: |
71 | void deleteClicked(); | 74 | void deleteClicked(); |
72 | void addClicked(); | 75 | void addClicked(); |
76 | void textChanged(); | ||
73 | }; | 77 | }; |
74 | 78 | ||
75 | #endif // CONFIGDOCUMENT_H | 79 | #endif // CONFIGDOCUMENT_H |
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp index 3603b24af1..56968a3c05 100644 --- a/utils/themeeditor/editorwindow.cpp +++ b/utils/themeeditor/editorwindow.cpp | |||
@@ -201,7 +201,7 @@ void EditorWindow::shiftTab(int index) | |||
201 | { | 201 | { |
202 | TabContent* widget = dynamic_cast<TabContent*> | 202 | TabContent* widget = dynamic_cast<TabContent*> |
203 | (ui->editorTabs->currentWidget()); | 203 | (ui->editorTabs->currentWidget()); |
204 | if(index < 0 || widget->type() != TabContent::Skin) | 204 | if(index < 0) |
205 | { | 205 | { |
206 | ui->parseTree->setModel(0); | 206 | ui->parseTree->setModel(0); |
207 | ui->actionSave_Document->setEnabled(false); | 207 | ui->actionSave_Document->setEnabled(false); |
@@ -210,6 +210,13 @@ void EditorWindow::shiftTab(int index) | |||
210 | ui->actionToolbarSave->setEnabled(false); | 210 | ui->actionToolbarSave->setEnabled(false); |
211 | ui->fromTree->setEnabled(false); | 211 | ui->fromTree->setEnabled(false); |
212 | } | 212 | } |
213 | else if(widget->type() == TabContent::Config) | ||
214 | { | ||
215 | ui->actionSave_Document->setEnabled(true); | ||
216 | ui->actionSave_Document_As->setEnabled(true); | ||
217 | ui->actionClose_Document->setEnabled(true); | ||
218 | ui->actionToolbarSave->setEnabled(true); | ||
219 | } | ||
213 | else | 220 | else |
214 | { | 221 | { |
215 | /* Syncing the tree view and the status bar */ | 222 | /* Syncing the tree view and the status bar */ |
@@ -318,6 +325,34 @@ void EditorWindow::openProject() | |||
318 | 325 | ||
319 | } | 326 | } |
320 | 327 | ||
328 | void EditorWindow::configFileChanged(QString configFile) | ||
329 | { | ||
330 | |||
331 | QSettings settings; | ||
332 | |||
333 | settings.beginGroup("ProjectModel"); | ||
334 | |||
335 | if(QFile::exists(configFile)) | ||
336 | { | ||
337 | |||
338 | if(project) | ||
339 | delete project; | ||
340 | |||
341 | project = new ProjectModel(configFile, this); | ||
342 | ui->projectTree->setModel(project); | ||
343 | |||
344 | QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)), | ||
345 | project, SLOT(activated(QModelIndex))); | ||
346 | |||
347 | configFile.chop(configFile.length() - configFile.lastIndexOf('/') - 1); | ||
348 | settings.setValue("defaultDirectory", configFile); | ||
349 | |||
350 | } | ||
351 | |||
352 | settings.endGroup(); | ||
353 | |||
354 | } | ||
355 | |||
321 | void EditorWindow::tabTitleChanged(QString title) | 356 | void EditorWindow::tabTitleChanged(QString title) |
322 | { | 357 | { |
323 | TabContent* sender = dynamic_cast<TabContent*>(QObject::sender()); | 358 | TabContent* sender = dynamic_cast<TabContent*>(QObject::sender()); |
@@ -342,7 +377,7 @@ void EditorWindow::closeEvent(QCloseEvent* event) | |||
342 | /* Closing all the tabs */ | 377 | /* Closing all the tabs */ |
343 | for(int i = 0; i < ui->editorTabs->count(); i++) | 378 | for(int i = 0; i < ui->editorTabs->count(); i++) |
344 | { | 379 | { |
345 | if(!dynamic_cast<SkinDocument*> | 380 | if(!dynamic_cast<TabContent*> |
346 | (ui->editorTabs->widget(i))->requestClose()) | 381 | (ui->editorTabs->widget(i))->requestClose()) |
347 | { | 382 | { |
348 | event->ignore(); | 383 | event->ignore(); |
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h index 7e62caadf2..51ca7a692d 100644 --- a/utils/themeeditor/editorwindow.h +++ b/utils/themeeditor/editorwindow.h | |||
@@ -53,6 +53,9 @@ public: | |||
53 | protected: | 53 | protected: |
54 | virtual void closeEvent(QCloseEvent* event); | 54 | virtual void closeEvent(QCloseEvent* event); |
55 | 55 | ||
56 | public slots: | ||
57 | void configFileChanged(QString configFile); | ||
58 | |||
56 | private slots: | 59 | private slots: |
57 | void showPanel(); | 60 | void showPanel(); |
58 | void newTab(); | 61 | void newTab(); |
diff --git a/utils/themeeditor/projectmodel.cpp b/utils/themeeditor/projectmodel.cpp index 2df4c0af00..632e0aa075 100644 --- a/utils/themeeditor/projectmodel.cpp +++ b/utils/themeeditor/projectmodel.cpp | |||
@@ -114,11 +114,18 @@ QVariant ProjectModel::data(const QModelIndex &index, int role) const | |||
114 | void ProjectModel::activated(const QModelIndex &index) | 114 | void ProjectModel::activated(const QModelIndex &index) |
115 | { | 115 | { |
116 | if(index.row() == 0) | 116 | if(index.row() == 0) |
117 | mainWindow->loadConfigTab(new ConfigDocument(settings, | 117 | { |
118 | settings.value("themebase", | 118 | ConfigDocument* doc = new ConfigDocument(settings, |
119 | "") + "/" + | 119 | settings.value("themebase", |
120 | files[index.row()])); | 120 | "") + "/" + |
121 | files[index.row()]); | ||
122 | QObject::connect(doc, SIGNAL(configFileChanged(QString)), | ||
123 | mainWindow, SLOT(configFileChanged(QString))); | ||
124 | mainWindow->loadConfigTab(doc); | ||
125 | } | ||
121 | else | 126 | else |
127 | { | ||
122 | mainWindow->loadTabFromSkinFile(settings.value("themebase", "") | 128 | mainWindow->loadTabFromSkinFile(settings.value("themebase", "") |
123 | + "/" + files[index.row()]); | 129 | + "/" + files[index.row()]); |
130 | } | ||
124 | } | 131 | } |