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

View File

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

View File

@ -270,6 +270,12 @@ public:
*/ */
bool isRestoringState() const; 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: public slots:
/** /**
* Opens the perspective with the given name. * 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 ? // Maybe a fixed drag distance is better here ?
int DragDistanceY = qAbs(d->DragStartMousePosition.y() - ev->pos().y()); int DragDistanceY = qAbs(d->DragStartMousePosition.y() - ev->pos().y());
int MinDragDistanceY = d->DockArea->titleBarGeometry().height() / 2; if (DragDistanceY >= CDockManager::startDragDistance())
if (DragDistanceY >= MinDragDistanceY)
{ {
// 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