From bae183633705b087f80afe11a36772f553a5cb26 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Mon, 12 Jul 2010 05:33:14 +0000 Subject: Theme Editor: Implemented some touch area click events git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27397 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/graphics/rbtoucharea.cpp | 55 +++++++++++++++++++++++++++++- utils/themeeditor/graphics/rbtoucharea.h | 4 ++- utils/themeeditor/gui/devicestate.cpp | 12 ++++--- 3 files changed, 65 insertions(+), 6 deletions(-) (limited to 'utils/themeeditor') 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 @@ #include "devicestate.h" #include +#include +#include RBTouchArea::RBTouchArea(int width, int height, QString action, const RBRenderInfo& info) : QGraphicsItem(info.screen()), - size(QRectF(0, 0, width, height)), action(action) + size(QRectF(0, 0, width, height)), action(action), + device(info.device()) { debug = info.device()->data("showtouch").toBool(); setZValue(5); + setCursor(Qt::PointingHandCursor); } RBTouchArea::~RBTouchArea() @@ -56,3 +60,52 @@ void RBTouchArea::paint(QPainter *painter, painter->drawRect(size); } } + +void RBTouchArea::mousePressEvent(QGraphicsSceneMouseEvent *event) +{ + if(action[0] == '&') + action = action.right(action.count() - 1); + + action = action.toLower(); + + if(action == "play") + { + if(device->data("?mp").toInt() == 2) + device->setData("mp", "Play"); + else + device->setData("mp", "Pause"); + } + else if(action == "ffwd") + { + device->setData("mp", "Fast Forward"); + } + else if(action == "rwd") + { + device->setData("mp", "Rewind"); + } + else if(action == "repmode") + { + int index = device->data("?mm").toInt(); + index = (index + 1) % 5; + device->setData("mm", index); + } + else if(action == "shuffle") + { + device->setData("ps", !device->data("ps").toBool()); + } + else if(action == "volup") + { + device->setData("pv", device->data("pv").toInt() + 1); + } + else if(action == "voldown") + { + device->setData("pv", device->data("pv").toInt() - 1); + } + else + { + event->ignore(); + return; + } + + event->accept(); +} 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 @@ #include #include "rbrenderinfo.h" +#include "devicestate.h" class RBTouchArea : public QGraphicsItem { @@ -37,11 +38,12 @@ public: void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget); + void mousePressEvent(QGraphicsSceneMouseEvent *event); private: QRectF size; QString action; - RBScreen* screen; + DeviceState* device; bool debug; }; 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) break; case Combo: - dynamic_cast - (found.second)-> - setCurrentIndex(dynamic_cast - (found.second)->findText(data.toString())); + if(data.type() == QVariant::String) + dynamic_cast + (found.second)-> + setCurrentIndex(dynamic_cast + (found.second)->findText(data.toString())); + else + dynamic_cast(found.second)-> + setCurrentIndex(data.toInt()); break; case Check: -- cgit v1.2.3