summaryrefslogtreecommitdiff
path: root/utils/themeeditor/graphics/rbviewport.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/graphics/rbviewport.cpp')
-rw-r--r--utils/themeeditor/graphics/rbviewport.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/utils/themeeditor/graphics/rbviewport.cpp b/utils/themeeditor/graphics/rbviewport.cpp
index e9c58eb6fb..f7b1bc4ca2 100644
--- a/utils/themeeditor/graphics/rbviewport.cpp
+++ b/utils/themeeditor/graphics/rbviewport.cpp
@@ -21,6 +21,11 @@
21 21
22#include <QPainter> 22#include <QPainter>
23#include <QPainterPath> 23#include <QPainterPath>
24#include <QGraphicsSceneMouseEvent>
25#include <QTransform>
26
27#include <QDebug>
28
24#include <cmath> 29#include <cmath>
25 30
26#include "rbviewport.h" 31#include "rbviewport.h"
@@ -40,6 +45,8 @@ RBViewport::RBViewport(skin_element* node, const RBRenderInfo& info)
40 statusBarTexture(":/render/statusbar.png"), 45 statusBarTexture(":/render/statusbar.png"),
41 leftGraphic(0), centerGraphic(0), rightGraphic(0), scrollTime(0) 46 leftGraphic(0), centerGraphic(0), rightGraphic(0), scrollTime(0)
42{ 47{
48 setFlags(ItemIsSelectable | ItemIsMovable | ItemSendsGeometryChanges);
49
43 if(!node->tag) 50 if(!node->tag)
44 { 51 {
45 /* Default viewport takes up the entire screen */ 52 /* Default viewport takes up the entire screen */
@@ -290,6 +297,26 @@ void RBViewport::showPlaylist(const RBRenderInfo &info, int start,
290 } 297 }
291} 298}
292 299
300QVariant RBViewport::itemChange(GraphicsItemChange change,
301 const QVariant &value)
302{
303 if(change == ItemPositionChange)
304 {
305 QPointF pos = value.toPointF();
306 QRectF bound = parentItem()->boundingRect();
307
308 pos.setX(qMax(0., pos.x()));
309 pos.setX(qMin(pos.x(), bound.width() - boundingRect().width()));
310
311 pos.setY(qMax(0., pos.y()));
312 pos.setY(qMin(pos.y(), bound.height() - boundingRect().height()));
313
314 return pos;
315 }
316
317 return QGraphicsItem::itemChange(change, value);
318}
319
293void RBViewport::alignLeft() 320void RBViewport::alignLeft()
294{ 321{
295 int y = textOffset.y(); 322 int y = textOffset.y();