Skip to content

Commit

Permalink
DEBUG WTrackProperty hover unintended drag
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Apr 1, 2024
1 parent 9f68007 commit bef525b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions res/skins/LateNight/style_palemoon.qss
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,11 @@ WSearchLineEdit {
border-color: #0c0c0c;
}

/* :hover causes unintended drag on hover (without click) */
WTrackProperty:hover,
/*WTrackProperty:hover[selected="false"],
WTrackProperty:hover[selected="true"],*/
/*WTrackProperty[selected="true"],*/
#BpmTapContainer:hover,
#PlayPositionText:hover, #PlayPositionTextSmall:hover {
background-color: #151517;
Expand Down
12 changes: 11 additions & 1 deletion src/util/dnd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,17 @@ bool mouseMoveInitiatesDragHelper(QMouseEvent* pEvent, bool isPress) {
const qreal x = pEvent->x();
const qreal y = pEvent->y();
#endif

static qreal pressX{};
static qreal pressY{};

qWarning() << " dndInitDragHelper: press?" << isPress;
qWarning() << " ev coord :" << x << y;
qWarning() << " press coord:" << pressX << pressY;
qWarning() << " threshold:" << static_cast<qreal>(QApplication::startDragDistance());
;

if (isPress) {
qWarning() << " >> store x + y";
pressX = x;
pressY = y;
return false;
Expand All @@ -128,6 +134,9 @@ bool mouseMoveInitiatesDragHelper(QMouseEvent* pEvent, bool isPress) {
// distance = sqrt(dx^2 + dy^2)
// We can avoid the sqrt by squaring the threshold.

qWarning() << " drag:"
<< QString(dx * dx + dy * dy >= threshold * threshold ? "yes"
: "no");
return dx * dx + dy * dy >= threshold * threshold;
}

Expand Down Expand Up @@ -210,6 +219,7 @@ bool DragAndDropHelper::allowDeckCloneAttempt(
// static
void DragAndDropHelper::mousePressed(QMouseEvent* pEvent) {
if (pEvent->button() == Qt::LeftButton) {
qWarning() << " dnd mousePressed";
mouseMoveInitiatesDragHelper(pEvent, true);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/widget/wtrackproperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ void WTrackProperty::updateLabel() {
}

void WTrackProperty::mousePressEvent(QMouseEvent* pEvent) {
qWarning() << " WTrackP mousePress";
DragAndDropHelper::mousePressed(pEvent);
}

void WTrackProperty::mouseMoveEvent(QMouseEvent* pEvent) {
if (m_pCurrentTrack && DragAndDropHelper::mouseMoveInitiatesDrag(pEvent)) {
qWarning() << " WTrackP mouseMove";
DragAndDropHelper::dragTrack(m_pCurrentTrack, this, m_group);
}
}
Expand Down

0 comments on commit bef525b

Please sign in to comment.