2019-11-26 21:40:56 +08:00
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
/// \file FloatingDragPreview.cpp
|
2019-11-26 21:40:56 +08:00
|
|
|
/// \author Uwe Kindler
|
|
|
|
/// \date 26.11.2019
|
2019-12-16 18:18:22 +08:00
|
|
|
/// \brief Implementation of CFloatingDragPreview
|
2019-11-26 21:40:56 +08:00
|
|
|
//============================================================================
|
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
// INCLUDES
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
#include "FloatingDragPreview.h"
|
2019-11-26 21:40:56 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <QEvent>
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QPainter>
|
2019-12-16 18:10:59 +08:00
|
|
|
#include <QKeyEvent>
|
2019-11-26 21:40:56 +08:00
|
|
|
|
|
|
|
#include "DockWidget.h"
|
|
|
|
#include "DockAreaWidget.h"
|
|
|
|
#include "DockManager.h"
|
|
|
|
#include "DockContainerWidget.h"
|
|
|
|
#include "DockOverlay.h"
|
|
|
|
|
|
|
|
namespace ads
|
|
|
|
{
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private data class (pimpl)
|
|
|
|
*/
|
2019-12-16 18:18:22 +08:00
|
|
|
struct FloatingDragPreviewPrivate
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
2019-12-16 18:18:22 +08:00
|
|
|
CFloatingDragPreview *_this;
|
2019-11-26 21:40:56 +08:00
|
|
|
QWidget* Content;
|
2019-11-27 19:00:04 +08:00
|
|
|
CDockAreaWidget* ContentSourceArea = nullptr;
|
2019-11-26 21:40:56 +08:00
|
|
|
QPoint DragStartMousePosition;
|
|
|
|
CDockManager* DockManager;
|
|
|
|
CDockContainerWidget *DropContainer = nullptr;
|
|
|
|
qreal WindowOpacity;
|
|
|
|
bool Hidden = false;
|
2019-11-28 16:09:36 +08:00
|
|
|
QPixmap ContentPreviewPixmap;
|
2020-02-27 03:51:29 +08:00
|
|
|
bool Canceled = false;
|
2019-11-26 21:40:56 +08:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Private data constructor
|
|
|
|
*/
|
2019-12-16 18:18:22 +08:00
|
|
|
FloatingDragPreviewPrivate(CFloatingDragPreview *_public);
|
2019-11-26 21:40:56 +08:00
|
|
|
void updateDropOverlays(const QPoint &GlobalPos);
|
|
|
|
|
|
|
|
void setHidden(bool Value)
|
|
|
|
{
|
|
|
|
Hidden = Value;
|
|
|
|
_this->update();
|
|
|
|
}
|
2019-12-16 18:10:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Cancel dragging and emit the draggingCanceled event
|
|
|
|
*/
|
|
|
|
void cancelDragging()
|
|
|
|
{
|
2020-02-27 03:51:29 +08:00
|
|
|
Canceled = true;
|
2019-12-16 18:10:59 +08:00
|
|
|
emit _this->draggingCanceled();
|
|
|
|
DockManager->containerOverlay()->hideOverlay();
|
|
|
|
DockManager->dockAreaOverlay()->hideOverlay();
|
|
|
|
_this->close();
|
|
|
|
}
|
2020-04-27 20:00:37 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Creates the real floating widget in case the mouse is released outside
|
|
|
|
* outside of any drop area
|
|
|
|
*/
|
|
|
|
void createFloatingWidget();
|
2019-11-26 21:40:56 +08:00
|
|
|
};
|
|
|
|
// struct LedArrayPanelPrivate
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
void FloatingDragPreviewPrivate::updateDropOverlays(const QPoint &GlobalPos)
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
|
|
|
if (!_this->isVisible() || !DockManager)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto Containers = DockManager->dockContainers();
|
|
|
|
CDockContainerWidget *TopContainer = nullptr;
|
|
|
|
for (auto ContainerWidget : Containers)
|
|
|
|
{
|
|
|
|
if (!ContainerWidget->isVisible())
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPoint MappedPos = ContainerWidget->mapFromGlobal(GlobalPos);
|
|
|
|
if (ContainerWidget->rect().contains(MappedPos))
|
|
|
|
{
|
|
|
|
if (!TopContainer || ContainerWidget->isInFrontOf(TopContainer))
|
|
|
|
{
|
|
|
|
TopContainer = ContainerWidget;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DropContainer = TopContainer;
|
|
|
|
auto ContainerOverlay = DockManager->containerOverlay();
|
|
|
|
auto DockAreaOverlay = DockManager->dockAreaOverlay();
|
2019-11-27 19:00:04 +08:00
|
|
|
auto DockDropArea = DockAreaOverlay->dropAreaUnderCursor();
|
|
|
|
auto ContainerDropArea = ContainerOverlay->dropAreaUnderCursor();
|
2019-11-26 21:40:56 +08:00
|
|
|
|
|
|
|
if (!TopContainer)
|
|
|
|
{
|
|
|
|
ContainerOverlay->hideOverlay();
|
|
|
|
DockAreaOverlay->hideOverlay();
|
2020-06-11 14:06:37 +08:00
|
|
|
if (CDockManager::testConfigFlag(CDockManager::DragPreviewIsDynamic))
|
2019-11-28 16:09:36 +08:00
|
|
|
{
|
|
|
|
setHidden(false);
|
|
|
|
}
|
2019-11-26 21:40:56 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int VisibleDockAreas = TopContainer->visibleDockAreaCount();
|
|
|
|
ContainerOverlay->setAllowedAreas(
|
|
|
|
VisibleDockAreas > 1 ? OuterDockAreas : AllDockAreas);
|
|
|
|
auto DockArea = TopContainer->dockAreaAt(GlobalPos);
|
2020-05-11 15:03:28 +08:00
|
|
|
if (DockArea && DockArea->isVisible() && VisibleDockAreas >= 0 && DockArea != ContentSourceArea)
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
|
|
|
DockAreaOverlay->enableDropPreview(true);
|
|
|
|
DockAreaOverlay->setAllowedAreas(
|
2020-02-02 22:56:31 +08:00
|
|
|
(VisibleDockAreas == 1) ? NoDockWidgetArea : DockArea->allowedAreas());
|
2019-11-26 21:40:56 +08:00
|
|
|
DockWidgetArea Area = DockAreaOverlay->showOverlay(DockArea);
|
|
|
|
|
|
|
|
// A CenterDockWidgetArea for the dockAreaOverlay() indicates that
|
|
|
|
// the mouse is in the title bar. If the ContainerArea is valid
|
|
|
|
// then we ignore the dock area of the dockAreaOverlay() and disable
|
|
|
|
// the drop preview
|
2020-05-11 15:03:28 +08:00
|
|
|
if ((Area == CenterDockWidgetArea) && (ContainerDropArea != InvalidDockWidgetArea))
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
|
|
|
DockAreaOverlay->enableDropPreview(false);
|
|
|
|
ContainerOverlay->enableDropPreview(true);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ContainerOverlay->enableDropPreview(InvalidDockWidgetArea == Area);
|
|
|
|
}
|
2020-05-11 15:03:28 +08:00
|
|
|
ContainerOverlay->showOverlay(TopContainer);
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DockAreaOverlay->hideOverlay();
|
2020-05-11 15:03:28 +08:00
|
|
|
// If there is only one single visible dock area in a container, then
|
|
|
|
// it does not make sense to show a dock overlay because the dock area
|
|
|
|
// would be removed and inserted at the same position
|
|
|
|
if (VisibleDockAreas <= 1)
|
|
|
|
{
|
|
|
|
ContainerOverlay->hideOverlay();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ContainerOverlay->showOverlay(TopContainer);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-27 19:00:04 +08:00
|
|
|
if (DockArea == ContentSourceArea && InvalidDockWidgetArea == ContainerDropArea)
|
|
|
|
{
|
|
|
|
DropContainer = nullptr;
|
|
|
|
}
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
|
|
|
|
2020-06-11 14:06:37 +08:00
|
|
|
if (CDockManager::testConfigFlag(CDockManager::DragPreviewIsDynamic))
|
2019-11-28 16:09:36 +08:00
|
|
|
{
|
|
|
|
setHidden(DockDropArea != InvalidDockWidgetArea || ContainerDropArea != InvalidDockWidgetArea);
|
|
|
|
}
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
FloatingDragPreviewPrivate::FloatingDragPreviewPrivate(CFloatingDragPreview *_public) :
|
2019-11-26 21:40:56 +08:00
|
|
|
_this(_public)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-27 20:00:37 +08:00
|
|
|
|
|
|
|
//============================================================================
|
|
|
|
void FloatingDragPreviewPrivate::createFloatingWidget()
|
|
|
|
{
|
|
|
|
CDockWidget* DockWidget = qobject_cast<CDockWidget*>(Content);
|
|
|
|
CDockAreaWidget* DockArea = qobject_cast<CDockAreaWidget*>(Content);
|
|
|
|
|
|
|
|
CFloatingDockContainer* FloatingWidget = nullptr;
|
|
|
|
|
|
|
|
if (DockWidget && DockWidget->features().testFlag(CDockWidget::DockWidgetFloatable))
|
|
|
|
{
|
|
|
|
FloatingWidget = new CFloatingDockContainer(DockWidget);
|
|
|
|
}
|
|
|
|
else if (DockArea && DockArea->features().testFlag(CDockWidget::DockWidgetFloatable))
|
|
|
|
{
|
|
|
|
FloatingWidget = new CFloatingDockContainer(DockArea);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FloatingWidget)
|
|
|
|
{
|
|
|
|
FloatingWidget->setGeometry(_this->geometry());
|
|
|
|
FloatingWidget->show();
|
2020-06-11 14:06:37 +08:00
|
|
|
if (!CDockManager::testConfigFlag(CDockManager::DragPreviewHasWindowFrame))
|
2020-04-27 20:00:37 +08:00
|
|
|
{
|
|
|
|
QApplication::processEvents();
|
|
|
|
int FrameHeight = FloatingWidget->frameGeometry().height() - FloatingWidget->geometry().height();
|
|
|
|
QRect FixedGeometry = _this->geometry();
|
|
|
|
FixedGeometry.adjust(0, FrameHeight, 0, 0);
|
|
|
|
FloatingWidget->setGeometry(FixedGeometry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-11-26 21:40:56 +08:00
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
|
2019-11-28 16:09:36 +08:00
|
|
|
QWidget(parent),
|
2019-12-16 18:18:22 +08:00
|
|
|
d(new FloatingDragPreviewPrivate(this))
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
|
|
|
d->Content = Content;
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose);
|
2020-06-11 14:06:37 +08:00
|
|
|
if (CDockManager::testConfigFlag(CDockManager::DragPreviewHasWindowFrame))
|
2019-11-28 16:09:36 +08:00
|
|
|
{
|
|
|
|
setWindowFlags(
|
|
|
|
Qt::Window | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
setWindowFlags(Qt::Tool | Qt::FramelessWindowHint);
|
|
|
|
setAttribute(Qt::WA_NoSystemBackground);
|
|
|
|
setAttribute(Qt::WA_TranslucentBackground);
|
|
|
|
}
|
2019-11-26 21:40:56 +08:00
|
|
|
|
2019-11-28 20:35:58 +08:00
|
|
|
#ifdef Q_OS_LINUX
|
|
|
|
auto Flags = windowFlags();
|
|
|
|
Flags |= Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint;
|
|
|
|
setWindowFlags(Flags);
|
|
|
|
#endif
|
|
|
|
|
2019-11-28 16:09:36 +08:00
|
|
|
setWindowOpacity(0.6);
|
|
|
|
|
|
|
|
// Create a static image of the widget that should get undocked
|
|
|
|
// This is like some kind preview image like it is uses in drag and drop
|
|
|
|
// operations
|
2020-06-11 14:06:37 +08:00
|
|
|
if (CDockManager::testConfigFlag(CDockManager::DragPreviewShowsContentPixmap))
|
2019-11-28 16:09:36 +08:00
|
|
|
{
|
|
|
|
d->ContentPreviewPixmap = QPixmap(Content->size());
|
|
|
|
Content->render(&d->ContentPreviewPixmap);
|
|
|
|
}
|
2019-12-16 18:10:59 +08:00
|
|
|
|
|
|
|
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
|
|
|
SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
2020-02-25 16:16:21 +08:00
|
|
|
|
2020-02-27 03:51:29 +08:00
|
|
|
// The only safe way to receive escape key presses is to install an event
|
|
|
|
// filter for the application object
|
|
|
|
qApp->installEventFilter(this);
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content)
|
|
|
|
: CFloatingDragPreview((QWidget*)Content, Content->dockManager())
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
|
|
|
d->DockManager = Content->dockManager();
|
2019-11-27 19:00:04 +08:00
|
|
|
if (Content->dockAreaWidget()->openDockWidgetsCount() == 1)
|
|
|
|
{
|
|
|
|
d->ContentSourceArea = Content->dockAreaWidget();
|
|
|
|
}
|
2019-11-28 16:09:36 +08:00
|
|
|
setWindowTitle(Content->windowTitle());
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content)
|
|
|
|
: CFloatingDragPreview((QWidget*)Content, Content->dockManager())
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
|
|
|
d->DockManager = Content->dockManager();
|
2019-11-27 19:00:04 +08:00
|
|
|
d->ContentSourceArea = Content;
|
2019-11-28 16:09:36 +08:00
|
|
|
setWindowTitle(Content->currentDockWidget()->windowTitle());
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
CFloatingDragPreview::~CFloatingDragPreview()
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
void CFloatingDragPreview::moveFloating()
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
|
|
|
int BorderSize = (frameSize().width() - size().width()) / 2;
|
|
|
|
const QPoint moveToPos = QCursor::pos() - d->DragStartMousePosition
|
|
|
|
- QPoint(BorderSize, 0);
|
|
|
|
move(moveToPos);
|
2020-05-23 01:43:50 +08:00
|
|
|
d->updateDropOverlays(QCursor::pos());
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
void CFloatingDragPreview::startFloating(const QPoint &DragStartMousePos,
|
2019-11-26 21:40:56 +08:00
|
|
|
const QSize &Size, eDragState DragState, QWidget *MouseEventHandler)
|
|
|
|
{
|
|
|
|
Q_UNUSED(MouseEventHandler)
|
|
|
|
Q_UNUSED(DragState)
|
|
|
|
resize(Size);
|
|
|
|
d->DragStartMousePosition = DragStartMousePos;
|
|
|
|
moveFloating();
|
|
|
|
show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
void CFloatingDragPreview::finishDragging()
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
2019-12-16 18:18:22 +08:00
|
|
|
ADS_PRINT("CFloatingDragPreview::finishDragging");
|
2020-03-12 17:23:41 +08:00
|
|
|
auto DockDropArea = d->DockManager->dockAreaOverlay()->visibleDropAreaUnderCursor();
|
|
|
|
auto ContainerDropArea = d->DockManager->containerOverlay()->visibleDropAreaUnderCursor();
|
2020-04-27 20:00:37 +08:00
|
|
|
if (!d->DropContainer)
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
2020-04-27 20:00:37 +08:00
|
|
|
d->createFloatingWidget();
|
2020-03-12 17:23:41 +08:00
|
|
|
}
|
2020-04-27 20:00:37 +08:00
|
|
|
else if (DockDropArea != InvalidDockWidgetArea)
|
2020-03-12 17:23:41 +08:00
|
|
|
{
|
2020-04-27 20:00:37 +08:00
|
|
|
d->DropContainer->dropWidget(d->Content, DockDropArea, d->DropContainer->dockAreaAt(QCursor::pos()));
|
2019-12-13 18:52:50 +08:00
|
|
|
}
|
2020-04-27 20:00:37 +08:00
|
|
|
else if (ContainerDropArea != InvalidDockWidgetArea)
|
2019-12-13 18:52:50 +08:00
|
|
|
{
|
2020-04-27 20:00:37 +08:00
|
|
|
// If there is only one single dock area, and we drop into the center
|
|
|
|
// then we tabify the dropped widget into the only visible dock area
|
|
|
|
if (d->DropContainer->visibleDockAreaCount() <= 1 && CenterDockWidgetArea == ContainerDropArea)
|
2019-11-27 19:00:04 +08:00
|
|
|
{
|
2020-04-27 20:00:37 +08:00
|
|
|
d->DropContainer->dropWidget(d->Content, ContainerDropArea, d->DropContainer->dockAreaAt(QCursor::pos()));
|
2019-12-13 18:52:50 +08:00
|
|
|
}
|
2020-04-27 20:00:37 +08:00
|
|
|
else
|
2019-12-13 18:52:50 +08:00
|
|
|
{
|
2020-04-27 20:00:37 +08:00
|
|
|
d->DropContainer->dropWidget(d->Content, ContainerDropArea, nullptr);
|
2019-11-27 19:00:04 +08:00
|
|
|
}
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
2020-05-04 21:14:35 +08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
d->createFloatingWidget();
|
|
|
|
}
|
2019-11-26 21:40:56 +08:00
|
|
|
|
2019-12-13 18:52:50 +08:00
|
|
|
this->close();
|
|
|
|
d->DockManager->containerOverlay()->hideOverlay();
|
|
|
|
d->DockManager->dockAreaOverlay()->hideOverlay();
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
void CFloatingDragPreview::paintEvent(QPaintEvent* event)
|
2019-11-26 21:40:56 +08:00
|
|
|
{
|
|
|
|
Q_UNUSED(event);
|
|
|
|
if (d->Hidden)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
QPainter painter(this);
|
2020-06-11 14:06:37 +08:00
|
|
|
if (CDockManager::testConfigFlag(CDockManager::DragPreviewShowsContentPixmap))
|
2019-11-28 16:09:36 +08:00
|
|
|
{
|
|
|
|
painter.drawPixmap(QPoint(0, 0), d->ContentPreviewPixmap);
|
|
|
|
}
|
|
|
|
|
2019-12-16 15:06:38 +08:00
|
|
|
// If we do not have a window frame then we paint a QRubberBand like
|
2019-11-28 17:32:39 +08:00
|
|
|
// frameless window
|
2020-06-11 14:06:37 +08:00
|
|
|
if (!CDockManager::testConfigFlag(CDockManager::DragPreviewHasWindowFrame))
|
2019-11-28 16:09:36 +08:00
|
|
|
{
|
|
|
|
QColor Color = palette().color(QPalette::Active, QPalette::Highlight);
|
|
|
|
QPen Pen = painter.pen();
|
|
|
|
Pen.setColor(Color.darker(120));
|
|
|
|
Pen.setStyle(Qt::SolidLine);
|
|
|
|
Pen.setWidth(1);
|
|
|
|
Pen.setCosmetic(true);
|
|
|
|
painter.setPen(Pen);
|
|
|
|
Color = Color.lighter(130);
|
|
|
|
Color.setAlpha(64);
|
|
|
|
painter.setBrush(Color);
|
|
|
|
painter.drawRect(rect().adjusted(0, 0, -1, -1));
|
|
|
|
}
|
2019-11-26 21:40:56 +08:00
|
|
|
}
|
|
|
|
|
2019-12-16 18:10:59 +08:00
|
|
|
//============================================================================
|
2019-12-16 18:18:22 +08:00
|
|
|
void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
|
2019-12-16 18:10:59 +08:00
|
|
|
{
|
|
|
|
if (state != Qt::ApplicationActive)
|
|
|
|
{
|
|
|
|
disconnect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
|
|
|
|
this, SLOT(onApplicationStateChanged(Qt::ApplicationState)));
|
|
|
|
d->cancelDragging();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-16 18:45:18 +08:00
|
|
|
//============================================================================
|
|
|
|
bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
|
|
|
|
{
|
2019-12-16 18:47:55 +08:00
|
|
|
Q_UNUSED(watched);
|
2020-02-27 03:51:29 +08:00
|
|
|
if (!d->Canceled && event->type() == QEvent::KeyPress)
|
2019-12-16 18:45:18 +08:00
|
|
|
{
|
|
|
|
QKeyEvent* e = static_cast<QKeyEvent*>(event);
|
|
|
|
if (e->key() == Qt::Key_Escape)
|
|
|
|
{
|
2020-02-17 15:08:25 +08:00
|
|
|
watched->removeEventFilter(this);
|
2019-12-16 18:45:18 +08:00
|
|
|
d->cancelDragging();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-12-16 18:10:59 +08:00
|
|
|
|
2019-11-26 21:40:56 +08:00
|
|
|
} // namespace ads
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
2019-12-16 18:18:22 +08:00
|
|
|
// EOF FloatingDragPreview.cpp
|