summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/gui/softkeys/main.cpp65
-rw-r--r--src/gui/softkeys/qsoftkeyaction.cpp161
-rw-r--r--src/gui/softkeys/qsoftkeyaction.h63
-rw-r--r--src/gui/softkeys/qsoftkeystack.cpp122
-rw-r--r--src/gui/softkeys/qsoftkeystack.h77
-rw-r--r--src/gui/softkeys/softkeys.pro13
-rw-r--r--src/gui/styles/qs60style.cpp3
7 files changed, 503 insertions, 1 deletions
diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp
new file mode 100644
index 0000000..e5a7065
--- /dev/null
+++ b/src/gui/softkeys/main.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#include <QApplication>
+#include <QMainWindow>
+#include <QPushButton>
+#include <QVBoxLayout>
+#include "qsoftkeystack.h"
+
+class MainWindow : public QMainWindow
+{
+ Q_OBJECT
+public:
+ MainWindow(QWidget *parent = 0);
+ ~MainWindow() {}
+};
+
+MainWindow::MainWindow(QWidget *parent)
+ : QMainWindow(parent)
+{
+ QWidget *central = new QWidget(this);
+ QVBoxLayout *layout = new QVBoxLayout(central);
+
+ QPushButton *button = new QPushButton("Hello");
+ layout->addWidget(button);
+
+ QSoftKeyStack *stack = new QSoftKeyStack(central);
+ QSoftKeyAction action1(central);
+ action1.setText(QString("text1"));
+ action1.setRole(QSoftKeyAction::Ok);
+ QSoftKeyAction action2(central);
+ action2.setText(QString("text2"));
+ action2.setRole(QSoftKeyAction::Back);
+ QSoftKeyAction action3(central);
+ action3.setText(QString("text3"));
+ action3.setRole(QSoftKeyAction::Cancel);
+
+ QList<QSoftKeyAction*> myActionList;
+ myActionList.append(&action1);
+ myActionList.append(&action2);
+ myActionList.append(&action3);
+ stack->push(myActionList);
+ stack->pop();
+ stack->push(&action1);
+
+ setCentralWidget(central);
+}
+
+int main(int argc, char *argv[])
+{
+ QApplication app(argc, argv);
+ MainWindow mw;
+ mw.show();
+ return app.exec();
+}
+
+#include "main.moc"
diff --git a/src/gui/softkeys/qsoftkeyaction.cpp b/src/gui/softkeys/qsoftkeyaction.cpp
new file mode 100644
index 0000000..bfa8330
--- /dev/null
+++ b/src/gui/softkeys/qsoftkeyaction.cpp
@@ -0,0 +1,161 @@
+/****************************************************************************
+**
+** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#include "qsoftkeyaction.h"
+
+/*!
+ \class QSoftKeyAction
+ \brief The QSoftKeyAction class defines a special kind of QAction that may also be displayed in a QSoftKeyBar.
+*/
+
+class QSoftKeyActionPrivate
+{
+public:
+ QSoftKeyActionPrivate(QSoftKeyAction::StandardRole role = QSoftKeyAction::Custom)
+ {
+ this->role = role;
+ }
+
+ QSoftKeyAction::StandardRole role;
+ QString roleName;
+ int nativePosition;
+ int qtContextKey;
+};
+
+/*!
+ \enum QSoftKeyAction::StandardRole
+ This enum defines the standard role for a QSoftKeyAction.
+
+ \value Options
+ \value Select
+ \value Back
+ \value Next
+ \value Previous
+ \value Ok
+ \value Cancel
+ \value Edit
+ \value View
+ \value BackSpace
+ \value EndEdit
+ \value RevertEdit
+ \value Deselect
+ \value Finish
+ \value Custom
+*/
+
+QSoftKeyAction::QSoftKeyAction(QObject *parent)
+ : QAction(parent)
+{
+ d = new QSoftKeyActionPrivate();
+}
+
+QSoftKeyAction::QSoftKeyAction(QSoftKeyAction::StandardRole role, QObject *parent)
+ : QAction(parent)
+{
+ d = new QSoftKeyActionPrivate(role);
+}
+
+QSoftKeyAction::QSoftKeyAction(const QString &text, QObject* parent)
+ : QAction(text, parent)
+{
+ d = new QSoftKeyActionPrivate();
+}
+
+QSoftKeyAction::QSoftKeyAction(QSoftKeyAction::StandardRole role, const QString &text, QObject* parent)
+ : QAction(text, parent)
+{
+ d = new QSoftKeyActionPrivate(role);
+}
+
+QSoftKeyAction::QSoftKeyAction(const QIcon &icon, const QString &text, QObject* parent)
+ : QAction(icon, text, parent)
+{
+ d = new QSoftKeyActionPrivate();
+}
+
+QSoftKeyAction::QSoftKeyAction(QSoftKeyAction::StandardRole role, const QIcon &icon, const QString &text, QObject* parent)
+ : QAction(icon, text, parent)
+{
+ d = new QSoftKeyActionPrivate(role);
+}
+
+QSoftKeyAction::~QSoftKeyAction()
+{
+ delete d;
+}
+
+/*!
+ Returns the standard role associated with this action, or Custom
+ if the role is defined by roleName().
+
+ \sa setRole(), roleName()
+*/
+QSoftKeyAction::StandardRole QSoftKeyAction::role() const
+{
+ return d->role;
+}
+
+/*!
+ Returns the custom role name if role() is Custom, or an empty
+ string otherwise.
+
+ \sa role(), setRole()
+*/
+QString QSoftKeyAction::roleName() const
+{
+ return d->roleName;
+}
+
+/*!
+ Sets the standard role associated with this action to \a role,
+ and also sets roleName() to the empty string.
+
+ \sa role(), roleName()
+*/
+void QSoftKeyAction::setRole(QSoftKeyAction::StandardRole role)
+{
+ d->role = role;
+ d->roleName = QString();
+ emit changed();
+}
+
+/*!
+ Sets the custom roleName() associated with this action to \a role,
+ and also sets role() to Custom.
+
+ \sa role(), roleName()
+*/
+void QSoftKeyAction::setRole(const QString& role)
+{
+ d->role = QSoftKeyAction::Custom;
+ 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
new file mode 100644
index 0000000..85f5bc7
--- /dev/null
+++ b/src/gui/softkeys/qsoftkeyaction.h
@@ -0,0 +1,63 @@
+/****************************************************************************
+**
+** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSOFTKEYACTION_H
+#define QSOFTKEYACTION_H
+
+#include <QtGui/qaction.h>
+
+class QSoftKeyActionPrivate;
+
+class QSoftKeyAction : public QAction
+{
+ Q_OBJECT
+public:
+ enum StandardRole
+ {
+ Options,
+ Select,
+ Back,
+ Next,
+ Previous,
+ Ok,
+ Cancel,
+ Edit,
+ View,
+ BackSpace,
+ EndEdit,
+ RevertEdit,
+ Deselect,
+ Finish,
+ Custom
+ };
+
+ QSoftKeyAction(QObject *parent);
+ QSoftKeyAction(QSoftKeyAction::StandardRole role, QObject *parent);
+ QSoftKeyAction(const QString &text, QObject* parent);
+ QSoftKeyAction(QSoftKeyAction::StandardRole role, const QString &text, QObject* parent);
+ QSoftKeyAction(const QIcon &icon, const QString &text, QObject* parent);
+ QSoftKeyAction(QSoftKeyAction::StandardRole role, const QIcon &icon, const QString &text, QObject* parent);
+ ~QSoftKeyAction();
+
+ QSoftKeyAction::StandardRole role() const;
+ QString roleName() const;
+
+ void setRole(QSoftKeyAction::StandardRole role);
+ void setRole(const QString& role);
+ int nativePosition();
+ void setNativePosition(int position);
+ int qtContextKey();
+ void setQtContextKey(int position);
+
+ QSoftKeyActionPrivate *d;
+};
+
+#endif // QSOFTKEYACTION_H
diff --git a/src/gui/softkeys/qsoftkeystack.cpp b/src/gui/softkeys/qsoftkeystack.cpp
new file mode 100644
index 0000000..bd9a636
--- /dev/null
+++ b/src/gui/softkeys/qsoftkeystack.cpp
@@ -0,0 +1,122 @@
+/****************************************************************************
+**
+** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#include <eikenv.h>
+#include <eikbtgpc.h>
+#include <eikappui.h>
+#include <aknappui.h>
+#include <avkon.rsg>
+
+#include "private/qcore_symbian_p.h"
+
+
+#include "qsoftkeystack.h"
+
+QSoftKeyStackPrivate::QSoftKeyStackPrivate()
+{
+
+}
+
+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;index<top.count();index++)
+ {
+ top.at(index)->setNativePosition(index+veryWeirdMagic);
+ top.at(index)->setQtContextKey(Qt::Key_Context1+index);
+ if (veryWeirdMagic==0)
+ veryWeirdMagic=1;
+ }
+ }
+}
+
+void QSoftKeyStackPrivate::setNativeSoftKeys()
+{
+ CCoeAppUi* appui = CEikonEnv::Static()->AppUi();
+ CAknAppUi* aknAppUi = static_cast <CAknAppUi*>(appui);
+ CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba();
+ nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS);
+ if(softKeyStack.isEmpty())
+ return;
+
+ QSoftkeySet top = softKeyStack.top();
+ mapSoftKeys(top);
+ for (int index=0;index<top.count();index++)
+ {
+ QSoftKeyAction* softKeyAction = top.at(index);
+ HBufC* text = qt_QString2HBufCNewL(softKeyAction->text());
+ CleanupStack::PushL(text);
+ nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART+softKeyAction->qtContextKey(), *text);
+ CleanupStack::PopAndDestroy();
+ }
+}
+
+void QSoftKeyStackPrivate::push(QSoftKeyAction *softKey)
+{
+ QSoftkeySet softKeySet;
+ softKeySet.append( softKey );
+ softKeyStack.push(softKeySet);
+ setNativeSoftKeys();
+
+}
+void QSoftKeyStackPrivate::push( QList<QSoftKeyAction*> softkeys)
+{
+ QSoftkeySet softKeySet(softkeys);
+ softKeyStack.push(softKeySet);
+ setNativeSoftKeys();
+}
+
+void QSoftKeyStackPrivate::pop()
+{
+ softKeyStack.pop();
+ setNativeSoftKeys();
+}
+
+EXPORT_C QSoftKeyStack::QSoftKeyStack(QWidget *parent)
+{
+ d = new QSoftKeyStackPrivate();
+}
+
+QSoftKeyStack::~QSoftKeyStack()
+{
+ delete d;
+}
+
+void QSoftKeyStack::push(QSoftKeyAction *softKey)
+{
+ d->push(softKey);
+}
+
+void QSoftKeyStack::push(QList<QSoftKeyAction*> softKeys)
+{
+ d->push(softKeys);
+}
+
+void QSoftKeyStack::pop()
+{
+ d->pop();
+}
+
diff --git a/src/gui/softkeys/qsoftkeystack.h b/src/gui/softkeys/qsoftkeystack.h
new file mode 100644
index 0000000..b96bf60
--- /dev/null
+++ b/src/gui/softkeys/qsoftkeystack.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the $MODULE$ of the Qt Toolkit.
+**
+** $TROLLTECH_DUAL_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QSOFTKEYSTACK_H
+#define QSOFTKEYSTACK_H
+
+#include <QtGui/qwidget.h>
+#include <QtGui/qaction.h>
+#include <QStack>
+
+#include "qsoftkeyaction.h"
+
+#define QSoftkeySet QList <QSoftKeyAction*>
+#define SOFTKEYSTART 5000
+#define SOFTKEYEND 5000+Qt::Key_Context4
+
+class QSoftKeyStackPrivate : public QObject
+ {
+ Q_OBJECT
+ public:
+ IMPORT_C QSoftKeyStackPrivate();
+ ~QSoftKeyStackPrivate();
+
+public:
+ void push(QSoftKeyAction *softKey);
+ void push(QList<QSoftKeyAction*> softKeys);
+ void pop();
+
+private:
+ void mapSoftKeys(QSoftkeySet& top);
+ void setNativeSoftKeys();
+
+private:
+ QStack <QSoftkeySet> softKeyStack;
+ };
+
+
+
+/*class QSoftkeySet
+ {
+ const QList<QSoftKeyAction*> softkeys;
+ };
+
+
+class QSoftkeySet
+ {
+ const QList<QSoftKeyAction*> softkeys;
+ };
+*/
+class QSoftKeyStack : public QObject
+{
+ Q_OBJECT
+public:
+ IMPORT_C QSoftKeyStack(QWidget *parent);
+ ~QSoftKeyStack();
+public:
+ void push(QSoftKeyAction *softKey);
+ void push(QList<QSoftKeyAction*> softkeys);
+ void pop();
+protected:
+
+private Q_SLOTS:
+
+private:
+ QSoftKeyStackPrivate *d;
+
+};
+
+#endif // QSOFTKEYSTACK_H
diff --git a/src/gui/softkeys/softkeys.pro b/src/gui/softkeys/softkeys.pro
new file mode 100644
index 0000000..88a813e
--- /dev/null
+++ b/src/gui/softkeys/softkeys.pro
@@ -0,0 +1,13 @@
+TEMPLATE = app
+TARGET = softkeys
+
+HEADERS += \
+ qsoftkeystack.h \
+ qsoftkeyaction.h
+
+SOURCES += \
+ main.cpp \
+ qsoftkeyaction.cpp \
+ qsoftkeystack.cpp
+
+iCONFIG += qt debug warn_on
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp
index 581ada0..2db73b6 100644
--- a/src/gui/styles/qs60style.cpp
+++ b/src/gui/styles/qs60style.cpp
@@ -2351,12 +2351,13 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple
ret = QCommonStyle::subControlRect(control, option, scontrol, widget);
switch (scontrol) {
case SC_GroupBoxCheckBox: //fallthrough
- case SC_GroupBoxLabel:
+ case SC_GroupBoxLabel: {
//slightly indent text and boxes, so that dialog border does not mess with them.
const int horizontalSpacing =
QS60StylePrivate::pixelMetric(QStyle::PM_LayoutHorizontalSpacing);
const int bottomMargin = QS60StylePrivate::pixelMetric(QStyle::PM_LayoutBottomMargin);
ret.adjust(2,horizontalSpacing-3,0,0);
+ }
break;
case SC_GroupBoxFrame: {
const QRect textBox = subControlRect(control, option, SC_GroupBoxLabel, widget);