summaryrefslogtreecommitdiff
path: root/utils/themeeditor/gui
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-17 06:59:46 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-17 06:59:46 +0000
commit75560845aad0cc8d1fccfeda5534489ca278ac80 (patch)
treecd51bb9dfb0a8a94677ac4b4beced11de9afd5b1 /utils/themeeditor/gui
parent36b934d241d2560be6693f90c9aba501a1ec0ae7 (diff)
downloadrockbox-75560845aad0cc8d1fccfeda5534489ca278ac80.zip
rockbox-75560845aad0cc8d1fccfeda5534489ca278ac80.tar.gz
rockbox-75560845aad0cc8d1fccfeda5534489ca278ac80.tar.bz2
rockbox-75560845aad0cc8d1fccfeda5534489ca278ac80.tar.xz
Theme Editor: Working on renderer infrastructure
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26878 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/gui')
-rw-r--r--utils/themeeditor/gui/configdocument.cpp2
-rw-r--r--utils/themeeditor/gui/editorwindow.cpp50
-rw-r--r--utils/themeeditor/gui/skindocument.cpp24
-rw-r--r--utils/themeeditor/gui/skindocument.h14
-rw-r--r--utils/themeeditor/gui/skinviewer.ui19
5 files changed, 85 insertions, 24 deletions
diff --git a/utils/themeeditor/gui/configdocument.cpp b/utils/themeeditor/gui/configdocument.cpp
index a897d3b..cfdd8c5 100644
--- a/utils/themeeditor/gui/configdocument.cpp
+++ b/utils/themeeditor/gui/configdocument.cpp
@@ -100,7 +100,7 @@ void ConfigDocument::save()
saved = toPlainText();
emit titleChanged(title());
-
+ emit configFileChanged(file());
}
void ConfigDocument::saveAs()
diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp
index 675520d..c40a420 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<SkinDocument*>(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<TabContent*>
+ (ui->editorTabs->widget(i));
+ if(doc->type() == TabContent::Skin)
+ {
+ dynamic_cast<SkinDocument*>(doc)->setProject(project);
+ if(i == ui->editorTabs->currentIndex())
+ {
+ viewer->setScene(dynamic_cast<SkinDocument*>(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<TabContent*>
+ (ui->editorTabs->widget(i));
+ if(doc->type() == TabContent::Skin)
+ {
+ dynamic_cast<SkinDocument*>(doc)->setProject(project);
+ if(i == ui->editorTabs->currentIndex())
+ {
+ viewer->setScene(dynamic_cast<SkinDocument*>(doc)->scene());
+ }
+ }
+ }
}
- settings.endGroup();
}
diff --git a/utils/themeeditor/gui/skindocument.cpp b/utils/themeeditor/gui/skindocument.cpp
index 82c7106..aeefcc3 100644
--- a/utils/themeeditor/gui/skindocument.cpp
+++ b/utils/themeeditor/gui/skindocument.cpp
@@ -29,8 +29,10 @@
#include <iostream>
-SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) :
- TabContent(parent), statusLabel(statusLabel)
+SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project,
+ QWidget *parent)
+ :TabContent(parent), statusLabel(statusLabel),
+ project(project)
{
setupUI();
@@ -41,8 +43,10 @@ SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) :
blockUpdate = false;
}
-SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent):
- TabContent(parent), fileName(file), statusLabel(statusLabel)
+SkinDocument::SkinDocument(QLabel* statusLabel, QString file,
+ ProjectModel* project, QWidget *parent)
+ :TabContent(parent), fileName(file),
+ statusLabel(statusLabel), project(project)
{
setupUI();
blockUpdate = false;
@@ -65,8 +69,8 @@ SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent):
SkinDocument::~SkinDocument()
{
- delete highlighter;
- delete model;
+ highlighter->deleteLater();
+ model->deleteLater();
}
void SkinDocument::connectPrefs(PreferencesDialog* prefs)
@@ -309,3 +313,11 @@ void SkinDocument::saveAs()
emit titleChanged(titleText);
}
+
+QString SkinDocument::findSetting(QString key, QString fallback)
+{
+ if(!project)
+ return fallback;
+ else
+ return project->getSetting(key, fallback);
+}
diff --git a/utils/themeeditor/gui/skindocument.h b/utils/themeeditor/gui/skindocument.h
index c6449ca..68bec43 100644
--- a/utils/themeeditor/gui/skindocument.h
+++ b/utils/themeeditor/gui/skindocument.h
@@ -25,12 +25,14 @@
#include <QWidget>
#include <QLabel>
#include <QHBoxLayout>
+#include <QGraphicsScene>
#include "skinhighlighter.h"
#include "parsetreemodel.h"
#include "preferencesdialog.h"
#include "codeeditor.h"
#include "tabcontent.h"
+#include "projectmodel.h"
class SkinDocument : public TabContent
{
@@ -46,8 +48,10 @@ public:
"All Files (*.*)");
}
- SkinDocument(QLabel* statusLabel, QWidget *parent = 0);
- SkinDocument(QLabel* statusLabel, QString file, QWidget* parent = 0);
+ SkinDocument(QLabel* statusLabel, ProjectModel* project = 0,
+ QWidget *parent = 0);
+ SkinDocument(QLabel* statusLabel, QString file, ProjectModel* project = 0,
+ QWidget* parent = 0);
virtual ~SkinDocument();
void connectPrefs(PreferencesDialog* prefs);
@@ -57,6 +61,7 @@ public:
QString title() const{ return titleText; }
QString getStatus(){ return parseStatus; }
void genCode(){ editor->document()->setPlainText(model->genCode()); }
+ void setProject(ProjectModel* project){ this->project = project; }
void save();
void saveAs();
@@ -65,6 +70,8 @@ public:
TabType type() const{ return Skin; }
+ QGraphicsScene* scene(){ return model->render(project); }
+
signals:
public slots:
@@ -76,6 +83,7 @@ private slots:
private:
void setupUI();
+ QString findSetting(QString key, QString fallback);
QString titleText;
QString fileName;
@@ -91,6 +99,8 @@ private:
QLabel* statusLabel;
bool blockUpdate;
+
+ ProjectModel* project;
};
#endif // SKINDOCUMENT_H
diff --git a/utils/themeeditor/gui/skinviewer.ui b/utils/themeeditor/gui/skinviewer.ui
index ed260d0..a5373de 100644
--- a/utils/themeeditor/gui/skinviewer.ui
+++ b/utils/themeeditor/gui/skinviewer.ui
@@ -20,10 +20,26 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
<widget class="QToolButton" name="zoomInButton">
<property name="text">
<string>Zoom In</string>
</property>
+ <property name="autoRepeat">
+ <bool>true</bool>
+ </property>
</widget>
</item>
<item>
@@ -31,6 +47,9 @@
<property name="text">
<string>Zoom Out</string>
</property>
+ <property name="autoRepeat">
+ <bool>true</bool>
+ </property>
</widget>
</item>
</layout>