summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-06-17 14:38:41 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-06-17 14:38:41 (GMT)
commit30525b802f17c2c815f02d81a1c771b8cee71458 (patch)
treeb9556de913f0915da07066253f5865d41e5214a6 /src
parent87ac26f0c489911d9a43bab04aef03cadbe8bbe6 (diff)
downloadQt-30525b802f17c2c815f02d81a1c771b8cee71458.zip
Qt-30525b802f17c2c815f02d81a1c771b8cee71458.tar.gz
Qt-30525b802f17c2c815f02d81a1c771b8cee71458.tar.bz2
Improve softkey implementation and add a default 'Exit' button to RSK.
The previous implementation had some problems where the actual position of the softkey was determined by it's position in the list. This is suboptimal since the position should be tied to the role. Actions that have "negative" conotation should be located on the right soft key (RSK) while "positive" actions go on the left soft key (LSK). This is according to the S60 User Interface Guide. It is also standard practice in S60 to have an 'Exit' button on the RSK so we add one of those if there is not already a key present there. Task-number: 256365 Reviewed-by: Markku Luukkainen
Diffstat (limited to 'src')
-rw-r--r--src/gui/kernel/qaction.h9
-rw-r--r--src/gui/kernel/qwidget_s60.cpp65
2 files changed, 53 insertions, 21 deletions
diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h
index dfa4933..3449acf 100644
--- a/src/gui/kernel/qaction.h
+++ b/src/gui/kernel/qaction.h
@@ -91,11 +91,10 @@ class Q_GUI_EXPORT QAction : public QObject
public:
enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole,
AboutRole, PreferencesRole, QuitRole };
- enum SoftKeyRole { OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, PreviousSoftKey,
- OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey,
- EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey,
- MenuSoftKey, ContextMenuSoftKey, ExitSoftKey, Key1SoftKey, Key2SoftKey,
- Key3SoftKey, Key4SoftKey, CustomSoftKey };
+ enum SoftKeyRole { OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, PreviousSoftKey,
+ OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey,
+ EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey,
+ MenuSoftKey, ContextMenuSoftKey, ExitSoftKey };
explicit QAction(QObject* parent);
QAction(const QString &text, QObject* parent);
QAction(const QIcon &icon, const QString &text, QObject* parent);
diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp
index bc69d6d..6109f17 100644
--- a/src/gui/kernel/qwidget_s60.cpp
+++ b/src/gui/kernel/qwidget_s60.cpp
@@ -85,29 +85,62 @@ void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys)
if (isEqual(old, softkeys ))
return;
}
- CCoeAppUi* appui = CEikonEnv::Static()->AppUi();
- CAknAppUi* aknAppUi = static_cast <CAknAppUi*>(appui);
- CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba();
+ CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer();
nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS);
- int placeInScreen=0;
+ int position = -1;
+ int command;
+ bool needsExitButton = true;
+
for (int index = 0; index < softkeys.count(); index++) {
const QAction* softKeyAction = softkeys.at(index);
- if (softKeyAction->softKeyRole() != QAction::ContextMenuSoftKey) {
+ switch (softKeyAction->softKeyRole()) {
+ // Positive Actions go on LSK
+ case QAction::OptionsSoftKey:
+ case QAction::MenuSoftKey:
+ case QAction::ContextMenuSoftKey:
+ command = EAknSoftkeyOptions; //Calls DynInitMenuPane in AppUI
+ position = 0;
+ break;
+ case QAction::SelectSoftKey:
+ case QAction::PreviousSoftKey:
+ case QAction::OkSoftKey:
+ case QAction::EditSoftKey:
+ case QAction::ViewSoftKey:
+ case QAction::EndEditSoftKey:
+ case QAction::FinishSoftKey:
+ command = SOFTKEYSTART + index;
+ position = 0;
+ break;
+ // Negative Actions on the RSK
+ case QAction::BackSoftKey:
+ case QAction::NextSoftKey:
+ case QAction::CancelSoftKey:
+ case QAction::BackSpaceSoftKey:
+ case QAction::RevertEditSoftKey:
+ case QAction::DeselectSoftKey:
+ needsExitButton = false;
+ command = SOFTKEYSTART + index;
+ position = 2;
+ break;
+ case QAction::ExitSoftKey:
+ needsExitButton = false;
+ command = EAknSoftkeyExit; //Calls HandleCommand in AppUI
+ position = 2;
+ break;
+ default:
+ break;
+ }
- HBufC* text = qt_QString2HBufC(softKeyAction->text());
- CleanupStack::PushL(text);
- if (softKeyAction->softKeyRole() == QAction::MenuSoftKey) {
- nativeContainer->SetCommandL(placeInScreen, EAknSoftkeyOptions, *text);
- } else {
- nativeContainer->SetCommandL(placeInScreen, SOFTKEYSTART + index, *text);
- }
- CleanupStack::PopAndDestroy();
- placeInScreen++;
+ if (position != -1) {
+ TPtrC text = qt_QString2TPtrC(softKeyAction->text());
+ nativeContainer->SetCommandL(position, command, text);
}
- if (placeInScreen==1)
- placeInScreen=2;
}
+
+ if (needsExitButton)
+ nativeContainer->SetCommandL(2, EAknSoftkeyExit, qt_QString2TPtrC(QObject::tr("Exit")));
+
nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation
}