1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
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"
24 #include "devicestate.h"
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
),
36 debug
= info
.device()->data("showtouch").toBool();
38 setCursor(Qt::PointingHandCursor
);
41 RBTouchArea::~RBTouchArea()
45 QRectF
RBTouchArea::boundingRect() const
50 void RBTouchArea::paint(QPainter
*painter
,
51 const QStyleOptionGraphicsItem
*option
,
56 QColor fill
= Qt::green
;
58 painter
->setBrush(fill
);
59 painter
->setPen(Qt::NoPen
);
60 painter
->drawRect(size
);
64 void RBTouchArea::mousePressEvent(QGraphicsSceneMouseEvent
*event
)
67 action
= action
.right(action
.count() - 1);
69 action
= action
.toLower();
73 if(device
->data("?mp").toInt() == 2)
74 device
->setData("mp", "Play");
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);