From 5cb7a1e919c76e98ac21e5bb50fb0394b0cbd613 Mon Sep 17 00:00:00 2001 From: ronso0 Date: Mon, 23 Sep 2019 03:08:03 +0200 Subject: [PATCH] open cover art view on left click release --- src/widget/wcoverart.cpp | 18 ++++++++++++++++-- src/widget/wcoverart.h | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/widget/wcoverart.cpp b/src/widget/wcoverart.cpp index dfdab514733..4d64463b671 100644 --- a/src/widget/wcoverart.cpp +++ b/src/widget/wcoverart.cpp @@ -231,13 +231,27 @@ void WCoverArt::mousePressEvent(QMouseEvent* event) { if (event->button() == Qt::RightButton && m_loadedTrack) { // show context-menu m_pMenu->setCoverArt(m_lastRequestedCover); m_pMenu->popup(event->globalPos()); - } else if (event->button() == Qt::LeftButton) { // init/close fullsize cover + } else if (event->button() == Qt::LeftButton) { + // do nothing if left button is pressed, + // wait for button release + m_clickTimer.setSingleShot(true); + m_clickTimer.start(500); + } +} + +void WCoverArt::mouseReleaseEvent(QMouseEvent* event) { + if (!m_bEnable) { + return; + } + + if (event->button() == Qt::LeftButton && m_loadedTrack && + m_clickTimer.isActive()) { // init/close fullsize cover if (m_pDlgFullSize->isVisible()) { m_pDlgFullSize->close(); } else { m_pDlgFullSize->init(m_loadedTrack); } - } + } // else it was a long leftclick or a right click that's already been processed } void WCoverArt::mouseMoveEvent(QMouseEvent* event) { diff --git a/src/widget/wcoverart.h b/src/widget/wcoverart.h index 1c71a365da5..c89255cd566 100644 --- a/src/widget/wcoverart.h +++ b/src/widget/wcoverart.h @@ -5,6 +5,7 @@ #include #include #include +#include #include "mixer/basetrackplayer.h" #include "preferences/usersettings.h" @@ -47,6 +48,7 @@ class WCoverArt : public QWidget, public WBaseWidget, public TrackDropTarget { void paintEvent(QPaintEvent* /*unused*/) override; void resizeEvent(QResizeEvent* /*unused*/) override; void mousePressEvent(QMouseEvent* /*unused*/) override; + void mouseReleaseEvent(QMouseEvent* /*unused*/) override; void dragEnterEvent(QDragEnterEvent *event) override; void dropEvent(QDropEvent *event) override; @@ -67,6 +69,7 @@ class WCoverArt : public QWidget, public WBaseWidget, public TrackDropTarget { CoverInfo m_lastRequestedCover; BaseTrackPlayer* m_pPlayer; DlgCoverArtFullSize* m_pDlgFullSize; + QTimer m_clickTimer; }; #endif // WCOVERART_H