From a4ef161f4f68d5182f4002f87778fed4322fbfe7 Mon Sep 17 00:00:00 2001 From: Rodrigo Oliva Date: Fri, 7 Feb 2020 23:07:07 +0100 Subject: [PATCH] Fix using escape button when dragging non-opaque preview to cancel drag operation (#114) * Added missing overrides. * Escape button to cancel dragging was not working in Windows either. Using the event filter added for Linux works. --- src/FloatingDragPreview.cpp | 21 +++------------------ src/FloatingDragPreview.h | 5 ----- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/FloatingDragPreview.cpp b/src/FloatingDragPreview.cpp index e34cce12..14346df2 100644 --- a/src/FloatingDragPreview.cpp +++ b/src/FloatingDragPreview.cpp @@ -207,12 +207,9 @@ CFloatingDragPreview::CFloatingDragPreview(QWidget* Content, QWidget* parent) : connect(qApp, SIGNAL(applicationStateChanged(Qt::ApplicationState)), SLOT(onApplicationStateChanged(Qt::ApplicationState))); -#ifdef Q_OS_LINUX - // In Windows this widget directly receives the escape key press events - // in Linux we need to install an event filter for the given Content - // widget to receive the escape key press - Content->installEventFilter(this); -#endif + // We need to install an event filter for the given Content + // widget to receive the escape key press + Content->installEventFilter(this); } @@ -355,18 +352,6 @@ void CFloatingDragPreview::paintEvent(QPaintEvent* event) } } - -//============================================================================ -void CFloatingDragPreview::keyPressEvent(QKeyEvent *event) -{ - Super::keyPressEvent(event); - if (event->key() == Qt::Key_Escape) - { - d->cancelDragging(); - } -} - - //============================================================================ void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state) { diff --git a/src/FloatingDragPreview.h b/src/FloatingDragPreview.h index cfcb3591..dca7083b 100644 --- a/src/FloatingDragPreview.h +++ b/src/FloatingDragPreview.h @@ -49,11 +49,6 @@ private slots: */ virtual void paintEvent(QPaintEvent *e) override; - /** - * Cancel non opaque undocking with escape key - */ - virtual void keyPressEvent(QKeyEvent *event) override; - /** * The content is a DockArea or a DockWidget */