From 34cb2ae91790fc65ca5c0f7b81bb928de22a32e5 Mon Sep 17 00:00:00 2001 From: Uwe Kindler Date: Tue, 25 Feb 2020 09:16:21 +0100 Subject: [PATCH] Fixed escape key press detection --- src/FloatingDragPreview.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/FloatingDragPreview.cpp b/src/FloatingDragPreview.cpp index 71adcaf..94948be 100644 --- a/src/FloatingDragPreview.cpp +++ b/src/FloatingDragPreview.cpp @@ -206,6 +206,11 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) : connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), SLOT(onApplicationStateChanged(Qt::ApplicationState))); + + // The focused object will receive key press events and therefore we + // install the event filter on it to receive escape key press for drag + // canceling + qApp->focusObject()->installEventFilter(this); } @@ -220,10 +225,6 @@ CFloatingDragPreview::CFloatingDragPreview(CDockWidget* Content) d->ContenSourceContainer = Content->dockContainer(); } 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,10 +236,6 @@ CFloatingDragPreview::CFloatingDragPreview(CDockAreaWidget* Content) d->ContentSourceArea = Content; d->ContenSourceContainer = Content->dockContainer(); 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); } @@ -395,7 +392,6 @@ bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event) - } // namespace ads //---------------------------------------------------------------------------