summaryrefslogtreecommitdiff
path: root/utils/themeeditor
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor')
-rw-r--r--utils/themeeditor/graphics/rbprogressbar.cpp106
-rw-r--r--utils/themeeditor/graphics/rbprogressbar.h51
-rw-r--r--utils/themeeditor/graphics/rbviewport.h4
-rw-r--r--utils/themeeditor/models/parsetreenode.cpp13
-rw-r--r--utils/themeeditor/themeeditor.pro6
5 files changed, 178 insertions, 2 deletions
diff --git a/utils/themeeditor/graphics/rbprogressbar.cpp b/utils/themeeditor/graphics/rbprogressbar.cpp
new file mode 100644
index 0000000000..1c14acfc5a
--- /dev/null
+++ b/utils/themeeditor/graphics/rbprogressbar.cpp
@@ -0,0 +1,106 @@
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 <QPainter>
23
24#include "rbprogressbar.h"
25#include "projectmodel.h"
26
27RBProgressBar::RBProgressBar(RBViewport *parent, const RBRenderInfo &info,
28 int paramCount, skin_tag_parameter *params)
29 :QGraphicsItem(parent)
30{
31 /* First we set everything to defaults */
32 bitmap = 0;
33 color = parent->getFGColor();
34 int x = 0;
35 int y = parent->getTextOffset();
36 int w = parent->boundingRect().width();
37 int h = 6;
38
39 /* Now we change defaults if the parameters are there */
40
41 if(paramCount > 0 && params[0].type != skin_tag_parameter::DEFAULT)
42 {
43 x = params[0].data.numeric;
44 }
45
46 if(paramCount > 1 && params[1].type != skin_tag_parameter::DEFAULT)
47 {
48 y = params[1].data.numeric;
49 }
50
51 if(paramCount > 2 && params[2].type != skin_tag_parameter::DEFAULT)
52 {
53 w = params[2].data.numeric;
54 }
55
56 if(paramCount > 3 && params[3].type != skin_tag_parameter::DEFAULT)
57 {
58 h = params[3].data.numeric;
59 }
60
61 if(paramCount > 4 && params[4].type != skin_tag_parameter::DEFAULT)
62 {
63 QString imPath(params[4].data.text);
64 imPath = info.settings()->value("imagepath", "") + "/" + imPath;
65 bitmap = new QPixmap(imPath);
66 if(bitmap->isNull())
67 {
68 delete bitmap;
69 bitmap = 0;
70 }
71 }
72
73
74 /* Finally, we scale the width according to the amount played */
75 int percent = info.device()->data("px").toInt();
76 w = w * percent / 100;
77
78 size = QRectF(0, 0, w, h);
79 setPos(x, y);
80 parent->addTextOffset(h);
81}
82
83RBProgressBar::~RBProgressBar()
84{
85 if(bitmap)
86 delete bitmap;
87}
88
89QRectF RBProgressBar::boundingRect() const
90{
91 return size;
92}
93
94void RBProgressBar::paint(QPainter *painter,
95 const QStyleOptionGraphicsItem *option,
96 QWidget *widget)
97{
98 if(bitmap && !bitmap->isNull())
99 {
100 painter->drawPixmap(size, *bitmap, size);
101 }
102 else
103 {
104 painter->fillRect(size, color);
105 }
106}
diff --git a/utils/themeeditor/graphics/rbprogressbar.h b/utils/themeeditor/graphics/rbprogressbar.h
new file mode 100644
index 0000000000..edcdd01d6e
--- /dev/null
+++ b/utils/themeeditor/graphics/rbprogressbar.h
@@ -0,0 +1,51 @@
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 RBPROGRESSBAR_H
23#define RBPROGRESSBAR_H
24
25#include <QGraphicsItem>
26#include <QPixmap>
27
28#include "rbrenderinfo.h"
29#include "rbviewport.h"
30#include "devicestate.h"
31#include "skin_parser.h"
32
33class RBProgressBar : public QGraphicsItem
34{
35public:
36 RBProgressBar(RBViewport* parent, const RBRenderInfo& info,
37 int paramCount, skin_tag_parameter* params);
38 virtual ~RBProgressBar();
39
40 QRectF boundingRect() const;
41 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
42 QWidget *widget);
43
44private:
45 QPixmap* bitmap;
46 QColor color;
47 QRectF size;
48
49};
50
51#endif // RBPROGRESSBAR_H
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h
index 70f52232af..624a9686da 100644
--- a/utils/themeeditor/graphics/rbviewport.h
+++ b/utils/themeeditor/graphics/rbviewport.h
@@ -49,13 +49,17 @@ public:
49 QWidget *widget); 49 QWidget *widget);
50 50
51 void setBGColor(QColor color){ background = color; } 51 void setBGColor(QColor color){ background = color; }
52 QColor getBGColor(){ return background; }
52 void setFGColor(QColor color){ foreground = color; } 53 void setFGColor(QColor color){ foreground = color; }
54 QColor getFGColor(){ return foreground; }
53 void makeCustomUI(){ customUI = true; } 55 void makeCustomUI(){ customUI = true; }
54 void clearCustomUI(){ customUI = false; } 56 void clearCustomUI(){ customUI = false; }
55 57
56 void newLine(); 58 void newLine();
57 void write(QString text); 59 void write(QString text);
58 void alignText(Alignment align){ textAlign = align; } 60 void alignText(Alignment align){ textAlign = align; }
61 int getTextOffset(){ return textOffset.y(); }
62 void addTextOffset(int height){ textOffset.setY(textOffset.y() + height); }
59 63
60 void enableStatusBar(){ showStatusBar = true; } 64 void enableStatusBar(){ showStatusBar = true; }
61 65
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp
index e61c6552e2..08ce703859 100644
--- a/utils/themeeditor/models/parsetreenode.cpp
+++ b/utils/themeeditor/models/parsetreenode.cpp
@@ -26,6 +26,7 @@
26#include "parsetreemodel.h" 26#include "parsetreemodel.h"
27 27
28#include "rbimage.h" 28#include "rbimage.h"
29#include "rbprogressbar.h"
29 30
30#include <iostream> 31#include <iostream>
31 32
@@ -611,6 +612,18 @@ bool ParseTreeNode::execTag(const RBRenderInfo& info, RBViewport* viewport)
611 612
612 return false; 613 return false;
613 614
615 case 'p':
616 switch(element->tag->name[1])
617 {
618 case 'b':
619 /* %pb */
620 new RBProgressBar(viewport, info, element->params_count,
621 element->params);
622 return true;
623 }
624
625 return false;
626
614 case 'w': 627 case 'w':
615 switch(element->tag->name[1]) 628 switch(element->tag->name[1])
616 { 629 {
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index 1e66faf88e..14fa73cc7d 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -44,7 +44,8 @@ HEADERS += models/parsetreemodel.h \
44 gui/devicestate.h \ 44 gui/devicestate.h \
45 findreplace/findreplaceform.h \ 45 findreplace/findreplaceform.h \
46 findreplace/findreplacedialog.h \ 46 findreplace/findreplacedialog.h \
47 graphics/rbalbumart.h 47 graphics/rbalbumart.h \
48 graphics/rbprogressbar.h
48SOURCES += main.cpp \ 49SOURCES += main.cpp \
49 models/parsetreemodel.cpp \ 50 models/parsetreemodel.cpp \
50 models/parsetreenode.cpp \ 51 models/parsetreenode.cpp \
@@ -64,7 +65,8 @@ SOURCES += main.cpp \
64 gui/devicestate.cpp \ 65 gui/devicestate.cpp \
65 findreplace/findreplaceform.cpp \ 66 findreplace/findreplaceform.cpp \
66 findreplace/findreplacedialog.cpp \ 67 findreplace/findreplacedialog.cpp \
67 graphics/rbalbumart.cpp 68 graphics/rbalbumart.cpp \
69 graphics/rbprogressbar.cpp
68OTHER_FILES += README \ 70OTHER_FILES += README \
69 resources/windowicon.png \ 71 resources/windowicon.png \
70 resources/appicon.xcf \ 72 resources/appicon.xcf \