diff --git a/CMakeLists.txt b/CMakeLists.txt index 265a902..15233b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ set(ads_SRCS src/DockingStateReader.cpp src/ElidingLabel.cpp src/FloatingDockContainer.cpp - src/FloatingOverlay.cpp + src/FloatingDragPreview.cpp src/IconProvider.cpp src/ads.qrc src/linux/FloatingWidgetTitleBar.cpp @@ -59,7 +59,7 @@ set(ads_INSTALL_INCLUDE src/DockingStateReader.h src/ElidingLabel.h src/FloatingDockContainer.h - src/FloatingOverlay.h + src/FloatingDragPreview.h src/IconProvider.h src/linux/FloatingWidgetTitleBar.h ) diff --git a/src/DockAreaTabBar.cpp b/src/DockAreaTabBar.cpp index 33a4e88..3d44934 100644 --- a/src/DockAreaTabBar.cpp +++ b/src/DockAreaTabBar.cpp @@ -27,6 +27,7 @@ //============================================================================ // INCLUDES //============================================================================ +#include #include "DockAreaTabBar.h" #include @@ -36,7 +37,6 @@ #include #include "FloatingDockContainer.h" -#include "FloatingOverlay.h" #include "DockAreaWidget.h" #include "DockOverlay.h" #include "DockManager.h" @@ -277,8 +277,8 @@ IFloatingWidget* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset, eDragSt } else { - auto w = new CFloatingOverlay(d->DockArea); - connect(w, &CFloatingOverlay::draggingCanceled, [=]() + auto w = new CFloatingDragPreview(d->DockArea); + connect(w, &CFloatingDragPreview::draggingCanceled, [=]() { d->DragState = DraggingInactive; }); diff --git a/src/DockContainerWidget.h b/src/DockContainerWidget.h index f44f45d..1ac037d 100644 --- a/src/DockContainerWidget.h +++ b/src/DockContainerWidget.h @@ -47,8 +47,8 @@ class CDockManager; struct DockManagerPrivate; class CFloatingDockContainer; struct FloatingDockContainerPrivate; -class CFloatingOverlay; -struct FloatingOverlayPrivate; +class CFloatingDragPreview; +struct FloatingDragPreviewPrivate; class CDockingStateReader; /** @@ -71,8 +71,8 @@ private: friend class CFloatingDockContainer; friend struct FloatingDockContainerPrivate; friend class CDockWidget; - friend class CFloatingOverlay; - friend struct FloatingOverlayPrivate; + friend class CFloatingDragPreview; + friend struct FloatingDragPreviewPrivate; protected: /** diff --git a/src/DockManager.h b/src/DockManager.h index 064e8a7..b948cef 100644 --- a/src/DockManager.h +++ b/src/DockManager.h @@ -86,8 +86,8 @@ private: friend class CDockWidgetTab; friend struct DockAreaWidgetPrivate; friend struct DockWidgetTabPrivate; - friend class CFloatingOverlay; - friend struct FloatingOverlayPrivate; + friend class CFloatingDragPreview; + friend struct FloatingDragPreviewPrivate; protected: /** diff --git a/src/DockWidgetTab.cpp b/src/DockWidgetTab.cpp index 9e8abf6..6c5329e 100644 --- a/src/DockWidgetTab.cpp +++ b/src/DockWidgetTab.cpp @@ -28,6 +28,7 @@ //============================================================================ // INCLUDES //============================================================================ +#include #include "ElidingLabel.h" #include "DockWidgetTab.h" @@ -46,7 +47,6 @@ #include "DockWidget.h" #include "DockAreaWidget.h" #include "FloatingDockContainer.h" -#include "FloatingOverlay.h" #include "DockOverlay.h" #include "DockManager.h" #include "IconProvider.h" @@ -151,8 +151,8 @@ struct DockWidgetTabPrivate } else { - auto w = new CFloatingOverlay(Widget); - _this->connect(w, &CFloatingOverlay::draggingCanceled, [=]() + auto w = new CFloatingDragPreview(Widget); + _this->connect(w, &CFloatingDragPreview::draggingCanceled, [=]() { DragState = DraggingInactive; }); diff --git a/src/FloatingOverlay.cpp b/src/FloatingDragPreview.cpp similarity index 87% rename from src/FloatingOverlay.cpp rename to src/FloatingDragPreview.cpp index b8a68b4..fa062af 100644 --- a/src/FloatingOverlay.cpp +++ b/src/FloatingDragPreview.cpp @@ -1,15 +1,14 @@ //============================================================================ -/// \file FloatingOverlay.cpp +/// \file FloatingDragPreview.cpp /// \author Uwe Kindler /// \date 26.11.2019 -/// \brief Implementation of CFloatingOverlay +/// \brief Implementation of CFloatingDragPreview //============================================================================ //============================================================================ // INCLUDES //============================================================================ -#include "FloatingOverlay.h" - +#include "FloatingDragPreview.h" #include #include @@ -29,9 +28,9 @@ namespace ads /** * Private data class (pimpl) */ -struct FloatingOverlayPrivate +struct FloatingDragPreviewPrivate { - CFloatingOverlay *_this; + CFloatingDragPreview *_this; QWidget* Content; CDockAreaWidget* ContentSourceArea = nullptr; CDockContainerWidget* ContenSourceContainer = nullptr; @@ -46,7 +45,7 @@ struct FloatingOverlayPrivate /** * Private data constructor */ - FloatingOverlayPrivate(CFloatingOverlay *_public); + FloatingDragPreviewPrivate(CFloatingDragPreview *_public); void updateDropOverlays(const QPoint &GlobalPos); void setHidden(bool Value) @@ -70,7 +69,7 @@ struct FloatingOverlayPrivate //============================================================================ -void FloatingOverlayPrivate::updateDropOverlays(const QPoint &GlobalPos) +void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos) { if (!_this->isVisible() || !DockManager) { @@ -163,16 +162,16 @@ void FloatingOverlayPrivate::updateDropOverlays(const QPoint &GlobalPos) //============================================================================ -FloatingOverlayPrivate::FloatingOverlayPrivate(CFloatingOverlay *_public) : +FloatingDragPreviewPrivate::FloatingDragPreviewPrivate(CFloatingDragPreview *_public) : _this(_public) { } //============================================================================ -CFloatingOverlay::CFloatingOverlay(QWidget* Content, QWidget* parent) : +CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) : QWidget(parent), - d(new FloatingOverlayPrivate(this)) + d(new FloatingDragPreviewPrivate(this)) { d->Content = Content; setAttribute(Qt::WA_DeleteOnClose); @@ -211,8 +210,8 @@ CFloatingOverlay::CFloatingOverlay(QWidget* Content, QWidget* parent) : //============================================================================ -CFloatingOverlay::CFloatingOverlay(CDockWidget* Content) - : CFloatingOverlay((QWidget*)Content, Content->dockManager()) +CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content) + : CFloatingDragPreview((QWidget*)Content, Content->dockManager()) { d->DockManager = Content->dockManager(); if (Content->dockAreaWidget()->openDockWidgetsCount() == 1) @@ -225,8 +224,8 @@ CFloatingOverlay::CFloatingOverlay(CDockWidget* Content) //============================================================================ -CFloatingOverlay::CFloatingOverlay(CDockAreaWidget* Content) - : CFloatingOverlay((QWidget*)Content, Content->dockManager()) +CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content) + : CFloatingDragPreview((QWidget*)Content, Content->dockManager()) { d->DockManager = Content->dockManager(); d->ContentSourceArea = Content; @@ -236,14 +235,14 @@ CFloatingOverlay::CFloatingOverlay(CDockAreaWidget* Content) //============================================================================ -CFloatingOverlay::~CFloatingOverlay() +CFloatingDragPreview::~CFloatingDragPreview() { delete d; } //============================================================================ -void CFloatingOverlay::moveFloating() +void CFloatingDragPreview::moveFloating() { int BorderSize = (frameSize().width() - size().width()) / 2; const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition @@ -253,7 +252,7 @@ void CFloatingOverlay::moveFloating() //============================================================================ -void CFloatingOverlay::startFloating(const QPoint &DragStartMousePos, +void CFloatingDragPreview::startFloating(const QPoint &DragStartMousePos, const QSize &Size, eDragState DragState, QWidget *MouseEventHandler) { Q_UNUSED(MouseEventHandler) @@ -267,7 +266,7 @@ void CFloatingOverlay::startFloating(const QPoint &DragStartMousePos, //============================================================================ -void CFloatingOverlay::moveEvent(QMoveEvent *event) +void CFloatingDragPreview::moveEvent(QMoveEvent *event) { QWidget::moveEvent(event); d->updateDropOverlays(QCursor::pos()); @@ -275,9 +274,9 @@ void CFloatingOverlay::moveEvent(QMoveEvent *event) //============================================================================ -void CFloatingOverlay::finishDragging() +void CFloatingDragPreview::finishDragging() { - ADS_PRINT("CFloatingOverlay::finishDragging"); + ADS_PRINT("CFloatingDragPreview::finishDragging"); auto DockDropArea = d->DockManager->dockAreaOverlay()->dropAreaUnderCursor(); auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor(); bool DropPossible = (DockDropArea != InvalidDockWidgetArea) || (ContainerDropArea != InvalidDockWidgetArea); @@ -317,7 +316,7 @@ void CFloatingOverlay::finishDragging() //============================================================================ -void CFloatingOverlay::paintEvent(QPaintEvent* event) +void CFloatingDragPreview::paintEvent(QPaintEvent* event) { Q_UNUSED(event); if (d->Hidden) @@ -351,7 +350,7 @@ void CFloatingOverlay::paintEvent(QPaintEvent* event) //============================================================================ -void CFloatingOverlay::keyPressEvent(QKeyEvent *event) +void CFloatingDragPreview::keyPressEvent(QKeyEvent *event) { Super::keyPressEvent(event); if (event->key() == Qt::Key_Escape) @@ -362,7 +361,7 @@ void CFloatingOverlay::keyPressEvent(QKeyEvent *event) //============================================================================ -void CFloatingOverlay::onApplicationStateChanged(Qt::ApplicationState state) +void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state) { if (state != Qt::ApplicationActive) { @@ -378,4 +377,4 @@ void CFloatingOverlay::onApplicationStateChanged(Qt::ApplicationState state) } // namespace ads //--------------------------------------------------------------------------- -// EOF FloatingOverlay.cpp +// EOF FloatingDragPreview.cpp diff --git a/src/FloatingOverlay.h b/src/FloatingDragPreview.h similarity index 77% rename from src/FloatingOverlay.h rename to src/FloatingDragPreview.h index c9af8c7..07b68ea 100644 --- a/src/FloatingOverlay.h +++ b/src/FloatingDragPreview.h @@ -1,10 +1,10 @@ -#ifndef FloatingOverlayH -#define FloatingOverlayH +#ifndef FloatingDragPreviewH +#define FloatingDragPreviewH //============================================================================ -/// \file FloatingOverlay.h +/// \file FloatingDragPreview.h /// \author Uwe Kindler /// \date 26.11.2019 -/// \brief Declaration of CFloatingOverlay +/// \brief Declaration of CFloatingDragPreview //============================================================================ //============================================================================ @@ -17,7 +17,7 @@ namespace ads { class CDockWidget; class CDockAreaWidget; -struct FloatingOverlayPrivate; +struct FloatingDragPreviewPrivate; /** * A floating overlay is a temporary floating widget that is just used to @@ -25,14 +25,17 @@ struct FloatingOverlayPrivate; * This widget is used as a placeholder for drag operations for non-opaque * docking */ -class CFloatingOverlay : public QWidget, public IFloatingWidget +class CFloatingDragPreview : public QWidget, public IFloatingWidget { Q_OBJECT private: - FloatingOverlayPrivate* d; - friend class FloatingOverlayPrivate; + FloatingDragPreviewPrivate* d; + friend class FloatingDragPreviewPrivate; private slots: + /** + * Cancel non opaque undocking if application becomes inactive + */ void onApplicationStateChanged(Qt::ApplicationState state); protected: @@ -46,12 +49,15 @@ protected: */ virtual void paintEvent(QPaintEvent *e) override; + /** + * Cancel non opaque undocking with escape key + */ virtual void keyPressEvent(QKeyEvent *event) override; /** * The content is a DockArea or a DockWidget */ - CFloatingOverlay(QWidget* Content, QWidget* parent); + CFloatingDragPreview(QWidget* Content, QWidget* parent); public: using Super = QWidget; @@ -59,18 +65,18 @@ public: /** * Creates an instance for undocking the DockWidget in Content parameter */ - CFloatingOverlay(CDockWidget* Content); + CFloatingDragPreview(CDockWidget* Content); /** * Creates an instance for undocking the DockArea given in Content * parameters */ - CFloatingOverlay(CDockAreaWidget* Content); + CFloatingDragPreview(CDockAreaWidget* Content); /** * Delete private data */ - ~CFloatingOverlay(); + ~CFloatingDragPreview(); public: // implements IFloatingWidget ----------------------------------------- @@ -102,5 +108,5 @@ signals: } // namespace ads //--------------------------------------------------------------------------- -#endif // FloatingOverlayH +#endif // FloatingDragPreviewH diff --git a/src/src.pro b/src/src.pro index e368232..755c7e5 100644 --- a/src/src.pro +++ b/src/src.pro @@ -38,7 +38,7 @@ HEADERS += \ DockWidgetTab.h \ DockingStateReader.h \ FloatingDockContainer.h \ - FloatingOverlay.h \ + FloatingDragPreview.h \ DockOverlay.h \ DockSplitter.h \ DockAreaTitleBar.h \ @@ -56,7 +56,7 @@ SOURCES += \ DockingStateReader.cpp \ DockWidgetTab.cpp \ FloatingDockContainer.cpp \ - FloatingOverlay.cpp \ + FloatingDragPreview.cpp \ DockOverlay.cpp \ DockSplitter.cpp \ DockAreaTitleBar.cpp \