mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
c8c4f8f0b9
commit
41d7942f63
1 changed files with 4 additions and 3 deletions
|
@ -31,12 +31,13 @@ void DivePictureWidget::doubleClicked(const QModelIndex &index)
|
||||||
void DivePictureWidget::mousePressEvent(QMouseEvent *event)
|
void DivePictureWidget::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
ulong doubleClickInterval = static_cast<ulong>(qApp->styleHints()->mouseDoubleClickInterval());
|
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()));
|
doubleClicked(indexAt(event->pos()));
|
||||||
} else {
|
} else {
|
||||||
lasttime = event->timestamp();
|
lasttime = timestamp;
|
||||||
QPixmap pixmap = model()->data(indexAt(event->pos()), Qt::DecorationRole).value<QPixmap>();
|
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();
|
||||||
|
|
Loading…
Add table
Reference in a new issue