summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/graphics')
-rw-r--r--utils/themeeditor/graphics/rbprogressbar.cpp106
-rw-r--r--utils/themeeditor/graphics/rbprogressbar.h51
-rw-r--r--utils/themeeditor/graphics/rbviewport.h4
3 files changed, 161 insertions, 0 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