this should fix the mouseGrabber issue.

On Wed, Jul 30, 2014 at 4:55 PM, Dirk Hohndel <d...@hohndel.org> wrote:

> On Wed, Jul 30, 2014 at 04:21:18PM -0300, Tomaz Canabrava wrote:
> > This is a missing functionality on the 4.2 that I'v talked to dirk and we
> > decided that it was better to implement it now before waiting for 4.3
> > because things can get messy if a user adds the wrong pictures on the
> dive.
>
> I decided to take it now. I realize this is way late. I very carefully
> reviewed them and made some small changes. But this is really rather
> important functionality, fixes a bug and shouldn't have any side effects
> (famous last words).
>
> It would be nice if the manual could be updated, but I find the UI so
> brilliantly intuitive, that I think worst case we can do without it
> explicitly mentioned. Up to Willem :-)
>
> /D
>
From 9a1a32f2edc6415dc55823dbf47bba2cacf286db Mon Sep 17 00:00:00 2001
From: Tomaz Canabrava <tomaz.canabr...@intel.com>
Date: Wed, 30 Jul 2014 17:20:38 -0300
Subject: [PATCH] Add a new 'show' Animation, and use it on the close button.

The error with 'ungrabMouse' warning that we got was because
we were removing an item that had the mouse grab instead of
waiting a few milisseconds so it won't be the mouse grabber
anymore.

So I'v used the Animations::hide() to get rid of it, and
since it worked well, I'v also added a Animations::show()
method to display it in a good fade-in way.

Signed-off-by: Tomaz Canabrava <tomaz.canabr...@intel.com>
---
 qt-ui/profile/animationfunctions.cpp | 12 ++++++++++++
 qt-ui/profile/animationfunctions.h   |  1 +
 qt-ui/profile/divepixmapitem.cpp     |  4 +++-
 3 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/qt-ui/profile/animationfunctions.cpp b/qt-ui/profile/animationfunctions.cpp
index dc46d7f..fb1c85f 100644
--- a/qt-ui/profile/animationfunctions.cpp
+++ b/qt-ui/profile/animationfunctions.cpp
@@ -18,6 +18,18 @@ namespace Animations {
 		}
 	}
 
+	void show(QObject *obj)
+	{
+		if (prefs.animation_speed != 0) {
+			QPropertyAnimation *animation = new QPropertyAnimation(obj, "opacity");
+			animation->setStartValue(0);
+			animation->setEndValue(1);
+			animation->start(QAbstractAnimation::DeleteWhenStopped);
+		} else {
+			obj->setProperty("opacity", 1);
+		}
+	}
+
 	void animDelete(QObject *obj)
 	{
 		if (prefs.animation_speed != 0) {
diff --git a/qt-ui/profile/animationfunctions.h b/qt-ui/profile/animationfunctions.h
index d8e44be..3cfcff5 100644
--- a/qt-ui/profile/animationfunctions.h
+++ b/qt-ui/profile/animationfunctions.h
@@ -8,6 +8,7 @@ class QObject;
 
 namespace Animations {
 	void hide(QObject *obj);
+	void show(QObject *obj);
 	void moveTo(QObject *obj, qreal x, qreal y);
 	void moveTo(QObject *obj, const QPointF &pos);
 	void animDelete(QObject *obj);
diff --git a/qt-ui/profile/divepixmapitem.cpp b/qt-ui/profile/divepixmapitem.cpp
index 41541c2..853b950 100644
--- a/qt-ui/profile/divepixmapitem.cpp
+++ b/qt-ui/profile/divepixmapitem.cpp
@@ -94,7 +94,9 @@ void DivePictureItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
 		scene()->addItem(button);
 	}
 	button->setPos(mapToScene(0,0));
+	button->setOpacity(0);
 	button->show();
+	Animations::show(button);
 	button->disconnect();
 	connect(button, SIGNAL(clicked()), this, SLOT(removePicture()));
 }
@@ -119,7 +121,7 @@ void DivePictureItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
 
 void DivePictureItem::removePicture()
 {
-	button->hide();
+	Animations::hide(button);
 	hide();
 	DivePictureModel::instance()->removePicture(fileUrl);
 }
-- 
2.0.3

_______________________________________________
subsurface mailing list
subsurface@hohndel.org
http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to