Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

open cover art view on left click release #2296

Merged
merged 1 commit into from
Sep 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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