46 #include <QGraphicsItem> 47 #include <QGraphicsSceneMouseEvent> 51 #include "zoomButton.hh" 52 #include "graphicsScene.hh" 65 QGraphicsPixmapItem (_parent),
74 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-in.png");
77 setPixmap (OpenFlipper::Options::iconDirStr()+OpenFlipper::Options::dirSeparator()+
"zoom-out.png");
83 setAcceptHoverEvents (
true);
85 connect (&timer_, SIGNAL (timeout ()),
this, SLOT (timeout ()));
98 void ZoomButton::hoverEnterEvent (QGraphicsSceneHoverEvent * )
106 void ZoomButton::hoverLeaveEvent (QGraphicsSceneHoverEvent * )
114 void ZoomButton::mousePressEvent (QGraphicsSceneMouseEvent *_event)
128 QRectF rect = scene_->sceneRect ();
129 pos_ = QPointF (rect.x () + (rect.width () / 2.0), rect.y () + (rect.height () / 2.0));
138 void ZoomButton::mouseReleaseEvent (QGraphicsSceneMouseEvent *_event)
147 void ZoomButton::wheelEvent (QGraphicsSceneWheelEvent *_event)
153 if (_event->delta () > 0)
164 void ZoomButton::timeout ()
184 if (!timer_.isActive ())
202 QGraphicsPixmapItem::setPos (_rect.topLeft ());
203 QGraphicsLayoutItem::setGeometry (_rect);
209 QSizeF ZoomButton::sizeHint (Qt::SizeHint _which,
const QSizeF &)
const 213 case Qt::MinimumSize:
214 case Qt::PreferredSize:
215 case Qt::MaximumSize:
216 sh = QSizeF (pixmap ().width (), pixmap ().height ());
void activate(QPointF _pos)
Activates the timer for zoom with center at _pos (will be called if an element is moved above) ...
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.
ZoomButton(GraphicsScene *_scene, QGraphicsItem *_parent, Type _type)
Constructor.
void deactivate()
Stop the timer.