52 #include <QPainterPath> 53 #include <QGraphicsItem> 54 #include <QGraphicsSceneMouseEvent> 59 #include "graphicsScene.hh" 73 QGraphicsPixmapItem (_parent),
82 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-up.png");
85 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-down.png");
88 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-right.png");
91 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-left.png");
94 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-center.png");
98 setOpacity ((highlight_)? 0.5 : 0.2);
100 setAcceptHoverEvents (
true);
102 connect (&timer_, SIGNAL (timeout ()),
this, SLOT (timeout ()));
115 void Arrow::hoverEnterEvent (QGraphicsSceneHoverEvent * )
123 void Arrow::hoverLeaveEvent (QGraphicsSceneHoverEvent * )
125 setOpacity ((highlight_)? 0.5 : 0.2);
131 void Arrow::mousePressEvent (QGraphicsSceneMouseEvent *_event)
135 qreal dx = 0.0, dy = 0.0;
154 QRectF rect = scene_->sceneRect();
155 dx = qMax (qMin ((rect.center () - bb.center ()).x (), 5.0), -5.0);
156 dy = qMax (qMin ((rect.center () - bb.center ()).y (), 5.0), -5.0);
164 moveSelected_ =
true;
170 void Arrow::mouseReleaseEvent (QGraphicsSceneMouseEvent *_event)
179 void Arrow::wheelEvent (QGraphicsSceneWheelEvent *_event)
183 qreal dx = 0.0, dy = 0.0;
198 dx *= _event->delta () / 4;
199 dy *= _event->delta () / 4;
206 void Arrow::timeout ()
208 if (timer_.interval () == 500)
210 timer_.setInterval (interval_ );
214 qreal dx = 0.0, dy = 0.0;
233 QRectF rect = scene_->sceneRect();
234 dx = qMax (qMin ((rect.center () - bb.center ()).x (), 2.0), -2.0);
235 dy = qMax (qMin ((rect.center () - bb.center ()).y (), 2.0), -2.0);
248 moveSelected_ =
false;
249 if (!timer_.isActive ())
258 setOpacity ((highlight_)? 0.5 : 0.2);
267 QGraphicsPixmapItem::setPos (_rect.topLeft ());
268 QGraphicsLayoutItem::setGeometry (_rect);
274 QSizeF Arrow::sizeHint (Qt::SizeHint _which,
const QSizeF &)
const 278 case Qt::MinimumSize:
279 case Qt::PreferredSize:
280 case Qt::MaximumSize:
281 sh = QSizeF (pixmap ().width (), pixmap ().height ());
295 highlight_ = _highlight;
297 if (opacity () != 1.0)
298 setOpacity ((highlight_)? 0.5 : 0.2);
void reset()
Stop the timer.
virtual void setGeometry(const QRectF &_rect)
Sets the geometry.
QRectF elementsBoundingRect()
Bounding rectangle of all scene elements.
void activate()
Activates the timer for movement (will be called if an element is moved above)
Arrow(GraphicsScene *_scene, QGraphicsItem *_parent, Direction _dir)
Constructor.
void setHighlight(bool _highlight)
Highlights the widget if the scene can be moved in this direction.
void moveElements(qreal _dx, qreal _dy, bool _selected=false)
Moves all elements.
Direction
Movement direction.