diff options
author | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-05-18 12:20:45 (GMT) |
---|---|---|
committer | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-05-18 12:20:45 (GMT) |
commit | e4010084c0dcf05f417e5aca6c8c0ad1767599ca (patch) | |
tree | bf9527a3e4a1c13710ff3cb5f95140aab97408ca /src/gui | |
parent | a9906c6993e7f7c2fd307b820da36bdfbbc27230 (diff) | |
download | Qt-e4010084c0dcf05f417e5aca6c8c0ad1767599ca.zip Qt-e4010084c0dcf05f417e5aca6c8c0ad1767599ca.tar.gz Qt-e4010084c0dcf05f417e5aca6c8c0ad1767599ca.tar.bz2 |
Implemented handling keypresses coming from software keys
Diffstat (limited to 'src/gui')
-rw-r--r-- | src/gui/widgets/qsoftkeystack.cpp | 6 | ||||
-rw-r--r-- | src/gui/widgets/qsoftkeystack_p.h | 1 | ||||
-rw-r--r-- | 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<QAction*> 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<QSoftKeyAction*> &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); } + |