From d24c24b6c0c840d7bbea5e8b81e1faaea6b5fede Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 4 May 2009 11:18:34 +0200 Subject: Very rough implementation of setting multiple buttons. Current implementation is missing loads of needed functionality but is enough to start testing the initial API --- src/gui/softkeys/qsoftkeystack.cpp | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/gui/softkeys/qsoftkeystack.cpp b/src/gui/softkeys/qsoftkeystack.cpp index 669198b..158d382 100644 --- a/src/gui/softkeys/qsoftkeystack.cpp +++ b/src/gui/softkeys/qsoftkeystack.cpp @@ -15,6 +15,9 @@ #include #include +#include "private/qcore_symbian_p.h" + + #include "qsoftkeystack.h" QSoftKeyStackPrivate::QSoftKeyStackPrivate() @@ -29,41 +32,50 @@ QSoftKeyStackPrivate::~QSoftKeyStackPrivate() void QSoftKeyStackPrivate::setNativeSoftKeys() { - QSoftkeySet top = softKeyStack.top(); CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); CAknAppUi* aknAppUi = static_cast (appui); CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba(); - int role = top.at(0)->role(); + nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + if(softKeyStack.isEmpty()) + return; + + QSoftkeySet top = softKeyStack.top(); - switch( top.at(0)->role() ) + // 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;indexSetCommandSetL(R_AVKON_SOFTKEYS_BACK); - } - break; - default: - { - } + QSoftKeyAction* softKeyAction = top.at(index); + HBufC* text = qt_QString2HBufCNewL(softKeyAction->text()); + CleanupStack::PushL(text); + nativeContainer->SetCommandL(index+veryWeirdMagic, softKeyAction->role(), *text); + CleanupStack::PopAndDestroy(); + if (veryWeirdMagic==0) + veryWeirdMagic=1; } } void QSoftKeyStackPrivate::push(QSoftKeyAction *softKey) { - QSoftkeySet softkeys; - softkeys.append( softKey ); - softKeyStack.push(softkeys); + QSoftkeySet softKeySet; + softKeySet.append( softKey ); + softKeyStack.push(softKeySet); setNativeSoftKeys(); } void QSoftKeyStackPrivate::push( QList softkeys) { - + QSoftkeySet softKeySet(softkeys); + softKeyStack.push(softKeySet); + setNativeSoftKeys(); } void QSoftKeyStackPrivate::pop() { softKeyStack.pop(); + setNativeSoftKeys(); } EXPORT_C QSoftKeyStack::QSoftKeyStack(QWidget *parent) -- cgit v0.12