Allow to configure the MDI popup threshold

This commit is contained in:
Sergio Martins
2021-03-03 16:33:32 +00:00
parent c81ca45e41
commit d263ae649e
3 changed files with 23 additions and 5 deletions

View File

@@ -59,6 +59,7 @@ public:
InternalFlags m_internalFlags = InternalFlag_None;
CustomizableWidgets m_disabledPaintEvents = CustomizableWidget_None;
qreal m_draggedWindowOpacity = Q_QNAN;
int m_mdiPopupThreshold = 250;
};
Config::Config()
@@ -310,4 +311,13 @@ Config::CustomizableWidgets Config::disabledPaintEvents() const
return d->m_disabledPaintEvents;
}
void Config::setMDIPopupThreshold(int threshold)
{
d->m_mdiPopupThreshold = threshold;
}
int Config::mdiPopupThreshold() const
{
return d->m_mdiPopupThreshold;
}
}

View File

@@ -237,6 +237,12 @@ public:
///@warning Not for public consumption, support will be limited.
void setInternalFlags(InternalFlags flags);
/// @brief Sets the MDI popup threshold. When the layout is MDI and you drag a dock widget
/// X pixels behond the window's edge, it will float the dock widget.
/// by default this value is 250px. Use -1 to disable
void setMDIPopupThreshold(int);
int mdiPopupThreshold() const;
#ifdef KDDOCKWIDGETS_QTQUICK
///@brief Sets the QQmlEngine to use. Applicable only when using QtQuick.
void setQmlEngine(QQmlEngine *);

View File

@@ -19,6 +19,7 @@
#include "Qt5Qt6Compat_p.h"
#include "Utils_p.h"
#include "WidgetResizeHandler_p.h"
#include "Config.h"
#include <QMouseEvent>
#include <QGuiApplication>
@@ -32,8 +33,6 @@
# include <windows.h>
#endif
#define MDI_POPOUT_THRESHOLD 250
using namespace KDDockWidgets;
namespace KDDockWidgets {
@@ -450,9 +449,12 @@ bool StateInternalMDIDragging::handleMouseMove(QPoint globalPos)
// Check if we need to pop out the MDI window (make it float)
// If we drag the window against an edge, and move behind the edge some threshold, we float it
const QPoint overflow = newLocalPosBounded - newLocalPos;
if (qAbs(overflow.x()) > MDI_POPOUT_THRESHOLD || qAbs(overflow.y()) > MDI_POPOUT_THRESHOLD)
Q_EMIT q->mdiPopOut();
const int threshold = Config::self().mdiPopupThreshold();
if (threshold != -1) {
const QPoint overflow = newLocalPosBounded - newLocalPos;
if (qAbs(overflow.x()) > threshold || qAbs(overflow.y()) > threshold)
Q_EMIT q->mdiPopOut();
}
return false;
}