update Chinese(Simplified) translation
[maemo-rb.git] / utils / themeeditor / graphics / rbtoucharea.cpp
blobeee858e28f4709c5e8574437f7fbb0bcfe0986af
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2010 Robert Bieber
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "rbtoucharea.h"
23 #include "rbscreen.h"
24 #include "devicestate.h"
26 #include <QPainter>
27 #include <QDebug>
28 #include <QGraphicsSceneMouseEvent>
30 RBTouchArea::RBTouchArea(int width, int height, QString action,
31 const RBRenderInfo& info, QGraphicsItem* parent)
32 : QGraphicsItem(parent),
33 size(QRectF(0, 0, width, height)), action(action),
34 device(info.device())
36 debug = info.device()->data("showtouch").toBool();
37 setZValue(5);
38 setCursor(Qt::PointingHandCursor);
41 RBTouchArea::~RBTouchArea()
45 QRectF RBTouchArea::boundingRect() const
47 return size;
50 void RBTouchArea::paint(QPainter *painter,
51 const QStyleOptionGraphicsItem *option,
52 QWidget *widget)
54 if(debug)
56 QColor fill = Qt::green;
57 fill.setAlpha(50);
58 painter->setBrush(fill);
59 painter->setPen(Qt::NoPen);
60 painter->drawRect(size);
64 void RBTouchArea::mousePressEvent(QGraphicsSceneMouseEvent *event)
66 if(action[0] == '&')
67 action = action.right(action.count() - 1);
69 action = action.toLower();
71 if(action == "play")
73 if(device->data("?mp").toInt() == 2)
74 device->setData("mp", "Play");
75 else
76 device->setData("mp", "Pause");
78 else if(action == "ffwd")
80 device->setData("mp", "Fast Forward");
82 else if(action == "rwd")
84 device->setData("mp", "Rewind");
86 else if(action == "repmode")
88 int index = device->data("?mm").toInt();
89 index = (index + 1) % 5;
90 device->setData("mm", index);
92 else if(action == "shuffle")
94 device->setData("ps", !device->data("ps").toBool());
96 else if(action == "volup")
98 device->setData("pv", device->data("pv").toInt() + 1);
100 else if(action == "voldown")
102 device->setData("pv", device->data("pv").toInt() - 1);
104 else
106 event->ignore();
107 return;
110 event->accept();