summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-08-06 20:53:50 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-08-06 20:53:50 +0000
commitdf1ff115f50f77473efeec33bea670388e7e3325 (patch)
treeaeecd16c878d72377b3ce8cb81601869c270552e
parent76d1377d0495f92ab10310018f05c11183ddc560 (diff)
downloadrockbox-df1ff115f50f77473efeec33bea670388e7e3325.tar.gz
rockbox-df1ff115f50f77473efeec33bea670388e7e3325.zip
Theme Editor: Added coordinate display when moving mouse around preview window
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27738 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/themeeditor/graphics/rbscene.cpp36
-rw-r--r--utils/themeeditor/graphics/rbscene.h41
-rw-r--r--utils/themeeditor/graphics/rbscreen.cpp15
-rw-r--r--utils/themeeditor/graphics/rbscreen.h3
-rw-r--r--utils/themeeditor/gui/skindocument.h2
-rw-r--r--utils/themeeditor/gui/skinviewer.cpp4
-rw-r--r--utils/themeeditor/gui/skinviewer.ui20
-rw-r--r--utils/themeeditor/models/parsetreemodel.cpp4
-rw-r--r--utils/themeeditor/models/parsetreemodel.h8
-rw-r--r--utils/themeeditor/themeeditor.pro6
10 files changed, 130 insertions, 9 deletions
diff --git a/utils/themeeditor/graphics/rbscene.cpp b/utils/themeeditor/graphics/rbscene.cpp
new file mode 100644
index 0000000000..836abee489
--- /dev/null
+++ b/utils/themeeditor/graphics/rbscene.cpp
@@ -0,0 +1,36 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include <QGraphicsSceneMouseEvent>
23
24#include <QDebug>
25
26#include "rbscene.h"
27
28RBScene::RBScene(QObject* parent)
29 : QGraphicsScene(parent)
30{
31}
32
33RBScene::~RBScene()
34{
35}
36
diff --git a/utils/themeeditor/graphics/rbscene.h b/utils/themeeditor/graphics/rbscene.h
new file mode 100644
index 0000000000..2c4e0ee193
--- /dev/null
+++ b/utils/themeeditor/graphics/rbscene.h
@@ -0,0 +1,41 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef RBSCENE_H
23#define RBSCENE_H
24
25#include <QGraphicsScene>
26
27class RBScene : public QGraphicsScene
28{
29 Q_OBJECT
30
31public:
32 RBScene(QObject* parent = 0);
33 ~RBScene();
34
35 void moveMouse(QString position){ emit mouseMoved(position); }
36
37signals:
38 void mouseMoved(QString position);
39};
40
41#endif // RBSCENE_H
diff --git a/utils/themeeditor/graphics/rbscreen.cpp b/utils/themeeditor/graphics/rbscreen.cpp
index df72d5005b..1b1adc8be4 100644
--- a/utils/themeeditor/graphics/rbscreen.cpp
+++ b/utils/themeeditor/graphics/rbscreen.cpp
@@ -19,12 +19,15 @@
19 * 19 *
20 ****************************************************************************/ 20 ****************************************************************************/
21 21
22#include "rbscene.h"
22#include "rbscreen.h" 23#include "rbscreen.h"
23#include "rbviewport.h" 24#include "rbviewport.h"
24#include "devicestate.h" 25#include "devicestate.h"
25 26
26#include <QPainter> 27#include <QPainter>
27#include <QFile> 28#include <QFile>
29#include <QGraphicsSceneHoverEvent>
30#include <QGraphicsSceneMouseEvent>
28 31
29RBScreen::RBScreen(const RBRenderInfo& info, bool remote, 32RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
30 QGraphicsItem *parent) 33 QGraphicsItem *parent)
@@ -32,6 +35,8 @@ RBScreen::RBScreen(const RBRenderInfo& info, bool remote,
32 albumArt(0), customUI(0) 35 albumArt(0), customUI(0)
33{ 36{
34 37
38 setAcceptHoverEvents(true);
39
35 if(remote) 40 if(remote)
36 { 41 {
37 fullWidth = info.device()->data("remotewidth").toInt(); 42 fullWidth = info.device()->data("remotewidth").toInt();
@@ -265,3 +270,13 @@ QColor RBScreen::stringToColor(QString str, QColor fallback)
265 return retval; 270 return retval;
266 271
267} 272}
273
274void RBScreen::hoverMoveEvent(QGraphicsSceneHoverEvent *event)
275{
276 RBScene* s = dynamic_cast<RBScene*>(scene());
277 QPoint p = event->scenePos().toPoint();
278 s->moveMouse("(" + QString::number(p.x()) + ", "
279 + QString::number(p.y()) + ")");
280
281 QGraphicsItem::hoverMoveEvent(event);
282}
diff --git a/utils/themeeditor/graphics/rbscreen.h b/utils/themeeditor/graphics/rbscreen.h
index 2903a29585..c9f6ae2dbc 100644
--- a/utils/themeeditor/graphics/rbscreen.h
+++ b/utils/themeeditor/graphics/rbscreen.h
@@ -88,6 +88,9 @@ public:
88 88
89 void breakSBS(); 89 void breakSBS();
90 90
91protected:
92 void hoverMoveEvent(QGraphicsSceneHoverEvent *event);
93
91private: 94private:
92 int width; 95 int width;
93 int height; 96 int height;
diff --git a/utils/themeeditor/gui/skindocument.h b/utils/themeeditor/gui/skindocument.h
index 5e72e29a8d..bf47897b0b 100644
--- a/utils/themeeditor/gui/skindocument.h
+++ b/utils/themeeditor/gui/skindocument.h
@@ -75,7 +75,7 @@ public:
75 75
76 TabType type() const{ return Skin; } 76 TabType type() const{ return Skin; }
77 77
78 QGraphicsScene* scene() 78 RBScene* scene()
79 { 79 {
80 return model->render(project, device, this, &fileName); 80 return model->render(project, device, this, &fileName);
81 } 81 }
diff --git a/utils/themeeditor/gui/skinviewer.cpp b/utils/themeeditor/gui/skinviewer.cpp
index f1f3af9c8c..ab4d522f2a 100644
--- a/utils/themeeditor/gui/skinviewer.cpp
+++ b/utils/themeeditor/gui/skinviewer.cpp
@@ -69,11 +69,15 @@ void SkinViewer::connectSkin(SkinDocument *skin)
69 QObject::connect(ui->codeUndoButton, SIGNAL(pressed()), 69 QObject::connect(ui->codeUndoButton, SIGNAL(pressed()),
70 skin, SLOT(parseCode())); 70 skin, SLOT(parseCode()));
71 71
72 QObject::connect(skin->scene(), SIGNAL(mouseMoved(QString)),
73 ui->coordinateLabel, SLOT(setText(QString)));
74
72 doc = skin; 75 doc = skin;
73 } 76 }
74 else 77 else
75 { 78 {
76 ui->viewer->setScene(0); 79 ui->viewer->setScene(0);
80 ui->coordinateLabel->setText("");
77 81
78 doc = 0; 82 doc = 0;
79 } 83 }
diff --git a/utils/themeeditor/gui/skinviewer.ui b/utils/themeeditor/gui/skinviewer.ui
index dc4a786a33..aa10cddbe7 100644
--- a/utils/themeeditor/gui/skinviewer.ui
+++ b/utils/themeeditor/gui/skinviewer.ui
@@ -55,6 +55,26 @@
55 </widget> 55 </widget>
56 </item> 56 </item>
57 <item> 57 <item>
58 <spacer name="horizontalSpacer_2">
59 <property name="orientation">
60 <enum>Qt::Horizontal</enum>
61 </property>
62 <property name="sizeHint" stdset="0">
63 <size>
64 <width>40</width>
65 <height>20</height>
66 </size>
67 </property>
68 </spacer>
69 </item>
70 <item>
71 <widget class="QLabel" name="coordinateLabel">
72 <property name="text">
73 <string/>
74 </property>
75 </widget>
76 </item>
77 <item>
58 <spacer name="horizontalSpacer"> 78 <spacer name="horizontalSpacer">
59 <property name="orientation"> 79 <property name="orientation">
60 <enum>Qt::Horizontal</enum> 80 <enum>Qt::Horizontal</enum>
diff --git a/utils/themeeditor/models/parsetreemodel.cpp b/utils/themeeditor/models/parsetreemodel.cpp
index 2186788fd6..fbedf10d45 100644
--- a/utils/themeeditor/models/parsetreemodel.cpp
+++ b/utils/themeeditor/models/parsetreemodel.cpp
@@ -44,7 +44,7 @@ ParseTreeModel::ParseTreeModel(const char* document, QObject* parent):
44 else 44 else
45 this->root = 0; 45 this->root = 0;
46 46
47 scene = new QGraphicsScene(); 47 scene = new RBScene();
48} 48}
49 49
50 50
@@ -272,7 +272,7 @@ bool ParseTreeModel::setData(const QModelIndex &index, const QVariant &value,
272 return true; 272 return true;
273} 273}
274 274
275QGraphicsScene* ParseTreeModel::render(ProjectModel* project, 275RBScene* ParseTreeModel::render(ProjectModel* project,
276 DeviceState* device, 276 DeviceState* device,
277 SkinDocument* doc, const QString* file) 277 SkinDocument* doc, const QString* file)
278{ 278{
diff --git a/utils/themeeditor/models/parsetreemodel.h b/utils/themeeditor/models/parsetreemodel.h
index f176b760d3..bef8cc8f48 100644
--- a/utils/themeeditor/models/parsetreemodel.h
+++ b/utils/themeeditor/models/parsetreemodel.h
@@ -29,10 +29,10 @@
29 29
30#include <QAbstractItemModel> 30#include <QAbstractItemModel>
31#include <QList> 31#include <QList>
32#include <QGraphicsScene>
33 32
34#include "parsetreenode.h" 33#include "parsetreenode.h"
35#include "devicestate.h" 34#include "devicestate.h"
35#include "rbscene.h"
36 36
37class ParseTreeModel : public QAbstractItemModel 37class ParseTreeModel : public QAbstractItemModel
38{ 38{
@@ -64,8 +64,8 @@ public:
64 Qt::ItemFlags flags(const QModelIndex &index) const; 64 Qt::ItemFlags flags(const QModelIndex &index) const;
65 bool setData(const QModelIndex &index, const QVariant &value, int role); 65 bool setData(const QModelIndex &index, const QVariant &value, int role);
66 66
67 QGraphicsScene* render(ProjectModel* project, DeviceState* device, 67 RBScene* render(ProjectModel* project, DeviceState* device,
68 SkinDocument* doc, const QString* file = 0); 68 SkinDocument* doc, const QString* file = 0);
69 69
70 static QString safeSetting(ProjectModel* project, QString key, 70 static QString safeSetting(ProjectModel* project, QString key,
71 QString fallback) 71 QString fallback)
@@ -85,7 +85,7 @@ private:
85 ParseTreeNode* root; 85 ParseTreeNode* root;
86 ParseTreeModel* sbsModel; 86 ParseTreeModel* sbsModel;
87 struct skin_element* tree; 87 struct skin_element* tree;
88 QGraphicsScene* scene; 88 RBScene* scene;
89}; 89};
90 90
91 91
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index 5418bbf555..0cecd2d96b 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -107,7 +107,8 @@ HEADERS += models/parsetreemodel.h \
107 gui/projectexporter.h \ 107 gui/projectexporter.h \
108 gui/targetdownloader.h \ 108 gui/targetdownloader.h \
109 gui/syntaxcompleter.h \ 109 gui/syntaxcompleter.h \
110 graphics/rbmovable.h 110 graphics/rbmovable.h \
111 graphics/rbscene.h
111SOURCES += main.cpp \ 112SOURCES += main.cpp \
112 models/parsetreemodel.cpp \ 113 models/parsetreemodel.cpp \
113 models/parsetreenode.cpp \ 114 models/parsetreenode.cpp \
@@ -149,7 +150,8 @@ SOURCES += main.cpp \
149 gui/projectexporter.cpp \ 150 gui/projectexporter.cpp \
150 gui/targetdownloader.cpp \ 151 gui/targetdownloader.cpp \
151 gui/syntaxcompleter.cpp \ 152 gui/syntaxcompleter.cpp \
152 graphics/rbmovable.cpp 153 graphics/rbmovable.cpp \
154 graphics/rbscene.cpp
153OTHER_FILES += README \ 155OTHER_FILES += README \
154 resources/windowicon.png \ 156 resources/windowicon.png \
155 resources/appicon.xcf \ 157 resources/appicon.xcf \