diff --git a/examples/dockwidgets/main.cpp b/examples/dockwidgets/main.cpp index 74c724d2..2bb9cde7 100644 --- a/examples/dockwidgets/main.cpp +++ b/examples/dockwidgets/main.cpp @@ -267,7 +267,8 @@ int main(int argc, char **argv) // Dock widget 8 will only be allowed to dock to the outer areasa auto func = [](KDDockWidgets::DropLocation location, const KDDockWidgets::DockWidgetBase::List &source, - const KDDockWidgets::DockWidgetBase::List &target) { + const KDDockWidgets::DockWidgetBase::List &target, + KDDockWidgets::DropArea *) { Q_UNUSED(target); // When dragging into a tab, 'target' would have the list of already tabbed dock widgets const bool isDraggingDW8 = std::find_if(source.cbegin(), source.cend(), [] (KDDockWidgets::DockWidgetBase *dw) { diff --git a/src/Config.h b/src/Config.h index 2548753c..1a0b69f6 100644 --- a/src/Config.h +++ b/src/Config.h @@ -34,6 +34,7 @@ namespace KDDockWidgets { class DockWidgetBase; class MainWindowBase; class FrameworkWidgetFactory; +class DropArea; typedef KDDockWidgets::DockWidgetBase *(*DockWidgetFactoryFunc)(const QString &name); typedef KDDockWidgets::MainWindowBase *(*MainWindowFactoryFunc)(const QString &name); @@ -47,11 +48,13 @@ typedef KDDockWidgets::MainWindowBase *(*MainWindowFactoryFunc)(const QString &n /// @param location The drop indicator location to allow or disallow /// @param source The dock widgets being dragged /// @param target The dock widgets within an existing docked tab group +/// @param dropArea The target drop area. Can belong to a MainWindow or a FloatingWindow. /// @return true if the docking is allowed. /// @sa setDropIndicatorAllowedFunc typedef bool (*DropIndicatorAllowedFunc)(DropLocation location, const QVector &source, - const QVector &target); + const QVector &target, + DropArea *dropArea); /// @deprecated Use DropIndicatorAllowedFunc instead. /// @brief Function to allow the user more granularity to disallow dock widgets to tab together @@ -262,7 +265,8 @@ public: * * auto func = [] (KDDockWidgets::DropLocation loc, * const KDDockWidgets::DockWidgetBase::List &source, - * const KDDockWidgets::DockWidgetBase::List &target) + * const KDDockWidgets::DockWidgetBase::List &target, + * KDDockWidgets::DropArea *) * { * // disallows dockFoo to be docked to outer areas * return !((loc & KDDockWidgets::DropLocation_Outter) && source.contains(dockFoo)); diff --git a/src/private/DragController_p.h b/src/private/DragController_p.h index 58efa3c3..e361e6fc 100644 --- a/src/private/DragController_p.h +++ b/src/private/DragController_p.h @@ -96,6 +96,9 @@ public: FloatingWindow *floatingWindowBeingDragged() const; + /// @brief Returns the current drop area under the mouse + DropArea *dropAreaUnderCursor() const; + ///@brief Returns the window being dragged WindowBeingDragged *windowBeingDragged() const; @@ -126,7 +129,6 @@ private: DragController(QObject * = nullptr); StateBase *activeState() const; WidgetType *qtTopLevelUnderCursor() const; - DropArea *dropAreaUnderCursor() const; Draggable *draggableForQObject(QObject *o) const; QPoint m_pressPos; QPoint m_offset; diff --git a/src/private/DropIndicatorOverlayInterface.cpp b/src/private/DropIndicatorOverlayInterface.cpp index ebb9aedb..ee40a8d2 100644 --- a/src/private/DropIndicatorOverlayInterface.cpp +++ b/src/private/DropIndicatorOverlayInterface.cpp @@ -161,7 +161,8 @@ bool DropIndicatorOverlayInterface::dropIndicatorVisible(DropLocation dropLoc) c } if (auto dropIndicatorAllowedFunc = Config::self().dropIndicatorAllowedFunc()) { - if (!dropIndicatorAllowedFunc(dropLoc, source, target)) + DropArea *dropArea = DragController::instance()->dropAreaUnderCursor(); + if (!dropIndicatorAllowedFunc(dropLoc, source, target, dropArea)) return false; }