Fixed drag canceling via ESC key

This commit is contained in:
Uwe Kindler 2020-02-17 08:08:25 +01:00
parent d4a18003d9
commit 2b9377b5ee

View File

@ -206,10 +206,6 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) :
connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)),
SLOT(onApplicationStateChanged(Qt::ApplicationState))); SLOT(onApplicationStateChanged(Qt::ApplicationState)));
// We need to install an event filter for the given Content
// widget to receive the escape key press
Content->installEventFilter(this);
} }
@ -224,6 +220,10 @@ CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content)
d->ContenSourceContainer = Content->dockContainer(); d->ContenSourceContainer = Content->dockContainer();
} }
setWindowTitle(Content->windowTitle()); setWindowTitle(Content->windowTitle());
// We need to install an event filter for the given Content
// widget to receive the escape key press
Content->dockAreaWidget()->installEventFilter(this);
} }
@ -235,6 +235,10 @@ CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content)
d->ContentSourceArea = Content; d->ContentSourceArea = Content;
d->ContenSourceContainer = Content->dockContainer(); d->ContenSourceContainer = Content->dockContainer();
setWindowTitle(Content->currentDockWidget()->windowTitle()); setWindowTitle(Content->currentDockWidget()->windowTitle());
// We need to install an event filter for the given Content
// widget to receive the escape key press
Content->installEventFilter(this);
} }
@ -381,7 +385,7 @@ bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
QKeyEvent* e = static_cast<QKeyEvent*>(event); QKeyEvent* e = static_cast<QKeyEvent*>(event);
if (e->key() == Qt::Key_Escape) if (e->key() == Qt::Key_Escape)
{ {
d->Content->removeEventFilter(this); watched->removeEventFilter(this);
d->cancelDragging(); d->cancelDragging();
} }
} }