diff --git a/src/FrameworkWidgetFactory.h b/src/FrameworkWidgetFactory.h index 1b0c2cab..27e8b98b 100644 --- a/src/FrameworkWidgetFactory.h +++ b/src/FrameworkWidgetFactory.h @@ -26,9 +26,9 @@ QT_END_NAMESPACE namespace KDDockWidgets { class DropIndicatorOverlayInterface; -class DropArea; namespace Controllers { +class DropArea; class Separator; class TabBar; class SideBar; @@ -114,7 +114,7 @@ public: ///@brief Called internally by the framework to create a DropIndicatorOverlayInterface /// Override to provide your own DropIndicatorOverlayInterface sub-class. ///@param dropArea Just forward to DropIndicatorOverlayInterface's constructor. - virtual DropIndicatorOverlayInterface *createDropIndicatorOverlay(DropArea *dropArea) const = 0; + virtual DropIndicatorOverlayInterface *createDropIndicatorOverlay(Controllers::DropArea *dropArea) const = 0; ///@brief Called internally by the framework to create a RubberBand to show as drop zone /// Returns a rubber band diff --git a/src/KDDockWidgets.h b/src/KDDockWidgets.h index abee661a..28077305 100644 --- a/src/KDDockWidgets.h +++ b/src/KDDockWidgets.h @@ -39,7 +39,10 @@ namespace KDDockWidgets { DOCKS_EXPORT Q_NAMESPACE class MultiSplitter; + +namespace Controllers { class DropArea; +} enum Location { Location_None, @@ -173,7 +176,7 @@ private: friend class Layouting::Item; friend class Layouting::ItemBoxContainer; friend class KDDockWidgets::MultiSplitter; - friend class KDDockWidgets::DropArea; + friend class KDDockWidgets::Controllers::DropArea; InitialOption(DefaultSizeMode mode) : sizeMode(mode) diff --git a/src/ViewWrapper.h b/src/ViewWrapper.h index 5353ff2a..709fd4fd 100644 --- a/src/ViewWrapper.h +++ b/src/ViewWrapper.h @@ -16,7 +16,10 @@ namespace KDDockWidgets { +namespace Controllers { class DropArea; +} + /// @brief The base class for view wrappers /// A view wrapper is a view that doesn't own the native GUI element(QWidget, QQuickItem etc.) @@ -66,7 +69,7 @@ public: void setMouseTracking(bool) override; /// TODOv2: Remove - virtual DropArea *asDropArea() const + virtual Controllers::DropArea *asDropArea() const { return {}; }; diff --git a/src/controllers/DropArea.h b/src/controllers/DropArea.h index 2cdbbb10..691477fd 100644 --- a/src/controllers/DropArea.h +++ b/src/controllers/DropArea.h @@ -18,6 +18,7 @@ #ifndef KD_DROP_AREA_P_H #define KD_DROP_AREA_P_H +#pragma once #include "kddockwidgets/docks_export.h" #include "kddockwidgets/KDDockWidgets.h" @@ -30,13 +31,12 @@ class TestDocks; namespace KDDockWidgets { +class Draggable; +struct WindowBeingDragged; + namespace Controllers { class Frame; class DockWidget; -} - -class Draggable; -struct WindowBeingDragged; /** * @brief A MultiSplitter with support for drop indicators when hovering over. @@ -59,10 +59,10 @@ public: { return m_dropIndicatorOverlay; } - void addDockWidget(Controllers::DockWidget *, KDDockWidgets::Location location, - Controllers::DockWidget *relativeTo, InitialOption = {}); + void addDockWidget(DockWidget *, KDDockWidgets::Location location, + DockWidget *relativeTo, InitialOption = {}); - bool containsDockWidget(Controllers::DockWidget *) const; + bool containsDockWidget(DockWidget *) const; /// Returns whether this layout has a single dock widget which is floating /// Implies it's in a FloatingWindow and that it has only one dock widget @@ -73,7 +73,7 @@ public: bool hasSingleFrame() const; QStringList affinities() const; - void layoutParentContainerEqually(Controllers::DockWidget *); + void layoutParentContainerEqually(DockWidget *); /// When DockWidget::Option_MDINestable is used, docked MDI dock widgets will be wrapped inside a DropArea, so they accept drops /// This DropArea is created implicitly while docking, and this function will return true @@ -108,5 +108,6 @@ private: Controllers::Frame *const m_centralFrame = nullptr; }; } +} #endif diff --git a/src/controllers/FloatingWindow.h b/src/controllers/FloatingWindow.h index 10bd03ee..714428a3 100644 --- a/src/controllers/FloatingWindow.h +++ b/src/controllers/FloatingWindow.h @@ -22,13 +22,13 @@ #include "kddockwidgets/docks_export.h" namespace KDDockWidgets { -class DropArea; class MultiSplitter; class LayoutWidget; } namespace KDDockWidgets::Controllers { +class DropArea; class Frame; class MainWindow; class TitleBar; diff --git a/src/controllers/MainWindow.h b/src/controllers/MainWindow.h index d36de0c8..3b9793f4 100644 --- a/src/controllers/MainWindow.h +++ b/src/controllers/MainWindow.h @@ -32,13 +32,12 @@ class TestDocks; namespace KDDockWidgets { -class DropArea; class MDILayoutWidget; class MultiSplitter; class LayoutWidget; -class DropArea; namespace Controllers { +class DropArea; class Frame; class SideBar; class DockWidget; diff --git a/src/private/DragController_p.h b/src/private/DragController_p.h index 398e3d96..5ac711b8 100644 --- a/src/private/DragController_p.h +++ b/src/private/DragController_p.h @@ -27,11 +27,14 @@ namespace KDDockWidgets { class StateBase; class StateNone; class StateInternalMDIDragging; -class DropArea; class Draggable; class FallbackMouseGrabber; class MinimalStateMachine; +namespace Controllers { +class DropArea; +} + class State : public QObject { Q_OBJECT @@ -124,7 +127,7 @@ private: DragController(QObject * = nullptr); StateBase *activeState() const; ViewWrapper::Ptr qtTopLevelUnderCursor() const; - DropArea *dropAreaUnderCursor() const; + Controllers::DropArea *dropAreaUnderCursor() const; Draggable *draggableForQObject(QObject *o) const; QPoint m_pressPos; QPoint m_offset; @@ -133,7 +136,7 @@ private: Draggable *m_draggable = nullptr; QPointer m_draggableGuard; // Just so we know if the draggable was destroyed for some reason std::unique_ptr m_windowBeingDragged; - DropArea *m_currentDropArea = nullptr; + Controllers::DropArea *m_currentDropArea = nullptr; bool m_nonClientDrag = false; FallbackMouseGrabber *m_fallbackMouseGrabber = nullptr; StateNone *m_stateNone = nullptr; @@ -166,19 +169,19 @@ public: } // Only interesting for Wayland - virtual bool handleDragEnter(QDragEnterEvent *, DropArea *) + virtual bool handleDragEnter(QDragEnterEvent *, Controllers::DropArea *) { return false; } - virtual bool handleDragLeave(DropArea *) + virtual bool handleDragLeave(Controllers::DropArea *) { return false; } - virtual bool handleDragMove(QDragMoveEvent *, DropArea *) + virtual bool handleDragMove(QDragMoveEvent *, Controllers::DropArea *) { return false; } - virtual bool handleDrop(QDropEvent *, DropArea *) + virtual bool handleDrop(QDropEvent *, Controllers::DropArea *) { return false; } @@ -252,10 +255,10 @@ public: ~StateDraggingWayland() override; void onEntry() override; bool handleMouseButtonRelease(QPoint globalPos) override; - bool handleDragEnter(QDragEnterEvent *, DropArea *) override; - bool handleDragMove(QDragMoveEvent *, DropArea *) override; - bool handleDragLeave(DropArea *) override; - bool handleDrop(QDropEvent *, DropArea *) override; + bool handleDragEnter(QDragEnterEvent *, Controllers::DropArea *) override; + bool handleDragMove(QDragMoveEvent *, Controllers::DropArea *) override; + bool handleDragLeave(Controllers::DropArea *) override; + bool handleDrop(QDropEvent *, Controllers::DropArea *) override; bool m_inQDrag = false; }; diff --git a/src/private/DropIndicatorOverlayInterface.cpp b/src/private/DropIndicatorOverlayInterface.cpp index c9c87903..98401ce4 100644 --- a/src/private/DropIndicatorOverlayInterface.cpp +++ b/src/private/DropIndicatorOverlayInterface.cpp @@ -21,7 +21,7 @@ using namespace KDDockWidgets; using namespace KDDockWidgets::Controllers; -DropIndicatorOverlayInterface::DropIndicatorOverlayInterface(DropArea *dropArea) +DropIndicatorOverlayInterface::DropIndicatorOverlayInterface(Controllers::DropArea *dropArea) : Views::View_qtwidgets(nullptr, Type::DropIndicatorOverlayInterface, dropArea) , m_dropArea(dropArea) { diff --git a/src/private/DropIndicatorOverlayInterface_p.h b/src/private/DropIndicatorOverlayInterface_p.h index 32f84ca6..e64a6a4d 100644 --- a/src/private/DropIndicatorOverlayInterface_p.h +++ b/src/private/DropIndicatorOverlayInterface_p.h @@ -20,7 +20,9 @@ namespace KDDockWidgets { -class DropArea; +namespace Controllers { +class DropARea; +} class DOCKS_EXPORT DropIndicatorOverlayInterface : public Views::View_qtwidgets { @@ -28,7 +30,7 @@ class DOCKS_EXPORT DropIndicatorOverlayInterface : public Views::View_qtwidgets< Q_PROPERTY(QRect hoveredFrameRect READ hoveredFrameRect NOTIFY hoveredFrameRectChanged) Q_PROPERTY(KDDockWidgets::DropLocation currentDropLocation READ currentDropLocation NOTIFY currentDropLocationChanged) public: - explicit DropIndicatorOverlayInterface(DropArea *dropArea); + explicit DropIndicatorOverlayInterface(Controllers::DropArea *dropArea); void setHoveredFrame(Controllers::Frame *); void setWindowBeingDragged(bool); QRect hoveredFrameRect() const; @@ -71,7 +73,7 @@ protected: virtual void updateVisibility() {}; Controllers::Frame *m_hoveredFrame = nullptr; - DropArea *const m_dropArea; + Controllers::DropArea *const m_dropArea; bool m_draggedWindowIsHovering = false; }; diff --git a/src/private/indicators/ClassicIndicators.cpp b/src/private/indicators/ClassicIndicators.cpp index 1fd898ab..1d3bd78e 100644 --- a/src/private/indicators/ClassicIndicators.cpp +++ b/src/private/indicators/ClassicIndicators.cpp @@ -32,7 +32,7 @@ static IndicatorWindow *createIndicatorWindow(ClassicIndicators *classicIndicato return window; } -ClassicIndicators::ClassicIndicators(DropArea *dropArea) +ClassicIndicators::ClassicIndicators(Controllers::DropArea *dropArea) : DropIndicatorOverlayInterface(dropArea) // Is parented on the drop-area, not a toplevel. , m_rubberBand(Config::self().frameworkWidgetFactory()->createRubberBand(rubberBandIsTopLevel() ? nullptr : dropArea)) , m_indicatorWindow(createIndicatorWindow(this)) diff --git a/src/private/indicators/ClassicIndicators_p.h b/src/private/indicators/ClassicIndicators_p.h index 126b14f4..443c0f9d 100644 --- a/src/private/indicators/ClassicIndicators_p.h +++ b/src/private/indicators/ClassicIndicators_p.h @@ -37,7 +37,7 @@ class DOCKS_EXPORT ClassicIndicators : public DropIndicatorOverlayInterface Q_PROPERTY(bool tabIndicatorVisible READ tabIndicatorVisible NOTIFY indicatorsVisibleChanged) public: - explicit ClassicIndicators(DropArea *dropArea); + explicit ClassicIndicators(Controllers::DropArea *dropArea); ~ClassicIndicators() override; DropLocation hover_impl(QPoint globalPos) override; QPoint posForIndicator(DropLocation) const override; diff --git a/src/private/indicators/NullIndicators.cpp b/src/private/indicators/NullIndicators.cpp index 22bf955f..e9c1fc7d 100644 --- a/src/private/indicators/NullIndicators.cpp +++ b/src/private/indicators/NullIndicators.cpp @@ -13,7 +13,7 @@ namespace KDDockWidgets { -NullIndicators::NullIndicators(DropArea *dropArea) +NullIndicators::NullIndicators(Controllers::DropArea *dropArea) : DropIndicatorOverlayInterface(dropArea) { } diff --git a/src/private/indicators/NullIndicators_p.h b/src/private/indicators/NullIndicators_p.h index 2c4dea03..4a17574a 100644 --- a/src/private/indicators/NullIndicators_p.h +++ b/src/private/indicators/NullIndicators_p.h @@ -25,7 +25,7 @@ class DOCKS_EXPORT NullIndicators : public DropIndicatorOverlayInterface { Q_OBJECT public: - explicit NullIndicators(DropArea *); + explicit NullIndicators(Controllers::DropArea *); ~NullIndicators() override; DropLocation hover_impl(QPoint) override { diff --git a/src/private/indicators/SegmentedIndicators.cpp b/src/private/indicators/SegmentedIndicators.cpp index baed0d97..5e72e895 100644 --- a/src/private/indicators/SegmentedIndicators.cpp +++ b/src/private/indicators/SegmentedIndicators.cpp @@ -26,7 +26,7 @@ QColor SegmentedIndicators::s_segmentBrushColor = QColor(0xbb, 0xd5, 0xee, /*alp QColor SegmentedIndicators::s_hoveredSegmentBrushColor = QColor(0x3574c5); -SegmentedIndicators::SegmentedIndicators(DropArea *dropArea) +SegmentedIndicators::SegmentedIndicators(Controllers::DropArea *dropArea) : DropIndicatorOverlayInterface(dropArea) { // If the app didn't choose opacity then we choose a suitable default value. diff --git a/src/private/indicators/SegmentedIndicators_p.h b/src/private/indicators/SegmentedIndicators_p.h index 56f1fd24..3a82b5ae 100644 --- a/src/private/indicators/SegmentedIndicators_p.h +++ b/src/private/indicators/SegmentedIndicators_p.h @@ -23,7 +23,7 @@ class DOCKS_EXPORT SegmentedIndicators : public DropIndicatorOverlayInterface { Q_OBJECT public: - explicit SegmentedIndicators(DropArea *dropArea); + explicit SegmentedIndicators(Controllers::DropArea *dropArea); ~SegmentedIndicators() override; DropLocation hover_impl(QPoint globalPos) override; diff --git a/src/qtwidgets/FrameworkWidgetFactory_qtwidgets.cpp b/src/qtwidgets/FrameworkWidgetFactory_qtwidgets.cpp index c56bbf2f..ef8f27ef 100644 --- a/src/qtwidgets/FrameworkWidgetFactory_qtwidgets.cpp +++ b/src/qtwidgets/FrameworkWidgetFactory_qtwidgets.cpp @@ -96,7 +96,7 @@ View *DefaultWidgetFactory_qtwidgets::createFloatingWindow(Controllers::Floating return new Views::FloatingWindow_qtwidgets(controller, mainwindow, windowFlags); } -DropIndicatorOverlayInterface *DefaultWidgetFactory_qtwidgets::createDropIndicatorOverlay(DropArea *dropArea) const +DropIndicatorOverlayInterface *DefaultWidgetFactory_qtwidgets::createDropIndicatorOverlay(Controllers::DropArea *dropArea) const { #ifdef Q_OS_WASM // On WASM windows don't support translucency, which is required for the classic indicators. diff --git a/src/qtwidgets/FrameworkWidgetFactory_qtwidgets.h b/src/qtwidgets/FrameworkWidgetFactory_qtwidgets.h index ac82c25b..fdf47a84 100644 --- a/src/qtwidgets/FrameworkWidgetFactory_qtwidgets.h +++ b/src/qtwidgets/FrameworkWidgetFactory_qtwidgets.h @@ -34,9 +34,9 @@ class Widget; namespace KDDockWidgets { class DropIndicatorOverlayInterface; -class DropArea; namespace Controllers { +class DropArea; class Separator; class TabBar; class SideBar; @@ -64,7 +64,7 @@ public: View *createFloatingWindow(Controllers::FloatingWindow *, Controllers::MainWindow *parent = nullptr, Qt::WindowFlags windowFlags = {}) const override; - DropIndicatorOverlayInterface *createDropIndicatorOverlay(DropArea *) const override; + DropIndicatorOverlayInterface *createDropIndicatorOverlay(Controllers::DropArea *) const override; QWidgetOrQuick *createRubberBand(QWidgetOrQuick *parent) const override; View *createSideBar(Controllers::SideBar *, Controllers::MainWindow *parent) const override; diff --git a/src/qtwidgets/views/ViewWrapper_qtwidgets.cpp b/src/qtwidgets/views/ViewWrapper_qtwidgets.cpp index 94c74f31..8e6a2255 100644 --- a/src/qtwidgets/views/ViewWrapper_qtwidgets.cpp +++ b/src/qtwidgets/views/ViewWrapper_qtwidgets.cpp @@ -300,9 +300,9 @@ bool ViewWrapper_qtwidgets::isNull() const return m_widget.data() == nullptr; } -DropArea *ViewWrapper_qtwidgets::asDropArea() const +Controllers::DropArea *ViewWrapper_qtwidgets::asDropArea() const { - return qobject_cast(m_widget); + return qobject_cast(m_widget); } QWidget *ViewWrapper_qtwidgets::widget() const diff --git a/src/qtwidgets/views/ViewWrapper_qtwidgets.h b/src/qtwidgets/views/ViewWrapper_qtwidgets.h index cb5d1a84..ece6ab08 100644 --- a/src/qtwidgets/views/ViewWrapper_qtwidgets.h +++ b/src/qtwidgets/views/ViewWrapper_qtwidgets.h @@ -57,7 +57,7 @@ public: bool isNull() const override; void setWindowTitle(const QString &title) override; QPoint mapTo(View *, QPoint) const override; - DropArea *asDropArea() const override; + Controllers::DropArea *asDropArea() const override; QWidget *widget() const; diff --git a/tests/utils.h b/tests/utils.h index 6ed08a76..7f493e76 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -144,7 +144,7 @@ Controllers::DockWidget *createDockWidget(const QString &name, QWidgetOrQuick *w bool show = true, const QString &affinityName = {}); Controllers::DockWidget *createDockWidget(const QString &name, QColor color = Qt::black); -void nestDockWidget(Controllers::DockWidget *dock, DropArea *dropArea, Controllers::Frame *relativeTo, +void nestDockWidget(Controllers::DockWidget *dock, Controllers::DropArea *dropArea, Controllers::Frame *relativeTo, KDDockWidgets::Location location); class MyWidget : public QWidgetOrQuick @@ -422,7 +422,7 @@ inline void dragFloatingWindowTo(Controllers::FloatingWindow *fw, QPoint globalD drag(draggable, draggable->mapToGlobal(QPoint(10, 10)), globalDest, buttonActions); } -inline void dragFloatingWindowTo(Controllers::FloatingWindow *fw, DropArea *target, DropLocation dropLocation) +inline void dragFloatingWindowTo(Controllers::FloatingWindow *fw, Controllers::DropArea *target, DropLocation dropLocation) { auto draggable = draggableFor(fw->view()); Q_ASSERT(draggable);