2019-12-16 18:18:22 +08:00
|
|
|
#ifndef FloatingDragPreviewH
|
|
|
|
#define FloatingDragPreviewH
|
2019-11-26 21:40:56 +08:00
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
/// \file FloatingDragPreview.h
|
2019-11-26 21:40:56 +08:00
|
|
|
/// \author Uwe Kindler
|
|
|
|
/// \date 26.11.2019
|
2019-12-16 18:18:22 +08:00
|
|
|
/// \brief Declaration of CFloatingDragPreview
|
2019-11-26 21:40:56 +08:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// INCLUDES
|
|
|
|
//============================================================================
|
2019-11-28 16:09:36 +08:00
|
|
|
#include <QWidget>
|
2019-11-26 21:40:56 +08:00
|
|
|
#include "FloatingDockContainer.h"
|
|
|
|
|
|
|
|
namespace ads
|
|
|
|
{
|
|
|
|
class CDockWidget;
|
|
|
|
class CDockAreaWidget;
|
2019-12-16 18:18:22 +08:00
|
|
|
struct FloatingDragPreviewPrivate;
|
2019-11-26 21:40:56 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A floating overlay is a temporary floating widget that is just used to
|
2019-12-16 15:06:38 +08:00
|
|
|
* indicate the floating widget movement.
|
|
|
|
* This widget is used as a placeholder for drag operations for non-opaque
|
|
|
|
* docking
|
2019-11-26 21:40:56 +08:00
|
|
|
*/
|
2019-12-16 18:18:22 +08:00
|
|
|
class CFloatingDragPreview : public QWidget, public IFloatingWidget
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
2019-12-16 15:41:15 +08:00
|
|
|
Q_OBJECT
|
2019-11-26 21:40:56 +08:00
|
|
|
private:
|
2019-12-16 18:18:22 +08:00
|
|
|
FloatingDragPreviewPrivate* d;
|
2020-01-12 22:12:47 +08:00
|
|
|
friend struct FloatingDragPreviewPrivate;
|
2019-11-26 21:40:56 +08:00
|
|
|
|
2021-01-22 13:18:34 +08:00
|
|
|
private Q_SLOTS:
|
2019-12-16 18:18:22 +08:00
|
|
|
/**
|
|
|
|
* Cancel non opaque undocking if application becomes inactive
|
|
|
|
*/
|
2019-12-16 18:10:59 +08:00
|
|
|
void onApplicationStateChanged(Qt::ApplicationState state);
|
|
|
|
|
2019-11-26 21:40:56 +08:00
|
|
|
protected:
|
2019-12-16 15:06:38 +08:00
|
|
|
/**
|
|
|
|
* Cares about painting the
|
|
|
|
*/
|
2019-11-26 21:40:56 +08:00
|
|
|
virtual void paintEvent(QPaintEvent *e) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The content is a DockArea or a DockWidget
|
|
|
|
*/
|
2019-12-16 18:18:22 +08:00
|
|
|
CFloatingDragPreview(QWidget* Content, QWidget* parent);
|
2019-11-26 21:40:56 +08:00
|
|
|
|
|
|
|
public:
|
2019-11-28 16:09:36 +08:00
|
|
|
using Super = QWidget;
|
2019-12-16 15:06:38 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an instance for undocking the DockWidget in Content parameter
|
|
|
|
*/
|
2019-12-16 18:18:22 +08:00
|
|
|
CFloatingDragPreview(CDockWidget* Content);
|
2019-12-16 15:06:38 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates an instance for undocking the DockArea given in Content
|
|
|
|
* parameters
|
|
|
|
*/
|
2019-12-16 18:18:22 +08:00
|
|
|
CFloatingDragPreview(CDockAreaWidget* Content);
|
2019-11-26 21:40:56 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Delete private data
|
|
|
|
*/
|
2019-12-16 18:18:22 +08:00
|
|
|
~CFloatingDragPreview();
|
2019-11-26 21:40:56 +08:00
|
|
|
|
2019-12-16 18:45:18 +08:00
|
|
|
/**
|
|
|
|
* We filter the events of the assigned content widget to receive
|
|
|
|
* escape key presses for canceling the drag operation
|
|
|
|
*/
|
|
|
|
virtual bool eventFilter(QObject *watched, QEvent *event) override;
|
|
|
|
|
2019-12-16 15:06:38 +08:00
|
|
|
|
|
|
|
public: // implements IFloatingWidget -----------------------------------------
|
2019-11-26 21:40:56 +08:00
|
|
|
virtual void startFloating(const QPoint& DragStartMousePos, const QSize& Size,
|
|
|
|
eDragState DragState, QWidget* MouseEventHandler) override;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Moves the widget to a new position relative to the position given when
|
|
|
|
* startFloating() was called
|
|
|
|
*/
|
|
|
|
virtual void moveFloating() override;
|
2019-12-13 18:52:50 +08:00
|
|
|
|
|
|
|
/**
|
2019-12-16 15:06:38 +08:00
|
|
|
* Finishes dragging.
|
|
|
|
* Hides the dock overlays and executes the real undocking and docking
|
|
|
|
* of the assigned Content widget
|
2019-12-13 18:52:50 +08:00
|
|
|
*/
|
|
|
|
virtual void finishDragging() override;
|
2019-12-16 18:10:59 +08:00
|
|
|
|
2022-09-05 17:29:42 +08:00
|
|
|
/**
|
|
|
|
* Cleanup overlay container if the dragged widget has one
|
|
|
|
*/
|
|
|
|
void cleanupOverlayContainerWidget();
|
|
|
|
|
2021-01-22 13:18:34 +08:00
|
|
|
Q_SIGNALS:
|
2019-12-16 18:10:59 +08:00
|
|
|
/**
|
|
|
|
* This signal is emitted, if dragging has been canceled by escape key
|
|
|
|
* or by active application switching via task manager
|
|
|
|
*/
|
|
|
|
void draggingCanceled();
|
2019-11-26 21:40:56 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace ads
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
2019-12-16 18:18:22 +08:00
|
|
|
#endif // FloatingDragPreviewH
|
2019-11-26 21:40:56 +08:00
|
|
|
|