2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2020 Uwe Kindler
|
2023-01-04 08:19:47 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-2.1-or-later OR GPL-3.0-or-later
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include "floatingdockcontainer.h"
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
|
|
namespace ADS {
|
|
|
|
|
|
|
|
|
|
class DockWidget;
|
|
|
|
|
class DockAreaWidget;
|
2020-03-03 16:55:33 +01:00
|
|
|
class FloatingDragPreviewPrivate;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A floating overlay is a temporary floating widget that is just used to
|
|
|
|
|
* indicate the floating widget movement.
|
|
|
|
|
* This widget is used as a placeholder for drag operations for non-opaque
|
|
|
|
|
* docking
|
|
|
|
|
*/
|
|
|
|
|
class FloatingDragPreview : public QWidget, public AbstractFloatingWidget
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
private:
|
|
|
|
|
FloatingDragPreviewPrivate *d;
|
2020-03-03 16:55:33 +01:00
|
|
|
friend class FloatingDragPreviewPrivate;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Cancel non opaque undocking if application becomes inactive
|
|
|
|
|
*/
|
|
|
|
|
void onApplicationStateChanged(Qt::ApplicationState state);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
/**
|
|
|
|
|
* Cares about painting the
|
|
|
|
|
*/
|
2020-06-14 14:41:00 +02:00
|
|
|
void paintEvent(QPaintEvent *event) override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The content is a DockArea or a DockWidget
|
|
|
|
|
*/
|
|
|
|
|
FloatingDragPreview(QWidget *content, QWidget *parent);
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
using Super = QWidget;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an instance for undocking the DockWidget in Content parameter
|
|
|
|
|
*/
|
|
|
|
|
FloatingDragPreview(DockWidget *content);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an instance for undocking the DockArea given in Content
|
|
|
|
|
* parameters
|
|
|
|
|
*/
|
|
|
|
|
FloatingDragPreview(DockAreaWidget *content);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Delete private data
|
|
|
|
|
*/
|
|
|
|
|
~FloatingDragPreview() override;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* We filter the events of the assigned content widget to receive
|
|
|
|
|
* escape key presses for canceling the drag operation
|
|
|
|
|
*/
|
2020-06-14 14:41:00 +02:00
|
|
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
public: // implements AbstractFloatingWidget
|
2020-06-14 14:41:00 +02:00
|
|
|
void startFloating(const QPoint &dragStartMousePos,
|
|
|
|
|
const QSize &size,
|
|
|
|
|
eDragState dragState,
|
|
|
|
|
QWidget *mouseEventHandler) override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Moves the widget to a new position relative to the position given when
|
|
|
|
|
* startFloating() was called
|
|
|
|
|
*/
|
2020-06-14 14:41:00 +02:00
|
|
|
void moveFloating() override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Finishes dragging.
|
|
|
|
|
* Hides the dock overlays and executes the real undocking and docking
|
|
|
|
|
* of the assigned Content widget
|
|
|
|
|
*/
|
2020-06-14 14:41:00 +02:00
|
|
|
void finishDragging() override;
|
2020-01-24 17:13:32 +01:00
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
/**
|
|
|
|
|
* This signal is emitted, if dragging has been canceled by escape key
|
|
|
|
|
* or by active application switching via task manager
|
|
|
|
|
*/
|
|
|
|
|
void draggingCanceled();
|
|
|
|
|
}; // class FloatingDragPreview
|
|
|
|
|
|
|
|
|
|
} // namespace ADS
|