46 #include <QPainterPath> 47 #include <QGraphicsItem> 48 #include <QGraphicsSceneMouseEvent> 53 #include "graphicsScene.hh" 67 QGraphicsPixmapItem (_parent),
76 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-up.png");
79 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-down.png");
82 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-right.png");
85 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-left.png");
88 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"go-center.png");
92 setOpacity ((highlight_)? 0.5 : 0.2);
94 setAcceptHoverEvents (
true);
96 connect (&timer_, SIGNAL (timeout ()),
this, SLOT (timeout ()));
109 void Arrow::hoverEnterEvent (QGraphicsSceneHoverEvent * )
117 void Arrow::hoverLeaveEvent (QGraphicsSceneHoverEvent * )
119 setOpacity ((highlight_)? 0.5 : 0.2);
125 void Arrow::mousePressEvent (QGraphicsSceneMouseEvent *_event)
129 qreal dx = 0.0, dy = 0.0;
148 QRectF rect = scene_->sceneRect();
149 dx = qMax (qMin ((rect.center () - bb.center ()).x (), 5.0), -5.0);
150 dy = qMax (qMin ((rect.center () - bb.center ()).y (), 5.0), -5.0);
158 moveSelected_ =
true;
164 void Arrow::mouseReleaseEvent (QGraphicsSceneMouseEvent *_event)
173 void Arrow::wheelEvent (QGraphicsSceneWheelEvent *_event)
177 qreal dx = 0.0, dy = 0.0;
192 dx *= _event->delta () / 4;
193 dy *= _event->delta () / 4;
200 void Arrow::timeout ()
202 if (timer_.interval () == 500)
204 timer_.setInterval (interval_ );
208 qreal dx = 0.0, dy = 0.0;
227 QRectF rect = scene_->sceneRect();
228 dx = qMax (qMin ((rect.center () - bb.center ()).x (), 2.0), -2.0);
229 dy = qMax (qMin ((rect.center () - bb.center ()).y (), 2.0), -2.0);
242 moveSelected_ =
false;
243 if (!timer_.isActive ())
252 setOpacity ((highlight_)? 0.5 : 0.2);
261 QGraphicsPixmapItem::setPos (_rect.topLeft ());
262 QGraphicsLayoutItem::setGeometry (_rect);
268 QSizeF Arrow::sizeHint (Qt::SizeHint _which,
const QSizeF &)
const 272 case Qt::MinimumSize:
273 case Qt::PreferredSize:
274 case Qt::MaximumSize:
275 sh = QSizeF (pixmap ().width (), pixmap ().height ());
289 highlight_ = _highlight;
291 if (opacity () != 1.0)
292 setOpacity ((highlight_)? 0.5 : 0.2);
Arrow(GraphicsScene *_scene, QGraphicsItem *_parent, Direction _dir)
Constructor.
void activate()
Activates the timer for movement (will be called if an element is moved above)
Direction
Movement direction.
QRectF elementsBoundingRect()
Bounding rectangle of all scene elements.
void moveElements(qreal _dx, qreal _dy, bool _selected=false)
Moves all elements.
void setHighlight(bool _highlight)
Highlights the widget if the scene can be moved in this direction.
virtual void setGeometry(const QRectF &_rect)
Sets the geometry.
void reset()
Stop the timer.