Skip to content

Commit

Permalink
Merge pull request #13035 from ronso0/dnd-hover-fix
Browse files Browse the repository at this point in the history
(fix) Drag'n'drop: avoid unintended drag on hover (WTrackProperty, WCoverArt etc.)
  • Loading branch information
m0dB authored Apr 5, 2024
2 parents cbd280f + 14b774f commit 3546e22
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/util/dnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ bool allowLoadToPlayer(

// Helper function for DragAndDropHelper::mousePressed and DragAndDropHelper::mouseMoveInitiatesDrag
bool mouseMoveInitiatesDragHelper(QMouseEvent* pEvent, bool isPress) {
if (pEvent->buttons() != Qt::LeftButton) {
return false;
}
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
const qreal x = pEvent->position().x();
const qreal y = pEvent->position().y();
Expand Down Expand Up @@ -209,9 +212,7 @@ bool DragAndDropHelper::allowDeckCloneAttempt(

// static
void DragAndDropHelper::mousePressed(QMouseEvent* pEvent) {
if (pEvent->button() == Qt::LeftButton) {
mouseMoveInitiatesDragHelper(pEvent, true);
}
mouseMoveInitiatesDragHelper(pEvent, true);
}

// static
Expand Down
4 changes: 2 additions & 2 deletions src/widget/wcoverart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ void WCoverArt::mousePressEvent(QMouseEvent* pEvent) {

DragAndDropHelper::mousePressed(pEvent);

if (pEvent->button() == Qt::LeftButton) {
if (pEvent->buttons() == Qt::LeftButton) {
pEvent->accept();
// do nothing if left button is pressed,
// wait for button release
Expand All @@ -259,7 +259,7 @@ void WCoverArt::mouseReleaseEvent(QMouseEvent* pEvent) {
return;
}

if (pEvent->button() == Qt::LeftButton && m_loadedTrack &&
if (pEvent->buttons() == Qt::LeftButton && m_loadedTrack &&
m_clickTimer.isActive()) { // init/close fullsize cover
if (m_pDlgFullSize->isVisible()) {
m_pDlgFullSize->close();
Expand Down

0 comments on commit 3546e22

Please sign in to comment.