summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
Diffstat (limited to 'utils')
-rw-r--r--utils/themeeditor/graphics/rbtoucharea.cpp55
-rw-r--r--utils/themeeditor/graphics/rbtoucharea.h4
-rw-r--r--utils/themeeditor/gui/devicestate.cpp12
3 files changed, 65 insertions, 6 deletions
diff --git a/utils/themeeditor/graphics/rbtoucharea.cpp b/utils/themeeditor/graphics/rbtoucharea.cpp
index 20d30d813f..e41129a213 100644
--- a/utils/themeeditor/graphics/rbtoucharea.cpp
+++ b/utils/themeeditor/graphics/rbtoucharea.cpp
@@ -24,14 +24,18 @@
24#include "devicestate.h" 24#include "devicestate.h"
25 25
26#include <QPainter> 26#include <QPainter>
27#include <QDebug>
28#include <QGraphicsSceneMouseEvent>
27 29
28RBTouchArea::RBTouchArea(int width, int height, QString action, 30RBTouchArea::RBTouchArea(int width, int height, QString action,
29 const RBRenderInfo& info) 31 const RBRenderInfo& info)
30 : QGraphicsItem(info.screen()), 32 : QGraphicsItem(info.screen()),
31 size(QRectF(0, 0, width, height)), action(action) 33 size(QRectF(0, 0, width, height)), action(action),
34 device(info.device())
32{ 35{
33 debug = info.device()->data("showtouch").toBool(); 36 debug = info.device()->data("showtouch").toBool();
34 setZValue(5); 37 setZValue(5);
38 setCursor(Qt::PointingHandCursor);
35} 39}
36 40
37RBTouchArea::~RBTouchArea() 41RBTouchArea::~RBTouchArea()
@@ -56,3 +60,52 @@ void RBTouchArea::paint(QPainter *painter,
56 painter->drawRect(size); 60 painter->drawRect(size);
57 } 61 }
58} 62}
63
64void RBTouchArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
65{
66 if(action[0] == '&')
67 action = action.right(action.count() - 1);
68
69 action = action.toLower();
70
71 if(action == "play")
72 {
73 if(device->data("?mp").toInt() == 2)
74 device->setData("mp", "Play");
75 else
76 device->setData("mp", "Pause");
77 }
78 else if(action == "ffwd")
79 {
80 device->setData("mp", "Fast Forward");
81 }
82 else if(action == "rwd")
83 {
84 device->setData("mp", "Rewind");
85 }
86 else if(action == "repmode")
87 {
88 int index = device->data("?mm").toInt();
89 index = (index + 1) % 5;
90 device->setData("mm", index);
91 }
92 else if(action == "shuffle")
93 {
94 device->setData("ps", !device->data("ps").toBool());
95 }
96 else if(action == "volup")
97 {
98 device->setData("pv", device->data("pv").toInt() + 1);
99 }
100 else if(action == "voldown")
101 {
102 device->setData("pv", device->data("pv").toInt() - 1);
103 }
104 else
105 {
106 event->ignore();
107 return;
108 }
109
110 event->accept();
111}
diff --git a/utils/themeeditor/graphics/rbtoucharea.h b/utils/themeeditor/graphics/rbtoucharea.h
index eb25d83261..ccc3edb272 100644
--- a/utils/themeeditor/graphics/rbtoucharea.h
+++ b/utils/themeeditor/graphics/rbtoucharea.h
@@ -25,6 +25,7 @@
25#include <QGraphicsItem> 25#include <QGraphicsItem>
26 26
27#include "rbrenderinfo.h" 27#include "rbrenderinfo.h"
28#include "devicestate.h"
28 29
29class RBTouchArea : public QGraphicsItem 30class RBTouchArea : public QGraphicsItem
30{ 31{
@@ -37,11 +38,12 @@ public:
37 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, 38 void paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
38 QWidget *widget); 39 QWidget *widget);
39 40
41 void mousePressEvent(QGraphicsSceneMouseEvent *event);
40 42
41private: 43private:
42 QRectF size; 44 QRectF size;
43 QString action; 45 QString action;
44 RBScreen* screen; 46 DeviceState* device;
45 bool debug; 47 bool debug;
46}; 48};
47 49
diff --git a/utils/themeeditor/gui/devicestate.cpp b/utils/themeeditor/gui/devicestate.cpp
index 21f95bfa10..89985bf730 100644
--- a/utils/themeeditor/gui/devicestate.cpp
+++ b/utils/themeeditor/gui/devicestate.cpp
@@ -474,10 +474,14 @@ void DeviceState::setData(QString tag, QVariant data)
474 break; 474 break;
475 475
476 case Combo: 476 case Combo:
477 dynamic_cast<QComboBox*> 477 if(data.type() == QVariant::String)
478 (found.second)-> 478 dynamic_cast<QComboBox*>
479 setCurrentIndex(dynamic_cast<QComboBox*> 479 (found.second)->
480 (found.second)->findText(data.toString())); 480 setCurrentIndex(dynamic_cast<QComboBox*>
481 (found.second)->findText(data.toString()));
482 else
483 dynamic_cast<QComboBox*>(found.second)->
484 setCurrentIndex(data.toInt());
481 break; 485 break;
482 486
483 case Check: 487 case Check: