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.
This commit is contained in:
Rodrigo Oliva 2020-02-07 23:07:07 +01:00 committed by GitHub
parent 8a16230213
commit a4ef161f4f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 23 deletions

View File

@ -207,12 +207,9 @@ 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)));
#ifdef Q_OS_LINUX // We need to install an event filter for the given Content
// In Windows this widget directly receives the escape key press events // widget to receive the escape key press
// in Linux we need to install an event filter for the given Content Content->installEventFilter(this);
// widget to receive the escape key press
Content->installEventFilter(this);
#endif
} }
@ -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) void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
{ {

View File

@ -49,11 +49,6 @@ protected:
*/ */
virtual void paintEvent(QPaintEvent *e) override; 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 * The content is a DockArea or a DockWidget
*/ */