<3
From acd028e7b517f4ddf354d96d8b323717438616a4 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Sun, 8 Jun 2014 12:05:36 -0300 Subject: [PATCH 1/6] Save the timestamp of the dive.
Save the timestamp of the dive if it exists on the data provided by the exif library. Signed-off-by: Tomaz Canabrava <[email protected]> --- save-xml.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/save-xml.c b/save-xml.c index 9f2c2b4..db25672 100644 --- a/save-xml.c +++ b/save-xml.c @@ -333,6 +333,8 @@ static void save_picture(struct membuffer *b, struct picture *pic) put_string(b, " <picture filename='"); put_string(b, pic->filename); put_string(b, "'"); + if(pic->timestamp) + put_format(b, " timestamp='%d'", pic->timestamp); if (pic->latitude.udeg || pic->longitude.udeg) { put_degrees(b, pic->latitude, " gps='", " "); put_degrees(b, pic->longitude, "", "'"); -- 2.0.0
From a3551ee4607f51cb2d94e05620fa56373e94355f Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Sun, 8 Jun 2014 12:22:45 -0300 Subject: [PATCH 2/6] Add a scaleTo animation ScaleTo animation will scale or shrinks an graphical element animatelly. This is going primarelly to be used on the pictures on the Profile, but can be used to anything else later. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/animationfunctions.cpp | 9 +++++++++ qt-ui/profile/animationfunctions.h | 1 + 2 files changed, 10 insertions(+) diff --git a/qt-ui/profile/animationfunctions.cpp b/qt-ui/profile/animationfunctions.cpp index bd08a22..d688d13 100644 --- a/qt-ui/profile/animationfunctions.cpp +++ b/qt-ui/profile/animationfunctions.cpp @@ -36,6 +36,15 @@ namespace Animations { } } + void scaleTo(QObject *obj, qreal scale){ + QPropertyAnimation *animation = new QPropertyAnimation(obj, "scale"); + animation->setDuration(prefs.animation); + animation->setStartValue(obj->property("scale").toReal()); + animation->setEndValue(QVariant::fromValue(scale)); + animation->setEasingCurve(QEasingCurve::InCubic); + animation->start(QAbstractAnimation::DeleteWhenStopped); + } + void moveTo(QObject *obj, const QPointF &pos) { moveTo(obj, pos.x(), pos.y()); diff --git a/qt-ui/profile/animationfunctions.h b/qt-ui/profile/animationfunctions.h index 9269e6d..d8e44be 100644 --- a/qt-ui/profile/animationfunctions.h +++ b/qt-ui/profile/animationfunctions.h @@ -11,6 +11,7 @@ namespace Animations { void moveTo(QObject *obj, qreal x, qreal y); void moveTo(QObject *obj, const QPointF &pos); void animDelete(QObject *obj); + void scaleTo(QObject *obj, qreal scale); } #endif // ANIMATIONFUNCTIONS_H -- 2.0.0
From 643f220a56d654340f2aac1dc1d399d46c25ae06 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Sun, 8 Jun 2014 12:43:04 -0300 Subject: [PATCH 3/6] 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 <[email protected]> --- qt-ui/profile/divepixmapitem.cpp | 24 +++++++++++++++++++++++- qt-ui/profile/divepixmapitem.h | 11 +++++++++++ qt-ui/profile/profilewidget2.cpp | 2 +- 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 d27d77c..b194234 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 aa25638..a0f542e 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 92c368c..b2021fd 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 a1ba7a2..7d55fe5 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; -- 2.0.0
From 682f60de0b8cffd9ac190509d8236fc95a0596ca Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Sun, 8 Jun 2014 13:11:00 -0300 Subject: [PATCH 4/6] Add a nice white rectangle around the picture This makes the picture looks a bit more like a real paper picture shadow's missing, tougth. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/divepixmapitem.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/qt-ui/profile/divepixmapitem.cpp b/qt-ui/profile/divepixmapitem.cpp index b194234..215ce99 100644 --- a/qt-ui/profile/divepixmapitem.cpp +++ b/qt-ui/profile/divepixmapitem.cpp @@ -1,5 +1,9 @@ #include "divepixmapitem.h" #include "animationfunctions.h" + +#include <QPen> +#include <QBrush> + DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem() { } @@ -13,6 +17,11 @@ DivePictureItem::DivePictureItem(QObject *parent): DivePixmapItem(parent) void DivePictureItem::setPixmap(const QPixmap &pix) { DivePixmapItem::setPixmap(pix); + QRectF r = boundingRect(); + QGraphicsRectItem *rect = new QGraphicsRectItem(0 - 10, 0 -10, r.width() + 20, r.height() + 20, this); + rect->setPen(Qt::NoPen); + rect->setBrush(QColor(Qt::white)); + rect->setFlag(ItemStacksBehindParent); setTransformOriginPoint(boundingRect().width()/2, boundingRect().height()/2); } -- 2.0.0
From d9891d4c4ee5393601a5d36e1ae7807a6000c42d Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Sun, 8 Jun 2014 13:39:32 -0300 Subject: [PATCH 5/6] Add a drop shadow on the picture This patch adds a drop shadow on the picture. a real blurry shadow could be much better, but without OpenGL it's too costly to calculate the shadow for each picture. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/divepixmapitem.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qt-ui/profile/divepixmapitem.cpp b/qt-ui/profile/divepixmapitem.cpp index 215ce99..4405195 100644 --- a/qt-ui/profile/divepixmapitem.cpp +++ b/qt-ui/profile/divepixmapitem.cpp @@ -3,6 +3,7 @@ #include <QPen> #include <QBrush> +#include <QGraphicsDropShadowEffect> DivePixmapItem::DivePixmapItem(QObject *parent) : QObject(parent), QGraphicsPixmapItem() { @@ -22,6 +23,15 @@ void DivePictureItem::setPixmap(const QPixmap &pix) rect->setPen(Qt::NoPen); rect->setBrush(QColor(Qt::white)); rect->setFlag(ItemStacksBehindParent); + rect->setZValue(-1); + + QGraphicsRectItem *shadow = new QGraphicsRectItem(rect->boundingRect(), this); + shadow->setPos(5,5); + shadow->setPen(Qt::NoPen); + shadow->setBrush(QColor(Qt::lightGray)); + shadow->setFlag(ItemStacksBehindParent); + shadow->setZValue(-2); + setTransformOriginPoint(boundingRect().width()/2, boundingRect().height()/2); } -- 2.0.0
From 3a2a3e480f2afe8e99e18b88aaf1246b074360b8 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava <[email protected]> Date: Sun, 8 Jun 2014 13:40:19 -0300 Subject: [PATCH 6/6] Rotate the picture around -4 and 4 degrees. This patch rotates the picture a bit, so it looks like it was splattered around the profile. Signed-off-by: Tomaz Canabrava <[email protected]> --- qt-ui/profile/divepixmapitem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qt-ui/profile/divepixmapitem.cpp b/qt-ui/profile/divepixmapitem.cpp index 4405195..c0eeb84 100644 --- a/qt-ui/profile/divepixmapitem.cpp +++ b/qt-ui/profile/divepixmapitem.cpp @@ -33,6 +33,12 @@ void DivePictureItem::setPixmap(const QPixmap &pix) shadow->setZValue(-2); setTransformOriginPoint(boundingRect().width()/2, boundingRect().height()/2); + + qreal angle = qrand() % 5; + if (rand() % 2) + angle *= -1; + + setRotation(angle); } void DivePictureItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -- 2.0.0
_______________________________________________ subsurface mailing list [email protected] http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
