summaryrefslogtreecommitdiff
path: root/utils/themeeditor/gui/editorwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/gui/editorwindow.cpp')
-rw-r--r--utils/themeeditor/gui/editorwindow.cpp50
1 files changed, 35 insertions, 15 deletions
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
154void EditorWindow::setupMenus() 149void EditorWindow::setupMenus()
@@ -204,7 +199,7 @@ void EditorWindow::addTab(TabContent *doc)
204 199
205void EditorWindow::newTab() 200void 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()
340void EditorWindow::configFileChanged(QString configFile) 354void 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