Hi Willem,

thanks for all your comments. As a first instalment...

On 29 Nov 2015, at 10:13, Willem Ferguson <[email protected]> wrote:

1) The ability to open an image from the photos tab has been removed: a simple double-click does not open an image any more. This may have disappeared because of other patches, not the drag&drop patch. But it was still active in V4.5.2. I would suggest that, in order to separate the two actions (open image; drag&drop image) they should be separated so as to make the drag&drop a little more difficult to do by accident. Would it make sense to initiate the drag&drop with a shift-click instead of just a click? And, of course to open the image with the usual double-click.

… here is a patch that reenables double clicks.

Best
Robert

From 2c368f47a3bbfae34feb31e3932006fbff22a1bb Mon Sep 17 00:00:00 2001
From: "Robert C. Helling" <[email protected]>
Date: Sun, 29 Nov 2015 16:13:57 +0100
Subject: [PATCH] Make pictures respond to double clicks again

The Drag & Drop functionality swallowd the click events so double
clicks never happend. So here, we detect this and call the handler
explicitly.

Signed-off-by: Robert C. Helling <[email protected]>
---
 desktop-widgets/divepicturewidget.cpp | 31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/desktop-widgets/divepicturewidget.cpp 
b/desktop-widgets/divepicturewidget.cpp
index c612ab6..d743867 100644
--- a/desktop-widgets/divepicturewidget.cpp
+++ b/desktop-widgets/divepicturewidget.cpp
@@ -30,22 +30,29 @@ void DivePictureWidget::doubleClicked(const QModelIndex 
&index)
 
 void DivePictureWidget::mousePressEvent(QMouseEvent *event)
 {
+    ulong doubleClickInterval = 
static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval());
+    static ulong lasttime = 0L;
 
-       QPixmap pixmap = model()->data(indexAt(event->pos()), 
Qt::DecorationRole).value<QPixmap>();
+    if (event->timestamp() - lasttime <= doubleClickInterval) {
+        doubleClicked(indexAt(event->pos()));
+    } else {
+        lasttime = event->timestamp();
+        QPixmap pixmap = model()->data(indexAt(event->pos()), 
Qt::DecorationRole).value<QPixmap>();
 
-       QString filename = model()->data(indexAt(event->pos()), 
Qt::DisplayPropertyRole).toString();
+        QString filename = model()->data(indexAt(event->pos()), 
Qt::DisplayPropertyRole).toString();
 
-       QByteArray itemData;
-       QDataStream dataStream(&itemData, QIODevice::WriteOnly);
-       dataStream << filename << event->pos();
+        QByteArray itemData;
+        QDataStream dataStream(&itemData, QIODevice::WriteOnly);
+        dataStream << filename << event->pos();
 
-       QMimeData *mimeData = new QMimeData;
-       mimeData->setData("application/x-subsurfaceimagedrop", itemData);
+        QMimeData *mimeData = new QMimeData;
+        mimeData->setData("application/x-subsurfaceimagedrop", itemData);
 
-       QDrag *drag = new QDrag(this);
-       drag->setMimeData(mimeData);
-       drag->setPixmap(pixmap);
-       drag->setHotSpot(event->pos() - 
rectForIndex(indexAt(event->pos())).topLeft());
+        QDrag *drag = new QDrag(this);
+        drag->setMimeData(mimeData);
+        drag->setPixmap(pixmap);
+        drag->setHotSpot(event->pos() - 
rectForIndex(indexAt(event->pos())).topLeft());
 
-       drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
+        drag->exec(Qt::CopyAction | Qt::MoveAction, Qt::CopyAction);
+    }
 }
-- 
1.9.5 (Apple Git-50.3)

Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

_______________________________________________
subsurface mailing list
[email protected]
http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface

Reply via email to