From 75560845aad0cc8d1fccfeda5534489ca278ac80 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Thu, 17 Jun 2010 06:59:46 +0000 Subject: Theme Editor: Working on renderer infrastructure git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26878 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/gui/editorwindow.cpp | 50 ++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 15 deletions(-) (limited to 'utils/themeeditor/gui/editorwindow.cpp') 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) } /* Adding a new document*/ - SkinDocument* doc = new SkinDocument(parseStatus, fileName); + SkinDocument* doc = new SkinDocument(parseStatus, fileName, project); addTab(doc); ui->editorTabs->setCurrentWidget(doc); @@ -144,11 +144,6 @@ void EditorWindow::setupUI() viewer = new SkinViewer(this); ui->skinPreviewLayout->addWidget(viewer); - //TODO: Remove this test code - QGraphicsScene* test = new QGraphicsScene(); - test->addRect(0,0,50,50); - - viewer->setScene(test); } void EditorWindow::setupMenus() @@ -204,7 +199,7 @@ void EditorWindow::addTab(TabContent *doc) void EditorWindow::newTab() { - SkinDocument* doc = new SkinDocument(parseStatus); + SkinDocument* doc = new SkinDocument(parseStatus, project); addTab(doc); ui->editorTabs->setCurrentWidget(doc); } @@ -221,6 +216,7 @@ void EditorWindow::shiftTab(int index) ui->actionClose_Document->setEnabled(false); ui->actionToolbarSave->setEnabled(false); ui->fromTree->setEnabled(false); + viewer->setScene(0); } else if(widget->type() == TabContent::Config) { @@ -228,8 +224,9 @@ void EditorWindow::shiftTab(int index) ui->actionSave_Document_As->setEnabled(true); ui->actionClose_Document->setEnabled(true); ui->actionToolbarSave->setEnabled(true); + viewer->setScene(0); } - else + else if(widget->type() == TabContent::Skin) { /* Syncing the tree view and the status bar */ SkinDocument* doc = dynamic_cast(widget); @@ -244,6 +241,9 @@ void EditorWindow::shiftTab(int index) sizeColumns(); + /* Syncing the preview */ + viewer->setScene(doc->scene()); + } } @@ -331,6 +331,20 @@ void EditorWindow::openProject() fileName.chop(fileName.length() - fileName.lastIndexOf('/') - 1); settings.setValue("defaultDirectory", fileName); + for(int i = 0; i < ui->editorTabs->count(); i++) + { + TabContent* doc = dynamic_cast + (ui->editorTabs->widget(i)); + if(doc->type() == TabContent::Skin) + { + dynamic_cast(doc)->setProject(project); + if(i == ui->editorTabs->currentIndex()) + { + viewer->setScene(dynamic_cast(doc)->scene()); + } + } + } + } settings.endGroup(); @@ -340,10 +354,6 @@ void EditorWindow::openProject() void EditorWindow::configFileChanged(QString configFile) { - QSettings settings; - - settings.beginGroup("ProjectModel"); - if(QFile::exists(configFile)) { @@ -356,12 +366,22 @@ void EditorWindow::configFileChanged(QString configFile) QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)), project, SLOT(activated(QModelIndex))); - configFile.chop(configFile.length() - configFile.lastIndexOf('/') - 1); - settings.setValue("defaultDirectory", configFile); + for(int i = 0; i < ui->editorTabs->count(); i++) + { + TabContent* doc = dynamic_cast + (ui->editorTabs->widget(i)); + if(doc->type() == TabContent::Skin) + { + dynamic_cast(doc)->setProject(project); + if(i == ui->editorTabs->currentIndex()) + { + viewer->setScene(dynamic_cast(doc)->scene()); + } + } + } } - settings.endGroup(); } -- cgit v1.2.3