From e4010084c0dcf05f417e5aca6c8c0ad1767599ca Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 18 May 2009 14:20:45 +0200 Subject: Implemented handling keypresses coming from software keys --- src/gui/widgets/qsoftkeystack.cpp | 6 ++++++ src/gui/widgets/qsoftkeystack_p.h | 1 + src/gui/widgets/qsoftkeystack_s60.cpp | 15 +++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index fc6e107..14daecd 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -137,3 +137,9 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) QList actions = now->actions(); // Do something with these actions. } + +void QSoftKeyStack::handleSoftKeyPress(int command) +{ + Q_D(QSoftKeyStack); + d->handleSoftKeyPress(command); +} diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index a8ab2d5..2469648 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -78,6 +78,7 @@ public: void push(const QList &softKeys); void pop(); const QSoftkeySet& top(); + 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 9e90fdf..a6b885e 100644 --- a/src/gui/widgets/qsoftkeystack_s60.cpp +++ b/src/gui/widgets/qsoftkeystack_s60.cpp @@ -90,15 +90,22 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() if (softKeyAction->role() == QSoftKeyAction::Menu) { nativeContainer->SetCommandL(softKeyAction->nativePosition(), EAknSoftkeyOptions, *text); } else { - nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART + softKeyAction->qtContextKey(), *text); + nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART + softKeyAction->qtContextKey()-Qt::Key_Context1, *text); } CleanupStack::PopAndDestroy(); } } } -void QSoftKeyStack::handleSoftKeyPress(int command) +void QSoftKeyStackPrivate::handleSoftKeyPress(int command) { - // Do the magic, here. - // Map the command back to actual softkey on the top of the stack and handle it + const QSoftkeySet top = softKeyStack.top(); + int index = command-SOFTKEYSTART; + if( index<0 || index>=top.count()){ + // ### FIX THIS, add proper error handling, now fail quietly + return; + } + + top.at(index)->activate(QAction::Trigger); } + -- cgit v0.12