diff options
author | Tomaz Canabrava <tomaz.canabrava@intel.com> | 2014-06-08 12:43:04 -0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-06-08 12:42:51 -0700 |
commit | e14a15e61c6fa5529f33de410bfc6e0ad351a7af (patch) | |
tree | 168daf4927e48f4b51dbfd6a0e8136518e99a9c6 /qt-ui/profile | |
parent | 38ac6ed35fc4e3a99cbf1ea1ae271ddea7a06661 (diff) | |
download | subsurface-e14a15e61c6fa5529f33de410bfc6e0ad351a7af.tar.gz |
Subtle animation when the picture gets hovered with the mouse.
This patch adds a subtle animation when the picture gets hovered
with the mouse, and restored to it's original size when mouse exits
the image area.
Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/profile')
-rw-r--r-- | qt-ui/profile/divepixmapitem.cpp | 24 | ||||
-rw-r--r-- | qt-ui/profile/divepixmapitem.h | 11 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.cpp | 2 | ||||
-rw-r--r-- | qt-ui/profile/profilewidget2.h | 3 |
4 files changed, 37 insertions, 3 deletions
diff --git a/qt-ui/profile/divepixmapitem.cpp b/qt-ui/profile/divepixmapitem.cpp index d27d77cba..b1942344e 100644 --- a/qt-ui/profile/divepixmapitem.cpp +++ b/qt-ui/profile/divepixmapitem.cpp @@ -1,5 +1,27 @@ #include "divepixmapitem.h" - +#include "animationfunctions.h" DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem() { } + +DivePictureItem::DivePictureItem(QObject *parent): DivePixmapItem(parent) +{ + setAcceptsHoverEvents(true); + setScale(0.2); +} + +void DivePictureItem::setPixmap(const QPixmap &pix) +{ + DivePixmapItem::setPixmap(pix); + setTransformOriginPoint(boundingRect().width()/2, boundingRect().height()/2); +} + +void DivePictureItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) +{ + Animations::scaleTo(this, 1.0); +} + +void DivePictureItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) +{ + Animations::scaleTo(this, 0.2); +} diff --git a/qt-ui/profile/divepixmapitem.h b/qt-ui/profile/divepixmapitem.h index aa2563877..a0f542ea0 100644 --- a/qt-ui/profile/divepixmapitem.h +++ b/qt-ui/profile/divepixmapitem.h @@ -14,4 +14,15 @@ public: DivePixmapItem(QObject *parent = 0); }; +class DivePictureItem : public DivePixmapItem { + Q_OBJECT + Q_PROPERTY(qreal scale WRITE setScale READ scale) +public: + DivePictureItem(QObject *parent = 0); + void setPixmap(const QPixmap& pix); +protected: + void hoverEnterEvent(QGraphicsSceneHoverEvent *event); + void hoverLeaveEvent(QGraphicsSceneHoverEvent *event); +}; + #endif // DIVEPIXMAPITEM_H diff --git a/qt-ui/profile/profilewidget2.cpp b/qt-ui/profile/profilewidget2.cpp index 92c368cb8..b2021fd8c 100644 --- a/qt-ui/profile/profilewidget2.cpp +++ b/qt-ui/profile/profilewidget2.cpp @@ -1309,7 +1309,7 @@ void ProfileWidget2::plotPictures() // information area. if (!pic->timestamp) continue; - DivePixmapItem *item = new DivePixmapItem(); + DivePictureItem *item = new DivePictureItem(); item->setPixmap(m->index(i,0).data(Qt::DecorationRole).value<QPixmap>()); // TODO: put the item in the correct place. use the pic.timestamp to find where it belongs on the dive. item->setPos(10 ,10); diff --git a/qt-ui/profile/profilewidget2.h b/qt-ui/profile/profilewidget2.h index a1ba7a23a..7d55fe5d0 100644 --- a/qt-ui/profile/profilewidget2.h +++ b/qt-ui/profile/profilewidget2.h @@ -43,6 +43,7 @@ class AbstractProfilePolygonItem; class DiveHandler; class QGraphicsSimpleTextItem; class QModelIndex; +class DivePictureItem; class ProfileWidget2 : public QGraphicsView { Q_OBJECT @@ -160,7 +161,7 @@ private: //specifics for ADD and PLAN QList<DiveHandler *> handles; QList<QGraphicsSimpleTextItem *> gases; - QList<DivePixmapItem*> pictures; + QList<DivePictureItem*> pictures; void repositionDiveHandlers(); int fixHandlerIndex(DiveHandler *activeHandler); friend class DiveHandler; |