From 93a61a4cbe092dce8e5d221858d6b613fa258f07 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 4 May 2009 14:26:13 +0200 Subject: Skeleton implementation allowing us to conviniently change place where softkeys are visualized on the screen. Added mapping to native and Qt id's for QSoftKeyActions. Added rudimentary implementation for reordering QSoftKeyActions. --- src/gui/softkeys/qsoftkeyaction.cpp | 22 ++++++++++++++++++++++ src/gui/softkeys/qsoftkeyaction.h | 4 ++++ src/gui/softkeys/qsoftkeystack.cpp | 33 +++++++++++++++++++++++++-------- src/gui/softkeys/qsoftkeystack.h | 3 ++- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/gui/softkeys/qsoftkeyaction.cpp b/src/gui/softkeys/qsoftkeyaction.cpp index ac6cb01..bfa8330 100644 --- a/src/gui/softkeys/qsoftkeyaction.cpp +++ b/src/gui/softkeys/qsoftkeyaction.cpp @@ -26,6 +26,8 @@ public: QSoftKeyAction::StandardRole role; QString roleName; + int nativePosition; + int qtContextKey; }; /*! @@ -137,3 +139,23 @@ void QSoftKeyAction::setRole(const QString& role) d->roleName = role; emit changed(); } + +int QSoftKeyAction::nativePosition() +{ + return d->nativePosition; +} + +void QSoftKeyAction::setNativePosition(int position) +{ + d->nativePosition = position; +} + +int QSoftKeyAction::qtContextKey() +{ + return d->qtContextKey; +} + +void QSoftKeyAction::setQtContextKey(int key) +{ + d->qtContextKey = key; +} diff --git a/src/gui/softkeys/qsoftkeyaction.h b/src/gui/softkeys/qsoftkeyaction.h index 67401e2..85f5bc7 100644 --- a/src/gui/softkeys/qsoftkeyaction.h +++ b/src/gui/softkeys/qsoftkeyaction.h @@ -52,6 +52,10 @@ public: void setRole(QSoftKeyAction::StandardRole role); void setRole(const QString& role); + int nativePosition(); + void setNativePosition(int position); + int qtContextKey(); + void setQtContextKey(int position); QSoftKeyActionPrivate *d; }; diff --git a/src/gui/softkeys/qsoftkeystack.cpp b/src/gui/softkeys/qsoftkeystack.cpp index 6cbcddd..bd9a636 100644 --- a/src/gui/softkeys/qsoftkeystack.cpp +++ b/src/gui/softkeys/qsoftkeystack.cpp @@ -30,6 +30,29 @@ QSoftKeyStackPrivate::~QSoftKeyStackPrivate() } +void QSoftKeyStackPrivate::mapSoftKeys(QSoftkeySet& top) +{ + if( top.count() == 1) + { + top.at(0)->setNativePosition(2); + top.at(0)->setQtContextKey(Qt::Key_Context2); + } + else + { + // FIX THIS + // veryWeirdMagic is needes as s60 5th edition sdk always panics if cba is set with index 1, this hops over it + // This needs further investigation why so that the hack can be removed + int veryWeirdMagic = 0; + for (int index=0;indexsetNativePosition(index+veryWeirdMagic); + top.at(index)->setQtContextKey(Qt::Key_Context1+index); + if (veryWeirdMagic==0) + veryWeirdMagic=1; + } + } +} + void QSoftKeyStackPrivate::setNativeSoftKeys() { CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); @@ -40,20 +63,14 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() return; QSoftkeySet top = softKeyStack.top(); - - // FIX THIS - // veryWeirdMagic is needes as s60 5th edition sdk always panics if cba is set with index 1, this hops over it - // This needs further investigation why so that the hack can be removed - int veryWeirdMagic = 0; + mapSoftKeys(top); for (int index=0;indextext()); CleanupStack::PushL(text); - nativeContainer->SetCommandL(index+veryWeirdMagic, SOFTKEYSTART+index, *text); + nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART+softKeyAction->qtContextKey(), *text); CleanupStack::PopAndDestroy(); - if (veryWeirdMagic==0) - veryWeirdMagic=1; } } diff --git a/src/gui/softkeys/qsoftkeystack.h b/src/gui/softkeys/qsoftkeystack.h index 98c2632..add4ab9 100644 --- a/src/gui/softkeys/qsoftkeystack.h +++ b/src/gui/softkeys/qsoftkeystack.h @@ -20,7 +20,7 @@ #define QSoftkeySet QList #define SOFTKEYSTART 5000 -#define SOFTKEYEND 5004 +#define SOFTKEYEND 5005 class QSoftKeyStackPrivate : public QObject { Q_OBJECT @@ -34,6 +34,7 @@ public: void pop(); private: + void mapSoftKeys(QSoftkeySet& top); void setNativeSoftKeys(); private: -- cgit v0.12