From e7864bbc420151aee1facc6383fd8c7fd9a63d13 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Thu, 30 Apr 2009 14:42:10 +0200 Subject: Initial skeleton of what is to become the cross platform softkey API. Current version is very experimental and can and will change very radically. Also functionality on this early version is very limited. API can only set single Back button on S60 platform. Work is somewhat based in softkey experiment done in Brisbane. Major difference is that this implementation will only be API through which softkeys will be adapted and will not have any kind of visualization in itself --- src/gui/softkeys/main.cpp | 42 +++++++++++ src/gui/softkeys/qsoftkeyaction.cpp | 139 ++++++++++++++++++++++++++++++++++++ src/gui/softkeys/qsoftkeyaction.h | 59 +++++++++++++++ src/gui/softkeys/qsoftkeystack.cpp | 93 ++++++++++++++++++++++++ src/gui/softkeys/qsoftkeystack.h | 74 +++++++++++++++++++ src/gui/softkeys/softkeys.pro | 13 ++++ 6 files changed, 420 insertions(+) create mode 100644 src/gui/softkeys/main.cpp create mode 100644 src/gui/softkeys/qsoftkeyaction.cpp create mode 100644 src/gui/softkeys/qsoftkeyaction.h create mode 100644 src/gui/softkeys/qsoftkeystack.cpp create mode 100644 src/gui/softkeys/qsoftkeystack.h create mode 100644 src/gui/softkeys/softkeys.pro 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 +#include +#include +#include +#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 + +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 +#include +#include +#include +#include + +#include "qsoftkeystack.h" + +QSoftKeyStackPrivate::QSoftKeyStackPrivate() +{ + +} + +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(); + + 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 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 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 +#include +#include + +#include "qsoftkeyaction.h" + +#define QSoftkeySet QList + +class QSoftKeyStackPrivate : public QObject + { + Q_OBJECT + public: + IMPORT_C QSoftKeyStackPrivate(); + ~QSoftKeyStackPrivate(); + +public: + void push(QSoftKeyAction *softKey); + void push(QList softKeys); + void pop(); + +private: + void setNativeSoftKeys(); + +private: + QStack softKeyStack; + }; + + + +/*class QSoftkeySet + { + const QList softkeys; + }; + + +class QSoftkeySet + { + const QList softkeys; + }; +*/ +class QSoftKeyStack : public QObject +{ + Q_OBJECT +public: + IMPORT_C QSoftKeyStack(QWidget *parent); + ~QSoftKeyStack(); +public: + void push(QSoftKeyAction *softKey); + void push(QList 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 -- cgit v0.12