diff options
Diffstat (limited to 'src/gui/widgets/qmainwindow.cpp')
-rw-r--r-- | src/gui/widgets/qmainwindow.cpp | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 990d821..17645cd 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -65,6 +65,9 @@ QT_BEGIN_NAMESPACE extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp QT_END_NAMESPACE #endif +#ifdef QT_KEYPAD_NAVIGATION +#include <private/qsoftkeymanager_p.h> +#endif QT_BEGIN_NAMESPACE @@ -77,6 +80,9 @@ public: #ifdef Q_WS_MAC , useHIToolBar(false) #endif +#ifdef QT_KEYPAD_NAVIGATION + , menuBarAction(0) +#endif #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) , hasOldCursor(false) , cursorAdjusted(false) #endif @@ -88,6 +94,9 @@ public: #ifdef Q_WS_MAC bool useHIToolBar; #endif +#ifdef QT_KEYPAD_NAVIGATION + QAction *menuBarAction; +#endif void init(); QList<int> hoverSeparator; QPoint hoverPos; @@ -108,6 +117,9 @@ void QMainWindowPrivate::init() const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); iconSize = QSize(metric, metric); q->setAttribute(Qt::WA_Hover); +#ifdef QT_KEYPAD_NAVIGATION + menuBarAction = QSoftKeyManager::createAction(QAction::MenuSoftKey, q); +#endif } /* @@ -479,11 +491,13 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) oldMenuBar->deleteLater(); } d->layout->setMenuBar(menuBar); - if (menuBar) { - QAction* menu = new QAction(QString::fromLatin1("Options"), this); - menu->setSoftKeyRole(QAction::MenuSoftKey); - setSoftKey(menu); - } + +#ifdef QT_KEYPAD_NAVIGATION + if (menuBar) + addAction(d->menuBarAction); + else + removeAction(d->menuBarAction); +#endif } /*! @@ -1412,16 +1426,6 @@ 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("Options"), this); - menu->setSoftKeyRole(QAction::MenuSoftKey); - setSoftKey(menu); - } - break; -#endif default: break; } |