Properly implemented support for canceling non-opaque undocking on Linux

This commit is contained in:
Uwe Kindler
2019-12-16 11:45:18 +01:00
parent e085a29484
commit 056f04d408
3 changed files with 31 additions and 2 deletions

View File

@@ -206,6 +206,13 @@ 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
}
@@ -372,6 +379,23 @@ void CFloatingDragPreview::onApplicationStateChanged(Qt::ApplicationState state)
}
//============================================================================
bool CFloatingDragPreview::eventFilter(QObject *watched, QEvent *event)
{
if (event->type() == QEvent::KeyPress)
{
QKeyEvent* e = static_cast<QKeyEvent*>(event);
if (e->key() == Qt::Key_Escape)
{
d->Content->removeEventFilter(this);
d->cancelDragging();
}
}
return false;
}
} // namespace ads