diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-06-21 20:11:58 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-06-21 20:11:58 +0000 |
commit | e1d8a3dc63391098f9381a3cb33d73e69b46c006 (patch) | |
tree | 0f503320d4fda330a003fe88ae7482537037db85 /utils/themeeditor/models | |
parent | bd380b399323d15a1572cdc017e0f95b1b9db151 (diff) | |
download | rockbox-e1d8a3dc63391098f9381a3cb33d73e69b46c006.tar.gz rockbox-e1d8a3dc63391098f9381a3cb33d73e69b46c006.zip |
Theme Editor: Reworked information passing among render functions, now loads all viewports and shows Custom UI viewport in blue
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27026 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/models')
-rw-r--r-- | utils/themeeditor/models/parsetreemodel.cpp | 27 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreemodel.h | 2 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreenode.cpp | 12 | ||||
-rw-r--r-- | utils/themeeditor/models/projectmodel.h | 2 |
4 files changed, 34 insertions, 9 deletions
diff --git a/utils/themeeditor/models/parsetreemodel.cpp b/utils/themeeditor/models/parsetreemodel.cpp index 41cecc4c20..4e94bfa0bf 100644 --- a/utils/themeeditor/models/parsetreemodel.cpp +++ b/utils/themeeditor/models/parsetreemodel.cpp @@ -29,6 +29,8 @@ #include <QObject> #include <QPixmap> +#include <QMap> +#include <QDir> ParseTreeModel::ParseTreeModel(const char* document, QObject* parent): QAbstractItemModel(parent) @@ -270,23 +272,40 @@ bool ParseTreeModel::setData(const QModelIndex &index, const QVariant &value, return true; } -QGraphicsScene* ParseTreeModel::render(ProjectModel* project) +QGraphicsScene* ParseTreeModel::render(ProjectModel* project, + const QString* file) { scene->clear(); /* Setting the background */ scene->setBackgroundBrush(QBrush(QPixmap(":/render/scenebg.png"))); + /* Preparing settings */ + QMap<QString, QString> settings; + if(project) + settings = project->getSettings(); + + /* Setting themebase if it can't be derived from the project */ + if(settings.value("themebase", "") == "" && file && QFile::exists(*file)) + { + QDir base(*file); + base.cdUp(); + settings.insert("themebase", base.canonicalPath()); + } + + RBScreen* screen = 0; + RBRenderInfo info(this, project, &settings, screen); + /* Adding the screen */ - RBScreen* screen = new RBScreen(project); + screen = new RBScreen(info); scene->addItem(screen); - RBRenderInfo info(this, project, screen); + info = RBRenderInfo(this, project, &settings, screen); + /* Rendering the tree */ if(root) root->render(info); - return scene; } diff --git a/utils/themeeditor/models/parsetreemodel.h b/utils/themeeditor/models/parsetreemodel.h index 1f252a3f20..df64403bf5 100644 --- a/utils/themeeditor/models/parsetreemodel.h +++ b/utils/themeeditor/models/parsetreemodel.h @@ -60,7 +60,7 @@ public: Qt::ItemFlags flags(const QModelIndex &index) const; bool setData(const QModelIndex &index, const QVariant &value, int role); - QGraphicsScene* render(ProjectModel* project); + QGraphicsScene* render(ProjectModel* project, const QString* file = 0); static QString safeSetting(ProjectModel* project, QString key, QString fallback) diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index 97beca4c3d..a74dd2350b 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp @@ -25,6 +25,8 @@ #include "parsetreenode.h" #include "parsetreemodel.h" +#include <iostream> + int ParseTreeNode::openConditionals = 0; /* Root element constructor */ @@ -490,11 +492,13 @@ void ParseTreeNode::render(const RBRenderInfo& info) return; } - switch(element->type) + if(element->type != VIEWPORT) { - case VIEWPORT: - rendered = new RBViewport(element, info); - break; + std::cerr << QObject::tr("Error in parse tree").toStdString() + << std::endl; + return; } + + rendered = new RBViewport(element, info); } diff --git a/utils/themeeditor/models/projectmodel.h b/utils/themeeditor/models/projectmodel.h index 791c07ea2e..4cc531b88f 100644 --- a/utils/themeeditor/models/projectmodel.h +++ b/utils/themeeditor/models/projectmodel.h @@ -49,6 +49,8 @@ public: return settings.value(key, fallback); } + const QMap<QString, QString>& getSettings() const{ return settings; } + signals: public slots: |