QWidgetWindow: Prioritize keyboard grabber over popup for key events.

Fix the inline editor of the QMenuBar in Qt Designer not working
due to the key events being sent to the QMenu which is open
at that time.

Task-number: QTBUG-31059
Change-Id: Ic96bc119d0d2566d8f8d6ee62858445a70a447b7
Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
This commit is contained in:
Friedemann Kleint 2013-05-08 14:14:04 +02:00 committed by The Qt Project
parent 2e82e474d6
commit 38dc6ccca0

View File

@ -490,14 +490,12 @@ void QWidgetWindow::handleKeyEvent(QKeyEvent *event)
if (QApplicationPrivate::instance()->modalState() && !qt_try_modal(m_widget, event->type()))
return;
QObject *receiver = 0;
if (QApplicationPrivate::inPopupMode()) {
QObject *receiver = QWidget::keyboardGrabber();
if (!receiver && QApplicationPrivate::inPopupMode()) {
QWidget *popup = QApplication::activePopupWidget();
QWidget *popupFocusWidget = popup->focusWidget();
receiver = popupFocusWidget ? popupFocusWidget : popup;
}
if (!receiver)
receiver = QWidget::keyboardGrabber();
if (!receiver)
receiver = focusObject();
QGuiApplication::sendSpontaneousEvent(receiver, event);