diff options
author | Robert C. Helling <helling@atdotde.de> | 2015-11-29 16:13:57 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-11-29 13:08:26 -0800 |
commit | 82d97093575d077f2c3703ad3d58124dcc127e27 (patch) | |
tree | 198b0aa01205ff6d64d8e029ff4f3e4245d762aa /desktop-widgets/divepicturewidget.cpp | |
parent | 3413dc30e534e60638ff81ffd38ffa74041a0de4 (diff) | |
download | subsurface-82d97093575d077f2c3703ad3d58124dcc127e27.tar.gz |
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 <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets/divepicturewidget.cpp')
-rw-r--r-- | desktop-widgets/divepicturewidget.cpp | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/desktop-widgets/divepicturewidget.cpp b/desktop-widgets/divepicturewidget.cpp index c612ab6d4..d52fbb9d7 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); + } } |