diff options
Diffstat (limited to 'utils/themeeditor/graphics')
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.cpp | 27 | ||||
-rw-r--r-- | utils/themeeditor/graphics/rbviewport.h | 3 |
2 files changed, 30 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 | ||
300 | QVariant 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 | |||
293 | void RBViewport::alignLeft() | 320 | void RBViewport::alignLeft() |
294 | { | 321 | { |
295 | int y = textOffset.y(); | 322 | int y = textOffset.y(); |
diff --git a/utils/themeeditor/graphics/rbviewport.h b/utils/themeeditor/graphics/rbviewport.h index c665108618..ea47225f09 100644 --- a/utils/themeeditor/graphics/rbviewport.h +++ b/utils/themeeditor/graphics/rbviewport.h | |||
@@ -77,6 +77,9 @@ public: | |||
77 | void showPlaylist(const RBRenderInfo& info, int start, skin_element* id3, | 77 | void showPlaylist(const RBRenderInfo& info, int start, skin_element* id3, |
78 | skin_element* noId3); | 78 | skin_element* noId3); |
79 | 79 | ||
80 | protected: | ||
81 | QVariant itemChange(GraphicsItemChange change, const QVariant &value); | ||
82 | |||
80 | private: | 83 | private: |
81 | 84 | ||
82 | void alignLeft(); | 85 | void alignLeft(); |