1
0
mirror of https://github.com/githubuser0xFFFF/Qt-Advanced-Docking-System.git synced 2025-04-01 02:42:39 +08:00

Renamed FloatingOverlay into FloatingDragPreview to match naming of global DockManager flags (like DragPreviewHasWindowFrame..)

This commit is contained in:
Uwe Kindler 2019-12-16 11:18:22 +01:00
parent ffd35cbce3
commit e085a29484
8 changed files with 59 additions and 54 deletions

View File

@ -40,7 +40,7 @@ set(ads_SRCS
src/DockingStateReader.cpp src/DockingStateReader.cpp
src/ElidingLabel.cpp src/ElidingLabel.cpp
src/FloatingDockContainer.cpp src/FloatingDockContainer.cpp
src/FloatingOverlay.cpp src/FloatingDragPreview.cpp
src/IconProvider.cpp src/IconProvider.cpp
src/ads.qrc src/ads.qrc
src/linux/FloatingWidgetTitleBar.cpp src/linux/FloatingWidgetTitleBar.cpp
@ -59,7 +59,7 @@ set(ads_INSTALL_INCLUDE
src/DockingStateReader.h src/DockingStateReader.h
src/ElidingLabel.h src/ElidingLabel.h
src/FloatingDockContainer.h src/FloatingDockContainer.h
src/FloatingOverlay.h src/FloatingDragPreview.h
src/IconProvider.h src/IconProvider.h
src/linux/FloatingWidgetTitleBar.h src/linux/FloatingWidgetTitleBar.h
) )

View File

