diff options
-rw-r--r-- | src/gui/softkeys/main.cpp | 42 | ||||
-rw-r--r-- | src/gui/softkeys/qsoftkeyaction.cpp | 139 | ||||
-rw-r--r-- | src/gui/softkeys/qsoftkeyaction.h | 59 | ||||
-rw-r--r-- | src/gui/softkeys/qsoftkeystack.cpp | 93 | ||||
-rw-r--r-- | src/gui/softkeys/qsoftkeystack.h | 74 | ||||
-rw-r--r-- | src/gui/softkeys/softkeys.pro | 13 |
6 files changed, 420 insertions, 0 deletions
diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp new file mode 100644 index 0000000..4f452d6 --- /dev/null +++ b/src/gui/softkeys/main.cpp @@ -0,0 +1,42 @@ + +#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 action(central); + action.setRole(QSoftKeyAction::Back); + int role = action.role(); + stack->push(&action); + + 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..ac6cb01 --- /dev/null +++ b/src/gui/softkeys/qsoftkeyaction.cpp @@ -0,0 +1,139 @@ +/**************************************************************************** +** +** 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; +}; + +/*! + \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(); +} diff --git a/src/gui/softkeys/qsoftkeyaction.h b/src/gui/softkeys/qsoftkeyaction.h new file mode 100644 index 0000000..67401e2 --- /dev/null +++ b/src/gui/softkeys/qsoftkeyaction.h @@ -0,0 +1,59 @@ +/**************************************************************************** +** +** 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); + + 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..669198b --- /dev/null +++ b/src/gui/softkeys/qsoftkeystack.cpp @@ -0,0 +1,93 @@ +/**************************************************************************** +** +** 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 "qsoftkeystack.h" + +QSoftKeyStackPrivate::QSoftKeyStackPrivate() +{ + +} + +QSoftKeyStackPrivate::~QSoftKeyStackPrivate() +{ + +} + +void QSoftKeyStackPrivate::setNativeSoftKeys() +{ + QSoftkeySet top = softKeyStack.top(); + CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); + CAknAppUi* aknAppUi = static_cast <CAknAppUi*>(appui); + CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba(); + int role = top.at(0)->role(); + + switch( top.at(0)->role() ) + { + case(QSoftKeyAction::Back): + { + nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_BACK); + } + break; + default: + { + } + } +} + +void QSoftKeyStackPrivate::push(QSoftKeyAction *softKey) +{ + QSoftkeySet softkeys; + softkeys.append( softKey ); + softKeyStack.push(softkeys); + setNativeSoftKeys(); + +} +void QSoftKeyStackPrivate::push( QList<QSoftKeyAction*> softkeys) +{ + +} + +void QSoftKeyStackPrivate::pop() +{ + softKeyStack.pop(); +} + +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..d725954 --- /dev/null +++ b/src/gui/softkeys/qsoftkeystack.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** 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*> + +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 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 |