From 98f3f51ba918f3e6350b834a32e5c8a1d721b7e5 Mon Sep 17 00:00:00 2001 From: WarmUpTill Date: Sat, 30 Dec 2023 17:39:02 +0100 Subject: [PATCH] Don't enable drag of macro segment when interacting with scrollbars --- src/macro-core/macro-segment-list.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/macro-core/macro-segment-list.cpp b/src/macro-core/macro-segment-list.cpp index 27d13ff6..090974f2 100644 --- a/src/macro-core/macro-segment-list.cpp +++ b/src/macro-core/macro-segment-list.cpp @@ -44,8 +44,28 @@ MacroSegmentList::~MacroSegmentList() } } +static bool posIsInScrollbar(const QScrollBar *scrollbar, const QPoint &pos) +{ + if (!scrollbar) { + return false; + } + if (!scrollbar->isVisible()) { + return false; + } + const auto geo = scrollbar->geometry(); + const auto globalGeo = QRect(scrollbar->mapToGlobal(geo.topLeft()), + scrollbar->mapToGlobal(geo.bottomRight())); + return globalGeo.contains(pos); +} + int MacroSegmentList::GetDragIndex(const QPoint &pos) { + // Don't drag widget when interacting with the scrollbars + if (posIsInScrollbar(horizontalScrollBar(), mapTo(this, pos)) || + posIsInScrollbar(verticalScrollBar(), mapTo(this, pos))) { + return -1; + } + for (int idx = 0; idx < _contentLayout->count(); ++idx) { auto item = _contentLayout->itemAt(idx); if (!item) {