@ -27,6 +27,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <FloatingDragPreview.h>
#include "DockAreaTabBar.h" #include "DockAreaTabBar.h"
#include <QMouseEvent> #include <QMouseEvent>
@ -36,7 +37,6 @@
#include <QApplication> #include <QApplication>
#include "FloatingDockContainer.h" #include "FloatingDockContainer.h"
#include "FloatingOverlay.h"
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "DockOverlay.h" #include "DockOverlay.h"
#include "DockManager.h" #include "DockManager.h"
@ -277,8 +277,8 @@ IFloatingWidget* CDockAreaTabBar::makeAreaFloating(const QPoint& Offset, eDragSt
} }
else else
{ {
auto w = new CFloatingOverlay(d->DockArea); auto w = new CFloatingDragPreview(d->DockArea);
connect(w, &CFloatingOverlay::draggingCanceled, [=]() connect(w, &CFloatingDragPreview::draggingCanceled, [=]()
{ {
d->DragState = DraggingInactive; d->DragState = DraggingInactive;
}); });

View File

@ -47,8 +47,8 @@ class CDockManager;
struct DockManagerPrivate; struct DockManagerPrivate;
class CFloatingDockContainer; class CFloatingDockContainer;
struct FloatingDockContainerPrivate; struct FloatingDockContainerPrivate;
class CFloatingOverlay; class CFloatingDragPreview;
struct FloatingOverlayPrivate; struct FloatingDragPreviewPrivate;
class CDockingStateReader; class CDockingStateReader;
/** /**
@ -71,8 +71,8 @@ private:
friend class CFloatingDockContainer; friend class CFloatingDockContainer;
friend struct FloatingDockContainerPrivate; friend struct FloatingDockContainerPrivate;
friend class CDockWidget; friend class CDockWidget;
friend class CFloatingOverlay; friend class CFloatingDragPreview;
friend struct FloatingOverlayPrivate; friend struct FloatingDragPreviewPrivate;
protected: protected:
/** /**

View File

@ -86,8 +86,8 @@ private:
friend class CDockWidgetTab; friend class CDockWidgetTab;
friend struct DockAreaWidgetPrivate; friend struct DockAreaWidgetPrivate;
friend struct DockWidgetTabPrivate; friend struct DockWidgetTabPrivate;
friend class CFloatingOverlay; friend class CFloatingDragPreview;
friend struct FloatingOverlayPrivate; friend struct FloatingDragPreviewPrivate;
protected: protected:
/** /**

View File

@ -28,6 +28,7 @@
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include <FloatingDragPreview.h>
#include "ElidingLabel.h" #include "ElidingLabel.h"
#include "DockWidgetTab.h" #include "DockWidgetTab.h"
@ -46,7 +47,6 @@
#include "DockWidget.h" #include "DockWidget.h"
#include "DockAreaWidget.h" #include "DockAreaWidget.h"
#include "FloatingDockContainer.h" #include "FloatingDockContainer.h"
#include "FloatingOverlay.h"
#include "DockOverlay.h" #include "DockOverlay.h"
#include "DockManager.h" #include "DockManager.h"
#include "IconProvider.h" #include "IconProvider.h"
@ -151,8 +151,8 @@ struct DockWidgetTabPrivate
} }
else else
{ {
auto w = new CFloatingOverlay(Widget); auto w = new CFloatingDragPreview(Widget);
_this->connect(w, &CFloatingOverlay::draggingCanceled, [=]() _this->connect(w, &CFloatingDragPreview::draggingCanceled, [=]()
{ {
DragState = DraggingInactive; DragState = DraggingInactive;
}); });

View File

@ -1,15 +1,14 @@
//============================================================================ //============================================================================
/// \file FloatingOverlay.cpp /// \file FloatingDragPreview.cpp
/// \author Uwe Kindler /// \author Uwe Kindler
/// \date 26.11.2019 /// \date 26.11.2019
/// \brief Implementation of CFloatingOverlay /// \brief Implementation of CFloatingDragPreview
//============================================================================ //============================================================================
//============================================================================ //============================================================================
// INCLUDES // INCLUDES
//============================================================================ //============================================================================
#include "FloatingOverlay.h" #include "FloatingDragPreview.h"
#include <iostream> #include <iostream>
#include <QEvent> #include <QEvent>
@ -29,9 +28,9 @@ namespace ads
/** /**
* Private data class (pimpl) * Private data class (pimpl)
*/ */
struct FloatingOverlayPrivate struct FloatingDragPreviewPrivate
{ {
CFloatingOverlay *_this; CFloatingDragPreview *_this;
QWidget* Content; QWidget* Content;
CDockAreaWidget* ContentSourceArea = nullptr; CDockAreaWidget* ContentSourceArea = nullptr;
CDockContainerWidget* ContenSourceContainer = nullptr; CDockContainerWidget* ContenSourceContainer = nullptr;
@ -46,7 +45,7 @@ struct FloatingOverlayPrivate
/** /**
* Private data constructor * Private data constructor
*/ */
FloatingOverlayPrivate(CFloatingOverlay *_public); FloatingDragPreviewPrivate(CFloatingDragPreview *_public);
void updateDropOverlays(const QPoint &GlobalPos); void updateDropOverlays(const QPoint &GlobalPos);
void setHidden(bool Value) 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) if (!_this->isVisible() || !DockManager)
{ {
@ -163,16 +162,16 @@ void FloatingOverlayPrivate::updateDropOverlays(const QPoint &GlobalPos)
//============================================================================ //============================================================================
FloatingOverlayPrivate::FloatingOverlayPrivate(CFloatingOverlay *_public) : FloatingDragPreviewPrivate::FloatingDragPreviewPrivate(CFloatingDragPreview *_public) :
_this(_public) _this(_public)
{ {
} }
//============================================================================ //============================================================================
CFloatingOverlay::CFloatingOverlay(QWidget* Content, QWidget* parent) : CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
QWidget(parent), QWidget(parent),
d(new FloatingOverlayPrivate(this)) d(new FloatingDragPreviewPrivate(this))
{ {
d->Content = Content; d->Content = Content;
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
@ -211,8 +210,8 @@ CFloatingOverlay::CFloatingOverlay(QWidget* Content, QWidget* parent) :
//============================================================================ //============================================================================
CFloatingOverlay::CFloatingOverlay(CDockWidget* Content) CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content)
: CFloatingOverlay((QWidget*)Content, Content->dockManager()) : CFloatingDragPreview((QWidget*)Content, Content->dockManager())
{ {
d->DockManager = Content->dockManager(); d->DockManager = Content->dockManager();
if (Content->dockAreaWidget()->openDockWidgetsCount() == 1) if (Content->dockAreaWidget()->openDockWidgetsCount() == 1)
@ -225,8 +224,8 @@ CFloatingOverlay::CFloatingOverlay(CDockWidget* Content)
//============================================================================ //============================================================================
CFloatingOverlay::CFloatingOverlay(CDockAreaWidget* Content) CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content)
: CFloatingOverlay((QWidget*)Content, Content->dockManager()) : CFloatingDragPreview((QWidget*)Content, Content->dockManager())
{ {
d->DockManager = Content->dockManager(); d->DockManager = Content->dockManager();
d->ContentSourceArea = Content; d->ContentSourceArea = Content;
@ -236,14 +235,14 @@ CFloatingOverlay::CFloatingOverlay(CDockAreaWidget* Content)
//============================================================================ //============================================================================
CFloatingOverlay::~CFloatingOverlay() CFloatingDragPreview::~CFloatingDragPreview()
{ {
delete d; delete d;
} }
//============================================================================ //============================================================================
void CFloatingOverlay::moveFloating() void CFloatingDragPreview::moveFloating()
{ {
int BorderSize = (frameSize().width() - size().width()) / 2; int BorderSize = (frameSize().width() - size().width()) / 2;
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition 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) const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
{ {
Q_UNUSED(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); QWidget::moveEvent(event);
d->updateDropOverlays(QCursor::pos()); 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 DockDropArea = d->DockManager->dockAreaOverlay()->dropAreaUnderCursor();
auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor(); auto ContainerDropArea = d->DockManager->containerOverlay()->dropAreaUnderCursor();
bool DropPossible = (DockDropArea != InvalidDockWidgetArea) || (ContainerDropArea != InvalidDockWidgetArea); 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); Q_UNUSED(event);
if (d->Hidden) 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); Super::keyPressEvent(event);
if (event->key() == Qt::Key_Escape) 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) if (state != Qt::ApplicationActive)
{ {
@ -378,4 +377,4 @@ void CFloatingOverlay::onApplicationStateChanged(Qt::ApplicationState state)
} // namespace ads } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// EOF FloatingOverlay.cpp // EOF FloatingDragPreview.cpp

View File

@ -1,10 +1,10 @@
#ifndef FloatingOverlayH #ifndef FloatingDragPreviewH
#define FloatingOverlayH #define FloatingDragPreviewH
//============================================================================ //============================================================================
/// \file FloatingOverlay.h /// \file FloatingDragPreview.h
/// \author Uwe Kindler /// \author Uwe Kindler
/// \date 26.11.2019 /// \date 26.11.2019
/// \brief Declaration of CFloatingOverlay /// \brief Declaration of CFloatingDragPreview
//============================================================================ //============================================================================
//============================================================================ //============================================================================
@ -17,7 +17,7 @@ namespace ads
{ {
class CDockWidget; class CDockWidget;
class CDockAreaWidget; class CDockAreaWidget;
struct FloatingOverlayPrivate; struct FloatingDragPreviewPrivate;
/** /**
* A floating overlay is a temporary floating widget that is just used to * 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 * This widget is used as a placeholder for drag operations for non-opaque
* docking * docking
*/ */
class CFloatingOverlay : public QWidget, public IFloatingWidget class CFloatingDragPreview : public QWidget, public IFloatingWidget
{ {
Q_OBJECT Q_OBJECT
private: private:
FloatingOverlayPrivate* d; FloatingDragPreviewPrivate* d;
friend class FloatingOverlayPrivate; friend class FloatingDragPreviewPrivate;
private slots: private slots:
/**
* Cancel non opaque undocking if application becomes inactive
*/
void onApplicationStateChanged(Qt::ApplicationState state); void onApplicationStateChanged(Qt::ApplicationState state);
protected: protected:
@ -46,12 +49,15 @@ protected:
*/ */
virtual void paintEvent(QPaintEvent *e) override; virtual void paintEvent(QPaintEvent *e) override;
/**
* Cancel non opaque undocking with escape key
*/
virtual void keyPressEvent(QKeyEvent *event) override; virtual void keyPressEvent(QKeyEvent *event) override;
/** /**
* The content is a DockArea or a DockWidget * The content is a DockArea or a DockWidget
*/ */
CFloatingOverlay(QWidget* Content, QWidget* parent); CFloatingDragPreview(QWidget* Content, QWidget* parent);
public: public:
using Super = QWidget; using Super = QWidget;
@ -59,18 +65,18 @@ public:
/** /**
* Creates an instance for undocking the DockWidget in Content parameter * 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 * Creates an instance for undocking the DockArea given in Content
* parameters * parameters
*/ */
CFloatingOverlay(CDockAreaWidget* Content); CFloatingDragPreview(CDockAreaWidget* Content);
/** /**
* Delete private data * Delete private data
*/ */
~CFloatingOverlay(); ~CFloatingDragPreview();
public: // implements IFloatingWidget ----------------------------------------- public: // implements IFloatingWidget -----------------------------------------
@ -102,5 +108,5 @@ signals:
} // namespace ads } // namespace ads
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
#endif // FloatingOverlayH #endif // FloatingDragPreviewH

View File

@ -38,7 +38,7 @@ HEADERS += \
DockWidgetTab.h \ DockWidgetTab.h \
DockingStateReader.h \ DockingStateReader.h \
FloatingDockContainer.h \ FloatingDockContainer.h \
FloatingOverlay.h \ FloatingDragPreview.h \
DockOverlay.h \ DockOverlay.h \
DockSplitter.h \ DockSplitter.h \
DockAreaTitleBar.h \ DockAreaTitleBar.h \
@ -56,7 +56,7 @@ SOURCES += \
DockingStateReader.cpp \ DockingStateReader.cpp \
DockWidgetTab.cpp \ DockWidgetTab.cpp \
FloatingDockContainer.cpp \ FloatingDockContainer.cpp \
FloatingOverlay.cpp \ FloatingDragPreview.cpp \
DockOverlay.cpp \ DockOverlay.cpp \
DockSplitter.cpp \ DockSplitter.cpp \
DockAreaTitleBar.cpp \ DockAreaTitleBar.cpp \