Respect the drag threshold when reordering macro blocks

This commit is contained in:
nanopink
2026-10-25 00:40:59 -04:00
committed by WarmUpTill
parent 1171714aa9
commit a5c663230b
2 changed files with 8 additions and 0 deletions

View File

@@ -3,6 +3,7 @@
#include "ui-helpers.hpp"
#include <QEvent>
#include <QApplication>
#include <QDrag>
#include <QGridLayout>
#include <QMimeData>
@@ -277,6 +278,7 @@ void MacroSegmentList::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton ||
event->button() == Qt::RightButton) {
_dragStartPos = event->globalPosition().toPoint();
_dragPosition = GetDragIndex(event->globalPosition().toPoint());
emit SelectionChanged(_dragPosition);
} else {
@@ -287,6 +289,11 @@ void MacroSegmentList::mousePressEvent(QMouseEvent *event)
void MacroSegmentList::mouseMoveEvent(QMouseEvent *event)
{
if (event->buttons() & Qt::LeftButton && _dragPosition != -1) {
if ((event->globalPosition().toPoint() - _dragStartPos)
.manhattanLength() <
QApplication::startDragDistance()) {
return;
}
auto item = _contentLayout->itemAt(_dragPosition);
if (!item) {
return;

View File

@@ -80,6 +80,7 @@ private:
int _dragPosition = -1;
int _dropLineIdx = -1;
QPoint _dragCursorPos;
QPoint _dragStartPos;
std::thread _autoScrollThread;
std::atomic_bool _autoScroll{false};