diff options
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 7 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 12 | ||||
-rw-r--r-- | src/gui/widgets/qmainwindow.cpp | 11 |
3 files changed, 23 insertions, 7 deletions
diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 4c008fb..42faf98 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1072,9 +1072,10 @@ void QApplication::symbianHandleCommand(int command) default: if (command >= SOFTKEYSTART && command <= SOFTKEYEND) { int index= command-SOFTKEYSTART; - QWidget* focused = QApplication::focusWidget(); - const QList<QAction*>& softKeys = focused->softKeys(); - Q_ASSERT(index<softKeys.count()); + QWidget *focused = QApplication::focusWidget(); + QWidget *softKeySource = focused ? focused : QApplication::activeWindow(); + const QList<QAction*>& softKeys = softKeySource->softKeys(); + Q_ASSERT(index < softKeys.count()); softKeys.at(index)->activate(QAction::Trigger); } else diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index a83a79f..8d2569e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5781,7 +5781,6 @@ bool QWidget::hasFocus() const void QWidget::setFocus(Qt::FocusReason reason) { Q_D(QWidget); - d->setSoftKeys_sys(softKeys()); if (!isEnabled()) return; @@ -7733,6 +7732,7 @@ bool QWidget::event(QEvent *event) #if defined(Q_WS_WIN) QInputContextPrivate::updateImeStatus(this, true); #endif + d->setSoftKeys_sys(softKeys()); focusInEvent((QFocusEvent*)event); break; @@ -7885,6 +7885,10 @@ bool QWidget::event(QEvent *event) if (w && w->isVisible() && !w->isWindow()) QApplication::sendEvent(w, event); } + + if (isWindow() && isActiveWindow()) + d->setSoftKeys_sys(softKeys()); + break; } case QEvent::LanguageChange: @@ -11617,7 +11621,8 @@ void QWidget::setSoftKey(QAction *softKey) d->softKeys.clear(); if (softKey) d->softKeys.append(softKey); - if (QApplication::focusWidget() == this) + if ((!QApplication::focusWidget() && this == QApplication::activeWindow()) + || QApplication::focusWidget() == this) d->setSoftKeys_sys(this->softKeys()); } @@ -11634,7 +11639,8 @@ void QWidget::setSoftKeys(const QList<QAction*> &softKeys) d->softKeys.clear(); d->softKeys = softKeys; - if ((QApplication::focusWidget() == this) || (QApplication::focusWidget()==0)) + if ((!QApplication::focusWidget() && this == QApplication::activeWindow()) + || QApplication::focusWidget() == this) d->setSoftKeys_sys(this->softKeys()); } diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 2f3b412..5f8371c 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -1396,7 +1396,16 @@ bool QMainWindow::event(QEvent *event) } break; #endif - +#ifndef QT_NO_MENUBAR + case QEvent::WindowActivate: + if (d->layout->menuBar()) { + // ### TODO: This is evil, there is no need to create a new action every time + QAction* menu = new QAction(QString::fromLatin1("Menu"), this); + menu->setSoftKeyRole(QAction::MenuSoftKey); + setSoftKey(menu); + } + break; +#endif default: break; } |