From 38643107d9e271c68548347e702ae052e811f4dc Mon Sep 17 00:00:00 2001 From: bieber Date: Sat, 26 Jun 2010 05:51:07 +0000 Subject: [PATCH] Theme Editor: Added Show Viewports option to device configuration panel, implemented simple rendering of info tags from device configuration git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27136 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/graphics/rbscreen.cpp | 22 +++++++++++++--------- utils/themeeditor/graphics/rbscreen.h | 3 ++- utils/themeeditor/graphics/rbviewport.cpp | 5 +++-- utils/themeeditor/graphics/rbviewport.h | 1 + utils/themeeditor/gui/skindocument.cpp | 4 ++++ utils/themeeditor/models/parsetreemodel.cpp | 8 +++++++- utils/themeeditor/models/parsetreenode.cpp | 7 +++++++ utils/themeeditor/resources/deviceoptions | 3 ++- 8 files changed, 39 insertions(+), 14 deletions(-) diff --git a/utils/themeeditor/graphics/rbscreen.cpp b/utils/themeeditor/graphics/rbscreen.cpp index da6d20bbe..b93d3c88a 100644 --- a/utils/themeeditor/graphics/rbscreen.cpp +++ b/utils/themeeditor/graphics/rbscreen.cpp @@ -26,17 +26,21 @@ #include #include -RBScreen::RBScreen(const RBRenderInfo& info, QGraphicsItem *parent) : - QGraphicsItem(parent), backdrop(0), project(project) +RBScreen::RBScreen(const RBRenderInfo& info, bool remote, + QGraphicsItem *parent) + :QGraphicsItem(parent), backdrop(0), project(project) { - /* - width = info.settings()->value("#screenwidth", "300").toInt(); - height = info.settings()->value("#screenheight", "200").toInt(); -*/ - - width = info.device()->data("screenwidth").toInt(); - height = info.device()->data("screenheight").toInt(); + if(remote) + { + width = info.device()->data("remotewidth").toInt(); + height = info.device()->data("remoteheight").toInt(); + } + else + { + width = info.device()->data("screenwidth").toInt(); + height = info.device()->data("screenheight").toInt(); + } QString bg = info.settings()->value("background color", "FFFFFF"); bgColor = stringToColor(bg, Qt::white); diff --git a/utils/themeeditor/graphics/rbscreen.h b/utils/themeeditor/graphics/rbscreen.h index 8b5f2f4a1..25f7c07bd 100644 --- a/utils/themeeditor/graphics/rbscreen.h +++ b/utils/themeeditor/graphics/rbscreen.h @@ -35,7 +35,8 @@ class RBScreen : public QGraphicsItem { public: - RBScreen(const RBRenderInfo& info, QGraphicsItem *parent = 0); + RBScreen(const RBRenderInfo& info, bool remote = false, + QGraphicsItem *parent = 0); virtual ~RBScreen(); QPainterPath shape() const; diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp index 03a760480..8fa05a2fc 100644 --- a/utils/themeeditor/graphics/rbviewport.cpp +++ b/utils/themeeditor/graphics/rbviewport.cpp @@ -105,7 +105,7 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info) setPos(x, y); size = QRectF(0, 0, w, h); - + debug = info.device()->data("showviewports").toBool(); } } @@ -135,7 +135,8 @@ void RBViewport::paint(QPainter *painter, painter->setBrush(Qt::NoBrush); painter->setPen(customUI ? Qt::blue : Qt::red); - painter->drawRect(size); + if(debug) + painter->drawRect(size); } void RBViewport::newLine() diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index 1ee85f2fc..c6f0c636c 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h @@ -56,6 +56,7 @@ private: QColor foreground; QColor background; + bool debug; bool customUI; QPoint textOffset; int lineHeight; diff --git a/utils/themeeditor/gui/skindocument.cpp b/utils/themeeditor/gui/skindocument.cpp index 4f48d341f..6863ff5a9 100644 --- a/utils/themeeditor/gui/skindocument.cpp +++ b/utils/themeeditor/gui/skindocument.cpp @@ -288,6 +288,8 @@ void SkinDocument::save() titleText = decompose.last(); emit titleChanged(titleText); + scene(); + } void SkinDocument::saveAs() @@ -320,6 +322,8 @@ void SkinDocument::saveAs() titleText = decompose[decompose.count() - 1]; emit titleChanged(titleText); + scene(); + } QString SkinDocument::findSetting(QString key, QString fallback) diff --git a/utils/themeeditor/models/parsetreemodel.cpp b/utils/themeeditor/models/parsetreemodel.cpp index ff8a27c66..4f6fd451e 100644 --- a/utils/themeeditor/models/parsetreemodel.cpp +++ b/utils/themeeditor/models/parsetreemodel.cpp @@ -295,6 +295,7 @@ QGraphicsScene* ParseTreeModel::render(ProjectModel* project, settings.insert("themebase", base.canonicalPath()); } + bool remote = false; if(file) { QString skinFile = *file; @@ -303,13 +304,18 @@ QGraphicsScene* ParseTreeModel::render(ProjectModel* project, skinFile.chop(skinFile.length() - skinFile.lastIndexOf(".")); settings.insert("imagepath", settings.value("themebase","") + "/wps/" + skinFile); + + decomp = file->split("."); + QString extension = decomp.last(); + if(extension[0] == 'r') + remote = true; } RBScreen* screen = 0; RBRenderInfo info(this, project, &settings, device, screen); /* Adding the screen */ - screen = new RBScreen(info); + screen = new RBScreen(info, remote); scene->addItem(screen); info = RBRenderInfo(this, project, &settings, device, screen); diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index 5e298be25..7b355687b 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp @@ -524,6 +524,13 @@ void ParseTreeNode::render(const RBRenderInfo &info, RBViewport* viewport) } else if(element->type == TAG) { + + if(info.device()->data(QString(element->tag->name)).isValid()) + viewport->write(info.device()-> + data(QString(element->tag->name)).toString()); + + /* These are for special cases */ + QString filename; QString id; int x, y, tiles, tile; diff --git a/utils/themeeditor/resources/deviceoptions b/utils/themeeditor/resources/deviceoptions index ddd5ed017..855c8baae 100644 --- a/utils/themeeditor/resources/deviceoptions +++ b/utils/themeeditor/resources/deviceoptions @@ -27,11 +27,12 @@ # performing much of any error checking on it: screwing up the syntax may very # well segfault the application on startup -[Screen Sizes] +[Rendering Info] screenwidth ; Screen Width ; spin(0,800) ; 300 screenheight ; Screen Height ; spin(0,800) ; 200 remotewidth ; Remote Width ; spin(0,800) ; 100 remoteheight ; Remote Height ; spin(0,800); 50 +showviewports ; Show Viewports ; check ; true [ID3 Info] ia ; Artist ; text ; Current Artist -- 2.11.4.GIT