From 10a294b71d0ccaddb48b1396352a744fdd0de6bf Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 May 2009 19:57:13 +0200 Subject: Moved SoftkeyStack files into src/widgets Corrected PImpl-ing and cleaned up headers --- src/gui/softkeys/qsoftkeyaction.cpp | 191 ------------------------------- src/gui/softkeys/qsoftkeyaction.h | 96 ---------------- src/gui/softkeys/qsoftkeystack.cpp | 100 ----------------- src/gui/softkeys/qsoftkeystack.h | 74 ------------ src/gui/softkeys/qsoftkeystack_p.h | 86 -------------- src/gui/softkeys/qsoftkeystack_s60.cpp | 100 ----------------- src/gui/widgets/qsoftkeyaction.cpp | 198 +++++++++++++++++++++++++++++++++ src/gui/widgets/qsoftkeyaction.h | 101 +++++++++++++++++ src/gui/widgets/qsoftkeystack.cpp | 102 +++++++++++++++++ src/gui/widgets/qsoftkeystack.h | 75 +++++++++++++ src/gui/widgets/qsoftkeystack_p.h | 86 ++++++++++++++ src/gui/widgets/qsoftkeystack_s60.cpp | 100 +++++++++++++++++ 12 files changed, 662 insertions(+), 647 deletions(-) delete mode 100644 src/gui/softkeys/qsoftkeyaction.cpp delete mode 100644 src/gui/softkeys/qsoftkeyaction.h delete mode 100644 src/gui/softkeys/qsoftkeystack.cpp delete mode 100644 src/gui/softkeys/qsoftkeystack.h delete mode 100644 src/gui/softkeys/qsoftkeystack_p.h delete mode 100644 src/gui/softkeys/qsoftkeystack_s60.cpp create mode 100644 src/gui/widgets/qsoftkeyaction.cpp create mode 100644 src/gui/widgets/qsoftkeyaction.h create mode 100644 src/gui/widgets/qsoftkeystack.cpp create mode 100644 src/gui/widgets/qsoftkeystack.h create mode 100644 src/gui/widgets/qsoftkeystack_p.h create mode 100644 src/gui/widgets/qsoftkeystack_s60.cpp diff --git a/src/gui/softkeys/qsoftkeyaction.cpp b/src/gui/softkeys/qsoftkeyaction.cpp deleted file mode 100644 index 1d21376..0000000 --- a/src/gui/softkeys/qsoftkeyaction.cpp +++ /dev/null @@ -1,191 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_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(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(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(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(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() const -{ - return d->nativePosition; -} - -void QSoftKeyAction::setNativePosition(int position) -{ - d->nativePosition = position; -} - -int QSoftKeyAction::qtContextKey() const -{ - 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 deleted file mode 100644 index e735376..0000000 --- a/src/gui/softkeys/qsoftkeyaction.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSOFTKEYACTION_H -#define QSOFTKEYACTION_H - -#include "QtGui/qaction.h" - -QT_BEGIN_NAMESPACE - -class QSoftKeyActionPrivate; - -class QSoftKeyAction : public QAction -{ -public: - enum StandardRole { - Options, - Select, - Back, - Next, - Previous, - Ok, - Cancel, - Edit, - View, - BackSpace, - EndEdit, - RevertEdit, - Deselect, - Finish, - Menu, - Custom - }; - - QSoftKeyAction(QObject *parent); - QSoftKeyAction(StandardRole role, QObject *parent); - QSoftKeyAction(const QString &text, QObject* parent); - QSoftKeyAction(StandardRole role, const QString &text, QObject* parent); - QSoftKeyAction(const QIcon &icon, const QString &text, QObject* parent); - QSoftKeyAction(StandardRole role, const QIcon &icon, const QString &text, QObject* parent); - ~QSoftKeyAction(); - - StandardRole role() const; - QString roleName() const; - - void setRole(StandardRole role); - void setRole(const QString& role); - int nativePosition() const; - void setNativePosition(int position); - int qtContextKey() const; - void setQtContextKey(int position); - - QSoftKeyActionPrivate *d; -}; - -QT_END_NAMESPACE - -#endif // QSOFTKEYACTION_H diff --git a/src/gui/softkeys/qsoftkeystack.cpp b/src/gui/softkeys/qsoftkeystack.cpp deleted file mode 100644 index a8bd3a9..0000000 --- a/src/gui/softkeys/qsoftkeystack.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qsoftkeystack.h" -#include "qsoftkeystack_p.h" - -QSoftKeyStackPrivate::QSoftKeyStackPrivate() -{ - -} - -QSoftKeyStackPrivate::~QSoftKeyStackPrivate() -{ - -} - -void QSoftKeyStackPrivate::push(QSoftKeyAction *softKey) -{ - QSoftkeySet softKeySet; - softKeySet.append(softKey); - softKeyStack.push(softKeySet); - setNativeSoftKeys(); - -} -void QSoftKeyStackPrivate::push(const QList &softkeys) -{ - QSoftkeySet softKeySet(softkeys); - softKeyStack.push(softKeySet); - setNativeSoftKeys(); -} - -void QSoftKeyStackPrivate::pop() -{ - softKeyStack.pop(); - setNativeSoftKeys(); -} - -QSoftKeyStack::QSoftKeyStack(QWidget *parent) -{ - d = new QSoftKeyStackPrivate(); -} - -QSoftKeyStack::~QSoftKeyStack() -{ - delete d; -} - -void QSoftKeyStack::push(QSoftKeyAction *softKey) -{ - d->push(softKey); -} - -void QSoftKeyStack::push(const QList &softKeys) -{ - d->push(softKeys); -} - -void QSoftKeyStack::pop() -{ - d->pop(); -} - diff --git a/src/gui/softkeys/qsoftkeystack.h b/src/gui/softkeys/qsoftkeystack.h deleted file mode 100644 index 90df43d..0000000 --- a/src/gui/softkeys/qsoftkeystack.h +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSOFTKEYSTACK_H -#define QSOFTKEYSTACK_H - -#include "QtGui/qwidget.h" -#include "QtGui/qaction.h" -#include "qstack.h" - -#include "qsoftkeyaction.h" - -QT_BEGIN_NAMESPACE - -#define QSoftkeySet QList - -class QSoftKeyStackPrivate; - -class QSoftKeyStack : public QObject -{ -public: - QSoftKeyStack(QWidget *parent); - ~QSoftKeyStack(); - -public: - void push(QSoftKeyAction *softKey); - void push(const QList &softkeys); - void pop(); - -private: - QSoftKeyStackPrivate *d; -}; - -QT_END_NAMESPACE - -#endif // QSOFTKEYSTACK_H diff --git a/src/gui/softkeys/qsoftkeystack_p.h b/src/gui/softkeys/qsoftkeystack_p.h deleted file mode 100644 index 8e029af..0000000 --- a/src/gui/softkeys/qsoftkeystack_p.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSOFTKEYSTACK_P_H -#define QSOFTKEYSTACK_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include "QtGui/qwidget.h" -#include "QtGui/qaction.h" -#include "qstack.h" - -#include "qsoftkeyaction.h" - -QT_BEGIN_NAMESPACE - -#define QSoftkeySet QList - -class QSoftKeyStackPrivate : public QObject -{ -public: - QSoftKeyStackPrivate(); - ~QSoftKeyStackPrivate(); - - void push(QSoftKeyAction *softKey); - void push(const QList &softKeys); - void pop(); - -private: - void mapSoftKeys(const QSoftkeySet &top); - void setNativeSoftKeys(); - -private: - QStack softKeyStack; -}; - -QT_END_NAMESPACE - -#endif // QSOFTKEYSTACK_P_H diff --git a/src/gui/softkeys/qsoftkeystack_s60.cpp b/src/gui/softkeys/qsoftkeystack_s60.cpp deleted file mode 100644 index ce4f116..0000000 --- a/src/gui/softkeys/qsoftkeystack_s60.cpp +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** Contact: Qt Software Information (qt-info@nokia.com) -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the either Technology Preview License Agreement or the -** Beta Release License Agreement. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain -** additional rights. These rights are described in the Nokia Qt LGPL -** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this -** package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** If you are unsure which license is appropriate for your use, please -** contact the sales department at qt-sales@nokia.com. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include -#include -#include -#include - -#include "private/qcore_symbian_p.h" - -#include "qsoftkeystack_p.h" - -#define SOFTKEYSTART 5000 -#define SOFTKEYEND (5000 + Qt::Key_Context4) - -void QSoftKeyStackPrivate::mapSoftKeys(const 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 (appui); - CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba(); - nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); - if (softKeyStack.isEmpty()) - return; - - const QSoftkeySet top = softKeyStack.top(); - mapSoftKeys(top); - - for (int index = 0; index < top.count(); index++) { - const QSoftKeyAction* softKeyAction = top.at(index); - HBufC* text = qt_QString2HBufCNewL(softKeyAction->text()); - CleanupStack::PushL(text); - if (softKeyAction->role() == QSoftKeyAction::Menu) { - nativeContainer->SetCommandL(softKeyAction->nativePosition(), EAknSoftkeyOptions, *text); - } else { - nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART + softKeyAction->qtContextKey(), *text); - } - CleanupStack::PopAndDestroy(); - } -} - - diff --git a/src/gui/widgets/qsoftkeyaction.cpp b/src/gui/widgets/qsoftkeyaction.cpp new file mode 100644 index 0000000..51b80bc --- /dev/null +++ b/src/gui/widgets/qsoftkeyaction.cpp @@ -0,0 +1,198 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_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) +{ +} + +QSoftKeyAction::QSoftKeyAction(StandardRole role, QObject *parent) + : QAction(parent) +{ + Q_D(QSoftKeyAction); + d->role = role; +} + +QSoftKeyAction::QSoftKeyAction(const QString &text, QObject* parent) + : QAction(text, parent) +{ +} + +QSoftKeyAction::QSoftKeyAction(StandardRole role, const QString &text, QObject* parent) + : QAction(text, parent) +{ + Q_D(QSoftKeyAction); + d->role = role; +} + +QSoftKeyAction::QSoftKeyAction(const QIcon &icon, const QString &text, QObject* parent) + : QAction(icon, text, parent) +{ +} + +QSoftKeyAction::QSoftKeyAction(StandardRole role, const QIcon &icon, const QString &text, QObject* parent) + : QAction(icon, text, parent) +{ + Q_D(QSoftKeyAction); + d->role = role; +} + +QSoftKeyAction::~QSoftKeyAction() +{ +} + +/*! + 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 +{ + Q_D(const QSoftKeyAction); + return d->role; +} + +/*! + Returns the custom role name if role() is Custom, or an empty + string otherwise. + + \sa role(), setRole() +*/ +QString QSoftKeyAction::roleName() const +{ + Q_D(const QSoftKeyAction); + 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(StandardRole role) +{ + Q_D(QSoftKeyAction); + 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) +{ + Q_D(QSoftKeyAction); + d->role = Custom; + d->roleName = role; + emit changed(); +} + +int QSoftKeyAction::nativePosition() const +{ + Q_D(const QSoftKeyAction); + return d->nativePosition; +} + +void QSoftKeyAction::setNativePosition(int position) +{ + Q_D(QSoftKeyAction); + d->nativePosition = position; +} + +int QSoftKeyAction::qtContextKey() const +{ + Q_D(const QSoftKeyAction); + return d->qtContextKey; +} + +void QSoftKeyAction::setQtContextKey(int key) +{ + Q_D(QSoftKeyAction); + d->qtContextKey = key; +} diff --git a/src/gui/widgets/qsoftkeyaction.h b/src/gui/widgets/qsoftkeyaction.h new file mode 100644 index 0000000..fc5baf1 --- /dev/null +++ b/src/gui/widgets/qsoftkeyaction.h @@ -0,0 +1,101 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSOFTKEYACTION_H +#define QSOFTKEYACTION_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +class QSoftKeyActionPrivate; + +class Q_GUI_EXPORT QSoftKeyAction : public QAction +{ + Q_DECLARE_PRIVATE(QSoftKeyAction) +public: + enum StandardRole { + Options, + Select, + Back, + Next, + Previous, + Ok, + Cancel, + Edit, + View, + BackSpace, + EndEdit, + RevertEdit, + Deselect, + Finish, + Menu, + Custom + }; + + QSoftKeyAction(QObject *parent); + QSoftKeyAction(StandardRole role, QObject *parent); + QSoftKeyAction(const QString &text, QObject *parent); + QSoftKeyAction(StandardRole role, const QString &text, QObject *parent); + QSoftKeyAction(const QIcon &icon, const QString &text, QObject *parent); + QSoftKeyAction(StandardRole role, const QIcon &icon, const QString &text, QObject *parent); + ~QSoftKeyAction(); + + StandardRole role() const; + QString roleName() const; + + void setRole(StandardRole role); + void setRole(const QString &role); + int nativePosition() const; + void setNativePosition(int position); + int qtContextKey() const; + void setQtContextKey(int position); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QSOFTKEYACTION_H diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp new file mode 100644 index 0000000..1054852 --- /dev/null +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -0,0 +1,102 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qsoftkeystack.h" +#include "qsoftkeystack_p.h" + +QSoftKeyStackPrivate::QSoftKeyStackPrivate() +{ + +} + +QSoftKeyStackPrivate::~QSoftKeyStackPrivate() +{ + +} + +void QSoftKeyStackPrivate::push(QSoftKeyAction *softKey) +{ + QSoftkeySet softKeySet; + softKeySet.append(softKey); + softKeyStack.push(softKeySet); + setNativeSoftKeys(); + +} +void QSoftKeyStackPrivate::push(const QList &softkeys) +{ + QSoftkeySet softKeySet(softkeys); + softKeyStack.push(softKeySet); + setNativeSoftKeys(); +} + +void QSoftKeyStackPrivate::pop() +{ + softKeyStack.pop(); + setNativeSoftKeys(); +} + +QSoftKeyStack::QSoftKeyStack(QWidget *parent) + : QObject(parent) +{ +} + +QSoftKeyStack::~QSoftKeyStack() +{ +} + +void QSoftKeyStack::push(QSoftKeyAction *softKey) +{ + Q_D(QSoftKeyStack); + d->push(softKey); +} + +void QSoftKeyStack::push(const QList &softKeys) +{ + Q_D(QSoftKeyStack); + d->push(softKeys); +} + +void QSoftKeyStack::pop() +{ + Q_D(QSoftKeyStack); + d->pop(); +} + diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h new file mode 100644 index 0000000..a9137d2 --- /dev/null +++ b/src/gui/widgets/qsoftkeystack.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSOFTKEYSTACK_H +#define QSOFTKEYSTACK_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +#define QSoftkeySet QList + +class QSoftKeyStackPrivate; +class QSoftKeyAction; + +class Q_GUI_EXPORT QSoftKeyStack : public QObject +{ + Q_DECLARE_PRIVATE(QSoftKeyStack) +public: + QSoftKeyStack(QWidget *parent); + ~QSoftKeyStack(); + +public: + void push(QSoftKeyAction *softKey); + void push(const QList &softkeys); + void pop(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QSOFTKEYSTACK_H diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h new file mode 100644 index 0000000..2e3fde1 --- /dev/null +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -0,0 +1,86 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSOFTKEYSTACK_P_H +#define QSOFTKEYSTACK_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "QtGui/qwidget.h" +#include "QtGui/qaction.h" +#include "qstack.h" + +#include "qsoftkeyaction.h" + +QT_BEGIN_NAMESPACE + +#define QSoftkeySet QList + +class QSoftKeyStackPrivate : public QObject +{ +public: + QSoftKeyStackPrivate(); + ~QSoftKeyStackPrivate(); + + void push(QSoftKeyAction *softKey); + void push(const QList &softKeys); + void pop(); + +private: + void mapSoftKeys(const QSoftkeySet &top); + void setNativeSoftKeys(); + +private: + QStack softKeyStack; +}; + +QT_END_NAMESPACE + +#endif // QSOFTKEYSTACK_P_H diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp new file mode 100644 index 0000000..ce4f116 --- /dev/null +++ b/src/gui/widgets/qsoftkeystack_s60.cpp @@ -0,0 +1,100 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the QtGui module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include + +#include "private/qcore_symbian_p.h" + +#include "qsoftkeystack_p.h" + +#define SOFTKEYSTART 5000 +#define SOFTKEYEND (5000 + Qt::Key_Context4) + +void QSoftKeyStackPrivate::mapSoftKeys(const 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 (appui); + CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba(); + nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + if (softKeyStack.isEmpty()) + return; + + const QSoftkeySet top = softKeyStack.top(); + mapSoftKeys(top); + + for (int index = 0; index < top.count(); index++) { + const QSoftKeyAction* softKeyAction = top.at(index); + HBufC* text = qt_QString2HBufCNewL(softKeyAction->text()); + CleanupStack::PushL(text); + if (softKeyAction->role() == QSoftKeyAction::Menu) { + nativeContainer->SetCommandL(softKeyAction->nativePosition(), EAknSoftkeyOptions, *text); + } else { + nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART + softKeyAction->qtContextKey(), *text); + } + CleanupStack::PopAndDestroy(); + } +} + + -- cgit v0.12