52 #include <QGraphicsItem> 53 #include <QGraphicsSceneMouseEvent> 57 #include "zoomButton.hh" 58 #include "graphicsScene.hh" 71 QGraphicsPixmapItem (_parent),
80 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
83 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-out.png");
89 setAcceptHoverEvents (
true);
91 connect (&timer_, SIGNAL (timeout ()),
this, SLOT (timeout ()));
104 void ZoomButton::hoverEnterEvent (QGraphicsSceneHoverEvent * )
112 void ZoomButton::hoverLeaveEvent (QGraphicsSceneHoverEvent * )
120 void ZoomButton::mousePressEvent (QGraphicsSceneMouseEvent *_event)
134 QRectF rect = scene_->sceneRect ();
135 pos_ = QPointF (rect.x () + (rect.width () / 2.0), rect.y () + (rect.height () / 2.0));
144 void ZoomButton::mouseReleaseEvent (QGraphicsSceneMouseEvent *_event)
153 void ZoomButton::wheelEvent (QGraphicsSceneWheelEvent *_event)
159 if (_event->delta () > 0)
170 void ZoomButton::timeout ()
190 if (!timer_.isActive ())
208 QGraphicsPixmapItem::setPos (_rect.topLeft ());
209 QGraphicsLayoutItem::setGeometry (_rect);
215 QSizeF ZoomButton::sizeHint (Qt::SizeHint _which,
const QSizeF &)
const 219 case Qt::MinimumSize:
220 case Qt::PreferredSize:
221 case Qt::MaximumSize:
222 sh = QSizeF (pixmap ().width (), pixmap ().height ());
virtual void setGeometry(const QRectF &_rect)
Sets the geometry.
void scaleElements(qreal _delta)
Scale all elements with scaling center in the center of the scene.
void deactivate()
Stop the timer.
ZoomButton(GraphicsScene *_scene, QGraphicsItem *_parent, Type _type)
Constructor.
void activate(QPointF _pos)
Activates the timer for zoom with center at _pos (will be called if an element is moved above) ...