Don't trust event->timestamp()

It seems the timestampt of QMouseEvents are not reliable on Linux. So we
better use currentDateTime to detect a double click.

Fixes #1103

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2016-12-13 09:30:52 +01:00 committed by Dirk Hohndel
parent c8c4f8f0b9
commit 41d7942f63

View file

@ -31,12 +31,13 @@ void DivePictureWidget::doubleClicked(const QModelIndex &index)
void DivePictureWidget::mousePressEvent(QMouseEvent *event)
{
ulong doubleClickInterval = static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval());
static ulong lasttime = 0L;
static qint64 lasttime = 0L;
qint64 timestamp = QDateTime::currentDateTime().toMSecsSinceEpoch();
if (event->timestamp() - lasttime <= doubleClickInterval) {
if (timestamp - lasttime <= doubleClickInterval) {
doubleClicked(indexAt(event->pos()));
} else {
lasttime = event->timestamp();
lasttime = timestamp;
QPixmap pixmap = model()->data(indexAt(event->pos()), Qt::DecorationRole).value<QPixmap>();
QString filename = model()->data(indexAt(event->pos()), Qt::DisplayPropertyRole).toString();