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

This commit is contained in:
Uwe Kindler 2018-11-05 09:58:46 +01:00
parent c973482b2b
commit 74b9d35c7b
4 changed files with 20 additions and 5 deletions

View File

@ -15,6 +15,7 @@
#include <QDebug>
#include <QBoxLayout>
#include <QMenu>
#include <QApplication>
#include "FloatingDockContainer.h"
#include "DockAreaWidget.h"
@ -185,9 +186,10 @@ void CDockAreaTabBar::mouseMoveEvent(QMouseEvent* ev)
return;
}
int DragDistanceY = qAbs(d->DragStartMousePos.y() - ev->pos().y());
int MinDragDistanceY = this->height() / 2;
if (DragDistanceY >= MinDragDistanceY)
/*int DragDistanceY = qAbs(d->DragStartMousePos.y() - ev->pos().y());
int MinDragDistanceY = this->height() / 2;*/
int DragDistance = (d->DragStartMousePos - ev->pos()).manhattanLength();
if (DragDistance >= CDockManager::startDragDistance())
{
qDebug() << "CTabsScrollArea::startFloating";
startFloating(d->DragStartMousePos);

View File

@ -44,6 +44,7 @@
#include <QXmlStreamReader>
#include <QSettings>
#include <QMenu>
#include <QApplication>
#include "FloatingDockContainer.h"
#include "DockOverlay.h"
@ -629,6 +630,13 @@ bool CDockManager::isRestoringState() const
return d->RestoringState;
}
//===========================================================================
int CDockManager::startDragDistance()
{
return QApplication::startDragDistance() * 1.5;
}
} // namespace ads
//---------------------------------------------------------------------------

View File

@ -270,6 +270,12 @@ public:
*/
bool isRestoringState() const;
/**
* The distance the user needs to move the mouse with the left button
* hold down before a dock widget start floating
*/
static int startDragDistance();
public slots:
/**
* Opens the perspective with the given name.

View File

@ -281,8 +281,7 @@ void CDockWidgetTab::mouseMoveEvent(QMouseEvent* ev)
// Maybe a fixed drag distance is better here ?
int DragDistanceY = qAbs(d->DragStartMousePosition.y() - ev->pos().y());
int MinDragDistanceY = d->DockArea->titleBarGeometry().height() / 2;
if (DragDistanceY >= MinDragDistanceY)
if (DragDistanceY >= CDockManager::startDragDistance())
{
// 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