1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-24 04:36:34 +01:00

ComboTabBar: Block moving tabs outside of tabbar

This commit is contained in:
David Rosca 2018-01-08 15:39:53 +01:00
parent 26a2b55c24
commit 68ed91c909

View File

@ -1403,6 +1403,28 @@ void TabBarHelper::mouseMoveEvent(QMouseEvent *event)
}
}
}
// Don't allow to move tabs outside of tabbar
if (m_dragInProgress && m_movingTab) {
QRect r = tabRect(m_pressedIndex);
r.moveLeft(r.x() + (event->pos().x() - m_dragStartPosition.x()));
bool sendEvent = false;
int diff = r.topRight().x() - tabRect(count() - 1).topRight().x();
if (diff > 0) {
sendEvent = true;
} else {
diff = r.topLeft().x() - tabRect(0).topLeft().x();
if (diff < 0) {
sendEvent = true;
}
}
if (sendEvent) {
QPoint pos = event->pos();
pos.setX(pos.x() - diff);
QMouseEvent ev(event->type(), pos, event->button(), event->buttons(), event->modifiers());
QTabBar::mouseMoveEvent(&ev);
}
}
}
void TabBarHelper::mouseReleaseEvent(QMouseEvent* event)