1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Implemented some touch area click events

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@27397 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-07-12 05:33:14 +00:00
parent c9f997cc91
commit bae1836337
3 changed files with 65 additions and 6 deletions

View file

@ -24,14 +24,18 @@
#include "devicestate.h"
#include <QPainter>
#include <QDebug>
#include <QGraphicsSceneMouseEvent>
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();
}