Skip to content

Commit 74b9d35

Browse files
author
Uwe Kindler
committed
Fixed start drag distance to be based on QApplication::startDragDistance, fixed dragging of dock widget title bar to support dragging in x and y direction
1 parent c973482 commit 74b9d35

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

src/DockAreaTabBar.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <QDebug>
1616
#include <QBoxLayout>
1717
#include <QMenu>
18+
#include <QApplication>
1819

1920
#include "FloatingDockContainer.h"
2021
#include "DockAreaWidget.h"
@@ -185,9 +186,10 @@ void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
185186
return;
186187
}
187188

188-
int DragDistanceY = qAbs(d->DragStartMousePos.y() - ev->pos().y());
189-
int MinDragDistanceY = this->height() / 2;
190-
if (DragDistanceY >= MinDragDistanceY)
189+
/*int DragDistanceY = qAbs(d->DragStartMousePos.y() - ev->pos().y());
190+
int MinDragDistanceY = this->height() / 2;*/
191+
int DragDistance = (d->DragStartMousePos - ev->pos()).manhattanLength();
192+
if (DragDistance >= CDockManager::startDragDistance())
191193
{
192194
qDebug() << "CTabsScrollArea::startFloating";
193195
startFloating(d->DragStartMousePos);

src/DockManager.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include <QXmlStreamReader>
4545
#include <QSettings>
4646
#include <QMenu>
47+
#include <QApplication>
4748

4849
#include "FloatingDockContainer.h"
4950
#include "DockOverlay.h"
@@ -629,6 +630,13 @@ bool CDockManager::isRestoringState() const
629630
return d->RestoringState;
630631
}
631632

633+
634+
//===========================================================================
635+
int CDockManager::startDragDistance()
636+
{
637+
return QApplication::startDragDistance() * 1.5;
638+
}
639+
632640
} // namespace ads
633641

634642
//---------------------------------------------------------------------------

src/DockManager.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,12 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
270270
*/
271271
bool isRestoringState() const;
272272

273+
/**
274+
* The distance the user needs to move the mouse with the left button
275+
* hold down before a dock widget start floating
276+
*/
277+
static int startDragDistance();
278+
273279
public slots:
274280
/**
275281
* Opens the perspective with the given name.

src/DockWidgetTab.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,8 +281,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
281281

282282
// Maybe a fixed drag distance is better here ?
283283
int DragDistanceY = qAbs(d->DragStartMousePosition.y() - ev->pos().y());
284-
int MinDragDistanceY = d->DockArea->titleBarGeometry().height() / 2;
285-
if (DragDistanceY >= MinDragDistanceY)
284+
if (DragDistanceY >= CDockManager::startDragDistance())
286285
{
287286
// If this is the last dock area in a dock container with only
288287
// one single dock widget it does not make sense to move it to a new

0 commit comments

Comments
 (0)