summaryrefslogtreecommitdiffstats
path: root/src/gui/kernel/qsoftkeymanager.cpp
diff options
context:
space:
mode:
authorJason Barron <jbarron@trolltech.com>2009-09-20 10:55:36 (GMT)
committerJason Barron <jbarron@trolltech.com>2009-09-21 08:07:50 (GMT)
commit7bb16c92a29d316b0dc385e95d99d3edfd1b4196 (patch)
tree462d020724be4048a6cc6738d55f6dd34db2f445 /src/gui/kernel/qsoftkeymanager.cpp
parentf01dd45eb52e6a9d76fbd2645466cc52319715a0 (diff)
downloadQt-7bb16c92a29d316b0dc385e95d99d3edfd1b4196.zip
Qt-7bb16c92a29d316b0dc385e95d99d3edfd1b4196.tar.gz
Qt-7bb16c92a29d316b0dc385e95d99d3edfd1b4196.tar.bz2
Simplify the soft key roles of QAction.
Previously there were many options here that were inherited from the Qtopia implementation. It was not clear to developers which value they actually should use. A good example was the 'Next' value. In a typical wizard application, next would be on the right and 'Previous' would be on the left. However, it is also common to have 'Next' on the left and have 'Cancel' on the right. Basically what people really wanted was a way to explicitly set the right and left soft keys, but since this relies on form factor and is wrong if the screen is rotated, we choose positive and negative actions as the values for these such that they still make sense when the screen is rotated. Also this helps people who don't know if a particular action should be on the left or right, but they *do* know if their action has destructive characterisitics (negative). As a convenience for widgets in Qt that use softkeys, we create a standard softkey enumeration. That maps the actions to the correct role and has default text. Reviewed-by: Alessandro Portale
Diffstat (limited to 'src/gui/kernel/qsoftkeymanager.cpp')
-rw-r--r--src/gui/kernel/qsoftkeymanager.cpp79
1 files changed, 28 insertions, 51 deletions
diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp
index b1ebd38..a7a5223 100644
--- a/src/gui/kernel/qsoftkeymanager.cpp
+++ b/src/gui/kernel/qsoftkeymanager.cpp
@@ -55,39 +55,24 @@ static const int s60CommandStart = 6000;
QWidget *QSoftKeyManager::softKeySource = 0;
QSoftKeyManager *QSoftKeyManager::self = 0;
-const char *QSoftKeyManager::standardSoftKeyText(QAction::SoftKeyRole role)
+const char *QSoftKeyManager::standardSoftKeyText(StandardSoftKey standardKey)
{
const char *softKeyText = 0;
- switch (role) {
- case QAction::OptionsSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Options");
+ switch (standardKey) {
+ case OkSoftKey:
+ softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Ok");
break;
- case QAction::SelectSoftKey:
+ case SelectSoftKey:
softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Select");
break;
- case QAction::BackSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Back");
- break;
- case QAction::NextSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Next");
- break;
- case QAction::PreviousSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Previous");
- break;
- case QAction::OkSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Ok");
+ case DoneSoftKey:
+ softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Done");
break;
- case QAction::CancelSoftKey:
+ case CancelSoftKey:
softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Cancel");
break;
- case QAction::EditSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Edit");
- break;
- case QAction::ViewSoftKey:
- softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "View");
- break;
default:
- ;
+ break;
};
return softKeyText;
@@ -105,10 +90,21 @@ QSoftKeyManager::QSoftKeyManager() : QObject()
{
}
-QAction *QSoftKeyManager::createAction(QAction::SoftKeyRole softKeyRole, QWidget *actionWidget)
+QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *actionWidget)
{
- const char* text = standardSoftKeyText(softKeyRole);
+ const char* text = standardSoftKeyText(standardKey);
QAction *action = new QAction(QSoftKeyManager::tr(text), actionWidget);
+ QAction::SoftKeyRole softKeyRole;
+ switch (standardKey) {
+ case OkSoftKey:
+ case SelectSoftKey:
+ case DoneSoftKey:
+ softKeyRole = QAction::PositiveSoftKey;
+ break;
+ case CancelSoftKey:
+ softKeyRole = QAction::NegativeSoftKey;
+ break;
+ }
action->setSoftKeyRole(softKeyRole);
return action;
}
@@ -119,9 +115,9 @@ QAction *QSoftKeyManager::createAction(QAction::SoftKeyRole softKeyRole, QWidget
\a actionWidget as a convenience.
*/
-QAction *QSoftKeyManager::createKeyedAction(QAction::SoftKeyRole softKeyRole, Qt::Key key, QWidget *actionWidget)
+QAction *QSoftKeyManager::createKeyedAction(StandardSoftKey standardKey, Qt::Key key, QWidget *actionWidget)
{
- QScopedPointer<QAction> action(createAction(softKeyRole, actionWidget));
+ QScopedPointer<QAction> action(createAction(standardKey, actionWidget));
connect(action.data(), SIGNAL(triggered()), QSoftKeyManager::instance(), SLOT(sendKeyEvent()));
@@ -186,42 +182,23 @@ void QSoftKeyManager::updateSoftKeys_sys(const QList<QAction*> &softkeys)
const QAction* softKeyAction = softkeys.at(index);
switch (softKeyAction->softKeyRole()) {
// Positive Actions go on LSK
- case QAction::OptionsSoftKey:
- case QAction::MenuSoftKey:
- case QAction::ContextMenuSoftKey:
- command = EAknSoftkeyOptions; //Calls DynInitMenuPane in AppUI
+ case QAction::PositiveSoftKey:
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 = s60CommandStart + 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:
+ case QAction::NegativeSoftKey:
needsExitButton = false;
- command = s60CommandStart + index;
- position = 2;
- break;
- case QAction::ExitSoftKey:
- needsExitButton = false;
- command = EAknSoftkeyExit; //Calls HandleCommand in AppUI
position = 2;
break;
default:
break;
}
+ command = s60CommandStart + index;
+
if (position != -1) {
TPtrC text = qt_QString2TPtrC(softKeyAction->text());
QT_TRAP_THROWING(nativeContainer->SetCommandL(position, command, text));