diff --git a/src/Config.cpp b/src/Config.cpp index 6721c67a..97c6e7b9 100644 --- a/src/Config.cpp +++ b/src/Config.cpp @@ -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; +} } diff --git a/src/Config.h b/src/Config.h index fbb89a9e..8431d140 100644 --- a/src/Config.h +++ b/src/Config.h @@ -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 *); diff --git a/src/private/DragController.cpp b/src/private/DragController.cpp index b1fc31d3..3f8935fe 100644 --- a/src/private/DragController.cpp +++ b/src/private/DragController.cpp @@ -19,6 +19,7 @@ #include "Qt5Qt6Compat_p.h" #include "Utils_p.h" #include "WidgetResizeHandler_p.h" +#include "Config.h" #include #include @@ -32,8 +33,6 @@ # include #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; }