mirror of
https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git
synced 2025-04-16 10:24:45 +08:00
Improved tab dragging, added support for undocking if mouse leaves tabbar during tb dragging
This commit is contained in:
parent
fd28f0f751
commit
8c12d912b4
@ -488,7 +488,7 @@ CMainWindow::CMainWindow(QWidget *parent) :
|
|||||||
|
|
||||||
// uncomment the following line if you want to use opaque undocking and
|
// uncomment the following line if you want to use opaque undocking and
|
||||||
// opaque splitter resizing
|
// opaque splitter resizing
|
||||||
// CDockManager::setConfigFlags(CDockManager::DefaultOpaqueConfig);
|
//CDockManager::setConfigFlags(CDockManager::DefaultOpaqueConfig);
|
||||||
|
|
||||||
// uncomment the following line if you want a fixed tab width that does
|
// uncomment the following line if you want a fixed tab width that does
|
||||||
// not change if the visibility of the close button changes
|
// not change if the visibility of the close button changes
|
||||||
|
@ -215,6 +215,8 @@ void DockWidgetTabPrivate::moveTab(QMouseEvent* ev)
|
|||||||
QPoint Distance = ev->globalPos() - GlobalDragStartMousePosition;
|
QPoint Distance = ev->globalPos() - GlobalDragStartMousePosition;
|
||||||
Distance.setY(0);
|
Distance.setY(0);
|
||||||
auto TargetPos = Distance + TabDragStartPosition;
|
auto TargetPos = Distance + TabDragStartPosition;
|
||||||
|
TargetPos.rx() = qMax(TargetPos.x(), 0);
|
||||||
|
TargetPos.rx() = qMin(_this->parentWidget()->rect().right() - _this->width() + 1, TargetPos.rx());
|
||||||
_this->move(TargetPos);
|
_this->move(TargetPos);
|
||||||
_this->raise();
|
_this->raise();
|
||||||
}
|
}
|
||||||
@ -357,19 +359,18 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// move tab
|
// move tab
|
||||||
bool TabOutsideBar = false;
|
|
||||||
if (d->isDraggingState(DraggingTab))
|
if (d->isDraggingState(DraggingTab))
|
||||||
{
|
{
|
||||||
// Moving the tab is always allowed because it does not mean moving the
|
// Moving the tab is always allowed because it does not mean moving the
|
||||||
// dock widget around
|
// dock widget around
|
||||||
d->moveTab(ev);
|
d->moveTab(ev);
|
||||||
TabOutsideBar = (geometry().right() < 0) || (geometry().left() > parentWidget()->rect().right());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto MappedPos = mapToParent(ev->pos());
|
||||||
|
bool MouseOutsideBar = (MappedPos.x() < 0) || (MappedPos.x() > parentWidget()->rect().right());
|
||||||
// Maybe a fixed drag distance is better here ?
|
// Maybe a fixed drag distance is better here ?
|
||||||
int DragDistanceY = qAbs(d->GlobalDragStartMousePosition.y() - ev->globalPos().y());
|
int DragDistanceY = qAbs(d->GlobalDragStartMousePosition.y() - ev->globalPos().y());
|
||||||
if (DragDistanceY >= CDockManager::startDragDistance() || TabOutsideBar)
|
if (DragDistanceY >= CDockManager::startDragDistance() || MouseOutsideBar)
|
||||||
{
|
{
|
||||||
// If this is the last dock area in a dock container with only
|
// If this is the last dock area in a dock container with only
|
||||||
// one single dock widget it does not make sense to move it to a new
|
// one single dock widget it does not make sense to move it to a new
|
||||||
|
Loading…
Reference in New Issue
Block a user