Fixed issue #641 - Unexpected behaviour with tab drag on scrollable tab bar

This commit is contained in:
Uwe Kindler 2024-07-08 10:43:02 +02:00
parent 06e8451fc0
commit 1c41cbff82

View File

@ -390,15 +390,18 @@ void CDockAreaTabBar::onTabWidgetMoved(const QPoint& GlobalPos)
int fromIndex = d->TabsLayout->indexOf(MovingTab); int fromIndex = d->TabsLayout->indexOf(MovingTab);
auto MousePos = mapFromGlobal(GlobalPos); auto MousePos = mapFromGlobal(GlobalPos);
MousePos.rx() = qMax(d->firstTab()->geometry().left(), MousePos.x()); MousePos.rx() = qMax(0, MousePos.x());
MousePos.rx() = qMin(d->lastTab()->geometry().right(), MousePos.x()); MousePos.rx() = qMin(width(), MousePos.x());
int toIndex = -1; int toIndex = -1;
// Find tab under mouse // Find tab under mouse
for (int i = 0; i < count(); ++i) for (int i = 0; i < count(); ++i)
{ {
CDockWidgetTab* DropTab = tab(i); CDockWidgetTab* DropTab = tab(i);
auto TabGeometry = DropTab->geometry();
TabGeometry.setTopLeft(d->TabsContainerWidget->mapToParent(TabGeometry.topLeft()));
TabGeometry.setBottomRight(d->TabsContainerWidget->mapToParent(TabGeometry.bottomRight()));
if (DropTab == MovingTab || !DropTab->isVisibleTo(this) if (DropTab == MovingTab || !DropTab->isVisibleTo(this)
|| !DropTab->geometry().contains(MousePos)) || !TabGeometry.contains(MousePos))
{ {
continue; continue;
} }