Properly implemented support for canceling non-opaque undocking on Linux
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user