From c32728c91c2579688d3e7ffc4afbea1acf2385e0 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Sat, 26 Jun 2010 05:18:21 +0000 Subject: Theme Editor: Began integrating device configuration panel with renderer git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27135 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/gui/configdocument.h | 1 - utils/themeeditor/gui/devicestate.cpp | 41 ++++++++++++++++++++++++++++++++++ utils/themeeditor/gui/devicestate.h | 1 + utils/themeeditor/gui/editorwindow.cpp | 12 ++++++++-- utils/themeeditor/gui/skindocument.cpp | 16 ++++++++----- utils/themeeditor/gui/skindocument.h | 9 +++++--- 6 files changed, 69 insertions(+), 11 deletions(-) (limited to 'utils/themeeditor/gui') diff --git a/utils/themeeditor/gui/configdocument.h b/utils/themeeditor/gui/configdocument.h index 0057ac15c4..e91c5cc357 100644 --- a/utils/themeeditor/gui/configdocument.h +++ b/utils/themeeditor/gui/configdocument.h @@ -75,7 +75,6 @@ private slots: void addClicked(); void textChanged(); - private: Ui::ConfigDocument *ui; QList containers; diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp index 3933926a48..80efd4d4d1 100644 --- a/utils/themeeditor/gui/devicestate.cpp +++ b/utils/themeeditor/gui/devicestate.cpp @@ -234,6 +234,47 @@ QVariant DeviceState::data(QString tag) return QVariant(); } +void DeviceState::setData(QString tag, QVariant data) +{ + QPair found = + inputs.value(tag, QPair(Slide, 0)); + + if(found.second == 0) + return; + + switch(found.first) + { + case Text: + dynamic_cast(found.second)->setText(data.toString()); + break; + + case Slide: + dynamic_cast(found.second)->setValue(data.toInt()); + break; + + case Spin: + dynamic_cast(found.second)->setValue(data.toInt()); + break; + + case DSpin: + dynamic_cast(found.second)->setValue(data.toDouble()); + break; + + case Combo: + dynamic_cast + (found.second)-> + setCurrentIndex(dynamic_cast + (found.second)->findText(data.toString())); + break; + + case Check: + dynamic_cast(found.second)->setChecked(data.toBool()); + break; + } + + emit settingsChanged(); +} + void DeviceState::input() { emit settingsChanged(); diff --git a/utils/themeeditor/gui/devicestate.h b/utils/themeeditor/gui/devicestate.h index c680e2c1ea..cae3cef7e1 100644 --- a/utils/themeeditor/gui/devicestate.h +++ b/utils/themeeditor/gui/devicestate.h @@ -47,6 +47,7 @@ public: virtual ~DeviceState(); QVariant data(QString tag); + void setData(QString tag, QVariant data); signals: void settingsChanged(); diff --git a/utils/themeeditor/gui/editorwindow.cpp b/utils/themeeditor/gui/editorwindow.cpp index 94e744e957..b778a1fba4 100644 --- a/utils/themeeditor/gui/editorwindow.cpp +++ b/utils/themeeditor/gui/editorwindow.cpp @@ -66,7 +66,8 @@ void EditorWindow::loadTabFromSkinFile(QString fileName) } /* Adding a new document*/ - SkinDocument* doc = new SkinDocument(parseStatus, fileName, project); + SkinDocument* doc = new SkinDocument(parseStatus, fileName, project, + deviceConfig); addTab(doc); ui->editorTabs->setCurrentWidget(doc); @@ -219,7 +220,7 @@ void EditorWindow::addTab(TabContent *doc) void EditorWindow::newTab() { - SkinDocument* doc = new SkinDocument(parseStatus, project); + SkinDocument* doc = new SkinDocument(parseStatus, project, deviceConfig); addTab(doc); ui->editorTabs->setCurrentWidget(doc); } @@ -345,6 +346,13 @@ void EditorWindow::openProject() project = new ProjectModel(fileName, this); ui->projectTree->setModel(project); + if(project->getSetting("#screenwidth") != "") + deviceConfig->setData("screenwidth", + project->getSetting("#screenwidth")); + if(project->getSetting("#screenheight") != "") + deviceConfig->setData("screenheight", + project->getSetting("#screenheight")); + QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)), project, SLOT(activated(QModelIndex))); diff --git a/utils/themeeditor/gui/skindocument.cpp b/utils/themeeditor/gui/skindocument.cpp index 8c98255cca..4f48d341fe 100644 --- a/utils/themeeditor/gui/skindocument.cpp +++ b/utils/themeeditor/gui/skindocument.cpp @@ -30,9 +30,9 @@ #include SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project, - QWidget *parent) + DeviceState* device, QWidget *parent) :TabContent(parent), statusLabel(statusLabel), - project(project) + project(project), device(device) { setupUI(); @@ -44,9 +44,11 @@ SkinDocument::SkinDocument(QLabel* statusLabel, ProjectModel* project, } SkinDocument::SkinDocument(QLabel* statusLabel, QString file, - ProjectModel* project, QWidget *parent) + ProjectModel* project, DeviceState* device, + QWidget *parent) :TabContent(parent), fileName(file), - statusLabel(statusLabel), project(project) + statusLabel(statusLabel), project(project), + device(device) { setupUI(); blockUpdate = false; @@ -145,6 +147,10 @@ void SkinDocument::setupUI() QObject::connect(editor, SIGNAL(cursorPositionChanged()), this, SLOT(cursorChanged())); + /* Connecting to device setting changes */ + QObject::connect(device, SIGNAL(settingsChanged()), + this, SLOT(deviceChanged())); + settingsChanged(); } @@ -257,7 +263,7 @@ void SkinDocument::codeChanged() else emit titleChanged(titleText); - model->render(project, &fileName); + model->render(project, device, &fileName); cursorChanged(); diff --git a/utils/themeeditor/gui/skindocument.h b/utils/themeeditor/gui/skindocument.h index f6ceb73e92..c6b36873f8 100644 --- a/utils/themeeditor/gui/skindocument.h +++ b/utils/themeeditor/gui/skindocument.h @@ -33,6 +33,7 @@ #include "codeeditor.h" #include "tabcontent.h" #include "projectmodel.h" +#include "devicestate.h" class SkinDocument : public TabContent { @@ -49,9 +50,9 @@ public: } SkinDocument(QLabel* statusLabel, ProjectModel* project = 0, - QWidget *parent = 0); + DeviceState* device = 0, QWidget *parent = 0); SkinDocument(QLabel* statusLabel, QString file, ProjectModel* project = 0, - QWidget* parent = 0); + DeviceState* device = 0, QWidget* parent = 0); virtual ~SkinDocument(); void connectPrefs(PreferencesDialog* prefs); @@ -70,7 +71,7 @@ public: TabType type() const{ return Skin; } - QGraphicsScene* scene(){ return model->render(project, &fileName); } + QGraphicsScene* scene(){ return model->render(project, device, &fileName); } signals: @@ -80,6 +81,7 @@ public slots: private slots: void codeChanged(); + void deviceChanged(){ scene(); } private: void setupUI(); @@ -101,6 +103,7 @@ private: bool blockUpdate; ProjectModel* project; + DeviceState* device; }; #endif // SKINDOCUMENT_H -- cgit v1.2.3