From 8c7098210e6dfa7886d6e33918899a211019b699 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 27 May 2009 22:47:19 +0200 Subject: Moved the soft key command relay acrobatics from QApplication to QSoftKeyStackPrivate. Removed QSoftKeyStack::handleSoftKeyPress and made QSoftKeyStackPrivate::handleSoftKeyPress static, so that it can be called from QApplication. --- src/gui/kernel/qapplication_s60.cpp | 12 +++--------- src/gui/widgets/qsoftkeystack.cpp | 6 ------ src/gui/widgets/qsoftkeystack.h | 2 -- src/gui/widgets/qsoftkeystack_p.h | 2 +- src/gui/widgets/qsoftkeystack_s60.cpp | 12 ++++++++++-- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index ad1c842..138ba8c 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -29,8 +29,6 @@ #include "private/qwindowsurface_s60_p.h" #include "qpaintengine.h" #include "qmenubar.h" -#include "qmainwindow.h" -#include "qsoftkeystack.h" #include "private/qsoftkeystack_p.h" #include "apgwgnam.h" // For CApaWindowGroupName @@ -1041,14 +1039,10 @@ void QApplication::s60HandleCommandL(int command) exit(); break; default: - if (command >= SOFTKEYSTART && command <= SOFTKEYEND) { - const QMainWindow *activeMainWindow = - qobject_cast(QApplication::activeWindow()); - if (activeMainWindow) - activeMainWindow->softKeyStack()->handleSoftKeyPress(command); - } else { + if (command >= SOFTKEYSTART && command <= SOFTKEYEND) + QSoftKeyStackPrivate::handleSoftKeyPress(command); + else QMenuBar::symbianCommands(command); - } break; } } diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 50d7939..c68fe19 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -201,12 +201,6 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) } } -void QSoftKeyStack::handleSoftKeyPress(int command) -{ - Q_D(QSoftKeyStack); - d->handleSoftKeyPress(command); -} - QMainWindow *QSoftKeyStack::mainWindowOfWidget(QWidget *widget) { QWidget *widgetParent = widget; diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index 2606bd1..423da66 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -71,8 +71,6 @@ public: const QSoftkeySet& top(); bool isEmpty(); - void handleSoftKeyPress(int command); - static QMainWindow *mainWindowOfWidget(QWidget *widget); static QSoftKeyStack *softKeyStackOfWidget(QWidget *widget); diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index e728cbb..75d7ad4 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -82,7 +82,7 @@ public: void popandPush(const QList &softkeys); const QSoftkeySet& top(); bool isEmpty(); - void handleSoftKeyPress(int command); + static void handleSoftKeyPress(int command); private: void mapSoftKeys(const QSoftkeySet &top); diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp index e9ca13a..8dfd5dd 100644 --- a/src/gui/widgets/qsoftkeystack_s60.cpp +++ b/src/gui/widgets/qsoftkeystack_s60.cpp @@ -48,6 +48,8 @@ #include "private/qcore_symbian_p.h" #include "qsoftkeystack_p.h" +#include "qapplication.h" +#include "qmainwindow.h" void QSoftKeyStackPrivate::mapSoftKeys(const QSoftkeySet &top) { @@ -99,9 +101,15 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() void QSoftKeyStackPrivate::handleSoftKeyPress(int command) { - const QSoftkeySet top = softKeyStack.top(); + const QMainWindow *activeMainWindow = + qobject_cast(QApplication::activeWindow()); + if (!activeMainWindow) + return; + QSoftKeyStackPrivate *d_ptr = activeMainWindow->softKeyStack()->d_func(); + + const QSoftkeySet top = d_ptr->softKeyStack.top(); int index = command-SOFTKEYSTART; - if( index<0 || index>=top.count()){ + if (index < 0 || index >= top.count()) { // ### FIX THIS, add proper error handling, now fail quietly return; } -- cgit v0.12