Skip to content

Commit

Permalink
open cover art view on left click release
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Sep 23, 2019
1 parent a7ae01d commit 5cb7a1e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/widget/wcoverart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions src/widget/wcoverart.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <QDomNode>
#include <QMouseEvent>
#include <QWidget>
#include <QTimer>

#include "mixer/basetrackplayer.h"
#include "preferences/usersettings.h"
Expand Down Expand Up @@ -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;
Expand All @@ -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

0 comments on commit 5cb7a1e

Please sign in to comment.