From 23b78dc988d9e5cf9e846510b0525166222b184c Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 29 Apr 2009 12:48:07 +0200 Subject: MSVC refuses to compile if variables get defined in a case block without braces. I think that is a useful feature. --- src/gui/styles/qs60style.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 58dcb98..059198d 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -2157,12 +2157,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); -- cgit v0.12 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 From d24c24b6c0c840d7bbea5e8b81e1faaea6b5fede Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 4 May 2009 11:18:34 +0200 Subject: Very rough implementation of setting multiple buttons. Current implementation is missing loads of needed functionality but is enough to start testing the initial API --- src/gui/softkeys/qsoftkeystack.cpp | 42 ++++++++++++++++++++++++-------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/gui/softkeys/qsoftkeystack.cpp b/src/gui/softkeys/qsoftkeystack.cpp index 669198b..158d382 100644 --- a/src/gui/softkeys/qsoftkeystack.cpp +++ b/src/gui/softkeys/qsoftkeystack.cpp @@ -15,6 +15,9 @@ #include #include +#include "private/qcore_symbian_p.h" + + #include "qsoftkeystack.h" QSoftKeyStackPrivate::QSoftKeyStackPrivate() @@ -29,41 +32,50 @@ 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(); + nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + if(softKeyStack.isEmpty()) + return; + + QSoftkeySet top = softKeyStack.top(); - switch( top.at(0)->role() ) + // 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;indexSetCommandSetL(R_AVKON_SOFTKEYS_BACK); - } - break; - default: - { - } + QSoftKeyAction* softKeyAction = top.at(index); + HBufC* text = qt_QString2HBufCNewL(softKeyAction->text()); + CleanupStack::PushL(text); + nativeContainer->SetCommandL(index+veryWeirdMagic, softKeyAction->role(), *text); + CleanupStack::PopAndDestroy(); + if (veryWeirdMagic==0) + veryWeirdMagic=1; } } void QSoftKeyStackPrivate::push(QSoftKeyAction *softKey) { - QSoftkeySet softkeys; - softkeys.append( softKey ); - softKeyStack.push(softkeys); + QSoftkeySet softKeySet; + softKeySet.append( softKey ); + softKeyStack.push(softKeySet); setNativeSoftKeys(); } void QSoftKeyStackPrivate::push( QList softkeys) { - + QSoftkeySet softKeySet(softkeys); + softKeyStack.push(softKeySet); + setNativeSoftKeys(); } void QSoftKeyStackPrivate::pop() { softKeyStack.pop(); + setNativeSoftKeys(); } EXPORT_C QSoftKeyStack::QSoftKeyStack(QWidget *parent) -- cgit v0.12 From 3a336c63f9eef19d99b114bda9ff375f84c99234 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 4 May 2009 11:19:47 +0200 Subject: More code to test the stack implementatioMore code to test the stack implementationn --- src/gui/softkeys/main.cpp | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index 4f452d6..fd82ce5 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -23,11 +23,24 @@ MainWindow::MainWindow(QWidget *parent) layout->addWidget(button); QSoftKeyStack *stack = new QSoftKeyStack(central); - QSoftKeyAction action(central); - action.setRole(QSoftKeyAction::Back); - int role = action.role(); - stack->push(&action); - + 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 myActionList; + myActionList.append(&action1); + myActionList.append(&action2); + myActionList.append(&action3); + stack->push(myActionList); + stack->pop(); + stack->push(&action1); + setCentralWidget(central); } -- cgit v0.12 From b83e03ce82c84eaaf08ac1df154dcaa88691063d Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 4 May 2009 13:17:52 +0200 Subject: Changed way how softkey command is mapped --- src/gui/softkeys/qsoftkeystack.cpp | 2 +- src/gui/softkeys/qsoftkeystack.h | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/gui/softkeys/qsoftkeystack.cpp b/src/gui/softkeys/qsoftkeystack.cpp index 158d382..6cbcddd 100644 --- a/src/gui/softkeys/qsoftkeystack.cpp +++ b/src/gui/softkeys/qsoftkeystack.cpp @@ -50,7 +50,7 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() QSoftKeyAction* softKeyAction = top.at(index); HBufC* text = qt_QString2HBufCNewL(softKeyAction->text()); CleanupStack::PushL(text); - nativeContainer->SetCommandL(index+veryWeirdMagic, softKeyAction->role(), *text); + nativeContainer->SetCommandL(index+veryWeirdMagic, SOFTKEYSTART+index, *text); CleanupStack::PopAndDestroy(); if (veryWeirdMagic==0) veryWeirdMagic=1; diff --git a/src/gui/softkeys/qsoftkeystack.h b/src/gui/softkeys/qsoftkeystack.h index d725954..98c2632 100644 --- a/src/gui/softkeys/qsoftkeystack.h +++ b/src/gui/softkeys/qsoftkeystack.h @@ -19,7 +19,8 @@ #include "qsoftkeyaction.h" #define QSoftkeySet QList - +#define SOFTKEYSTART 5000 +#define SOFTKEYEND 5004 class QSoftKeyStackPrivate : public QObject { Q_OBJECT -- cgit v0.12 From 93a61a4cbe092dce8e5d221858d6b613fa258f07 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 4 May 2009 14:26:13 +0200 Subject: Skeleton implementation allowing us to conviniently change place where softkeys are visualized on the screen. Added mapping to native and Qt id's for QSoftKeyActions. Added rudimentary implementation for reordering QSoftKeyActions. --- src/gui/softkeys/qsoftkeyaction.cpp | 22 ++++++++++++++++++++++ src/gui/softkeys/qsoftkeyaction.h | 4 ++++ src/gui/softkeys/qsoftkeystack.cpp | 33 +++++++++++++++++++++++++-------- src/gui/softkeys/qsoftkeystack.h | 3 ++- 4 files changed, 53 insertions(+), 9 deletions(-) diff --git a/src/gui/softkeys/qsoftkeyaction.cpp b/src/gui/softkeys/qsoftkeyaction.cpp index ac6cb01..bfa8330 100644 --- a/src/gui/softkeys/qsoftkeyaction.cpp +++ b/src/gui/softkeys/qsoftkeyaction.cpp @@ -26,6 +26,8 @@ public: QSoftKeyAction::StandardRole role; QString roleName; + int nativePosition; + int qtContextKey; }; /*! @@ -137,3 +139,23 @@ void QSoftKeyAction::setRole(const QString& role) 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 index 67401e2..85f5bc7 100644 --- a/src/gui/softkeys/qsoftkeyaction.h +++ b/src/gui/softkeys/qsoftkeyaction.h @@ -52,6 +52,10 @@ public: void setRole(QSoftKeyAction::StandardRole role); void setRole(const QString& role); + int nativePosition(); + void setNativePosition(int position); + int qtContextKey(); + void setQtContextKey(int position); QSoftKeyActionPrivate *d; }; diff --git a/src/gui/softkeys/qsoftkeystack.cpp b/src/gui/softkeys/qsoftkeystack.cpp index 6cbcddd..bd9a636 100644 --- a/src/gui/softkeys/qsoftkeystack.cpp +++ b/src/gui/softkeys/qsoftkeystack.cpp @@ -30,6 +30,29 @@ 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;indexsetNativePosition(index+veryWeirdMagic); + top.at(index)->setQtContextKey(Qt::Key_Context1+index); + if (veryWeirdMagic==0) + veryWeirdMagic=1; + } + } +} + void QSoftKeyStackPrivate::setNativeSoftKeys() { CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); @@ -40,20 +63,14 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() return; QSoftkeySet top = softKeyStack.top(); - - // 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; + mapSoftKeys(top); for (int index=0;indextext()); CleanupStack::PushL(text); - nativeContainer->SetCommandL(index+veryWeirdMagic, SOFTKEYSTART+index, *text); + nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART+softKeyAction->qtContextKey(), *text); CleanupStack::PopAndDestroy(); - if (veryWeirdMagic==0) - veryWeirdMagic=1; } } diff --git a/src/gui/softkeys/qsoftkeystack.h b/src/gui/softkeys/qsoftkeystack.h index 98c2632..add4ab9 100644 --- a/src/gui/softkeys/qsoftkeystack.h +++ b/src/gui/softkeys/qsoftkeystack.h @@ -20,7 +20,7 @@ #define QSoftkeySet QList #define SOFTKEYSTART 5000 -#define SOFTKEYEND 5004 +#define SOFTKEYEND 5005 class QSoftKeyStackPrivate : public QObject { Q_OBJECT @@ -34,6 +34,7 @@ public: void pop(); private: + void mapSoftKeys(QSoftkeySet& top); void setNativeSoftKeys(); private: -- cgit v0.12 From cfe8216b0fd5270d4dc90d5cf3df62e12d0c35b3 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 4 May 2009 14:30:41 +0200 Subject: Changed mapping of softkey id's --- src/gui/softkeys/qsoftkeystack.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gui/softkeys/qsoftkeystack.h b/src/gui/softkeys/qsoftkeystack.h index add4ab9..b96bf60 100644 --- a/src/gui/softkeys/qsoftkeystack.h +++ b/src/gui/softkeys/qsoftkeystack.h @@ -20,7 +20,8 @@ #define QSoftkeySet QList #define SOFTKEYSTART 5000 -#define SOFTKEYEND 5005 +#define SOFTKEYEND 5000+Qt::Key_Context4 + class QSoftKeyStackPrivate : public QObject { Q_OBJECT -- cgit v0.12 From 2e76d2bfedce77064fde85573f5267032ce7979e Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 4 May 2009 16:17:15 +0200 Subject: Added proper headers --- src/gui/softkeys/main.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index fd82ce5..e5a7065 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -1,3 +1,13 @@ +/**************************************************************************** +** +** 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 -- cgit v0.12 From 4bf005f424ed4aa86f3539ee3018bf11779550cd Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 11 May 2009 13:58:24 +0200 Subject: Refactored implementation so that it works with multiple QMainWindows --- src/gui/widgets/qmenu_symbian.cpp | 59 +++++++++++++++++++++++++-------------- 1 file changed, 38 insertions(+), 21 deletions(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 9e53df5..4c8b4ae 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -32,8 +32,10 @@ QT_BEGIN_NAMESPACE // ### FIX/Document this, we need some safe range of menu id's for Qt that don't clash with AIW ones +typedef QHash MenuBarHash; +Q_GLOBAL_STATIC(MenuBarHash, menubars) + #define QT_FIRST_MENU_ITEM 32000 -static QList s60_menubars; struct SymbianMenuItem { @@ -47,6 +49,15 @@ static QList symbianMenus; static QList nativeMenuBars; static uint qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; +bool menuExists() +{ + QWidget *w = qApp->activeWindow(); + QMenuBarPrivate *mb = menubars()->value(w); + if (!mb) + return false; + return true; +} + // ### FIX THIS, copy/paste of original (faulty) stripped text implementation. // Implementation should be removed from QAction implementation to some generic place static QString qt_strippedText_copy_from_qaction(QString s) @@ -167,7 +178,7 @@ static void setSoftkeys() { CEikButtonGroupContainer* cba = CEikonEnv::Static()->AppUiFactory()->Cba(); if (cba){ - if (s60_menubars.count()>0) + if (menuExists()) cba->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT); else cba->SetCommandSetL(R_AVKON_SOFTKEYS_EXIT); @@ -176,24 +187,23 @@ static void setSoftkeys() static void rebuildMenu() { - qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; - deleteAll( &symbianMenus ); - if (s60_menubars.count()==0) - return; - for (int i = 0; i < s60_menubars.last()->actions.size(); ++i) { - QSymbianMenuAction *symbianActionTopLevel = new QSymbianMenuAction; - symbianActionTopLevel->action = s60_menubars.last()->actions.at(i); - symbianActionTopLevel->parent = 0; - symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++; - qt_symbian_insert_action(symbianActionTopLevel, &symbianMenus); + QMenuBarPrivate *mb = 0; + setSoftkeys(); + QWidget *w = qApp->activeWindow(); + if (w) + { + mb = menubars()->value(w); + qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; + deleteAll( &symbianMenus ); + if (!mb) + return; + mb->symbian_menubar->rebuild(); } - - return; } Q_GUI_EXPORT void qt_symbian_show_toplevel( CEikMenuPane* menuPane) { - if (s60_menubars.count()==0) + if (!menuExists()) return; rebuildMenu(); for (int i = 0; i < symbianMenus.count(); ++i) @@ -251,6 +261,7 @@ void QMenuBarPrivate::symbianCreateMenuBar(QWidget *parent) { Q_Q(QMenuBar); if (parent && parent->isWindow()){ + menubars()->insert(q->window(), this); symbian_menubar = new QSymbianMenuBarPrivate(this); nativeMenuBars.append(q); } @@ -261,7 +272,7 @@ void QMenuBarPrivate::symbianDestroyMenuBar() Q_Q(QMenuBar); int index = nativeMenuBars.indexOf(q); nativeMenuBars.removeAt(index); - s60_menubars.removeLast(); + menubars()->remove(q->window()); rebuildMenu(); if (symbian_menubar) delete symbian_menubar; @@ -271,7 +282,6 @@ void QMenuBarPrivate::symbianDestroyMenuBar() QMenuBarPrivate::QSymbianMenuBarPrivate::QSymbianMenuBarPrivate(QMenuBarPrivate *menubar) { d = menubar; - s60_menubars.append(menubar); } QMenuBarPrivate::QSymbianMenuBarPrivate::~QSymbianMenuBarPrivate() @@ -364,10 +374,17 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::removeAction(QSymbianMenuAction *a void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild() { setSoftkeys(); - if (s60_menubars.count()==0) + qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; + deleteAll( &symbianMenus ); + if (!d) return; - - rebuildMenu(); - } + for (int i = 0; i < d->actions.size(); ++i) { + QSymbianMenuAction *symbianActionTopLevel = new QSymbianMenuAction; + symbianActionTopLevel->action = d->actions.at(i); + symbianActionTopLevel->parent = 0; + symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++; + qt_symbian_insert_action(symbianActionTopLevel, &symbianMenus); + } +} #endif //QT_NO_MENUBAR -- cgit v0.12 From 61b111228d0abf66130b229fcb6c5e2a54faecbf Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 12 May 2009 15:24:43 +0200 Subject: Removed setting native softkeys from menu implementation as from now on the menu softkey will be set by the brand new softkey stack. --- src/gui/widgets/qmenu_symbian.cpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index aee55b9..1dc727c 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -173,21 +173,9 @@ void deleteAll(QList *items) } } -static void setSoftkeys() -{ - CEikButtonGroupContainer* cba = CEikonEnv::Static()->AppUiFactory()->Cba(); - if (cba){ - if (menuExists()) - cba->SetCommandSetL(R_AVKON_SOFTKEYS_OPTIONS_EXIT); - else - cba->SetCommandSetL(R_AVKON_SOFTKEYS_EXIT); - } -} - static void rebuildMenu() { QMenuBarPrivate *mb = 0; - setSoftkeys(); QWidget *w = qApp->activeWindow(); if (w) { @@ -372,7 +360,6 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::removeAction(QSymbianMenuAction *a void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild() { - setSoftkeys(); qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; deleteAll( &symbianMenus ); if (!d) -- cgit v0.12 From 9ef6e374126ba212bccbf3cf61f86f8412099c49 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 12 May 2009 15:31:18 +0200 Subject: Initial naive implementation for menu softkey --- src/gui/softkeys/main.cpp | 29 ++++++++++++++++++++--------- src/gui/softkeys/qsoftkeyaction.h | 1 + 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index e5a7065..a61e512 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -11,8 +11,8 @@ #include #include -#include -#include +#include + #include "qsoftkeystack.h" class MainWindow : public QMainWindow @@ -26,22 +26,26 @@ public: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { - QWidget *central = new QWidget(this); - QVBoxLayout *layout = new QVBoxLayout(central); - QPushButton *button = new QPushButton("Hello"); - layout->addWidget(button); + QWidget *central = new QWidget(this); + + QMenuBar* menuBar = new QMenuBar(this); + menuBar->addAction("MyMenuItem1"); + this->setMenuBar(menuBar); QSoftKeyStack *stack = new QSoftKeyStack(central); QSoftKeyAction action1(central); - action1.setText(QString("text1")); + action1.setText(QString("Ok")); action1.setRole(QSoftKeyAction::Ok); QSoftKeyAction action2(central); - action2.setText(QString("text2")); + action2.setText(QString("Back")); action2.setRole(QSoftKeyAction::Back); QSoftKeyAction action3(central); - action3.setText(QString("text3")); + action3.setText(QString("Cancel")); action3.setRole(QSoftKeyAction::Cancel); + QSoftKeyAction action4(central); + action4.setText(QString("Menu")); + action4.setRole(QSoftKeyAction::Menu); QList myActionList; myActionList.append(&action1); @@ -50,6 +54,13 @@ MainWindow::MainWindow(QWidget *parent) stack->push(myActionList); stack->pop(); stack->push(&action1); + stack->pop(); + + QList myActionList2; + myActionList2.append(&action4); + myActionList2.append(&action1); + stack->push(myActionList2); + setCentralWidget(central); } diff --git a/src/gui/softkeys/qsoftkeyaction.h b/src/gui/softkeys/qsoftkeyaction.h index 85f5bc7..76be8ee 100644 --- a/src/gui/softkeys/qsoftkeyaction.h +++ b/src/gui/softkeys/qsoftkeyaction.h @@ -36,6 +36,7 @@ public: RevertEdit, Deselect, Finish, + Menu, Custom }; -- cgit v0.12 From 21d8da6365281426c50d6d5b8393d833e16d4096 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 12 May 2009 16:17:35 +0200 Subject: Added handling of softkey with the role of menu --- src/gui/softkeys/qsoftkeystack.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gui/softkeys/qsoftkeystack.cpp b/src/gui/softkeys/qsoftkeystack.cpp index bd9a636..c1d6e98 100644 --- a/src/gui/softkeys/qsoftkeystack.cpp +++ b/src/gui/softkeys/qsoftkeystack.cpp @@ -64,12 +64,18 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() QSoftkeySet top = softKeyStack.top(); mapSoftKeys(top); + for (int index=0;indextext()); CleanupStack::PushL(text); - nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART+softKeyAction->qtContextKey(), *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 From 27ace2c1eb1faecf01b6229cf7ebb7534a1c6125 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 May 2009 18:48:22 +0200 Subject: Qt-ifications. Mostly license headers and coding conventions. --- src/gui/softkeys/qsoftkeyaction.cpp | 48 ++++++++++++--- src/gui/softkeys/qsoftkeyaction.h | 60 ++++++++++++++----- src/gui/softkeys/qsoftkeystack.cpp | 104 ++++++++++++--------------------- src/gui/softkeys/qsoftkeystack.h | 91 ++++++++++++++--------------- src/gui/softkeys/qsoftkeystack_p.h | 86 +++++++++++++++++++++++++++ src/gui/softkeys/qsoftkeystack_s60.cpp | 100 +++++++++++++++++++++++++++++++ src/gui/softkeys/softkeys.pro | 2 + 7 files changed, 355 insertions(+), 136 deletions(-) create mode 100644 src/gui/softkeys/qsoftkeystack_p.h create mode 100644 src/gui/softkeys/qsoftkeystack_s60.cpp diff --git a/src/gui/softkeys/qsoftkeyaction.cpp b/src/gui/softkeys/qsoftkeyaction.cpp index bfa8330..1d21376 100644 --- a/src/gui/softkeys/qsoftkeyaction.cpp +++ b/src/gui/softkeys/qsoftkeyaction.cpp @@ -1,11 +1,41 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 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. +** This file is part of the QtGui module of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $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$ ** ****************************************************************************/ @@ -57,7 +87,7 @@ QSoftKeyAction::QSoftKeyAction(QObject *parent) d = new QSoftKeyActionPrivate(); } -QSoftKeyAction::QSoftKeyAction(QSoftKeyAction::StandardRole role, QObject *parent) +QSoftKeyAction::QSoftKeyAction(StandardRole role, QObject *parent) : QAction(parent) { d = new QSoftKeyActionPrivate(role); @@ -69,7 +99,7 @@ QSoftKeyAction::QSoftKeyAction(const QString &text, QObject* parent) d = new QSoftKeyActionPrivate(); } -QSoftKeyAction::QSoftKeyAction(QSoftKeyAction::StandardRole role, const QString &text, QObject* parent) +QSoftKeyAction::QSoftKeyAction(StandardRole role, const QString &text, QObject* parent) : QAction(text, parent) { d = new QSoftKeyActionPrivate(role); @@ -81,7 +111,7 @@ QSoftKeyAction::QSoftKeyAction(const QIcon &icon, const QString &text, QObject* d = new QSoftKeyActionPrivate(); } -QSoftKeyAction::QSoftKeyAction(QSoftKeyAction::StandardRole role, const QIcon &icon, const QString &text, QObject* parent) +QSoftKeyAction::QSoftKeyAction(StandardRole role, const QIcon &icon, const QString &text, QObject* parent) : QAction(icon, text, parent) { d = new QSoftKeyActionPrivate(role); @@ -120,7 +150,7 @@ QString QSoftKeyAction::roleName() const \sa role(), roleName() */ -void QSoftKeyAction::setRole(QSoftKeyAction::StandardRole role) +void QSoftKeyAction::setRole(StandardRole role) { d->role = role; d->roleName = QString(); @@ -140,7 +170,7 @@ void QSoftKeyAction::setRole(const QString& role) emit changed(); } -int QSoftKeyAction::nativePosition() +int QSoftKeyAction::nativePosition() const { return d->nativePosition; } @@ -150,7 +180,7 @@ void QSoftKeyAction::setNativePosition(int position) d->nativePosition = position; } -int QSoftKeyAction::qtContextKey() +int QSoftKeyAction::qtContextKey() const { return d->qtContextKey; } diff --git a/src/gui/softkeys/qsoftkeyaction.h b/src/gui/softkeys/qsoftkeyaction.h index 76be8ee..e735376 100644 --- a/src/gui/softkeys/qsoftkeyaction.h +++ b/src/gui/softkeys/qsoftkeyaction.h @@ -1,27 +1,57 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 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. +** This file is part of the QtGui module of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $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 +#include "QtGui/qaction.h" + +QT_BEGIN_NAMESPACE class QSoftKeyActionPrivate; class QSoftKeyAction : public QAction { - Q_OBJECT public: - enum StandardRole - { + enum StandardRole { Options, Select, Back, @@ -41,24 +71,26 @@ public: }; QSoftKeyAction(QObject *parent); - QSoftKeyAction(QSoftKeyAction::StandardRole role, QObject *parent); + QSoftKeyAction(StandardRole role, QObject *parent); QSoftKeyAction(const QString &text, QObject* parent); - QSoftKeyAction(QSoftKeyAction::StandardRole role, const QString &text, QObject* parent); + 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(StandardRole role, const QIcon &icon, const QString &text, QObject* parent); ~QSoftKeyAction(); - QSoftKeyAction::StandardRole role() const; + StandardRole role() const; QString roleName() const; - void setRole(QSoftKeyAction::StandardRole role); + void setRole(StandardRole role); void setRole(const QString& role); - int nativePosition(); + int nativePosition() const; void setNativePosition(int position); - int qtContextKey(); + 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 index c1d6e98..a8bd3a9 100644 --- a/src/gui/softkeys/qsoftkeystack.cpp +++ b/src/gui/softkeys/qsoftkeystack.cpp @@ -1,24 +1,46 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 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. +** This file is part of the QtGui module of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $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.h" +#include "qsoftkeystack_p.h" QSoftKeyStackPrivate::QSoftKeyStackPrivate() { @@ -30,65 +52,15 @@ 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;indexsetNativePosition(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; - - QSoftkeySet top = softKeyStack.top(); - mapSoftKeys(top); - - for (int index=0;indextext()); - 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(); - } -} - void QSoftKeyStackPrivate::push(QSoftKeyAction *softKey) { QSoftkeySet softKeySet; - softKeySet.append( softKey ); + softKeySet.append(softKey); softKeyStack.push(softKeySet); setNativeSoftKeys(); } -void QSoftKeyStackPrivate::push( QList softkeys) +void QSoftKeyStackPrivate::push(const QList &softkeys) { QSoftkeySet softKeySet(softkeys); softKeyStack.push(softKeySet); @@ -101,7 +73,7 @@ void QSoftKeyStackPrivate::pop() setNativeSoftKeys(); } -EXPORT_C QSoftKeyStack::QSoftKeyStack(QWidget *parent) +QSoftKeyStack::QSoftKeyStack(QWidget *parent) { d = new QSoftKeyStackPrivate(); } @@ -116,7 +88,7 @@ void QSoftKeyStack::push(QSoftKeyAction *softKey) d->push(softKey); } -void QSoftKeyStack::push(QList softKeys) +void QSoftKeyStack::push(const QList &softKeys) { d->push(softKeys); } diff --git a/src/gui/softkeys/qsoftkeystack.h b/src/gui/softkeys/qsoftkeystack.h index b96bf60..90df43d 100644 --- a/src/gui/softkeys/qsoftkeystack.h +++ b/src/gui/softkeys/qsoftkeystack.h @@ -1,77 +1,74 @@ /**************************************************************************** ** -** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). +** Copyright (C) 2009 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. +** This file is part of the QtGui module of the Qt Toolkit. ** -** $TROLLTECH_DUAL_LICENSE$ +** $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 -#include -#include +#include "QtGui/qwidget.h" +#include "QtGui/qaction.h" +#include "qstack.h" #include "qsoftkeyaction.h" -#define QSoftkeySet QList -#define SOFTKEYSTART 5000 -#define SOFTKEYEND 5000+Qt::Key_Context4 +QT_BEGIN_NAMESPACE -class QSoftKeyStackPrivate : public QObject - { - Q_OBJECT - public: - IMPORT_C QSoftKeyStackPrivate(); - ~QSoftKeyStackPrivate(); - -public: - void push(QSoftKeyAction *softKey); - void push(QList softKeys); - void pop(); - -private: - void mapSoftKeys(QSoftkeySet& top); - void setNativeSoftKeys(); - -private: - QStack softKeyStack; - }; - - - -/*class QSoftkeySet - { - const QList softkeys; - }; +#define QSoftkeySet QList +class QSoftKeyStackPrivate; -class QSoftkeySet - { - const QList softkeys; - }; -*/ class QSoftKeyStack : public QObject { - Q_OBJECT public: - IMPORT_C QSoftKeyStack(QWidget *parent); + QSoftKeyStack(QWidget *parent); ~QSoftKeyStack(); + public: void push(QSoftKeyAction *softKey); - void push(QList softkeys); + void push(const QList &softkeys); void pop(); -protected: - -private Q_SLOTS: 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 new file mode 100644 index 0000000..8e029af --- /dev/null +++ b/src/gui/softkeys/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/softkeys/qsoftkeystack_s60.cpp b/src/gui/softkeys/qsoftkeystack_s60.cpp new file mode 100644 index 0000000..ce4f116 --- /dev/null +++ b/src/gui/softkeys/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(); + } +} + + diff --git a/src/gui/softkeys/softkeys.pro b/src/gui/softkeys/softkeys.pro index 88a813e..6bb584e 100644 --- a/src/gui/softkeys/softkeys.pro +++ b/src/gui/softkeys/softkeys.pro @@ -3,11 +3,13 @@ TARGET = softkeys HEADERS += \ qsoftkeystack.h \ + qsoftkeystack_p.h \ qsoftkeyaction.h SOURCES += \ main.cpp \ qsoftkeyaction.cpp \ + qsoftkeystack_s60.cpp \ qsoftkeystack.cpp iCONFIG += qt debug warn_on -- cgit v0.12 From 282a724b26b734aa4d9406567f5ec4ca96e8c320 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 May 2009 18:49:38 +0200 Subject: Removed redundancies --- src/gui/softkeys/softkeys.pro | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/gui/softkeys/softkeys.pro b/src/gui/softkeys/softkeys.pro index 6bb584e..e9e700c 100644 --- a/src/gui/softkeys/softkeys.pro +++ b/src/gui/softkeys/softkeys.pro @@ -1,6 +1,3 @@ -TEMPLATE = app -TARGET = softkeys - HEADERS += \ qsoftkeystack.h \ qsoftkeystack_p.h \ @@ -11,5 +8,3 @@ SOURCES += \ qsoftkeyaction.cpp \ qsoftkeystack_s60.cpp \ qsoftkeystack.cpp - -iCONFIG += qt debug warn_on -- cgit v0.12 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 From f8de827f56c6548490681fd3b5c252853f6fffb6 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 May 2009 21:14:49 +0200 Subject: Adapted example code --- src/gui/softkeys/main.cpp | 6 +----- src/gui/softkeys/softkeys.pro | 10 +--------- 2 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index a61e512..c305d19 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -9,11 +9,7 @@ ** ****************************************************************************/ -#include -#include -#include - -#include "qsoftkeystack.h" +#include class MainWindow : public QMainWindow { diff --git a/src/gui/softkeys/softkeys.pro b/src/gui/softkeys/softkeys.pro index e9e700c..a16103e 100644 --- a/src/gui/softkeys/softkeys.pro +++ b/src/gui/softkeys/softkeys.pro @@ -1,10 +1,2 @@ -HEADERS += \ - qsoftkeystack.h \ - qsoftkeystack_p.h \ - qsoftkeyaction.h - SOURCES += \ - main.cpp \ - qsoftkeyaction.cpp \ - qsoftkeystack_s60.cpp \ - qsoftkeystack.cpp + main.cpp -- cgit v0.12 From a32fa3b48f2e58b409e27a465e99f5ef915ed3ed Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 12 May 2009 21:15:46 +0200 Subject: Adding qsoftkey* to widgets.pri. Currently, only for S60. It will spread as soon as it builds cross platform. --- src/gui/widgets/widgets.pri | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index fc57944..c9e68a1 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -162,5 +162,14 @@ wince*: { } symbian*: { - SOURCES += widgets/qmenu_symbian.cpp + HEADERS += \ + widgets/qsoftkeyaction.h \ + widgets/qsoftkeystack.h \ + widgets/qsoftkeystack_p.h + + SOURCES += \ + widgets/qmenu_symbian.cpp \ + widgets/qsoftkeyaction.cpp \ + widgets/qsoftkeystack.cpp \ + widgets/qsoftkeystack_s60.cpp } -- cgit v0.12 From af612206adc919e3c13b7856f9f7c020ef9c3a7b Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 13 May 2009 14:52:25 +0200 Subject: Fixed pImpl, the private object were not created. --- src/gui/widgets/qsoftkeyaction.cpp | 21 ++++++++++++++------- src/gui/widgets/qsoftkeyaction.h | 5 ++++- src/gui/widgets/qsoftkeystack.cpp | 2 +- src/gui/widgets/qsoftkeystack.h | 6 ++++-- src/gui/widgets/qsoftkeystack_p.h | 6 +++--- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/gui/widgets/qsoftkeyaction.cpp b/src/gui/widgets/qsoftkeyaction.cpp index 51b80bc..583cf65 100644 --- a/src/gui/widgets/qsoftkeyaction.cpp +++ b/src/gui/widgets/qsoftkeyaction.cpp @@ -40,13 +40,14 @@ ****************************************************************************/ #include "qsoftkeyaction.h" +#include /*! \class QSoftKeyAction \brief The QSoftKeyAction class defines a special kind of QAction that may also be displayed in a QSoftKeyBar. */ -class QSoftKeyActionPrivate +class QSoftKeyActionPrivate : public QActionPrivate { public: QSoftKeyActionPrivate(QSoftKeyAction::StandardRole role = QSoftKeyAction::Custom) @@ -82,37 +83,43 @@ public: */ QSoftKeyAction::QSoftKeyAction(QObject *parent) - : QAction(parent) + : QAction(*new QSoftKeyActionPrivate(), parent) { } QSoftKeyAction::QSoftKeyAction(StandardRole role, QObject *parent) - : QAction(parent) + : QAction(*new QSoftKeyActionPrivate(), parent) { Q_D(QSoftKeyAction); d->role = role; } QSoftKeyAction::QSoftKeyAction(const QString &text, QObject* parent) - : QAction(text, parent) + : QAction(*new QSoftKeyActionPrivate(), parent) { + setText(text); } QSoftKeyAction::QSoftKeyAction(StandardRole role, const QString &text, QObject* parent) - : QAction(text, parent) + : QAction(*new QSoftKeyActionPrivate(), parent) { + setText(text); Q_D(QSoftKeyAction); d->role = role; } QSoftKeyAction::QSoftKeyAction(const QIcon &icon, const QString &text, QObject* parent) - : QAction(icon, text, parent) + : QAction(*new QSoftKeyActionPrivate(), parent) { + setIcon(icon); + setText(text); } QSoftKeyAction::QSoftKeyAction(StandardRole role, const QIcon &icon, const QString &text, QObject* parent) - : QAction(icon, text, parent) + : QAction(*new QSoftKeyActionPrivate(), parent) { + setIcon(icon); + setText(text); Q_D(QSoftKeyAction); d->role = role; } diff --git a/src/gui/widgets/qsoftkeyaction.h b/src/gui/widgets/qsoftkeyaction.h index fc5baf1..26fa601 100644 --- a/src/gui/widgets/qsoftkeyaction.h +++ b/src/gui/widgets/qsoftkeyaction.h @@ -54,7 +54,6 @@ class QSoftKeyActionPrivate; class Q_GUI_EXPORT QSoftKeyAction : public QAction { - Q_DECLARE_PRIVATE(QSoftKeyAction) public: enum StandardRole { Options, @@ -92,6 +91,10 @@ public: void setNativePosition(int position); int qtContextKey() const; void setQtContextKey(int position); + +private: + Q_DECLARE_PRIVATE(QSoftKeyAction) + Q_DISABLE_COPY(QSoftKeyAction) }; QT_END_NAMESPACE diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 1054852..687b236 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -74,7 +74,7 @@ void QSoftKeyStackPrivate::pop() } QSoftKeyStack::QSoftKeyStack(QWidget *parent) - : QObject(parent) + : QObject(*new QSoftKeyStackPrivate, parent) { } diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index a9137d2..66edab0 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -57,15 +57,17 @@ 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(); + +private: + Q_DECLARE_PRIVATE(QSoftKeyStack) + Q_DISABLE_COPY(QSoftKeyStack) }; QT_END_NAMESPACE diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index 2e3fde1..1e8d0d1 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -53,9 +53,9 @@ // We mean it. // -#include "QtGui/qwidget.h" -#include "QtGui/qaction.h" + #include "qstack.h" +#include #include "qsoftkeyaction.h" @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE #define QSoftkeySet QList -class QSoftKeyStackPrivate : public QObject +class QSoftKeyStackPrivate : public QObjectPrivate { public: QSoftKeyStackPrivate(); -- cgit v0.12 From a28a4bccad5d885bf3ac5f58a8febb8d59fffe0f Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 13 May 2009 16:25:24 +0200 Subject: Added Methods to set and access QSoftKeyStack from QMainWindow. --- src/gui/softkeys/main.cpp | 8 ++++++ src/gui/widgets/qmainwindow.cpp | 47 +++++++++++++++++++++++++++++++++++ src/gui/widgets/qmainwindow.h | 11 ++++++-- src/gui/widgets/qsoftkeyaction.h | 1 + src/gui/widgets/qsoftkeystack_s60.cpp | 17 +++++++------ 5 files changed, 75 insertions(+), 9 deletions(-) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index c305d19..6a75c40 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -30,6 +30,8 @@ MainWindow::MainWindow(QWidget *parent) this->setMenuBar(menuBar); QSoftKeyStack *stack = new QSoftKeyStack(central); + setSoftKeyStack(stack); + QSoftKeyAction action1(central); action1.setText(QString("Ok")); action1.setRole(QSoftKeyAction::Ok); @@ -43,6 +45,11 @@ MainWindow::MainWindow(QWidget *parent) action4.setText(QString("Menu")); action4.setRole(QSoftKeyAction::Menu); + QSoftKeyAction action5(central); + action5.setText(QString("ContextMenu")); + action5.setRole(QSoftKeyAction::ContextMenu); + + QList myActionList; myActionList.append(&action1); myActionList.append(&action2); @@ -55,6 +62,7 @@ MainWindow::MainWindow(QWidget *parent) QList myActionList2; myActionList2.append(&action4); myActionList2.append(&action1); + myActionList2.append(&action5); stack->push(myActionList2); diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 502c1e9..43bc098 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -66,6 +66,10 @@ extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp QT_END_NAMESPACE #endif +#ifndef QT_NO_SOFTKEYSTACK +#include +#endif + QT_BEGIN_NAMESPACE class QMainWindowPrivate : public QWidgetPrivate @@ -80,6 +84,9 @@ public: #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) , hasOldCursor(false) , cursorAdjusted(false) #endif +#ifndef QT_NO_SOFTKEYSTACK + , softKeyStack(0) +#endif { } QMainWindowLayout *layout; QSize iconSize; @@ -99,6 +106,10 @@ public: uint hasOldCursor : 1; uint cursorAdjusted : 1; #endif + +#ifndef QT_NO_SOFTKEYSTACK + QSoftKeyStack* softKeyStack; +#endif }; void QMainWindowPrivate::init() @@ -514,6 +525,42 @@ void QMainWindow::setMenuWidget(QWidget *menuBar) } #endif // QT_NO_MENUBAR +#ifndef QT_NO_SOFTKEYSTACK +/*! + Returns the softkey stack for the main window. This function creates + and returns an empty soft key stack if the stack does not exist. + + \sa softKeyStack() +*/ +QSoftKeyStack *QMainWindow::softKeyStack() const +{ + if (!d_func()->softKeyStack) { + QMainWindow *self = const_cast(this); + QSoftKeyStack* softKeyStack = new QSoftKeyStack(self); + self->setSoftKeyStack(softKeyStack); + } + return d_func()->softKeyStack; +} + +/*! + Sets the softkey stackfor the main window to \a softKeyStack. + + Note: QMainWindow takes ownership of the \a softKeyStack pointer and + deletes it at the appropriate time. + + \sa softKeyStack() +*/ +void QMainWindow::setSoftKeyStack(QSoftKeyStack *softKeyStack) +{ + Q_D(QMainWindow); + if (d->softKeyStack && d->softKeyStack != softKeyStack) { + QSoftKeyStack *oldSoftKeyStack = d->softKeyStack; + delete oldSoftKeyStack; + } + d->softKeyStack = softKeyStack; +} +#endif // QT_NO_SOFTKEYSTACK + #ifndef QT_NO_STATUSBAR /*! Returns the status bar for the main window. This function creates diff --git a/src/gui/widgets/qmainwindow.h b/src/gui/widgets/qmainwindow.h index 9983c7a..e2dcd5e 100644 --- a/src/gui/widgets/qmainwindow.h +++ b/src/gui/widgets/qmainwindow.h @@ -59,7 +59,9 @@ class QMenuBar; class QStatusBar; class QToolBar; class QMenu; - +#ifndef QT_NO_SOFTKEYSTACK +class QSoftKeyStack; +#endif class Q_GUI_EXPORT QMainWindow : public QWidget { Q_OBJECT @@ -129,7 +131,12 @@ public: QWidget *menuWidget() const; void setMenuWidget(QWidget *menubar); #endif - + +#ifndef QT_NO_SOFTKEYSTACK + QSoftKeyStack *softKeyStack() const; + void setSoftKeyStack(QSoftKeyStack *softKeyStack); +#endif + #ifndef QT_NO_STATUSBAR QStatusBar *statusBar() const; void setStatusBar(QStatusBar *statusbar); diff --git a/src/gui/widgets/qsoftkeyaction.h b/src/gui/widgets/qsoftkeyaction.h index 26fa601..4ce5c5b 100644 --- a/src/gui/widgets/qsoftkeyaction.h +++ b/src/gui/widgets/qsoftkeyaction.h @@ -71,6 +71,7 @@ public: Deselect, Finish, Menu, + ContextMenu, Custom }; diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp index ce4f116..35835f6 100644 --- a/src/gui/widgets/qsoftkeystack_s60.cpp +++ b/src/gui/widgets/qsoftkeystack_s60.cpp @@ -86,14 +86,17 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() 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); + if (softKeyAction->role() != QSoftKeyAction::ContextMenu) { + + 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(); } - CleanupStack::PopAndDestroy(); } } -- cgit v0.12 From 062e913e56a104f7d794cd4a7cecebbd33ead5a9 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 13 May 2009 19:27:24 +0200 Subject: QSoftKeyStack::handleSoftKeyPress(int command) will be called whenever a softkey is pressed. --- src/gui/widgets/qsoftkeystack.h | 2 ++ src/gui/widgets/qsoftkeystack_p.h | 5 +++++ src/gui/widgets/qsoftkeystack_s60.cpp | 9 +++++---- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index 66edab0..ca06072 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -65,6 +65,8 @@ public: void push(const QList &softkeys); void pop(); + void handleSoftKeyPress(int command); + private: Q_DECLARE_PRIVATE(QSoftKeyStack) Q_DISABLE_COPY(QSoftKeyStack) diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index 1e8d0d1..77ae553 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -58,9 +58,14 @@ #include #include "qsoftkeyaction.h" +#include "qsoftkeystack.h" QT_BEGIN_NAMESPACE +// The following 2 defines may only be needed for s60. To be seen. +#define SOFTKEYSTART 5000 +#define SOFTKEYEND (5000 + Qt::Key_Context4) + #define QSoftkeySet QList class QSoftKeyStackPrivate : public QObjectPrivate diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp index 35835f6..9e90fdf 100644 --- a/src/gui/widgets/qsoftkeystack_s60.cpp +++ b/src/gui/widgets/qsoftkeystack_s60.cpp @@ -49,9 +49,6 @@ #include "qsoftkeystack_p.h" -#define SOFTKEYSTART 5000 -#define SOFTKEYEND (5000 + Qt::Key_Context4) - void QSoftKeyStackPrivate::mapSoftKeys(const QSoftkeySet &top) { if (top.count() == 1) { @@ -100,4 +97,8 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() } } - +void QSoftKeyStack::handleSoftKeyPress(int command) +{ + // Do the magic, here. + // Map the command back to actual softkey on the top of the stack and handle it +} -- cgit v0.12 From 3cd818783435ceb1314aba9a94f575ab52bd3d0f Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 13 May 2009 19:28:56 +0200 Subject: If the command is in a magic range pass it along to a currently active QMainWindow's softKeyStack. --- src/gui/kernel/qapplication_s60.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 72c2855..c0b4dc5 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -28,6 +28,9 @@ #include "private/qwindowsurface_s60_p.h" #include "qpaintengine.h" #include "qmenubar.h" +#include "qmainwindow.h" +#include "qsoftkeystack.h" +#include "private/qsoftkeystack_p.h" #include "apgwgnam.h" // For CApaWindowGroupName #include // For CMdaAudioToneUtility @@ -1019,8 +1022,14 @@ void QApplication::s60HandleCommandL(int command) qApp->exit(); break; default: - // For now assume all unknown menu items are Qt menu items - QMenuBar::symbianCommands(command); + if (command >= SOFTKEYSTART && command <= SOFTKEYEND) { + const QMainWindow *activeMainWindow = + qobject_cast(QApplication::activeWindow()); + if (activeMainWindow) + activeMainWindow->softKeyStack()->handleSoftKeyPress(command); + } else { + QMenuBar::symbianCommands(command); + } break; } } -- cgit v0.12 From b60c4838f3a40609136c45e4832b50007dc2be37 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 13 May 2009 19:29:12 +0200 Subject: Less meat. --- src/gui/kernel/qapplication_s60.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index c0b4dc5..8cf2f8f 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1017,9 +1017,8 @@ void QApplication::s60HandleCommandL(int command) { switch (command) { case EEikCmdExit: - case EAknSoftkeyBack: case EAknSoftkeyExit: - qApp->exit(); + exit(); break; default: if (command >= SOFTKEYSTART && command <= SOFTKEYEND) { -- cgit v0.12 From 99d848f54c34aaa935d67ec406352bbafef03ae9 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 14 May 2009 21:27:30 +0200 Subject: Use the new QMainWindow::softKeyStack() --- src/gui/softkeys/main.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index 6a75c40..e69156a 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -23,15 +23,16 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { - QWidget *central = new QWidget(this); + QWidget *central = new QWidget(this); + central->setLayout(new QVBoxLayout); + central->layout()->addWidget(new QPushButton); + central->layout()->addWidget(new QPushButton); + central->layout()->addWidget(new QPushButton); QMenuBar* menuBar = new QMenuBar(this); menuBar->addAction("MyMenuItem1"); this->setMenuBar(menuBar); - QSoftKeyStack *stack = new QSoftKeyStack(central); - setSoftKeyStack(stack); - QSoftKeyAction action1(central); action1.setText(QString("Ok")); action1.setRole(QSoftKeyAction::Ok); @@ -54,16 +55,16 @@ MainWindow::MainWindow(QWidget *parent) myActionList.append(&action1); myActionList.append(&action2); myActionList.append(&action3); - stack->push(myActionList); - stack->pop(); - stack->push(&action1); - stack->pop(); + softKeyStack()->push(myActionList); + softKeyStack()->pop(); + softKeyStack()->push(&action1); + softKeyStack()->pop(); QList myActionList2; myActionList2.append(&action4); myActionList2.append(&action1); myActionList2.append(&action5); - stack->push(myActionList2); + softKeyStack()->push(myActionList2); setCentralWidget(central); -- cgit v0.12 From 285ce9a19f2dd16f0aca650b52ac25daf6656b09 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Thu, 14 May 2009 21:28:30 +0200 Subject: Connecting to focusChanged in order to ask the freshly focussed widget for its actions. --- src/gui/widgets/qsoftkeystack.cpp | 26 ++++++++++++++++++++++++++ src/gui/widgets/qsoftkeystack.h | 4 ++++ 2 files changed, 30 insertions(+) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 687b236..61f7b64 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -41,6 +41,8 @@ #include "qsoftkeystack.h" #include "qsoftkeystack_p.h" +#include "qapplication.h" +#include "qmainwindow.h" QSoftKeyStackPrivate::QSoftKeyStackPrivate() { @@ -76,6 +78,7 @@ void QSoftKeyStackPrivate::pop() QSoftKeyStack::QSoftKeyStack(QWidget *parent) : QObject(*new QSoftKeyStackPrivate, parent) { + connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), SLOT(handleFocusChanged(QWidget*, QWidget*))); } QSoftKeyStack::~QSoftKeyStack() @@ -100,3 +103,26 @@ void QSoftKeyStack::pop() d->pop(); } +void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) +{ + if (!now) + return; + bool nowInOurMainWindow = false; + const QMainWindow *ourMainWindow = qobject_cast(parent()); + Q_ASSERT(ourMainWindow); + + // "ourMainWindow" in parent chain of "now"? Isn't there a helper in Qt for this? + QWidget *nowParent = now; + while (nowParent = nowParent->parentWidget()) { + if (nowParent == ourMainWindow) { + nowInOurMainWindow = true; + break; + } + } + + if (!nowInOurMainWindow) + return; + + QList actions = now->actions(); + // Do something with these actions. +} diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index ca06072..d126b32 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -57,6 +57,7 @@ class QSoftKeyAction; class Q_GUI_EXPORT QSoftKeyStack : public QObject { + Q_OBJECT public: QSoftKeyStack(QWidget *parent); ~QSoftKeyStack(); @@ -67,6 +68,9 @@ public: void handleSoftKeyPress(int command); +private Q_SLOTS: + void handleFocusChanged(QWidget *old, QWidget *now); + private: Q_DECLARE_PRIVATE(QSoftKeyStack) Q_DISABLE_COPY(QSoftKeyStack) -- cgit v0.12 From c0e517977eefb579628c66716fa6bfcf5058f6b1 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Fri, 15 May 2009 12:05:37 +0200 Subject: Added method to return top of the stack --- src/gui/widgets/qsoftkeystack.cpp | 11 +++++++++++ src/gui/widgets/qsoftkeystack.h | 1 + src/gui/widgets/qsoftkeystack_p.h | 3 ++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 61f7b64..fc6e107 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -75,6 +75,11 @@ void QSoftKeyStackPrivate::pop() setNativeSoftKeys(); } +const QSoftkeySet& QSoftKeyStackPrivate::top() +{ + return softKeyStack.top(); +} + QSoftKeyStack::QSoftKeyStack(QWidget *parent) : QObject(*new QSoftKeyStackPrivate, parent) { @@ -103,6 +108,12 @@ void QSoftKeyStack::pop() d->pop(); } +const QSoftkeySet& QSoftKeyStack::top() +{ + Q_D(QSoftKeyStack); + return d->top(); +} + void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) { if (!now) diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index d126b32..c9a05c3 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -65,6 +65,7 @@ public: void push(QSoftKeyAction *softKey); void push(const QList &softkeys); void pop(); + const QSoftkeySet& top(); void handleSoftKeyPress(int command); diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index 77ae553..06e9253 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -77,7 +77,8 @@ public: void push(QSoftKeyAction *softKey); void push(const QList &softKeys); void pop(); - + const QSoftkeySet& top(); + private: void mapSoftKeys(const QSoftkeySet &top); void setNativeSoftKeys(); -- cgit v0.12 From c5417af885d7e9ff52f0b27526516dd39a788288 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 18 May 2009 10:52:17 +0200 Subject: Initial implementation for context menus --- src/gui/widgets/qmenu_symbian.cpp | 45 ++++++++++++++++++++++++++++++--------- src/gui/widgets/qmenubar_p.h | 1 + src/gui/widgets/qsoftkeyaction.h | 2 +- 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 1dc727c..b9633b5 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -26,7 +26,8 @@ #include #include #include - +#include +#include #ifndef QT_NO_MENUBAR QT_BEGIN_NAMESPACE @@ -47,6 +48,7 @@ struct SymbianMenuItem static QList symbianMenus; static QList nativeMenuBars; static uint qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; +static QWidget* widgetWithContextMenu=0; bool menuExists() { @@ -177,6 +179,22 @@ static void rebuildMenu() { QMenuBarPrivate *mb = 0; QWidget *w = qApp->activeWindow(); + QMainWindow *mainWindow = qobject_cast(w); + QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); + const QSoftkeySet& softKeyTop = softKeyStack->top(); + + int index=0; + bool found=false; + while( indexrole(); + if(softAction->role() == QSoftKeyAction::ContextMenu) { + widgetWithContextMenu = softAction->parentWidget(); + found=true; + } + index++; + } if (w) { mb = menubars()->value(w); @@ -186,7 +204,8 @@ static void rebuildMenu() return; mb->symbian_menubar->rebuild(); } - } + widgetWithContextMenu = 0; +} Q_GUI_EXPORT void qt_symbian_show_toplevel( CEikMenuPane* menuPane) { @@ -358,21 +377,27 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::removeAction(QSymbianMenuAction *a rebuild(); } -void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild() +void QMenuBarPrivate::QSymbianMenuBarPrivate::InsertNativeMenuItems(const QList &actions) { - qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; - deleteAll( &symbianMenus ); - if (!d) - return; - for (int i = 0; i < d->actions.size(); ++i) { + for (int i = 0; i action = d->actions.at(i); + symbianActionTopLevel->action = actions.at(i); symbianActionTopLevel->parent = 0; symbianActionTopLevel->command = qt_symbian_menu_static_cmd_id++; qt_symbian_insert_action(symbianActionTopLevel, &symbianMenus); - } + } } +void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild() +{ + qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; + deleteAll( &symbianMenus ); + if (d) + InsertNativeMenuItems(d->actions); + + if (widgetWithContextMenu) + InsertNativeMenuItems(widgetWithContextMenu->actions()); + } QT_END_NAMESPACE #endif //QT_NO_MENUBAR diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h index d562cd9..1b9bac7 100644 --- a/src/gui/widgets/qmenubar_p.h +++ b/src/gui/widgets/qmenubar_p.h @@ -257,6 +257,7 @@ public: } return 0; } + void InsertNativeMenuItems(const QList &actions); } *symbian_menubar; bool symbianCommands(int command); diff --git a/src/gui/widgets/qsoftkeyaction.h b/src/gui/widgets/qsoftkeyaction.h index 4ce5c5b..43c4ea7 100644 --- a/src/gui/widgets/qsoftkeyaction.h +++ b/src/gui/widgets/qsoftkeyaction.h @@ -56,7 +56,7 @@ class Q_GUI_EXPORT QSoftKeyAction : public QAction { public: enum StandardRole { - Options, + Options=0, Select, Back, Next, -- cgit v0.12 From 620cfd6a8d4fc84f5626b7eac3b70882620d5ef1 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 18 May 2009 10:52:50 +0200 Subject: Refactored test code and added test case for context sensitive menu --- src/gui/softkeys/main.cpp | 69 ++++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index e69156a..b0d5ae1 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -16,59 +16,72 @@ class MainWindow : public QMainWindow Q_OBJECT public: MainWindow(QWidget *parent = 0); - ~MainWindow() {} + ~MainWindow(); + QAction* context1; + QAction* context2; + QAction* context3; + QSoftKeyAction *action1; + QSoftKeyAction *action2; + QSoftKeyAction *action3; + QSoftKeyAction *action4; + QSoftKeyAction *action5; }; MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) + : QMainWindow(parent), + context1(0), context2(0), context3(0), + action1(0),action2(0),action3(0),action4(0),action5(0) + { - QWidget *central = new QWidget(this); central->setLayout(new QVBoxLayout); central->layout()->addWidget(new QPushButton); central->layout()->addWidget(new QPushButton); central->layout()->addWidget(new QPushButton); - + context1 = new QAction(QString("Context1"), central); + context2 = new QAction(QString("Context2"), central); + context3 = new QAction(QString("Context3"), context2); + central->addAction(context1); + central->addAction(context2); QMenuBar* menuBar = new QMenuBar(this); menuBar->addAction("MyMenuItem1"); this->setMenuBar(menuBar); - QSoftKeyAction action1(central); - action1.setText(QString("Ok")); - action1.setRole(QSoftKeyAction::Ok); - QSoftKeyAction action2(central); - action2.setText(QString("Back")); - action2.setRole(QSoftKeyAction::Back); - QSoftKeyAction action3(central); - action3.setText(QString("Cancel")); - action3.setRole(QSoftKeyAction::Cancel); - QSoftKeyAction action4(central); - action4.setText(QString("Menu")); - action4.setRole(QSoftKeyAction::Menu); - - QSoftKeyAction action5(central); - action5.setText(QString("ContextMenu")); - action5.setRole(QSoftKeyAction::ContextMenu); - + action1 = new QSoftKeyAction(QSoftKeyAction::Ok, QString("Ok"), central); + action2 = new QSoftKeyAction(QSoftKeyAction::Back, QString("Back"), central); + action3 = new QSoftKeyAction(QSoftKeyAction::Cancel, QString("Cancel"), central); + action4 = new QSoftKeyAction(QSoftKeyAction::Menu, QString("Menu"), central); + action5 = new QSoftKeyAction(QSoftKeyAction::ContextMenu,QString("ContextMenu"), central); + QList myActionList; - myActionList.append(&action1); - myActionList.append(&action2); - myActionList.append(&action3); + myActionList.append(action1); + myActionList.append(action2); + myActionList.append(action3); softKeyStack()->push(myActionList); softKeyStack()->pop(); - softKeyStack()->push(&action1); + softKeyStack()->push(action1); softKeyStack()->pop(); QList myActionList2; - myActionList2.append(&action4); - myActionList2.append(&action1); - myActionList2.append(&action5); + myActionList2.append(action4); + myActionList2.append(action5); softKeyStack()->push(myActionList2); setCentralWidget(central); } +MainWindow::~MainWindow() +{ + delete context1; + delete context2; + delete context3; + delete action1; + delete action2; + delete action3; + delete action4; + delete action5; +} int main(int argc, char *argv[]) { -- cgit v0.12 From 1e2b8d3d63c05bc81f2024959480235489a479a7 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 18 May 2009 11:00:52 +0200 Subject: Added test case for submenus inside context sensitive menu --- src/gui/softkeys/main.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index b0d5ae1..e89c737 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -17,6 +17,7 @@ class MainWindow : public QMainWindow public: MainWindow(QWidget *parent = 0); ~MainWindow(); + QMenu *contextMenu; QAction* context1; QAction* context2; QAction* context3; @@ -29,24 +30,30 @@ public: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), + contextMenu(0), context1(0), context2(0), context3(0), action1(0),action2(0),action3(0),action4(0),action5(0) { QWidget *central = new QWidget(this); + contextMenu = new QMenu(); + central->setLayout(new QVBoxLayout); central->layout()->addWidget(new QPushButton); central->layout()->addWidget(new QPushButton); central->layout()->addWidget(new QPushButton); context1 = new QAction(QString("Context1"), central); context2 = new QAction(QString("Context2"), central); - context3 = new QAction(QString("Context3"), context2); + + context3 = new QAction(QString("Context3"), contextMenu); central->addAction(context1); central->addAction(context2); QMenuBar* menuBar = new QMenuBar(this); menuBar->addAction("MyMenuItem1"); this->setMenuBar(menuBar); - + context2->setMenu(contextMenu); + contextMenu->addAction(context3); + action1 = new QSoftKeyAction(QSoftKeyAction::Ok, QString("Ok"), central); action2 = new QSoftKeyAction(QSoftKeyAction::Back, QString("Back"), central); action3 = new QSoftKeyAction(QSoftKeyAction::Cancel, QString("Cancel"), central); @@ -81,6 +88,7 @@ MainWindow::~MainWindow() delete action3; delete action4; delete action5; + delete contextMenu; } int main(int argc, char *argv[]) -- cgit v0.12 From bfe64f383c418b37a71ad2b395dc207d47916a90 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 18 May 2009 13:53:59 +0200 Subject: Fixed SOFTKEYEND definition to be of right value --- src/gui/widgets/qsoftkeystack_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index 06e9253..a8ab2d5 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -64,7 +64,7 @@ QT_BEGIN_NAMESPACE // The following 2 defines may only be needed for s60. To be seen. #define SOFTKEYSTART 5000 -#define SOFTKEYEND (5000 + Qt::Key_Context4) +#define SOFTKEYEND (5000 + Qt::Key_Context4-Qt::Key_Context1) #define QSoftkeySet QList -- cgit v0.12 From 906c9646b448aeaaeba89bf66e9fc4ce2bb305c9 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 18 May 2009 13:54:32 +0200 Subject: Catch actions coming from context sensitive menu items --- src/gui/softkeys/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index e89c737..6adbb2d 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -15,6 +15,12 @@ class MainWindow : public QMainWindow { Q_OBJECT public: + +private slots: + void context1Slot(); + void context3Slot(); +public: + MainWindow(QWidget *parent = 0); ~MainWindow(); QMenu *contextMenu; @@ -54,6 +60,8 @@ MainWindow::MainWindow(QWidget *parent) context2->setMenu(contextMenu); contextMenu->addAction(context3); + connect(context1, SIGNAL(triggered()), this, SLOT(context1Slot())); + connect(context3, SIGNAL(triggered()), this, SLOT(context3Slot())); action1 = new QSoftKeyAction(QSoftKeyAction::Ok, QString("Ok"), central); action2 = new QSoftKeyAction(QSoftKeyAction::Back, QString("Back"), central); action3 = new QSoftKeyAction(QSoftKeyAction::Cancel, QString("Cancel"), central); @@ -91,6 +99,13 @@ MainWindow::~MainWindow() delete contextMenu; } +void MainWindow::context1Slot() + { + } +void MainWindow::context3Slot() + { + } + int main(int argc, char *argv[]) { QApplication app(argc, argv); -- cgit v0.12 From e4010084c0dcf05f417e5aca6c8c0ad1767599ca Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 18 May 2009 14:20:45 +0200 Subject: Implemented handling keypresses coming from software keys --- src/gui/widgets/qsoftkeystack.cpp | 6 ++++++ src/gui/widgets/qsoftkeystack_p.h | 1 + src/gui/widgets/qsoftkeystack_s60.cpp | 15 +++++++++++---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index fc6e107..14daecd 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -137,3 +137,9 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) QList actions = now->actions(); // Do something with these actions. } + +void QSoftKeyStack::handleSoftKeyPress(int command) +{ + Q_D(QSoftKeyStack); + d->handleSoftKeyPress(command); +} diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index a8ab2d5..2469648 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -78,6 +78,7 @@ public: void push(const QList &softKeys); void pop(); const QSoftkeySet& top(); + void handleSoftKeyPress(int command); private: void mapSoftKeys(const QSoftkeySet &top); diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp index 9e90fdf..a6b885e 100644 --- a/src/gui/widgets/qsoftkeystack_s60.cpp +++ b/src/gui/widgets/qsoftkeystack_s60.cpp @@ -90,15 +90,22 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() if (softKeyAction->role() == QSoftKeyAction::Menu) { nativeContainer->SetCommandL(softKeyAction->nativePosition(), EAknSoftkeyOptions, *text); } else { - nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART + softKeyAction->qtContextKey(), *text); + nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART + softKeyAction->qtContextKey()-Qt::Key_Context1, *text); } CleanupStack::PopAndDestroy(); } } } -void QSoftKeyStack::handleSoftKeyPress(int command) +void QSoftKeyStackPrivate::handleSoftKeyPress(int command) { - // Do the magic, here. - // Map the command back to actual softkey on the top of the stack and handle it + const QSoftkeySet top = softKeyStack.top(); + int index = command-SOFTKEYSTART; + if( index<0 || index>=top.count()){ + // ### FIX THIS, add proper error handling, now fail quietly + return; + } + + top.at(index)->activate(QAction::Trigger); } + -- cgit v0.12 From 3d49f6854f35f19866c4076d551228aa63f38e3d Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 18 May 2009 14:21:44 +0200 Subject: Added slot that is triggered when back softkey is pressed --- src/gui/softkeys/main.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index 6adbb2d..a92e2c2 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -19,6 +19,7 @@ public: private slots: void context1Slot(); void context3Slot(); + void softKeySlot(); public: MainWindow(QWidget *parent = 0); @@ -68,7 +69,8 @@ MainWindow::MainWindow(QWidget *parent) action4 = new QSoftKeyAction(QSoftKeyAction::Menu, QString("Menu"), central); action5 = new QSoftKeyAction(QSoftKeyAction::ContextMenu,QString("ContextMenu"), central); - + connect(action2, SIGNAL(triggered()), this, SLOT(softKeySlot())); + QList myActionList; myActionList.append(action1); myActionList.append(action2); @@ -80,6 +82,7 @@ MainWindow::MainWindow(QWidget *parent) QList myActionList2; myActionList2.append(action4); + myActionList2.append(action2); myActionList2.append(action5); softKeyStack()->push(myActionList2); @@ -106,6 +109,11 @@ void MainWindow::context3Slot() { } +void MainWindow::softKeySlot() +{ + +} + int main(int argc, char *argv[]) { QApplication app(argc, argv); -- cgit v0.12 From b64e097303707161d0db663db06fdf239d40d4a2 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 19 May 2009 12:39:49 +0200 Subject: added Q_OBJECT macro --- src/gui/widgets/qsoftkeyaction.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qsoftkeyaction.h b/src/gui/widgets/qsoftkeyaction.h index 43c4ea7..77aeac0 100644 --- a/src/gui/widgets/qsoftkeyaction.h +++ b/src/gui/widgets/qsoftkeyaction.h @@ -54,6 +54,7 @@ class QSoftKeyActionPrivate; class Q_GUI_EXPORT QSoftKeyAction : public QAction { + Q_OBJECT public: enum StandardRole { Options=0, -- cgit v0.12 From ad475e3b8935b1314382e2d2c6a7d09ace98b550 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 19 May 2009 14:44:47 +0200 Subject: First hacky approach to context menus. This was commited so stuff relied on context menus can be implemented concurrently while making the internals of context menu implementation cleaner. --- src/gui/widgets/qmenu_symbian.cpp | 30 +++++++++++++++++++++++------- src/gui/widgets/qsoftkeystack.cpp | 19 +++++++++++++++++++ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index b9633b5..1cff1bf 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -49,6 +49,9 @@ static QList symbianMenus; static QList nativeMenuBars; static uint qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; static QWidget* widgetWithContextMenu=0; +static QList contextMenuActionList; +static QAction contextAction(0); +static int contexMenuCommand=0; bool menuExists() { @@ -177,6 +180,7 @@ void deleteAll(QList *items) static void rebuildMenu() { + widgetWithContextMenu = 0; QMenuBarPrivate *mb = 0; QWidget *w = qApp->activeWindow(); QMainWindow *mainWindow = qobject_cast(w); @@ -185,8 +189,7 @@ static void rebuildMenu() int index=0; bool found=false; - while( indexrole(); if(softAction->role() == QSoftKeyAction::ContextMenu) { @@ -195,8 +198,8 @@ static void rebuildMenu() } index++; } - if (w) - { + + if (w) { mb = menubars()->value(w); qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; deleteAll( &symbianMenus ); @@ -204,7 +207,6 @@ static void rebuildMenu() return; mb->symbian_menubar->rebuild(); } - widgetWithContextMenu = 0; } Q_GUI_EXPORT void qt_symbian_show_toplevel( CEikMenuPane* menuPane) @@ -233,6 +235,11 @@ void QMenu::symbianCommands(int command) void QMenuBar::symbianCommands(int command) { + if (command == contexMenuCommand) { + QContextMenuEvent* event = new QContextMenuEvent(QContextMenuEvent::Keyboard, QPoint(0,0)); + QCoreApplication::postEvent(widgetWithContextMenu, event); + } + int size = nativeMenuBars.size(); for (int i = 0; i < nativeMenuBars.size(); ++i) { bool result = nativeMenuBars.at(i)->d_func()->symbianCommands(command); @@ -388,16 +395,25 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::InsertNativeMenuItems(const QList< } } + + void QMenuBarPrivate::QSymbianMenuBarPrivate::rebuild() { + contexMenuCommand = 0; qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; deleteAll( &symbianMenus ); if (d) InsertNativeMenuItems(d->actions); - if (widgetWithContextMenu) - InsertNativeMenuItems(widgetWithContextMenu->actions()); + contextMenuActionList.clear(); + if (widgetWithContextMenu) { + contexMenuCommand = qt_symbian_menu_static_cmd_id; + contextAction.setText(QString("Actions")); + contextMenuActionList.append(&contextAction); + InsertNativeMenuItems(contextMenuActionList); } + +} QT_END_NAMESPACE #endif //QT_NO_MENUBAR diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 14daecd..f702530 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -118,6 +118,24 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) { if (!now) return; + QWidget *w = qApp->activeWindow(); + QMainWindow *mainWindow = qobject_cast(w); + QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); + if (old) + softKeyStack->pop(); + + Qt::ContextMenuPolicy policy = now->contextMenuPolicy(); + if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) { + QList actionList; + QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString("Menu"), now); + QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString("ContextMenu"), now); + actionList.append(menu); + actionList.append(contextMenu); + softKeyStack->push(actionList); + } + +/* if (!now) + return; bool nowInOurMainWindow = false; const QMainWindow *ourMainWindow = qobject_cast(parent()); Q_ASSERT(ourMainWindow); @@ -136,6 +154,7 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) QList actions = now->actions(); // Do something with these actions. +*/ } void QSoftKeyStack::handleSoftKeyPress(int command) -- cgit v0.12 From d2a9a4c38df32aed0bbcc21c0f971e1cf799226a Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 19 May 2009 14:45:55 +0200 Subject: Changed stylesheets example to create softkeystack. This commit should probably be reverted before merging to master --- examples/widgets/stylesheet/mainwindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/widgets/stylesheet/mainwindow.cpp b/examples/widgets/stylesheet/mainwindow.cpp index a1307a8..a0a38ad 100644 --- a/examples/widgets/stylesheet/mainwindow.cpp +++ b/examples/widgets/stylesheet/mainwindow.cpp @@ -46,6 +46,9 @@ MainWindow::MainWindow() { + QSoftKeyStack* stack = new QSoftKeyStack(this); + setSoftKeyStack(stack); + ui.setupUi(this); ui.nameLabel->setProperty("class", "mandatory QLabel"); -- cgit v0.12 From 3cfd4e97aa8f5e8c7b9eda9d7847b3f236d3efb5 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 19 May 2009 15:03:41 +0200 Subject: experiment with QMainWindow --- src/gui/widgets/qsoftkeystack.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index f702530..cd17171 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -120,6 +120,8 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) return; QWidget *w = qApp->activeWindow(); QMainWindow *mainWindow = qobject_cast(w); + if( !mainWindow) + return; QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); if (old) softKeyStack->pop(); -- cgit v0.12 From eb4c00a469f473a33103652ed977eabb4fb9ce9b Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 19 May 2009 19:13:39 +0200 Subject: Testing 'dictionary' if it contains a value before using operator[]. T & QMap::operator[]: "If the map contains no item with key key, the function inserts a default-constructed value into the map with key key, and returns a reference to it" How many occurences of 'dictionary["foo"].startsWith("bar")' has that file by the way? --- tools/configure/configureapp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 2c20d51..a879e5d 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -1886,14 +1886,14 @@ bool Configure::checkAvailability(const QString &part) else if (part == "SQL_DB2") available = findFile("sqlcli.h") && findFile("sqlcli1.h") && findFile("db2cli.lib"); else if (part == "SQL_SQLITE") - if (dictionary["XQMAKESPEC"].startsWith("symbian")) + if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) available = false; // In Symbian we only support system sqlite option else available = true; // Built in, we have a fork else if (part == "SQL_SQLITE_LIB") { if (dictionary[ "SQL_SQLITE_LIB" ] == "system") { // Symbian has multiple .lib/.dll files we need to find - if (dictionary["XQMAKESPEC"].startsWith("symbian")) { + if (dictionary.contains("XQMAKESPEC") && dictionary["XQMAKESPEC"].startsWith("symbian")) { available = true; // There is sqlite_symbian plugin which exports the necessary stuff dictionary[ "QT_LFLAGS_SQLITE" ] += "-lsqlite3"; } else { -- cgit v0.12 From 38c0b9100b5636e7f92185159cac5a5addbe4264 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 19 May 2009 19:14:55 +0200 Subject: Fresh build with commit eb4c00a469f473a33103652ed977eabb4fb9ce9b (MSVC 2008, No MS runtimes, UPXed) --- configure.exe | Bin 856064 -> 535040 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/configure.exe b/configure.exe index 5710503..30383d8 100755 Binary files a/configure.exe and b/configure.exe differ -- cgit v0.12 From 26e6d20ef0abee7b2d721637d6eaea67e932b907 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 19 May 2009 19:58:57 +0200 Subject: Stub for backgroundTexture() --- src/gui/styles/qs60style_simulated.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 17c1ebe..5a88f9a 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -191,6 +191,25 @@ QVariant QS60StylePrivate::styleProperty_specific(const char *name) const return styleProperty(name); } +QPixmap QS60StylePrivate::backgroundTexture() +{ + static QPixmap result; + // Poor mans caching. + Making sure that there is always only one background image in memory at a time + +/* + TODO: 1) Hold the background QPixmap as pointer in a static class member. + Also add a deleteBackground() function and call that in ~QS60StylePrivate() + 2) Don't cache the background at all as soon as we have native pixmap support +*/ + + if (!m_backgroundValid) { + result = QPixmap(); + result = part(QS60StyleEnums::SP_QsnBgScreen, QApplication::activeWindow()->size()); + m_backgroundValid = true; + } + return result; +} + bool QS60StylePrivate::isTouchSupported() { #ifdef QT_KEYPAD_NAVIGATION -- cgit v0.12 From 1588c0fe43f2173e026d7b52bdea0cf85b18ea1d Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 19 May 2009 20:14:07 +0200 Subject: Softkeys also for non-S60. Currently only as stub. Will eventually go into a separate implementation file. --- src/gui/widgets/qsoftkeystack.cpp | 11 +++++++++++ src/gui/widgets/widgets.pri | 18 +++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index cd17171..32a2df9 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -164,3 +164,14 @@ void QSoftKeyStack::handleSoftKeyPress(int command) Q_D(QSoftKeyStack); d->handleSoftKeyPress(command); } + +#if !defined(Q_WS_S60) +void QSoftKeyStackPrivate::handleSoftKeyPress(int command) +{ + Q_UNUSED(command) +} + +void QSoftKeyStackPrivate::setNativeSoftKeys() +{ +} +#endif // !defined(Q_WS_S60) \ No newline at end of file diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index c9e68a1..0c0641a 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -78,8 +78,10 @@ HEADERS += \ widgets/qtoolbararealayout_p.h \ widgets/qplaintextedit.h \ widgets/qplaintextedit_p.h \ - widgets/qprintpreviewwidget.h - + widgets/qprintpreviewwidget.h \ + widgets/qsoftkeyaction.h \ + widgets/qsoftkeystack.h \ + widgets/qsoftkeystack_p.h SOURCES += \ widgets/qabstractbutton.cpp \ widgets/qabstractslider.cpp \ @@ -138,8 +140,9 @@ SOURCES += \ widgets/qwidgetanimator.cpp \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp \ - widgets/qprintpreviewwidget.cpp - + widgets/qprintpreviewwidget.cpp \ + widgets/qsoftkeyaction.cpp \ + widgets/qsoftkeystack.cpp !embedded:mac { HEADERS += widgets/qmacnativewidget_mac.h \ @@ -162,14 +165,7 @@ wince*: { } symbian*: { - HEADERS += \ - widgets/qsoftkeyaction.h \ - widgets/qsoftkeystack.h \ - widgets/qsoftkeystack_p.h - SOURCES += \ widgets/qmenu_symbian.cpp \ - widgets/qsoftkeyaction.cpp \ - widgets/qsoftkeystack.cpp \ widgets/qsoftkeystack_s60.cpp } -- cgit v0.12 From ade1bdc75245bb233022b1cc0358b89df2180466 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 19 May 2009 20:14:58 +0200 Subject: Not using deprecated QString constructor --- src/gui/widgets/qsoftkeystack.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 32a2df9..ae58e8d 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -129,8 +129,8 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) Qt::ContextMenuPolicy policy = now->contextMenuPolicy(); if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) { QList actionList; - QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString("Menu"), now); - QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString("ContextMenu"), now); + QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString::fromLatin1("Menu"), now); + QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString::fromLatin1("ContextMenu"), now); actionList.append(menu); actionList.append(contextMenu); softKeyStack->push(actionList); -- cgit v0.12 From ce7444677bdcdb14a167f9f87c4487d0d341c314 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 20 May 2009 16:32:08 +0200 Subject: Part cache key nitpick --- src/gui/styles/qs60style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 1e2a889..a1ede1d 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -186,7 +186,7 @@ QPixmap QS60StylePrivate::cachedPart(QS60StyleEnums::SkinParts part, { QPixmap result; const QString cacheKey = - QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinElementFlags=%4") + QString::fromLatin1("S60Style: SkinParts=%1 QSize=%2|%3 SkinPartFlags=%4") .arg((int)part).arg(size.width()).arg(size.height()).arg((int)flags); if (!QPixmapCache::find(cacheKey, result)) { result = QS60StylePrivate::part(part, size, flags); -- cgit v0.12 From 164d3de4329019d34b10a802be16ea35aaafc5da Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 20 May 2009 16:32:33 +0200 Subject: Fixes --- src/gui/styles/qs60style_simulated.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/styles/qs60style_simulated.cpp b/src/gui/styles/qs60style_simulated.cpp index 5a88f9a..f10da2b 100644 --- a/src/gui/styles/qs60style_simulated.cpp +++ b/src/gui/styles/qs60style_simulated.cpp @@ -204,7 +204,8 @@ QPixmap QS60StylePrivate::backgroundTexture() if (!m_backgroundValid) { result = QPixmap(); - result = part(QS60StyleEnums::SP_QsnBgScreen, QApplication::activeWindow()->size()); + const QSize size = QApplication::activeWindow()?QApplication::activeWindow()->size():QSize(100, 100); + result = part(QS60StyleEnums::SP_QsnBgScreen, size); m_backgroundValid = true; } return result; @@ -285,8 +286,10 @@ QStringList QS60Style::colorListKeys() void QS60Style::setS60Theme(const QHash &parts, const QHash, QColor> &colors) { + Q_D(QS60Style); QS60StyleModeSpecifics::m_partPictures = parts; QS60StyleModeSpecifics::m_colors = colors; + d->clearCaches(); } QT_END_NAMESPACE -- cgit v0.12 From e7f7d1f20ed691a274dcf07801baa17f7a8aabf9 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 22 May 2009 13:18:59 +0200 Subject: Added helper softKeyStackOfWidget. It returns the stack of the MainWindow of a widget (which might want to push its actions to the stack) --- src/gui/widgets/qsoftkeystack.cpp | 16 ++++++++++++++++ src/gui/widgets/qsoftkeystack.h | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index ae58e8d..723b9bf 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -165,6 +165,22 @@ void QSoftKeyStack::handleSoftKeyPress(int command) d->handleSoftKeyPress(command); } +QMainWindow *QSoftKeyStack::mainWindowOfWidget(QWidget *widget) +{ + QWidget *widgetParent = widget; + while (widgetParent = widgetParent->parentWidget()) + if (QMainWindow *mainWindow = qobject_cast(widgetParent)) + return mainWindow; + + return 0; +} + +QSoftKeyStack *QSoftKeyStack::softKeyStackOfWidget(QWidget *widget) +{ + QMainWindow *mainWindow = mainWindowOfWidget(widget); + return mainWindow ? mainWindow->softKeyStack() : 0; +} + #if !defined(Q_WS_S60) void QSoftKeyStackPrivate::handleSoftKeyPress(int command) { diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index c9a05c3..7c955da 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -69,6 +69,9 @@ public: void handleSoftKeyPress(int command); + static QMainWindow *mainWindowOfWidget(QWidget *widget); + static QSoftKeyStack *softKeyStackOfWidget(QWidget *widget); + private Q_SLOTS: void handleFocusChanged(QWidget *old, QWidget *now); -- cgit v0.12 From b52451f6074446ec77f3bca712cdaeae46a50066 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 22 May 2009 13:44:56 +0200 Subject: compile --- src/gui/widgets/qsoftkeystack.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index 7c955da..2a63ab8 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -54,6 +54,7 @@ QT_MODULE(Gui) class QSoftKeyStackPrivate; class QSoftKeyAction; +class QMainWindow; class Q_GUI_EXPORT QSoftKeyStack : public QObject { -- cgit v0.12 From b23dc7fb8bc8de6617684249411b5399f1d06631 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 22 May 2009 13:45:49 +0200 Subject: Cleanup. --- src/gui/widgets/qsoftkeystack.cpp | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 723b9bf..05fe397 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -134,29 +134,7 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) actionList.append(menu); actionList.append(contextMenu); softKeyStack->push(actionList); - } - -/* if (!now) - return; - bool nowInOurMainWindow = false; - const QMainWindow *ourMainWindow = qobject_cast(parent()); - Q_ASSERT(ourMainWindow); - - // "ourMainWindow" in parent chain of "now"? Isn't there a helper in Qt for this? - QWidget *nowParent = now; - while (nowParent = nowParent->parentWidget()) { - if (nowParent == ourMainWindow) { - nowInOurMainWindow = true; - break; - } } - - if (!nowInOurMainWindow) - return; - - QList actions = now->actions(); - // Do something with these actions. -*/ } void QSoftKeyStack::handleSoftKeyPress(int command) @@ -190,4 +168,4 @@ void QSoftKeyStackPrivate::handleSoftKeyPress(int command) void QSoftKeyStackPrivate::setNativeSoftKeys() { } -#endif // !defined(Q_WS_S60) \ No newline at end of file +#endif // !defined(Q_WS_S60) -- cgit v0.12 From a4fd37805642f092942b7a761cd50991cc6d7d34 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 25 May 2009 18:14:39 +0200 Subject: Providing a translated default text for standard roles. --- src/gui/widgets/qsoftkeyaction.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/gui/widgets/qsoftkeyaction.cpp b/src/gui/widgets/qsoftkeyaction.cpp index 583cf65..302850c 100644 --- a/src/gui/widgets/qsoftkeyaction.cpp +++ b/src/gui/widgets/qsoftkeyaction.cpp @@ -55,12 +55,40 @@ public: this->role = role; } + static QString roleText(QSoftKeyAction::StandardRole role); + QSoftKeyAction::StandardRole role; QString roleName; int nativePosition; int qtContextKey; }; +QString QSoftKeyActionPrivate::roleText(QSoftKeyAction::StandardRole role) +{ + switch (role) { + case QSoftKeyAction::Options: + return QSoftKeyAction::tr("Options"); + case QSoftKeyAction::Select: + return QSoftKeyAction::tr("Select"); + case QSoftKeyAction::Back: + return QSoftKeyAction::tr("Back"); + case QSoftKeyAction::Next: + return QSoftKeyAction::tr("Next"); + case QSoftKeyAction::Previous: + return QSoftKeyAction::tr("Previous"); + case QSoftKeyAction::Ok: + return QSoftKeyAction::tr("Ok"); + case QSoftKeyAction::Cancel: + return QSoftKeyAction::tr("Cancel"); + case QSoftKeyAction::Edit: + return QSoftKeyAction::tr("Edit"); + case QSoftKeyAction::View: + return QSoftKeyAction::tr("View"); + default: + return QString(); + }; +} + /*! \enum QSoftKeyAction::StandardRole This enum defines the standard role for a QSoftKeyAction. @@ -92,6 +120,7 @@ QSoftKeyAction::QSoftKeyAction(StandardRole role, QObject *parent) { Q_D(QSoftKeyAction); d->role = role; + setText(QSoftKeyActionPrivate::roleText(role)); } QSoftKeyAction::QSoftKeyAction(const QString &text, QObject* parent) -- cgit v0.12 From 62743959699d78a63057e98b43fe3c79ace87234 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 26 May 2009 14:32:50 +0200 Subject: Implemented popandPush method. This is needed to optimize popping and pushing. This avoid unnecessary screen redraw and setting of native softkeys. One such case occurs when focused widge changes. --- src/gui/widgets/qsoftkeystack.cpp | 54 ++++++++++++++++++++++++++++++++++++--- src/gui/widgets/qsoftkeystack.h | 2 ++ src/gui/widgets/qsoftkeystack_p.h | 2 ++ 3 files changed, 55 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 05fe397..a7fa3f1 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -44,6 +44,22 @@ #include "qapplication.h" #include "qmainwindow.h" +static bool isSame(const QSoftkeySet& a, const QSoftkeySet& b) +{ + bool isSame=true; + if ( a.count() != b.count()) + return false; + int index=0; + while (indexrole() != b.at(index)->role()) + return false; + if (a.at(index)->text().compare(b.at(index)->text())!=0) + return false; + index++; + } + return true; +} + QSoftKeyStackPrivate::QSoftKeyStackPrivate() { @@ -75,6 +91,25 @@ void QSoftKeyStackPrivate::pop() setNativeSoftKeys(); } +void QSoftKeyStackPrivate::popandPush(QSoftKeyAction *softKey) +{ + QSoftkeySet oldSoftKeySet = softKeyStack.pop(); + QSoftkeySet newSoftKeySet; + newSoftKeySet.append(newSoftKeySet); + softKeyStack.push(newSoftKeySet); + if( !isSame(oldSoftKeySet, newSoftKeySet)) + setNativeSoftKeys(); +} + +void QSoftKeyStackPrivate::popandPush(const QList &softkeys) +{ + QSoftkeySet oldSoftKeySet = softKeyStack.pop(); + QSoftkeySet newSoftKeySet(softkeys); + softKeyStack.push(newSoftKeySet); + if( !isSame(oldSoftKeySet, newSoftKeySet)) + setNativeSoftKeys(); +} + const QSoftkeySet& QSoftKeyStackPrivate::top() { return softKeyStack.top(); @@ -108,6 +143,18 @@ void QSoftKeyStack::pop() d->pop(); } +void QSoftKeyStack::popandPush(QSoftKeyAction *softKey) +{ + Q_D(QSoftKeyStack); + d->popandPush(softKey); +} + +void QSoftKeyStack::popandPush(const QList &softkeys) +{ + Q_D(QSoftKeyStack); + d->popandPush(softkeys); +} + const QSoftkeySet& QSoftKeyStack::top() { Q_D(QSoftKeyStack); @@ -123,8 +170,6 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) if( !mainWindow) return; QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); - if (old) - softKeyStack->pop(); Qt::ContextMenuPolicy policy = now->contextMenuPolicy(); if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) { @@ -133,7 +178,10 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString::fromLatin1("ContextMenu"), now); actionList.append(menu); actionList.append(contextMenu); - softKeyStack->push(actionList); + if (old) + softKeyStack->popandPush(actionList); + else + softKeyStack->push(actionList); } } diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index 2a63ab8..10d9153 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -66,6 +66,8 @@ public: void push(QSoftKeyAction *softKey); void push(const QList &softkeys); void pop(); + void popandPush(QSoftKeyAction *softKey); + void popandPush(const QList &softkeys); const QSoftkeySet& top(); void handleSoftKeyPress(int command); diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index 2469648..57475bd 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -77,6 +77,8 @@ public: void push(QSoftKeyAction *softKey); void push(const QList &softKeys); void pop(); + void popandPush(QSoftKeyAction *softKey); + void popandPush(const QList &softkeys); const QSoftkeySet& top(); void handleSoftKeyPress(int command); -- cgit v0.12 From ba552dae4daab3db8596e20f8491393e4479e7b0 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 26 May 2009 14:40:36 +0200 Subject: Added method isEmpty() to interface. This can be used to query if stack actually has any items in it --- src/gui/widgets/qsoftkeystack.cpp | 11 +++++++++++ src/gui/widgets/qsoftkeystack.h | 1 + src/gui/widgets/qsoftkeystack_p.h | 1 + 3 files changed, 13 insertions(+) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index a7fa3f1..0054c6b 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -115,6 +115,11 @@ const QSoftkeySet& QSoftKeyStackPrivate::top() return softKeyStack.top(); } +bool QSoftKeyStackPrivate::isEmpty() +{ + return softKeyStack.isEmpty(); +} + QSoftKeyStack::QSoftKeyStack(QWidget *parent) : QObject(*new QSoftKeyStackPrivate, parent) { @@ -161,6 +166,12 @@ const QSoftkeySet& QSoftKeyStack::top() return d->top(); } +bool QSoftKeyStack::isEmpty() +{ + Q_D(QSoftKeyStack); + return d->isEmpty(); +} + void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) { if (!now) diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index 10d9153..2606bd1 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -69,6 +69,7 @@ public: void popandPush(QSoftKeyAction *softKey); void popandPush(const QList &softkeys); const QSoftkeySet& top(); + bool isEmpty(); void handleSoftKeyPress(int command); diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index 57475bd..b698178 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -80,6 +80,7 @@ public: void popandPush(QSoftKeyAction *softKey); void popandPush(const QList &softkeys); const QSoftkeySet& top(); + bool isEmpty(); void handleSoftKeyPress(int command); private: -- cgit v0.12 From a86927b9463d15893d45c11af912b70383c4ee2d Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 26 May 2009 14:41:14 +0200 Subject: Fixed crash when building menu while softkeystack is empty --- src/gui/widgets/qmenu_symbian.cpp | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 1cff1bf..491c78e 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -185,20 +185,21 @@ static void rebuildMenu() QWidget *w = qApp->activeWindow(); QMainWindow *mainWindow = qobject_cast(w); QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); - const QSoftkeySet& softKeyTop = softKeyStack->top(); - - int index=0; - bool found=false; - while( indexrole(); - if(softAction->role() == QSoftKeyAction::ContextMenu) { - widgetWithContextMenu = softAction->parentWidget(); - found=true; - } - index++; + if (!softKeyStack->isEmpty()) { + const QSoftkeySet& softKeyTop = softKeyStack->top(); + int index=0; + bool found=false; + while( indexrole(); + if(softAction->role() == QSoftKeyAction::ContextMenu) { + widgetWithContextMenu = softAction->parentWidget(); + found=true; + } + index++; + } } - + if (w) { mb = menubars()->value(w); qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; -- cgit v0.12 From 3cded6c4a90233e214447f769efc4a3524df6872 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 26 May 2009 16:08:12 +0200 Subject: Bugfix for mapping keys when there is only one softkey in the stack --- src/gui/widgets/qsoftkeystack_s60.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp index a6b885e..e9ca13a 100644 --- a/src/gui/widgets/qsoftkeystack_s60.cpp +++ b/src/gui/widgets/qsoftkeystack_s60.cpp @@ -53,7 +53,7 @@ void QSoftKeyStackPrivate::mapSoftKeys(const QSoftkeySet &top) { if (top.count() == 1) { top.at(0)->setNativePosition(2); - top.at(0)->setQtContextKey(Qt::Key_Context2); + top.at(0)->setQtContextKey(Qt::Key_Context1); } else { // FIX THIS -- cgit v0.12 From 52071c71ddfde1354e6c17737660a3d161d0bc89 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 26 May 2009 20:59:55 +0200 Subject: Introducing QKeyEventSoftKey helper class. It maps softkeys to actual key events. Making it easy and non-intrusive to add softkey usage to existing widgets. --- src/gui/widgets/qsoftkeystack.cpp | 24 ++++++++++++++++++++++++ src/gui/widgets/qsoftkeystack_p.h | 14 ++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 0054c6b..3591dc1 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -43,6 +43,7 @@ #include "qsoftkeystack_p.h" #include "qapplication.h" #include "qmainwindow.h" +#include "qevent.h" static bool isSame(const QSoftkeySet& a, const QSoftkeySet& b) { @@ -228,3 +229,26 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() { } #endif // !defined(Q_WS_S60) + +QKeyEventSoftKey::QKeyEventSoftKey(QSoftKeyAction *softKeyAction, Qt::Key key, QObject *parent) + : QObject(parent) + , m_softKeyAction(softKeyAction) + , m_key(key) +{ +} + +void QKeyEventSoftKey::addSoftKey(QSoftKeyAction::StandardRole standardRole, Qt::Key key, QWidget *actionWidget) +{ + QSoftKeyStack *stack = QSoftKeyStack::softKeyStackOfWidget(actionWidget); + if (!stack) + return; + QSoftKeyAction *action = new QSoftKeyAction(standardRole, actionWidget); + QKeyEventSoftKey *softKey = new QKeyEventSoftKey(action, key, actionWidget); + connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent())); + stack->push(action); +} + +void QKeyEventSoftKey::sendKeyEvent() +{ + QApplication::postEvent(parent(), new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier)); +} diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index b698178..e728cbb 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -70,6 +70,7 @@ QT_BEGIN_NAMESPACE class QSoftKeyStackPrivate : public QObjectPrivate { + Q_DECLARE_PUBLIC(QSoftKeyStack); public: QSoftKeyStackPrivate(); ~QSoftKeyStackPrivate(); @@ -91,6 +92,19 @@ private: QStack softKeyStack; }; +class QKeyEventSoftKey : QObject +{ + Q_OBJECT +public: + QKeyEventSoftKey(QSoftKeyAction *softKeyAction, Qt::Key key, QObject *parent); + static void addSoftKey(QSoftKeyAction::StandardRole standardRole, Qt::Key key, QWidget *actionWidget); +private: + QSoftKeyAction *m_softKeyAction; + Qt::Key m_key; +private Q_SLOTS: + void sendKeyEvent(); +}; + QT_END_NAMESPACE #endif // QSOFTKEYSTACK_P_H -- cgit v0.12 From f414d09532e6add26c70dc485743f414ee6bc118 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 26 May 2009 21:02:04 +0200 Subject: Platforms that do not yet have a softkey adaptation layer will show the softkeys in a toolbar inside the respective QMainWindow. This is a kind-of-usable stub and definitely useful for debugging. --- src/gui/widgets/qsoftkeystack.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 3591dc1..ac58d2a 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -45,6 +45,10 @@ #include "qmainwindow.h" #include "qevent.h" +#if !defined(Q_WS_S60) +#include "qtoolbar.h" +#endif + static bool isSame(const QSoftkeySet& a, const QSoftkeySet& b) { bool isSame=true; @@ -225,8 +229,38 @@ void QSoftKeyStackPrivate::handleSoftKeyPress(int command) Q_UNUSED(command) } +QToolBar* softKeyToolBar(QMainWindow *mainWindow) +{ + Q_ASSERT(mainWindow); + const QString toolBarName = QString::fromLatin1("SoftKeyToolBarForDebugging"); + QToolBar *result = 0; + foreach (QObject *child, mainWindow->children()) { + result = qobject_cast(child); + if (result && result->objectName() == toolBarName) + return result; + } + result = mainWindow->addToolBar(toolBarName); + result->setObjectName(toolBarName); + return result; +} + void QSoftKeyStackPrivate::setNativeSoftKeys() { + Q_Q(QSoftKeyStack); + QMainWindow *parent = qobject_cast(q->parent()); + if (!parent) + return; + QToolBar* toolbar = softKeyToolBar(parent); + toolbar->clear(); + foreach (const QSoftkeySet &set, softKeyStack) { + foreach (QSoftKeyAction *skAction, set) + toolbar->addAction(skAction); + toolbar->addSeparator(); + } + if (toolbar->actions().isEmpty()) { + parent->removeToolBar(toolbar); + delete toolbar; + } } #endif // !defined(Q_WS_S60) -- cgit v0.12 From 6b35dbafe0c42f26335d94d5fae43bf13c6b3584 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 26 May 2009 21:03:31 +0200 Subject: KeyPadNavigation: showing a 'Back' softkey while in editfocus. --- src/gui/itemviews/qabstractitemview.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 159a997..6e24c85 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -61,6 +61,9 @@ #ifndef QT_NO_ACCESSIBILITY #include #endif +#ifdef QT_KEYPAD_NAVIGATION +#include +#endif QT_BEGIN_NAMESPACE @@ -2003,16 +2006,19 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) if (QApplication::keypadNavigationEnabled()) { if (!hasEditFocus()) { setEditFocus(true); + QKeyEventSoftKey::addSoftKey(QSoftKeyAction::Back, Qt::Key_Back, this); return; } } break; case Qt::Key_Back: - case Qt::Key_Context2: // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey support is there - if (QApplication::keypadNavigationEnabled() && hasEditFocus()) + if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { + if (QSoftKeyStack *stack = QSoftKeyStack::softKeyStackOfWidget(this)) + stack->pop(); setEditFocus(false); - else + } else { event->ignore(); + } return; default: if (QApplication::keypadNavigationEnabled() && !hasEditFocus()) { -- cgit v0.12 From 9d5308b95bed09e72203eb53ced1a57c21744c71 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 27 May 2009 09:48:33 +0200 Subject: Added handling for a case when menu is being rebuilt and menu is not inside a QMainWindow. --- src/gui/widgets/qmenu_symbian.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 491c78e..1ed3505 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -184,19 +184,21 @@ static void rebuildMenu() QMenuBarPrivate *mb = 0; QWidget *w = qApp->activeWindow(); QMainWindow *mainWindow = qobject_cast(w); - QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); - if (!softKeyStack->isEmpty()) { - const QSoftkeySet& softKeyTop = softKeyStack->top(); - int index=0; - bool found=false; - while( indexrole(); - if(softAction->role() == QSoftKeyAction::ContextMenu) { - widgetWithContextMenu = softAction->parentWidget(); - found=true; - } - index++; + if (mainWindow) { + QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); + if (!softKeyStack->isEmpty()) { + const QSoftkeySet& softKeyTop = softKeyStack->top(); + int index=0; + bool found=false; + while( indexrole(); + if(softAction->role() == QSoftKeyAction::ContextMenu) { + widgetWithContextMenu = softAction->parentWidget(); + found=true; + } + index++; + } } } -- cgit v0.12 From 5e38702684529cf7c3d1ab8ac6cd14900ca20b89 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 27 May 2009 10:43:32 +0200 Subject: Added method bool hasSoftKeyStack() so that user can check if QMainWindow has a softkeystack or not. Making method QSoftKeyStack *softKeyStack() const return 0 when there is no softkeystack was also evaluated. Returning 0 was discarded as it would make softKeyStack() behave differently than statusBar() and menuBar() methods. It would be bad API design to have methods in same class behave differently. --- src/gui/widgets/qmainwindow.cpp | 15 ++++++++++++++- src/gui/widgets/qmainwindow.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index e12b879..618023e 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -543,7 +543,7 @@ QSoftKeyStack *QMainWindow::softKeyStack() const } /*! - Sets the softkey stackfor the main window to \a softKeyStack. + Sets the softkey stack for the main window to \a softKeyStack. Note: QMainWindow takes ownership of the \a softKeyStack pointer and deletes it at the appropriate time. @@ -559,6 +559,19 @@ void QMainWindow::setSoftKeyStack(QSoftKeyStack *softKeyStack) } d->softKeyStack = softKeyStack; } + +/*! + Returns true if QMainWindow has a softkeystack and false otherwise + + \sa softKeyStack() +*/ +bool QMainWindow::hasSoftKeyStack() +{ + Q_D(QMainWindow); + if (d->softKeyStack ) + return true; + return false; +} #endif // QT_NO_SOFTKEYSTACK #ifndef QT_NO_STATUSBAR diff --git a/src/gui/widgets/qmainwindow.h b/src/gui/widgets/qmainwindow.h index e2dcd5e..01b275e 100644 --- a/src/gui/widgets/qmainwindow.h +++ b/src/gui/widgets/qmainwindow.h @@ -135,6 +135,7 @@ public: #ifndef QT_NO_SOFTKEYSTACK QSoftKeyStack *softKeyStack() const; void setSoftKeyStack(QSoftKeyStack *softKeyStack); + bool hasSoftKeyStack(); #endif #ifndef QT_NO_STATUSBAR -- cgit v0.12 From f7c182fa3d6526b05403b0374f29b30aed9995e0 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 27 May 2009 11:38:55 +0200 Subject: Changed menu adaptation to handle case where no softkeystack is instantiated better --- src/gui/widgets/qmenu_symbian.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index 1ed3505..1577977 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -184,7 +184,7 @@ static void rebuildMenu() QMenuBarPrivate *mb = 0; QWidget *w = qApp->activeWindow(); QMainWindow *mainWindow = qobject_cast(w); - if (mainWindow) { + if ((mainWindow) && mainWindow->hasSoftKeyStack()) { QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); if (!softKeyStack->isEmpty()) { const QSoftkeySet& softKeyTop = softKeyStack->top(); -- cgit v0.12 From 51d580aef7fce99a7c531fa35e50637ec8704a5d Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 27 May 2009 21:43:02 +0200 Subject: QSoftKeyStack::softKeyStackOfWidget only returns a stack if has one. No implicit creation happens. --- src/gui/widgets/qsoftkeystack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index ac58d2a..50d7939 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -220,7 +220,7 @@ QMainWindow *QSoftKeyStack::mainWindowOfWidget(QWidget *widget) QSoftKeyStack *QSoftKeyStack::softKeyStackOfWidget(QWidget *widget) { QMainWindow *mainWindow = mainWindowOfWidget(widget); - return mainWindow ? mainWindow->softKeyStack() : 0; + return (mainWindow && mainWindow->hasSoftKeyStack()) ? mainWindow->softKeyStack() : 0; } #if !defined(Q_WS_S60) -- cgit v0.12 From 8c7098210e6dfa7886d6e33918899a211019b699 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 27 May 2009 22:47:19 +0200 Subject: Moved the soft key command relay acrobatics from QApplication to QSoftKeyStackPrivate. Removed QSoftKeyStack::handleSoftKeyPress and made QSoftKeyStackPrivate::handleSoftKeyPress static, so that it can be called from QApplication. --- src/gui/kernel/qapplication_s60.cpp | 12 +++--------- src/gui/widgets/qsoftkeystack.cpp | 6 ------ src/gui/widgets/qsoftkeystack.h | 2 -- src/gui/widgets/qsoftkeystack_p.h | 2 +- src/gui/widgets/qsoftkeystack_s60.cpp | 12 ++++++++++-- 5 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index ad1c842..138ba8c 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -29,8 +29,6 @@ #include "private/qwindowsurface_s60_p.h" #include "qpaintengine.h" #include "qmenubar.h" -#include "qmainwindow.h" -#include "qsoftkeystack.h" #include "private/qsoftkeystack_p.h" #include "apgwgnam.h" // For CApaWindowGroupName @@ -1041,14 +1039,10 @@ void QApplication::s60HandleCommandL(int command) exit(); break; default: - if (command >= SOFTKEYSTART && command <= SOFTKEYEND) { - const QMainWindow *activeMainWindow = - qobject_cast(QApplication::activeWindow()); - if (activeMainWindow) - activeMainWindow->softKeyStack()->handleSoftKeyPress(command); - } else { + if (command >= SOFTKEYSTART && command <= SOFTKEYEND) + QSoftKeyStackPrivate::handleSoftKeyPress(command); + else QMenuBar::symbianCommands(command); - } break; } } diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 50d7939..c68fe19 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -201,12 +201,6 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) } } -void QSoftKeyStack::handleSoftKeyPress(int command) -{ - Q_D(QSoftKeyStack); - d->handleSoftKeyPress(command); -} - QMainWindow *QSoftKeyStack::mainWindowOfWidget(QWidget *widget) { QWidget *widgetParent = widget; diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h index 2606bd1..423da66 100644 --- a/src/gui/widgets/qsoftkeystack.h +++ b/src/gui/widgets/qsoftkeystack.h @@ -71,8 +71,6 @@ public: const QSoftkeySet& top(); bool isEmpty(); - void handleSoftKeyPress(int command); - static QMainWindow *mainWindowOfWidget(QWidget *widget); static QSoftKeyStack *softKeyStackOfWidget(QWidget *widget); diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index e728cbb..75d7ad4 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -82,7 +82,7 @@ public: void popandPush(const QList &softkeys); const QSoftkeySet& top(); bool isEmpty(); - void handleSoftKeyPress(int command); + static void handleSoftKeyPress(int command); private: void mapSoftKeys(const QSoftkeySet &top); diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp index e9ca13a..8dfd5dd 100644 --- a/src/gui/widgets/qsoftkeystack_s60.cpp +++ b/src/gui/widgets/qsoftkeystack_s60.cpp @@ -48,6 +48,8 @@ #include "private/qcore_symbian_p.h" #include "qsoftkeystack_p.h" +#include "qapplication.h" +#include "qmainwindow.h" void QSoftKeyStackPrivate::mapSoftKeys(const QSoftkeySet &top) { @@ -99,9 +101,15 @@ void QSoftKeyStackPrivate::setNativeSoftKeys() void QSoftKeyStackPrivate::handleSoftKeyPress(int command) { - const QSoftkeySet top = softKeyStack.top(); + const QMainWindow *activeMainWindow = + qobject_cast(QApplication::activeWindow()); + if (!activeMainWindow) + return; + QSoftKeyStackPrivate *d_ptr = activeMainWindow->softKeyStack()->d_func(); + + const QSoftkeySet top = d_ptr->softKeyStack.top(); int index = command-SOFTKEYSTART; - if( index<0 || index>=top.count()){ + if (index < 0 || index >= top.count()) { // ### FIX THIS, add proper error handling, now fail quietly return; } -- cgit v0.12 From 0bd369dd52561d4654697b09a89141e96305e837 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Fri, 29 May 2009 09:58:33 +0200 Subject: Implemented better way to detect when to add automagically a menu button to softkeys --- src/gui/widgets/qsoftkeystack.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index c68fe19..984922e 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -185,15 +185,20 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) QMainWindow *mainWindow = qobject_cast(w); if( !mainWindow) return; + if (!mainWindow->hasSoftKeyStack()) + return; QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); - - Qt::ContextMenuPolicy policy = now->contextMenuPolicy(); - if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) { + if( mainWindow->menuWidget() ) + { QList actionList; QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString::fromLatin1("Menu"), now); - QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString::fromLatin1("ContextMenu"), now); actionList.append(menu); - actionList.append(contextMenu); + + Qt::ContextMenuPolicy policy = now->contextMenuPolicy(); + if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) { + QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString::fromLatin1("ContextMenu"), now); + actionList.append(contextMenu); + } if (old) softKeyStack->popandPush(actionList); else -- cgit v0.12 From 8506cc8ce89c23fbfe27f9fb4d4e0cd7c90e9b24 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 29 May 2009 16:23:06 +0200 Subject: Making hasSoftKeyStack() const. +coding conventions. --- src/gui/widgets/qmainwindow.cpp | 14 ++++++-------- src/gui/widgets/qmainwindow.h | 5 ++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 618023e..6843d4e 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -67,7 +67,7 @@ QT_END_NAMESPACE #endif #ifndef QT_NO_SOFTKEYSTACK -#include +#include #endif QT_BEGIN_NAMESPACE @@ -85,7 +85,7 @@ public: , hasOldCursor(false) , cursorAdjusted(false) #endif #ifndef QT_NO_SOFTKEYSTACK - , softKeyStack(0) + , softKeyStack(0) #endif { } QMainWindowLayout *layout; @@ -108,7 +108,7 @@ public: #endif #ifndef QT_NO_SOFTKEYSTACK - QSoftKeyStack* softKeyStack; + QSoftKeyStack *softKeyStack; #endif }; @@ -565,12 +565,10 @@ void QMainWindow::setSoftKeyStack(QSoftKeyStack *softKeyStack) \sa softKeyStack() */ -bool QMainWindow::hasSoftKeyStack() +bool QMainWindow::hasSoftKeyStack() const { - Q_D(QMainWindow); - if (d->softKeyStack ) - return true; - return false; + Q_D(const QMainWindow); + return d->softKeyStack != 0; } #endif // QT_NO_SOFTKEYSTACK diff --git a/src/gui/widgets/qmainwindow.h b/src/gui/widgets/qmainwindow.h index 01b275e..81457d6 100644 --- a/src/gui/widgets/qmainwindow.h +++ b/src/gui/widgets/qmainwindow.h @@ -59,9 +59,8 @@ class QMenuBar; class QStatusBar; class QToolBar; class QMenu; -#ifndef QT_NO_SOFTKEYSTACK class QSoftKeyStack; -#endif + class Q_GUI_EXPORT QMainWindow : public QWidget { Q_OBJECT @@ -135,7 +134,7 @@ public: #ifndef QT_NO_SOFTKEYSTACK QSoftKeyStack *softKeyStack() const; void setSoftKeyStack(QSoftKeyStack *softKeyStack); - bool hasSoftKeyStack(); + bool hasSoftKeyStack() const; #endif #ifndef QT_NO_STATUSBAR -- cgit v0.12 From 42fbf668b6da3251aea2ce27a25882437b9a4a06 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 29 May 2009 16:40:27 +0200 Subject: Pulled helper menuActionList() out of QSoftKeyStack::handleFocusChanged. It is also needed in other places. --- src/gui/widgets/qsoftkeystack.cpp | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 984922e..c07dd9e 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -177,6 +177,21 @@ bool QSoftKeyStack::isEmpty() return d->isEmpty(); } +QList menuActionList(QWidget *widget) +{ + QList result; + + QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString::fromLatin1("Menu"), widget); + result.append(menu); + const Qt::ContextMenuPolicy policy = widget->contextMenuPolicy(); + if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) { + QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString::fromLatin1("ContextMenu"), widget); + result.append(contextMenu); + } + + return result; +} + void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) { if (!now) @@ -188,17 +203,8 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) if (!mainWindow->hasSoftKeyStack()) return; QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); - if( mainWindow->menuWidget() ) - { - QList actionList; - QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString::fromLatin1("Menu"), now); - actionList.append(menu); - - Qt::ContextMenuPolicy policy = now->contextMenuPolicy(); - if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) { - QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString::fromLatin1("ContextMenu"), now); - actionList.append(contextMenu); - } + if (mainWindow->menuWidget()) { + QList actionList = menuActionList(now); if (old) softKeyStack->popandPush(actionList); else -- cgit v0.12 From dc599015e702320cbb868855ba76f37d264dc074 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 29 May 2009 17:08:32 +0200 Subject: Append and push the softKey instead of the empty list --- src/gui/widgets/qsoftkeystack.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index c07dd9e..0c5648e 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -100,7 +100,7 @@ void QSoftKeyStackPrivate::popandPush(QSoftKeyAction *softKey) { QSoftkeySet oldSoftKeySet = softKeyStack.pop(); QSoftkeySet newSoftKeySet; - newSoftKeySet.append(newSoftKeySet); + newSoftKeySet.append(softKey); softKeyStack.push(newSoftKeySet); if( !isSame(oldSoftKeySet, newSoftKeySet)) setNativeSoftKeys(); -- cgit v0.12 From afef05497be340509ffb604ab23d7d036bc363ea Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Fri, 29 May 2009 18:33:30 +0200 Subject: Implemented QKeyEventSoftKey::removeSoftkey and using it in QAbstractItemView::keyPressEvent to remove the "Back" key. --- src/gui/itemviews/qabstractitemview.cpp | 3 +-- src/gui/widgets/qsoftkeystack.cpp | 11 ++++++++++- src/gui/widgets/qsoftkeystack_p.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 6e24c85..565bc28 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -2013,8 +2013,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) break; case Qt::Key_Back: if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { - if (QSoftKeyStack *stack = QSoftKeyStack::softKeyStackOfWidget(this)) - stack->pop(); + QKeyEventSoftKey::removeSoftkey(this); setEditFocus(false); } else { event->ignore(); diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 0c5648e..db9b7a2 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -284,7 +284,16 @@ void QKeyEventSoftKey::addSoftKey(QSoftKeyAction::StandardRole standardRole, Qt: QSoftKeyAction *action = new QSoftKeyAction(standardRole, actionWidget); QKeyEventSoftKey *softKey = new QKeyEventSoftKey(action, key, actionWidget); connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent())); - stack->push(action); + stack->popandPush(action); +} + +void QKeyEventSoftKey::removeSoftkey(QWidget *focussedWidget) +{ + QSoftKeyStack *stack = QSoftKeyStack::softKeyStackOfWidget(focussedWidget); + if (!stack) + return; + QList actionList = menuActionList(focussedWidget); + stack->popandPush(actionList); } void QKeyEventSoftKey::sendKeyEvent() diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index 75d7ad4..c9d7f8d 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -98,6 +98,7 @@ class QKeyEventSoftKey : QObject public: QKeyEventSoftKey(QSoftKeyAction *softKeyAction, Qt::Key key, QObject *parent); static void addSoftKey(QSoftKeyAction::StandardRole standardRole, Qt::Key key, QWidget *actionWidget); + static void removeSoftkey(QWidget *focussedWidget); private: QSoftKeyAction *m_softKeyAction; Qt::Key m_key; -- cgit v0.12 From 824e8c4decf952b93279dc2c8c58e5d8dc0aa509 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Sat, 30 May 2009 18:48:27 +0200 Subject: Delete the actions in the popped SoftKeySets. --- src/gui/widgets/qsoftkeystack.cpp | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index db9b7a2..494471e 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -79,10 +79,9 @@ void QSoftKeyStackPrivate::push(QSoftKeyAction *softKey) { QSoftkeySet softKeySet; softKeySet.append(softKey); - softKeyStack.push(softKeySet); - setNativeSoftKeys(); - + push(softKeySet); } + void QSoftKeyStackPrivate::push(const QList &softkeys) { QSoftkeySet softKeySet(softkeys); @@ -92,18 +91,15 @@ void QSoftKeyStackPrivate::push(const QList &softkeys) void QSoftKeyStackPrivate::pop() { - softKeyStack.pop(); + qDeleteAll(softKeyStack.pop()); setNativeSoftKeys(); } void QSoftKeyStackPrivate::popandPush(QSoftKeyAction *softKey) { - QSoftkeySet oldSoftKeySet = softKeyStack.pop(); QSoftkeySet newSoftKeySet; newSoftKeySet.append(softKey); - softKeyStack.push(newSoftKeySet); - if( !isSame(oldSoftKeySet, newSoftKeySet)) - setNativeSoftKeys(); + popandPush(newSoftKeySet); } void QSoftKeyStackPrivate::popandPush(const QList &softkeys) @@ -111,8 +107,14 @@ void QSoftKeyStackPrivate::popandPush(const QList &softkeys) QSoftkeySet oldSoftKeySet = softKeyStack.pop(); QSoftkeySet newSoftKeySet(softkeys); softKeyStack.push(newSoftKeySet); - if( !isSame(oldSoftKeySet, newSoftKeySet)) +#ifdef Q_WS_S60 + // Don't flicker on Symbian. + // Platforms that use QActions as native SoftKeys must always call setNativeSoftKeys + // Otherwise the following deletion of oldSoftKeySet would remove the softkeys + if (!isSame(oldSoftKeySet, newSoftKeySet)) +#endif setNativeSoftKeys(); + qDeleteAll(oldSoftKeySet); } const QSoftkeySet& QSoftKeyStackPrivate::top() -- cgit v0.12 From cde524b88f9db46588773d20bf5c36b4e31d234a Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Sat, 30 May 2009 18:49:53 +0200 Subject: Make sure that the QKeyEventSoftKey gets deleted when the action gets deleted. --- src/gui/widgets/qsoftkeystack.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 494471e..7946f4a 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -286,6 +286,7 @@ void QKeyEventSoftKey::addSoftKey(QSoftKeyAction::StandardRole standardRole, Qt: QSoftKeyAction *action = new QSoftKeyAction(standardRole, actionWidget); QKeyEventSoftKey *softKey = new QKeyEventSoftKey(action, key, actionWidget); connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent())); + connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater())); stack->popandPush(action); } -- cgit v0.12 From 19f36cfed2c64160c17d0b8a6ed8a3b90dbf0d4b Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 1 Jun 2009 19:04:24 +0200 Subject: warnings-- --- src/gui/widgets/qsoftkeystack.cpp | 3 +-- src/gui/widgets/qsoftkeystack_p.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 7946f4a..9a5a66c 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -216,8 +216,7 @@ void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) QMainWindow *QSoftKeyStack::mainWindowOfWidget(QWidget *widget) { - QWidget *widgetParent = widget; - while (widgetParent = widgetParent->parentWidget()) + for (QWidget *widgetParent = widget; widgetParent; widgetParent = widgetParent->parentWidget()) if (QMainWindow *mainWindow = qobject_cast(widgetParent)) return mainWindow; diff --git a/src/gui/widgets/qsoftkeystack_p.h b/src/gui/widgets/qsoftkeystack_p.h index c9d7f8d..4532515 100644 --- a/src/gui/widgets/qsoftkeystack_p.h +++ b/src/gui/widgets/qsoftkeystack_p.h @@ -70,7 +70,7 @@ QT_BEGIN_NAMESPACE class QSoftKeyStackPrivate : public QObjectPrivate { - Q_DECLARE_PUBLIC(QSoftKeyStack); + Q_DECLARE_PUBLIC(QSoftKeyStack) public: QSoftKeyStackPrivate(); ~QSoftKeyStackPrivate(); -- cgit v0.12 From 988f6ae93c771fe94f12a0307d34c14edd5f2c3b Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 1 Jun 2009 19:06:04 +0200 Subject: Using softkeys for the Cancel/Back buttons during keypad navigation --- src/gui/widgets/qcombobox.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 16e2f39..59b740f 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -75,6 +75,9 @@ #ifndef QT_NO_EFFECTS # include #endif +#ifdef QT_KEYPAD_NAVIGATION +# include +#endif QT_BEGIN_NAMESPACE extern QHash *qt_app_fonts_hash(); @@ -628,6 +631,9 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) case Qt::Key_Select: #endif if (view->currentIndex().isValid() && (view->currentIndex().flags() & Qt::ItemIsEnabled) ) { +#ifdef QT_KEYPAD_NAVIGATION + QKeyEventSoftKey::removeSoftkey(this); +#endif combo->hidePopup(); emit itemSelected(view->currentIndex()); } @@ -640,7 +646,7 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) case Qt::Key_Escape: #ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Back: - case Qt::Key_Context2: // TODO: aportale, KEYPAD_NAVIGATION_HACK when softkey support is there + QKeyEventSoftKey::removeSoftkey(this); #endif combo->hidePopup(); return true; @@ -2435,6 +2441,7 @@ void QComboBox::showPopup() #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) view()->setEditFocus(true); + QKeyEventSoftKey::addSoftKey(QSoftKeyAction::Cancel, Qt::Key_Back, this); #endif } -- cgit v0.12 From b2d43b06d1c1debcd42afbc7dfd85c4991c670d5 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 3 Jun 2009 12:49:29 +0200 Subject: Added automatic creation for symbian os if softkeystack is enabled. This circumvents the need to go and change every example to explicitly start using softkeystack --- src/gui/widgets/qmainwindow.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 6843d4e..37b1398 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -121,6 +121,9 @@ void QMainWindowPrivate::init() explicitIconSize = false; q->setAttribute(Qt::WA_Hover); +#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SOFTKEYSTACK) + softKeyStack = new QSoftKeyStack(q); +#endif } /* -- cgit v0.12 From c1af1b23442f6d879d3f7eb8c193935f9887244a Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 3 Jun 2009 17:16:59 +0200 Subject: Fix merge --- src/gui/kernel/qapplication_s60.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 542ad43..3921331 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -** +1** ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** @@ -1102,7 +1102,6 @@ void QApplication::symbianResourceChange(int type) #endif default: ->>>>>>> master:src/gui/kernel/qapplication_s60.cpp break; } } -- cgit v0.12 From 4e7ab98ebd48cc1d5fa7643290e34ee166b9ab03 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 3 Jun 2009 19:30:39 +0200 Subject: Adding and removing a 'Cancel' SoftKey --- src/gui/widgets/qmenu.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index 6be0f19..c4db539 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -60,6 +60,9 @@ #ifndef QT_NO_WHATSTHIS # include #endif +#ifdef QT_KEYPAD_NAVIGATION +# include +#endif #include "qmenu_p.h" #include "qmenubar_p.h" @@ -578,8 +581,14 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason //when the action has no QWidget, the QMenu itself should // get the focus // Since the menu is a pop-up, it uses the popup reason. - if (!q->hasFocus()) + if (!q->hasFocus()) { q->setFocus(Qt::PopupFocusReason); +#ifdef QT_KEYPAD_NAVIGATION + // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey stack + // handles focus related and user related actions separately... + QKeyEventSoftKey::addSoftKey(QSoftKeyAction::Cancel, Qt::Key_Back, q); +#endif + } } } } else { //action is a separator @@ -1937,6 +1946,9 @@ void QMenu::popup(const QPoint &p, QAction *atAction) #ifndef QT_NO_ACCESSIBILITY QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuStart); #endif +#ifdef QT_KEYPAD_NAVIGATION + QKeyEventSoftKey::addSoftKey(QSoftKeyAction::Cancel, Qt::Key_Back, this); +#endif } /*! @@ -2587,7 +2599,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) case Qt::Key_Escape: #ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Back: - case Qt::Key_Context2: // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey support is there + QKeyEventSoftKey::removeSoftkey(this); #endif key_consumed = true; if (d->tornoff) { -- cgit v0.12 From dfffbd4d134f9b8adc75b2c33c31a2ee859903e6 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Fri, 5 Jun 2009 17:02:56 +0200 Subject: Initial version of softkey implementation that doesn't use softkeystack but instead softkeys are stored in QWidgets. --- src/gui/kernel/qwidget.cpp | 35 +++++++++++++- src/gui/kernel/qwidget.h | 4 ++ src/gui/kernel/qwidget_p.h | 4 ++ src/gui/kernel/qwidget_s60.cpp | 91 +++++++++++++++++++++++++++++++++++ src/gui/widgets/qmainwindow.cpp | 11 +++-- src/gui/widgets/qsoftkeystack.cpp | 2 + src/gui/widgets/qsoftkeystack_s60.cpp | 1 + 7 files changed, 144 insertions(+), 4 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 955ac8b..157a18e 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -5715,9 +5715,12 @@ bool QWidget::hasFocus() const void QWidget::setFocus(Qt::FocusReason reason) { + Q_D(QWidget); + d->setNativeSoftKeys(softKeys()); + if (!isEnabled()) return; - + QWidget *f = this; while (f->d_func()->extra && f->d_func()->extra->focus_proxy) f = f->d_func()->extra->focus_proxy; @@ -11509,6 +11512,36 @@ void QWidget::clearMask() setMask(QRegion()); } +const QList& QWidget::softKeys() const +{ + Q_D(const QWidget); + if( d->softKeys.count() > 0) + return d->softKeys; + + if (isWindow() || !parentWidget()) + return d->softKeys; + + return parentWidget()->softKeys(); +} + +void QWidget::setSoftKeys(QSoftKeyAction *softKey) +{ + Q_D(QWidget); + qDeleteAll(d->softKeys); + d->softKeys.append(softKey); +// d->setNativeSoftKeys(softkeys); +} + +void QWidget::setSoftKeys(const QList &softKeys) +{ + Q_D(QWidget); + qDeleteAll(d->softKeys); + for(int i = 0; i < softKeys.count(); i++) + d->softKeys.append(softKeys.at(i)); + + // d->setNativeSoftKeys(softkeys); +} + /*! \fn const QX11Info &QWidget::x11Info() const Returns information about the configuration of the X display used to display the widget. diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 0dd470d..516d69a 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -70,6 +70,7 @@ class QWSRegionManager; class QStyle; class QAction; class QVariant; +class QSoftKeyAction; class QActionEvent; class QMouseEvent; @@ -554,6 +555,9 @@ public: void removeAction(QAction *action); QList actions() const; #endif + const QList& softKeys() const; + void setSoftKeys(QSoftKeyAction *softKey); + void setSoftKeys(const QList &softKeys); QWidget *parentWidget() const; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index d5f1b98..90d9c93 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -85,6 +85,7 @@ class CCoeControl; class CAknTitlePane; class CAknContextPane; #endif +class QSoftKeyAction; QT_BEGIN_NAMESPACE @@ -102,6 +103,7 @@ class QPixmap; class QWidgetBackingStore; class QGraphicsProxyWidget; class QWidgetItemV2; +class QSoftKeyAction; class QStyle; @@ -224,6 +226,7 @@ public: explicit QWidgetPrivate(int version = QObjectPrivateVersion); ~QWidgetPrivate(); + void setNativeSoftKeys(const QList &softkeys); QWExtra *extraData() const; QTLWExtra *topData() const; QTLWExtra *maybeTopData() const; @@ -511,6 +514,7 @@ public: #ifndef QT_NO_ACTION QList actions; #endif + QList softKeys; QLayout *layout; QWidgetItemV2 *widgetItem; #if !defined(QT_NO_IM) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 11cb974..c39dbf4 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -52,6 +52,9 @@ #include +#include +#include "qsoftkeyaction.h" + QT_BEGIN_NAMESPACE extern bool qt_nograb(); @@ -59,6 +62,83 @@ extern bool qt_nograb(); QWidget *QWidgetPrivate::mouseGrabber = 0; QWidget *QWidgetPrivate::keyboardGrabber = 0; +#define QSoftkeySet QList +// The following 2 defines may only be needed for s60. To be seen. +#define SOFTKEYSTART 5000 +#define SOFTKEYEND (5000 + Qt::Key_Context4-Qt::Key_Context1) + +static void mapSoftKeys(const QSoftkeySet &softkeys) +{ + if (softkeys.count() == 1 && softkeys.at(0)->role()==QSoftKeyAction::Menu) { + softkeys.at(0)->setNativePosition(0); + softkeys.at(0)->setQtContextKey(Qt::Key_Context1); + } + else if(softkeys.count() == 1 && softkeys.at(0)->role()!=QSoftKeyAction::Menu) { + softkeys.at(0)->setNativePosition(2); + softkeys.at(0)->setQtContextKey(Qt::Key_Context1); + } + 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 < softkeys.count(); index++) { + softkeys.at(index)->setNativePosition(index + veryWeirdMagic); + softkeys.at(index)->setQtContextKey(Qt::Key_Context1 + index); + if (veryWeirdMagic == 0) + veryWeirdMagic = 1; + } + } +} + +static bool isSame(const QList& a, const QList& b) +{ + bool isSame=true; + if ( a.count() != b.count()) + return false; + int index=0; + while (indexrole() != b.at(index)->role()) + return false; + if (a.at(index)->text().compare(b.at(index)->text())!=0) + return false; + index++; + } + return true; +} + + +void QWidgetPrivate::setNativeSoftKeys(const QList &softkeys) +{ + if (QApplication::focusWidget()) { + QList old = QApplication::focusWidget()->softKeys(); + if (isSame(old, softkeys )) + return; + } + + CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); + CAknAppUi* aknAppUi = static_cast (appui); + CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba(); + nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + + mapSoftKeys(softkeys); + + for (int index = 0; index < softkeys.count(); index++) { + const QSoftKeyAction* softKeyAction = softkeys.at(index); + if (softKeyAction->role() != QSoftKeyAction::ContextMenu) { + + 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()-Qt::Key_Context1, *text); + } + CleanupStack::PopAndDestroy(); + } + } +} + void QWidgetPrivate::setWSGeometry(bool dontShow) { @@ -1003,5 +1083,16 @@ void QWidget::activateWindow() rw->SetOrdinalPosition(0); } } +/* +void QWidget::setSoftKeys(QSoftKeyAction *softKey) +{ + Q_D(QWidget); + d-> +} +void QWidget::setSoftKeys(const QList &softkeys) +{ + Q_D(QWidget); +} +*/ QT_END_NAMESPACE diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 37b1398..20270b4 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -69,6 +69,7 @@ QT_END_NAMESPACE #ifndef QT_NO_SOFTKEYSTACK #include #endif +#include QT_BEGIN_NAMESPACE @@ -121,9 +122,9 @@ void QMainWindowPrivate::init() explicitIconSize = false; q->setAttribute(Qt::WA_Hover); -#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SOFTKEYSTACK) - softKeyStack = new QSoftKeyStack(q); -#endif +//#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SOFTKEYSTACK) +// softKeyStack = new QSoftKeyStack(q); +//#endif } /* @@ -495,6 +496,10 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) oldMenuBar->deleteLater(); } d->layout->setMenuBar(menuBar); + if (menuBar) { + QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString::fromLatin1("Menu"), this); + setSoftKeys(menu); + } } /*! diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp index 9a5a66c..6c00d35 100644 --- a/src/gui/widgets/qsoftkeystack.cpp +++ b/src/gui/widgets/qsoftkeystack.cpp @@ -196,6 +196,7 @@ QList menuActionList(QWidget *widget) void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) { + return; if (!now) return; QWidget *w = qApp->activeWindow(); @@ -252,6 +253,7 @@ QToolBar* softKeyToolBar(QMainWindow *mainWindow) void QSoftKeyStackPrivate::setNativeSoftKeys() { + return; Q_Q(QSoftKeyStack); QMainWindow *parent = qobject_cast(q->parent()); if (!parent) diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp index 8dfd5dd..a315a3b 100644 --- a/src/gui/widgets/qsoftkeystack_s60.cpp +++ b/src/gui/widgets/qsoftkeystack_s60.cpp @@ -73,6 +73,7 @@ void QSoftKeyStackPrivate::mapSoftKeys(const QSoftkeySet &top) void QSoftKeyStackPrivate::setNativeSoftKeys() { + return; CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); CAknAppUi* aknAppUi = static_cast (appui); CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba(); -- cgit v0.12 From b8d6e02fc73fec1c1bc6b5b21e80104be61b946e Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 13:09:26 +0200 Subject: Added SoftKeyRole --- src/gui/kernel/qaction.cpp | 25 +++++++++++++++++++++++++ src/gui/kernel/qaction.h | 9 +++++++++ src/gui/kernel/qaction_p.h | 1 + 3 files changed, 35 insertions(+) diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index abb17d7..e32416a 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -1348,6 +1348,31 @@ QAction::MenuRole QAction::menuRole() const } /*! + \property QAction::softKeyRole + \brief the action's softkey role + \since 4.6 + + This indicates what softkey action this action is. Usually used on mobile + platforms to map QActions no hardware keys. + + The softkey role can be changed any time. +*/ +void QAction::setSoftKeyRole(SoftKeyRole softKeyRole) +{ + Q_D(QAction); + if (d->softKeyRole == softKeyRole) + return; + + d->softKeyRole = softKeyRole; + d->sendDataChanged(); +} + +QAction::SoftKeyRole QAction::softKeyRole() const +{ + Q_D(const QAction); + return d->softKeyRole; +} +/*! \property QAction::iconVisibleInMenu \brief Whether or not an action should show an icon in a menu \since 4.4 diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h index d7bf8c3..e9c64c8 100644 --- a/src/gui/kernel/qaction.h +++ b/src/gui/kernel/qaction.h @@ -67,6 +67,7 @@ class Q_GUI_EXPORT QAction : public QObject Q_DECLARE_PRIVATE(QAction) Q_ENUMS(MenuRole) + Q_ENUMS(SoftKeyRole) Q_PROPERTY(bool checkable READ isCheckable WRITE setCheckable) Q_PROPERTY(bool checked READ isChecked WRITE setChecked DESIGNABLE isCheckable NOTIFY toggled) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled) @@ -84,11 +85,16 @@ class Q_GUI_EXPORT QAction : public QObject #endif Q_PROPERTY(bool visible READ isVisible WRITE setVisible) Q_PROPERTY(MenuRole menuRole READ menuRole WRITE setMenuRole) + Q_PROPERTY(SoftKeyRole softKeyRole READ softKeyRole WRITE setSoftKeyRole) Q_PROPERTY(bool iconVisibleInMenu READ isIconVisibleInMenu WRITE setIconVisibleInMenu) public: enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, AboutRole, PreferencesRole, QuitRole }; + enum SoftKeyRole { Options, Select, Back, Next, Previous, Ok, Cancel, Edit, + View, BackSpace, EndEdit, RevertEdit, Deselect, Finish, Menu, + ContextMenu, Custom, SoftKey1, SoftKey2, SoftKey3, SoftKey4 }; + explicit QAction(QObject* parent); QAction(const QString &text, QObject* parent); QAction(const QIcon &icon, const QString &text, QObject* parent); @@ -168,6 +174,9 @@ public: void setMenuRole(MenuRole menuRole); MenuRole menuRole() const; + void setSoftKeyRole(SoftKeyRole softKeyRole); + SoftKeyRole softKeyRole() const; + void setIconVisibleInMenu(bool visible); bool isIconVisibleInMenu() const; diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h index 0617ef5..6051d9a 100644 --- a/src/gui/kernel/qaction_p.h +++ b/src/gui/kernel/qaction_p.h @@ -102,6 +102,7 @@ public: uint separator : 1; uint fontSet : 1; QAction::MenuRole menuRole; + QAction::SoftKeyRole softKeyRole; int iconVisibleInMenu : 3; // Only has values -1, 0, and 1 QList widgets; #ifndef QT_NO_GRAPHICSVIEW -- cgit v0.12 From f87e69fcb26387e8d22546778bb1f5d43ba8e200 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 14:11:10 +0200 Subject: Renamed SoftKeyRoles to be more descriptive --- src/gui/kernel/qaction.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h index e9c64c8..6725f42 100644 --- a/src/gui/kernel/qaction.h +++ b/src/gui/kernel/qaction.h @@ -91,9 +91,11 @@ class Q_GUI_EXPORT QAction : public QObject public: enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, AboutRole, PreferencesRole, QuitRole }; - enum SoftKeyRole { Options, Select, Back, Next, Previous, Ok, Cancel, Edit, - View, BackSpace, EndEdit, RevertEdit, Deselect, Finish, Menu, - ContextMenu, Custom, SoftKey1, SoftKey2, SoftKey3, SoftKey4 }; + enum SoftKeyRole { OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, PreviousSoftKey, + OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey, + EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey, + MenuSoftKey, ContextMenuSoftKey, Key1SoftKey, Key2SoftKey, + Key3SoftKey, Key4SoftKey, CustomSoftKey }; explicit QAction(QObject* parent); QAction(const QString &text, QObject* parent); -- cgit v0.12 From 449d4b00c6e3d8a277821e5fb5837e3da2e6b920 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 14:11:53 +0200 Subject: Replaced usage of QSoftKeyActions with QActions+SoftKeyRoles --- src/gui/kernel/qwidget.cpp | 6 +++--- src/gui/kernel/qwidget.h | 7 +++---- src/gui/kernel/qwidget_p.h | 5 ++--- src/gui/kernel/qwidget_s60.cpp | 33 +++++++++++++++++++-------------- src/gui/widgets/qmainwindow.cpp | 3 ++- 5 files changed, 29 insertions(+), 25 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 157a18e..e18b66b 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11512,7 +11512,7 @@ void QWidget::clearMask() setMask(QRegion()); } -const QList& QWidget::softKeys() const +const QList& QWidget::softKeys() const { Q_D(const QWidget); if( d->softKeys.count() > 0) @@ -11524,7 +11524,7 @@ const QList& QWidget::softKeys() const return parentWidget()->softKeys(); } -void QWidget::setSoftKeys(QSoftKeyAction *softKey) +void QWidget::setSoftKeys(QAction *softKey) { Q_D(QWidget); qDeleteAll(d->softKeys); @@ -11532,7 +11532,7 @@ void QWidget::setSoftKeys(QSoftKeyAction *softKey) // d->setNativeSoftKeys(softkeys); } -void QWidget::setSoftKeys(const QList &softKeys) +void QWidget::setSoftKeys(const QList &softKeys) { Q_D(QWidget); qDeleteAll(d->softKeys); diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 516d69a..36a30ac 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -70,7 +70,6 @@ class QWSRegionManager; class QStyle; class QAction; class QVariant; -class QSoftKeyAction; class QActionEvent; class QMouseEvent; @@ -555,9 +554,9 @@ public: void removeAction(QAction *action); QList actions() const; #endif - const QList& softKeys() const; - void setSoftKeys(QSoftKeyAction *softKey); - void setSoftKeys(const QList &softKeys); + const QList& softKeys() const; + void setSoftKeys(QAction *softKey); + void setSoftKeys(const QList &softKeys); QWidget *parentWidget() const; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 90d9c93..645b13d 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -85,7 +85,6 @@ class CCoeControl; class CAknTitlePane; class CAknContextPane; #endif -class QSoftKeyAction; QT_BEGIN_NAMESPACE @@ -226,7 +225,7 @@ public: explicit QWidgetPrivate(int version = QObjectPrivateVersion); ~QWidgetPrivate(); - void setNativeSoftKeys(const QList &softkeys); + void setNativeSoftKeys(const QList &softkeys); QWExtra *extraData() const; QTLWExtra *topData() const; QTLWExtra *maybeTopData() const; @@ -514,7 +513,7 @@ public: #ifndef QT_NO_ACTION QList actions; #endif - QList softKeys; + QList softKeys; QLayout *layout; QWidgetItemV2 *widgetItem; #if !defined(QT_NO_IM) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index c39dbf4..a23469e 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -53,7 +53,6 @@ #include #include -#include "qsoftkeyaction.h" QT_BEGIN_NAMESPACE @@ -62,18 +61,18 @@ extern bool qt_nograb(); QWidget *QWidgetPrivate::mouseGrabber = 0; QWidget *QWidgetPrivate::keyboardGrabber = 0; -#define QSoftkeySet QList +#define QSoftkeySet QList // The following 2 defines may only be needed for s60. To be seen. #define SOFTKEYSTART 5000 #define SOFTKEYEND (5000 + Qt::Key_Context4-Qt::Key_Context1) static void mapSoftKeys(const QSoftkeySet &softkeys) { - if (softkeys.count() == 1 && softkeys.at(0)->role()==QSoftKeyAction::Menu) { +/* if (softkeys.count() == 1 && softkeys.at(0)->menuRole()==QAction::MenuSoftKey) { softkeys.at(0)->setNativePosition(0); softkeys.at(0)->setQtContextKey(Qt::Key_Context1); } - else if(softkeys.count() == 1 && softkeys.at(0)->role()!=QSoftKeyAction::Menu) { + else if(softkeys.count() == 1 && softkeys.at(0)->menuRole()!=QAction::MenuSoftKey) { softkeys.at(0)->setNativePosition(2); softkeys.at(0)->setQtContextKey(Qt::Key_Context1); } @@ -89,16 +88,17 @@ static void mapSoftKeys(const QSoftkeySet &softkeys) veryWeirdMagic = 1; } } +*/ } -static bool isSame(const QList& a, const QList& b) +static bool isSame(const QList& a, const QList& b) { bool isSame=true; if ( a.count() != b.count()) return false; int index=0; while (indexrole() != b.at(index)->role()) + if (a.at(index)->softKeyRole() != b.at(index)->softKeyRole()) return false; if (a.at(index)->text().compare(b.at(index)->text())!=0) return false; @@ -108,10 +108,10 @@ static bool isSame(const QList& a, const QList } -void QWidgetPrivate::setNativeSoftKeys(const QList &softkeys) +void QWidgetPrivate::setNativeSoftKeys(const QList &softkeys) { if (QApplication::focusWidget()) { - QList old = QApplication::focusWidget()->softKeys(); + QList old = QApplication::focusWidget()->softKeys(); if (isSame(old, softkeys )) return; } @@ -122,20 +122,25 @@ void QWidgetPrivate::setNativeSoftKeys(const QList &softkeys) nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); mapSoftKeys(softkeys); - + int placeInScreen=0; + for (int index = 0; index < softkeys.count(); index++) { - const QSoftKeyAction* softKeyAction = softkeys.at(index); - if (softKeyAction->role() != QSoftKeyAction::ContextMenu) { + const QAction* softKeyAction = softkeys.at(index); + if (softKeyAction->softKeyRole() != QAction::ContextMenuSoftKey) { HBufC* text = qt_QString2HBufCNewL(softKeyAction->text()); CleanupStack::PushL(text); - if (softKeyAction->role() == QSoftKeyAction::Menu) { - nativeContainer->SetCommandL(softKeyAction->nativePosition(), EAknSoftkeyOptions, *text); + if (softKeyAction->softKeyRole() == QAction::MenuSoftKey) { + nativeContainer->SetCommandL(placeInScreen, EAknSoftkeyOptions, *text); } else { - nativeContainer->SetCommandL(softKeyAction->nativePosition(), SOFTKEYSTART + softKeyAction->qtContextKey()-Qt::Key_Context1, *text); + nativeContainer->SetCommandL(placeInScreen, SOFTKEYSTART + index, *text); } CleanupStack::PopAndDestroy(); + placeInScreen++; } + if (placeInScreen==1) + placeInScreen=2; + } } diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 20270b4..a12c32b 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -497,7 +497,8 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) } d->layout->setMenuBar(menuBar); if (menuBar) { - QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString::fromLatin1("Menu"), this); + QAction* menu = new QAction(QString::fromLatin1("Menu"), this); + menu->setSoftKeyRole(QAction::MenuSoftKey); setSoftKeys(menu); } } -- cgit v0.12 From 4dd8985db4653a3f4f406f4fe7c910ffd02643b3 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 14:29:00 +0200 Subject: Added mapping from native hardware keys to softkeys. This enables the QActions with softKeyRole to be triggered --- src/gui/kernel/qapplication_s60.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 94e59b3..2c7fc02 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1064,8 +1064,15 @@ void QApplication::symbianHandleCommand(int command) exit(); break; default: - if (command >= SOFTKEYSTART && command <= SOFTKEYEND) - QSoftKeyStackPrivate::handleSoftKeyPress(command); + if (command >= SOFTKEYSTART && command <= SOFTKEYEND) { + int index= command-SOFTKEYSTART; + QWidget* focused = QApplication::focusWidget(); + const QList& softKeys = focused->softKeys(); + if (index>=softKeys.count()) { + // Assert horrible state error + } + softKeys.at(index)->activate(QAction::Trigger); + } else QMenuBarPrivate::symbianCommands(command); break; -- cgit v0.12 From d0432c7d7c06c83ccaa2266217e5b1823fa8dba6 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 14:30:32 +0200 Subject: Replaced usage of QSoftKeyStack with QActions having SoftKeyRole --- src/gui/widgets/qmainwindow.cpp | 62 ----------------------------------------- src/gui/widgets/qmainwindow.h | 9 +----- 2 files changed, 1 insertion(+), 70 deletions(-) diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index a12c32b..90c5db9 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -66,11 +66,6 @@ extern OSWindowRef qt_mac_window_for(const QWidget *); // qwidget_mac.cpp QT_END_NAMESPACE #endif -#ifndef QT_NO_SOFTKEYSTACK -#include -#endif -#include - QT_BEGIN_NAMESPACE class QMainWindowPrivate : public QWidgetPrivate @@ -85,9 +80,6 @@ public: #if !defined(QT_NO_DOCKWIDGET) && !defined(QT_NO_CURSOR) , hasOldCursor(false) , cursorAdjusted(false) #endif -#ifndef QT_NO_SOFTKEYSTACK - , softKeyStack(0) -#endif { } QMainWindowLayout *layout; QSize iconSize; @@ -107,10 +99,6 @@ public: uint hasOldCursor : 1; uint cursorAdjusted : 1; #endif - -#ifndef QT_NO_SOFTKEYSTACK - QSoftKeyStack *softKeyStack; -#endif }; void QMainWindowPrivate::init() @@ -122,9 +110,6 @@ void QMainWindowPrivate::init() explicitIconSize = false; q->setAttribute(Qt::WA_Hover); -//#if defined(Q_OS_SYMBIAN) && !defined(QT_NO_SOFTKEYSTACK) -// softKeyStack = new QSoftKeyStack(q); -//#endif } /* @@ -534,53 +519,6 @@ void QMainWindow::setMenuWidget(QWidget *menuBar) } #endif // QT_NO_MENUBAR -#ifndef QT_NO_SOFTKEYSTACK -/*! - Returns the softkey stack for the main window. This function creates - and returns an empty soft key stack if the stack does not exist. - - \sa softKeyStack() -*/ -QSoftKeyStack *QMainWindow::softKeyStack() const -{ - if (!d_func()->softKeyStack) { - QMainWindow *self = const_cast(this); - QSoftKeyStack* softKeyStack = new QSoftKeyStack(self); - self->setSoftKeyStack(softKeyStack); - } - return d_func()->softKeyStack; -} - -/*! - Sets the softkey stack for the main window to \a softKeyStack. - - Note: QMainWindow takes ownership of the \a softKeyStack pointer and - deletes it at the appropriate time. - - \sa softKeyStack() -*/ -void QMainWindow::setSoftKeyStack(QSoftKeyStack *softKeyStack) -{ - Q_D(QMainWindow); - if (d->softKeyStack && d->softKeyStack != softKeyStack) { - QSoftKeyStack *oldSoftKeyStack = d->softKeyStack; - delete oldSoftKeyStack; - } - d->softKeyStack = softKeyStack; -} - -/*! - Returns true if QMainWindow has a softkeystack and false otherwise - - \sa softKeyStack() -*/ -bool QMainWindow::hasSoftKeyStack() const -{ - Q_D(const QMainWindow); - return d->softKeyStack != 0; -} -#endif // QT_NO_SOFTKEYSTACK - #ifndef QT_NO_STATUSBAR /*! Returns the status bar for the main window. This function creates diff --git a/src/gui/widgets/qmainwindow.h b/src/gui/widgets/qmainwindow.h index 81457d6..9983c7a 100644 --- a/src/gui/widgets/qmainwindow.h +++ b/src/gui/widgets/qmainwindow.h @@ -59,7 +59,6 @@ class QMenuBar; class QStatusBar; class QToolBar; class QMenu; -class QSoftKeyStack; class Q_GUI_EXPORT QMainWindow : public QWidget { @@ -130,13 +129,7 @@ public: QWidget *menuWidget() const; void setMenuWidget(QWidget *menubar); #endif - -#ifndef QT_NO_SOFTKEYSTACK - QSoftKeyStack *softKeyStack() const; - void setSoftKeyStack(QSoftKeyStack *softKeyStack); - bool hasSoftKeyStack() const; -#endif - + #ifndef QT_NO_STATUSBAR QStatusBar *statusBar() const; void setStatusBar(QStatusBar *statusbar); -- cgit v0.12 From 934ebcd3e3c1c568ac8371dbb1d96cd06385883d Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 14:31:22 +0200 Subject: Disabled context sensitive menu because it would cause compilation failure. Context menu will be enabled again once the QAction SoftKeyRole implementation is in state where context menu can be properly supported --- src/gui/widgets/qmenu_symbian.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index f27e580..df95061 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -214,7 +214,7 @@ static void rebuildMenu() QMenuBarPrivate *mb = 0; QWidget *w = qApp->activeWindow(); QMainWindow *mainWindow = qobject_cast(w); - if ((mainWindow) && mainWindow->hasSoftKeyStack()) { + /* if ((mainWindow) && mainWindow->hasSoftKeyStack()) { QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); if (!softKeyStack->isEmpty()) { const QSoftkeySet& softKeyTop = softKeyStack->top(); @@ -231,7 +231,7 @@ static void rebuildMenu() } } } - +*/ if (w) { mb = menubars()->value(w); qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; -- cgit v0.12 From 7749376ff1536c703d223e16506eed1a61132a41 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 16:17:01 +0200 Subject: Removed QSoftKeyStack and replaced places using it with the new improved softkey interface in QWidget --- src/gui/itemviews/qabstractitemview.cpp | 5 +- src/gui/kernel/qapplication_s60.cpp | 1 - src/gui/kernel/qwidget.cpp | 3 +- src/gui/kernel/qwidget_p.h | 1 - src/gui/widgets/qcombobox.cpp | 7 +- src/gui/widgets/qmenu.cpp | 8 +- src/gui/widgets/qmenu_symbian.cpp | 2 - src/gui/widgets/qsoftkeyaction.cpp | 234 ------------------------ src/gui/widgets/qsoftkeyaction.h | 106 ----------- src/gui/widgets/qsoftkeystack.cpp | 306 -------------------------------- src/gui/widgets/qsoftkeystack.h | 89 ---------- src/gui/widgets/qsoftkeystack_p.h | 111 ------------ src/gui/widgets/qsoftkeystack_s60.cpp | 120 ------------- src/gui/widgets/widgets.pri | 8 +- 14 files changed, 10 insertions(+), 991 deletions(-) delete mode 100644 src/gui/widgets/qsoftkeyaction.cpp delete mode 100644 src/gui/widgets/qsoftkeyaction.h delete mode 100644 src/gui/widgets/qsoftkeystack.cpp delete mode 100644 src/gui/widgets/qsoftkeystack.h delete mode 100644 src/gui/widgets/qsoftkeystack_p.h delete mode 100644 src/gui/widgets/qsoftkeystack_s60.cpp diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 565bc28..187e2cd 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -61,9 +61,6 @@ #ifndef QT_NO_ACCESSIBILITY #include #endif -#ifdef QT_KEYPAD_NAVIGATION -#include -#endif QT_BEGIN_NAMESPACE @@ -2006,7 +2003,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) if (QApplication::keypadNavigationEnabled()) { if (!hasEditFocus()) { setEditFocus(true); - QKeyEventSoftKey::addSoftKey(QSoftKeyAction::Back, Qt::Key_Back, this); + QKeyEventSoftKey::addSoftKey(QAction::Back, Qt::Key_Back, this); return; } } diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 2c7fc02..6ee7899 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -58,7 +58,6 @@ #endif #include "private/qwindowsurface_s60_p.h" #include "qpaintengine.h" -#include "private/qsoftkeystack_p.h" #include "private/qmenubar_p.h" #include "apgwgnam.h" // For CApaWindowGroupName diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index e18b66b..0a7fea3 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11528,7 +11528,8 @@ void QWidget::setSoftKeys(QAction *softKey) { Q_D(QWidget); qDeleteAll(d->softKeys); - d->softKeys.append(softKey); + if (softKey) + d->softKeys.append(softKey); // d->setNativeSoftKeys(softkeys); } diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 645b13d..9a606dc 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -102,7 +102,6 @@ class QPixmap; class QWidgetBackingStore; class QGraphicsProxyWidget; class QWidgetItemV2; -class QSoftKeyAction; class QStyle; diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 59b740f..aa90909 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -63,7 +63,7 @@ #include #include #include - +#include #ifdef Q_WS_X11 #include #endif @@ -75,9 +75,6 @@ #ifndef QT_NO_EFFECTS # include #endif -#ifdef QT_KEYPAD_NAVIGATION -# include -#endif QT_BEGIN_NAMESPACE extern QHash *qt_app_fonts_hash(); @@ -2441,7 +2438,7 @@ void QComboBox::showPopup() #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) view()->setEditFocus(true); - QKeyEventSoftKey::addSoftKey(QSoftKeyAction::Cancel, Qt::Key_Back, this); + QKeyEventSoftKey::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, this); #endif } diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index c4db539..d713081 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -60,9 +60,7 @@ #ifndef QT_NO_WHATSTHIS # include #endif -#ifdef QT_KEYPAD_NAVIGATION -# include -#endif +#include #include "qmenu_p.h" #include "qmenubar_p.h" @@ -586,7 +584,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason #ifdef QT_KEYPAD_NAVIGATION // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey stack // handles focus related and user related actions separately... - QKeyEventSoftKey::addSoftKey(QSoftKeyAction::Cancel, Qt::Key_Back, q); + QKeyEventSoftKey::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, q); #endif } } @@ -1947,7 +1945,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuStart); #endif #ifdef QT_KEYPAD_NAVIGATION - QKeyEventSoftKey::addSoftKey(QSoftKeyAction::Cancel, Qt::Key_Back, this); + QKeyEventSoftKey::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, this); #endif } diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index df95061..e422882 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -56,8 +56,6 @@ #include #include #include -#include -#include #ifndef QT_NO_MENUBAR QT_BEGIN_NAMESPACE diff --git a/src/gui/widgets/qsoftkeyaction.cpp b/src/gui/widgets/qsoftkeyaction.cpp deleted file mode 100644 index 302850c..0000000 --- a/src/gui/widgets/qsoftkeyaction.cpp +++ /dev/null @@ -1,234 +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" -#include - -/*! - \class QSoftKeyAction - \brief The QSoftKeyAction class defines a special kind of QAction that may also be displayed in a QSoftKeyBar. -*/ - -class QSoftKeyActionPrivate : public QActionPrivate -{ -public: - QSoftKeyActionPrivate(QSoftKeyAction::StandardRole role = QSoftKeyAction::Custom) - { - this->role = role; - } - - static QString roleText(QSoftKeyAction::StandardRole role); - - QSoftKeyAction::StandardRole role; - QString roleName; - int nativePosition; - int qtContextKey; -}; - -QString QSoftKeyActionPrivate::roleText(QSoftKeyAction::StandardRole role) -{ - switch (role) { - case QSoftKeyAction::Options: - return QSoftKeyAction::tr("Options"); - case QSoftKeyAction::Select: - return QSoftKeyAction::tr("Select"); - case QSoftKeyAction::Back: - return QSoftKeyAction::tr("Back"); - case QSoftKeyAction::Next: - return QSoftKeyAction::tr("Next"); - case QSoftKeyAction::Previous: - return QSoftKeyAction::tr("Previous"); - case QSoftKeyAction::Ok: - return QSoftKeyAction::tr("Ok"); - case QSoftKeyAction::Cancel: - return QSoftKeyAction::tr("Cancel"); - case QSoftKeyAction::Edit: - return QSoftKeyAction::tr("Edit"); - case QSoftKeyAction::View: - return QSoftKeyAction::tr("View"); - default: - return QString(); - }; -} - -/*! - \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(*new QSoftKeyActionPrivate(), parent) -{ -} - -QSoftKeyAction::QSoftKeyAction(StandardRole role, QObject *parent) - : QAction(*new QSoftKeyActionPrivate(), parent) -{ - Q_D(QSoftKeyAction); - d->role = role; - setText(QSoftKeyActionPrivate::roleText(role)); -} - -QSoftKeyAction::QSoftKeyAction(const QString &text, QObject* parent) - : QAction(*new QSoftKeyActionPrivate(), parent) -{ - setText(text); -} - -QSoftKeyAction::QSoftKeyAction(StandardRole role, const QString &text, QObject* parent) - : QAction(*new QSoftKeyActionPrivate(), parent) -{ - setText(text); - Q_D(QSoftKeyAction); - d->role = role; -} - -QSoftKeyAction::QSoftKeyAction(const QIcon &icon, const QString &text, QObject* parent) - : QAction(*new QSoftKeyActionPrivate(), parent) -{ - setIcon(icon); - setText(text); -} - -QSoftKeyAction::QSoftKeyAction(StandardRole role, const QIcon &icon, const QString &text, QObject* parent) - : QAction(*new QSoftKeyActionPrivate(), parent) -{ - setIcon(icon); - setText(text); - 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 deleted file mode 100644 index 77aeac0..0000000 --- a/src/gui/widgets/qsoftkeyaction.h +++ /dev/null @@ -1,106 +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 - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -class QSoftKeyActionPrivate; - -class Q_GUI_EXPORT QSoftKeyAction : public QAction -{ - Q_OBJECT -public: - enum StandardRole { - Options=0, - Select, - Back, - Next, - Previous, - Ok, - Cancel, - Edit, - View, - BackSpace, - EndEdit, - RevertEdit, - Deselect, - Finish, - Menu, - ContextMenu, - 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); - -private: - Q_DECLARE_PRIVATE(QSoftKeyAction) - Q_DISABLE_COPY(QSoftKeyAction) -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QSOFTKEYACTION_H diff --git a/src/gui/widgets/qsoftkeystack.cpp b/src/gui/widgets/qsoftkeystack.cpp deleted file mode 100644 index 6c00d35..0000000 --- a/src/gui/widgets/qsoftkeystack.cpp +++ /dev/null @@ -1,306 +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" -#include "qapplication.h" -#include "qmainwindow.h" -#include "qevent.h" - -#if !defined(Q_WS_S60) -#include "qtoolbar.h" -#endif - -static bool isSame(const QSoftkeySet& a, const QSoftkeySet& b) -{ - bool isSame=true; - if ( a.count() != b.count()) - return false; - int index=0; - while (indexrole() != b.at(index)->role()) - return false; - if (a.at(index)->text().compare(b.at(index)->text())!=0) - return false; - index++; - } - return true; -} - -QSoftKeyStackPrivate::QSoftKeyStackPrivate() -{ - -} - -QSoftKeyStackPrivate::~QSoftKeyStackPrivate() -{ - -} - -void QSoftKeyStackPrivate::push(QSoftKeyAction *softKey) -{ - QSoftkeySet softKeySet; - softKeySet.append(softKey); - push(softKeySet); -} - -void QSoftKeyStackPrivate::push(const QList &softkeys) -{ - QSoftkeySet softKeySet(softkeys); - softKeyStack.push(softKeySet); - setNativeSoftKeys(); -} - -void QSoftKeyStackPrivate::pop() -{ - qDeleteAll(softKeyStack.pop()); - setNativeSoftKeys(); -} - -void QSoftKeyStackPrivate::popandPush(QSoftKeyAction *softKey) -{ - QSoftkeySet newSoftKeySet; - newSoftKeySet.append(softKey); - popandPush(newSoftKeySet); -} - -void QSoftKeyStackPrivate::popandPush(const QList &softkeys) -{ - QSoftkeySet oldSoftKeySet = softKeyStack.pop(); - QSoftkeySet newSoftKeySet(softkeys); - softKeyStack.push(newSoftKeySet); -#ifdef Q_WS_S60 - // Don't flicker on Symbian. - // Platforms that use QActions as native SoftKeys must always call setNativeSoftKeys - // Otherwise the following deletion of oldSoftKeySet would remove the softkeys - if (!isSame(oldSoftKeySet, newSoftKeySet)) -#endif - setNativeSoftKeys(); - qDeleteAll(oldSoftKeySet); -} - -const QSoftkeySet& QSoftKeyStackPrivate::top() -{ - return softKeyStack.top(); -} - -bool QSoftKeyStackPrivate::isEmpty() -{ - return softKeyStack.isEmpty(); -} - -QSoftKeyStack::QSoftKeyStack(QWidget *parent) - : QObject(*new QSoftKeyStackPrivate, parent) -{ - connect(qApp, SIGNAL(focusChanged(QWidget*, QWidget*)), SLOT(handleFocusChanged(QWidget*, QWidget*))); -} - -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(); -} - -void QSoftKeyStack::popandPush(QSoftKeyAction *softKey) -{ - Q_D(QSoftKeyStack); - d->popandPush(softKey); -} - -void QSoftKeyStack::popandPush(const QList &softkeys) -{ - Q_D(QSoftKeyStack); - d->popandPush(softkeys); -} - -const QSoftkeySet& QSoftKeyStack::top() -{ - Q_D(QSoftKeyStack); - return d->top(); -} - -bool QSoftKeyStack::isEmpty() -{ - Q_D(QSoftKeyStack); - return d->isEmpty(); -} - -QList menuActionList(QWidget *widget) -{ - QList result; - - QSoftKeyAction* menu = new QSoftKeyAction(QSoftKeyAction::Menu, QString::fromLatin1("Menu"), widget); - result.append(menu); - const Qt::ContextMenuPolicy policy = widget->contextMenuPolicy(); - if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) { - QSoftKeyAction* contextMenu = new QSoftKeyAction(QSoftKeyAction::ContextMenu, QString::fromLatin1("ContextMenu"), widget); - result.append(contextMenu); - } - - return result; -} - -void QSoftKeyStack::handleFocusChanged(QWidget *old, QWidget *now) -{ - return; - if (!now) - return; - QWidget *w = qApp->activeWindow(); - QMainWindow *mainWindow = qobject_cast(w); - if( !mainWindow) - return; - if (!mainWindow->hasSoftKeyStack()) - return; - QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); - if (mainWindow->menuWidget()) { - QList actionList = menuActionList(now); - if (old) - softKeyStack->popandPush(actionList); - else - softKeyStack->push(actionList); - } -} - -QMainWindow *QSoftKeyStack::mainWindowOfWidget(QWidget *widget) -{ - for (QWidget *widgetParent = widget; widgetParent; widgetParent = widgetParent->parentWidget()) - if (QMainWindow *mainWindow = qobject_cast(widgetParent)) - return mainWindow; - - return 0; -} - -QSoftKeyStack *QSoftKeyStack::softKeyStackOfWidget(QWidget *widget) -{ - QMainWindow *mainWindow = mainWindowOfWidget(widget); - return (mainWindow && mainWindow->hasSoftKeyStack()) ? mainWindow->softKeyStack() : 0; -} - -#if !defined(Q_WS_S60) -void QSoftKeyStackPrivate::handleSoftKeyPress(int command) -{ - Q_UNUSED(command) -} - -QToolBar* softKeyToolBar(QMainWindow *mainWindow) -{ - Q_ASSERT(mainWindow); - const QString toolBarName = QString::fromLatin1("SoftKeyToolBarForDebugging"); - QToolBar *result = 0; - foreach (QObject *child, mainWindow->children()) { - result = qobject_cast(child); - if (result && result->objectName() == toolBarName) - return result; - } - result = mainWindow->addToolBar(toolBarName); - result->setObjectName(toolBarName); - return result; -} - -void QSoftKeyStackPrivate::setNativeSoftKeys() -{ - return; - Q_Q(QSoftKeyStack); - QMainWindow *parent = qobject_cast(q->parent()); - if (!parent) - return; - QToolBar* toolbar = softKeyToolBar(parent); - toolbar->clear(); - foreach (const QSoftkeySet &set, softKeyStack) { - foreach (QSoftKeyAction *skAction, set) - toolbar->addAction(skAction); - toolbar->addSeparator(); - } - if (toolbar->actions().isEmpty()) { - parent->removeToolBar(toolbar); - delete toolbar; - } -} -#endif // !defined(Q_WS_S60) - -QKeyEventSoftKey::QKeyEventSoftKey(QSoftKeyAction *softKeyAction, Qt::Key key, QObject *parent) - : QObject(parent) - , m_softKeyAction(softKeyAction) - , m_key(key) -{ -} - -void QKeyEventSoftKey::addSoftKey(QSoftKeyAction::StandardRole standardRole, Qt::Key key, QWidget *actionWidget) -{ - QSoftKeyStack *stack = QSoftKeyStack::softKeyStackOfWidget(actionWidget); - if (!stack) - return; - QSoftKeyAction *action = new QSoftKeyAction(standardRole, actionWidget); - QKeyEventSoftKey *softKey = new QKeyEventSoftKey(action, key, actionWidget); - connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent())); - connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater())); - stack->popandPush(action); -} - -void QKeyEventSoftKey::removeSoftkey(QWidget *focussedWidget) -{ - QSoftKeyStack *stack = QSoftKeyStack::softKeyStackOfWidget(focussedWidget); - if (!stack) - return; - QList actionList = menuActionList(focussedWidget); - stack->popandPush(actionList); -} - -void QKeyEventSoftKey::sendKeyEvent() -{ - QApplication::postEvent(parent(), new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier)); -} diff --git a/src/gui/widgets/qsoftkeystack.h b/src/gui/widgets/qsoftkeystack.h deleted file mode 100644 index 423da66..0000000 --- a/src/gui/widgets/qsoftkeystack.h +++ /dev/null @@ -1,89 +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 - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#define QSoftkeySet QList - -class QSoftKeyStackPrivate; -class QSoftKeyAction; -class QMainWindow; - -class Q_GUI_EXPORT QSoftKeyStack : public QObject -{ - Q_OBJECT -public: - QSoftKeyStack(QWidget *parent); - ~QSoftKeyStack(); - - void push(QSoftKeyAction *softKey); - void push(const QList &softkeys); - void pop(); - void popandPush(QSoftKeyAction *softKey); - void popandPush(const QList &softkeys); - const QSoftkeySet& top(); - bool isEmpty(); - - static QMainWindow *mainWindowOfWidget(QWidget *widget); - static QSoftKeyStack *softKeyStackOfWidget(QWidget *widget); - -private Q_SLOTS: - void handleFocusChanged(QWidget *old, QWidget *now); - -private: - Q_DECLARE_PRIVATE(QSoftKeyStack) - Q_DISABLE_COPY(QSoftKeyStack) -}; - -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 deleted file mode 100644 index 4532515..0000000 --- a/src/gui/widgets/qsoftkeystack_p.h +++ /dev/null @@ -1,111 +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 "qstack.h" -#include - -#include "qsoftkeyaction.h" -#include "qsoftkeystack.h" - -QT_BEGIN_NAMESPACE - -// The following 2 defines may only be needed for s60. To be seen. -#define SOFTKEYSTART 5000 -#define SOFTKEYEND (5000 + Qt::Key_Context4-Qt::Key_Context1) - -#define QSoftkeySet QList - -class QSoftKeyStackPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QSoftKeyStack) -public: - QSoftKeyStackPrivate(); - ~QSoftKeyStackPrivate(); - - void push(QSoftKeyAction *softKey); - void push(const QList &softKeys); - void pop(); - void popandPush(QSoftKeyAction *softKey); - void popandPush(const QList &softkeys); - const QSoftkeySet& top(); - bool isEmpty(); - static void handleSoftKeyPress(int command); - -private: - void mapSoftKeys(const QSoftkeySet &top); - void setNativeSoftKeys(); - -private: - QStack softKeyStack; -}; - -class QKeyEventSoftKey : QObject -{ - Q_OBJECT -public: - QKeyEventSoftKey(QSoftKeyAction *softKeyAction, Qt::Key key, QObject *parent); - static void addSoftKey(QSoftKeyAction::StandardRole standardRole, Qt::Key key, QWidget *actionWidget); - static void removeSoftkey(QWidget *focussedWidget); -private: - QSoftKeyAction *m_softKeyAction; - Qt::Key m_key; -private Q_SLOTS: - void sendKeyEvent(); -}; - -QT_END_NAMESPACE - -#endif // QSOFTKEYSTACK_P_H diff --git a/src/gui/widgets/qsoftkeystack_s60.cpp b/src/gui/widgets/qsoftkeystack_s60.cpp deleted file mode 100644 index a315a3b..0000000 --- a/src/gui/widgets/qsoftkeystack_s60.cpp +++ /dev/null @@ -1,120 +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" -#include "qapplication.h" -#include "qmainwindow.h" - -void QSoftKeyStackPrivate::mapSoftKeys(const QSoftkeySet &top) -{ - if (top.count() == 1) { - top.at(0)->setNativePosition(2); - top.at(0)->setQtContextKey(Qt::Key_Context1); - } - 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() -{ - return; - 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); - if (softKeyAction->role() != QSoftKeyAction::ContextMenu) { - - 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()-Qt::Key_Context1, *text); - } - CleanupStack::PopAndDestroy(); - } - } -} - -void QSoftKeyStackPrivate::handleSoftKeyPress(int command) -{ - const QMainWindow *activeMainWindow = - qobject_cast(QApplication::activeWindow()); - if (!activeMainWindow) - return; - QSoftKeyStackPrivate *d_ptr = activeMainWindow->softKeyStack()->d_func(); - - const QSoftkeySet top = d_ptr->softKeyStack.top(); - int index = command-SOFTKEYSTART; - if (index < 0 || index >= top.count()) { - // ### FIX THIS, add proper error handling, now fail quietly - return; - } - - top.at(index)->activate(QAction::Trigger); -} - diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index 0c0641a..150eed7 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -79,9 +79,7 @@ HEADERS += \ widgets/qplaintextedit.h \ widgets/qplaintextedit_p.h \ widgets/qprintpreviewwidget.h \ - widgets/qsoftkeyaction.h \ - widgets/qsoftkeystack.h \ - widgets/qsoftkeystack_p.h + widgets/qkeyeventsoftkey.h \ SOURCES += \ widgets/qabstractbutton.cpp \ widgets/qabstractslider.cpp \ @@ -141,8 +139,7 @@ SOURCES += \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp \ widgets/qprintpreviewwidget.cpp \ - widgets/qsoftkeyaction.cpp \ - widgets/qsoftkeystack.cpp + widgets/qkeyeventsoftkey.cpp \ !embedded:mac { HEADERS += widgets/qmacnativewidget_mac.h \ @@ -167,5 +164,4 @@ wince*: { symbian*: { SOURCES += \ widgets/qmenu_symbian.cpp \ - widgets/qsoftkeystack_s60.cpp } -- cgit v0.12 From fcb5ca1ef0a1c1639624d951b03750abc631e60d Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 16:18:14 +0200 Subject: Added helper class to make adding/removing softkeys easier --- src/gui/widgets/qkeyeventsoftkey.cpp | 78 ++++++++++++++++++++++++++++++++++++ src/gui/widgets/qkeyeventsoftkey.h | 71 ++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+) create mode 100644 src/gui/widgets/qkeyeventsoftkey.cpp create mode 100644 src/gui/widgets/qkeyeventsoftkey.h diff --git a/src/gui/widgets/qkeyeventsoftkey.cpp b/src/gui/widgets/qkeyeventsoftkey.cpp new file mode 100644 index 0000000..e836dfe --- /dev/null +++ b/src/gui/widgets/qkeyeventsoftkey.cpp @@ -0,0 +1,78 @@ +/**************************************************************************** +** +** 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 "qkeyeventsoftkey.h" + +QT_BEGIN_NAMESPACE + +QKeyEventSoftKey::QKeyEventSoftKey(QAction *softKeyAction, Qt::Key key, QObject *parent) + : QObject(parent) + , m_softKeyAction(softKeyAction) + , m_key(key) +{ + +} + +void QKeyEventSoftKey::addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget) +{ + QAction *action = new QAction(actionWidget); + action->setSoftKeyRole(standardRole); + QKeyEventSoftKey *softKey = new QKeyEventSoftKey(action, key, actionWidget); + connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent())); + connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater())); + actionWidget->setSoftKeys(action); +} + +void QKeyEventSoftKey::removeSoftkey(QWidget *focussedWidget) +{ + focussedWidget->setSoftKeys(0); +} + +void QKeyEventSoftKey::sendKeyEvent() +{ + QApplication::postEvent(parent(), new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier)); +} + +QT_END_NAMESPACE + +#include "moc_qkeyeventsoftkey.cpp" + +#endif // QT_NO_ACTION diff --git a/src/gui/widgets/qkeyeventsoftkey.h b/src/gui/widgets/qkeyeventsoftkey.h new file mode 100644 index 0000000..92cf0df --- /dev/null +++ b/src/gui/widgets/qkeyeventsoftkey.h @@ -0,0 +1,71 @@ +/**************************************************************************** +** +** 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 QKEYEVENSOFTKEY_H +#define QKEYEVENSOFTKEY_H + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Gui) + +#include "qaction.h" + +class QKeyEventSoftKey : QObject +{ + Q_OBJECT +public: + QKeyEventSoftKey(QAction *softKeyAction, Qt::Key key, QObject *parent); + static void addSoftKey(QAction::StandardRole standardRole, Qt::Key key, QWidget *actionWidget); + static void removeSoftkey(QWidget *focussedWidget); +private: + QAction *m_softKeyAction; + Qt::Key m_key; +private Q_SLOTS: + void sendKeyEvent(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif //QKEYEVENSOFTKEY_H -- cgit v0.12 From 93922e26a2411c0f11e7cdc49b306823e23cda8b Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 18:40:00 +0200 Subject: Fixes to make gui compile after clean configure. Removal of QSoftKeyStack broke compilation on clean environment... --- examples/widgets/stylesheet/mainwindow.cpp | 3 --- src/gui/itemviews/qabstractitemview.cpp | 3 ++- src/gui/kernel/qwidget_p.h | 3 +++ src/gui/kernel/qwidget_s60.cpp | 3 --- src/gui/widgets/qkeyeventsoftkey.cpp | 3 ++- src/gui/widgets/qkeyeventsoftkey.h | 8 +++++--- src/gui/widgets/widgets.pri | 12 ++++++------ 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/examples/widgets/stylesheet/mainwindow.cpp b/examples/widgets/stylesheet/mainwindow.cpp index a0a38ad..a1307a8 100644 --- a/examples/widgets/stylesheet/mainwindow.cpp +++ b/examples/widgets/stylesheet/mainwindow.cpp @@ -46,9 +46,6 @@ MainWindow::MainWindow() { - QSoftKeyStack* stack = new QSoftKeyStack(this); - setSoftKeyStack(stack); - ui.setupUi(this); ui.nameLabel->setProperty("class", "mandatory QLabel"); diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 187e2cd..69e630e 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -61,6 +61,7 @@ #ifndef QT_NO_ACCESSIBILITY #include #endif +#include QT_BEGIN_NAMESPACE @@ -2003,7 +2004,7 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) if (QApplication::keypadNavigationEnabled()) { if (!hasEditFocus()) { setEditFocus(true); - QKeyEventSoftKey::addSoftKey(QAction::Back, Qt::Key_Back, this); + QKeyEventSoftKey::addSoftKey(QAction::BackSoftKey, Qt::Key_Back, this); return; } } diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 9a606dc..2119849 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -84,6 +84,9 @@ class RDrawableWindow; class CCoeControl; class CAknTitlePane; class CAknContextPane; +// The following 2 defines may only be needed for s60. To be seen. +#define SOFTKEYSTART 5000 +#define SOFTKEYEND (5000 + Qt::Key_Context4-Qt::Key_Context1) #endif QT_BEGIN_NAMESPACE diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index a23469e..4e03206 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -62,9 +62,6 @@ QWidget *QWidgetPrivate::mouseGrabber = 0; QWidget *QWidgetPrivate::keyboardGrabber = 0; #define QSoftkeySet QList -// The following 2 defines may only be needed for s60. To be seen. -#define SOFTKEYSTART 5000 -#define SOFTKEYEND (5000 + Qt::Key_Context4-Qt::Key_Context1) static void mapSoftKeys(const QSoftkeySet &softkeys) { diff --git a/src/gui/widgets/qkeyeventsoftkey.cpp b/src/gui/widgets/qkeyeventsoftkey.cpp index e836dfe..08f5c6f 100644 --- a/src/gui/widgets/qkeyeventsoftkey.cpp +++ b/src/gui/widgets/qkeyeventsoftkey.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +#include "qapplication.h" +#include "qevent.h" #include "qkeyeventsoftkey.h" QT_BEGIN_NAMESPACE @@ -75,4 +77,3 @@ QT_END_NAMESPACE #include "moc_qkeyeventsoftkey.cpp" -#endif // QT_NO_ACTION diff --git a/src/gui/widgets/qkeyeventsoftkey.h b/src/gui/widgets/qkeyeventsoftkey.h index 92cf0df..fd69907 100644 --- a/src/gui/widgets/qkeyeventsoftkey.h +++ b/src/gui/widgets/qkeyeventsoftkey.h @@ -42,20 +42,22 @@ #ifndef QKEYEVENSOFTKEY_H #define QKEYEVENSOFTKEY_H +#include +#include "QtGui/qaction.h" QT_BEGIN_HEADER QT_BEGIN_NAMESPACE QT_MODULE(Gui) -#include "qaction.h" -class QKeyEventSoftKey : QObject + +class Q_GUI_EXPORT QKeyEventSoftKey : QObject { Q_OBJECT public: QKeyEventSoftKey(QAction *softKeyAction, Qt::Key key, QObject *parent); - static void addSoftKey(QAction::StandardRole standardRole, Qt::Key key, QWidget *actionWidget); + static void addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget); static void removeSoftkey(QWidget *focussedWidget); private: QAction *m_softKeyAction; diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index 150eed7..d0f981c 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -25,6 +25,7 @@ HEADERS += \ widgets/qframe.h \ widgets/qframe_p.h \ widgets/qgroupbox.h \ + widgets/qkeyeventsoftkey.h \ widgets/qlabel.h \ widgets/qlabel_p.h \ widgets/qlcdnumber.h \ @@ -78,8 +79,8 @@ HEADERS += \ widgets/qtoolbararealayout_p.h \ widgets/qplaintextedit.h \ widgets/qplaintextedit_p.h \ - widgets/qprintpreviewwidget.h \ - widgets/qkeyeventsoftkey.h \ + widgets/qprintpreviewwidget.h + SOURCES += \ widgets/qabstractbutton.cpp \ widgets/qabstractslider.cpp \ @@ -97,6 +98,7 @@ SOURCES += \ widgets/qfontcombobox.cpp \ widgets/qframe.cpp \ widgets/qgroupbox.cpp \ + widgets/qkeyeventsoftkey.cpp \ widgets/qlabel.cpp \ widgets/qlcdnumber.cpp \ widgets/qlineedit.cpp \ @@ -138,8 +140,7 @@ SOURCES += \ widgets/qwidgetanimator.cpp \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp \ - widgets/qprintpreviewwidget.cpp \ - widgets/qkeyeventsoftkey.cpp \ + widgets/qprintpreviewwidget.cpp !embedded:mac { HEADERS += widgets/qmacnativewidget_mac.h \ @@ -162,6 +163,5 @@ wince*: { } symbian*: { - SOURCES += \ - widgets/qmenu_symbian.cpp \ + SOURCES += widgets/qmenu_symbian.cpp } -- cgit v0.12 From 9420db9284f20e28239d1c6e8a4cccf7707c014e Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 18:50:17 +0200 Subject: Fixed bug that caused the softkeys list not to be cleared after the softkeys in the list were deleted --- src/gui/kernel/qwidget.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 0a7fea3..7a8b143 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11528,6 +11528,7 @@ void QWidget::setSoftKeys(QAction *softKey) { Q_D(QWidget); qDeleteAll(d->softKeys); + d->softKeys.clear(); if (softKey) d->softKeys.append(softKey); // d->setNativeSoftKeys(softkeys); @@ -11537,6 +11538,7 @@ void QWidget::setSoftKeys(const QList &softKeys) { Q_D(QWidget); qDeleteAll(d->softKeys); + d->softKeys.clear(); for(int i = 0; i < softKeys.count(); i++) d->softKeys.append(softKeys.at(i)); -- cgit v0.12 From ef0f6267822c782f0b555e15ddab24c41c51d2e8 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 19:37:37 +0200 Subject: Added support for setting softkeys dynamically --- src/gui/kernel/qwidget.cpp | 6 ++++-- src/gui/kernel/qwidget_s60.cpp | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 7a8b143..e82fbd2 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11531,7 +11531,8 @@ void QWidget::setSoftKeys(QAction *softKey) d->softKeys.clear(); if (softKey) d->softKeys.append(softKey); -// d->setNativeSoftKeys(softkeys); + if (QApplication::focusWidget() == this) + d->setNativeSoftKeys(this->softKeys()); } void QWidget::setSoftKeys(const QList &softKeys) @@ -11542,7 +11543,8 @@ void QWidget::setSoftKeys(const QList &softKeys) for(int i = 0; i < softKeys.count(); i++) d->softKeys.append(softKeys.at(i)); - // d->setNativeSoftKeys(softkeys); + if (QApplication::focusWidget() == this) + d->setNativeSoftKeys(this->softKeys()); } /*! \fn const QX11Info &QWidget::x11Info() const diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 4e03206..cb2fc8f 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -107,7 +107,8 @@ static bool isSame(const QList& a, const QList& b) void QWidgetPrivate::setNativeSoftKeys(const QList &softkeys) { - if (QApplication::focusWidget()) { + Q_Q(QWidget); + if (QApplication::focusWidget() && q!=QApplication::focusWidget()) { QList old = QApplication::focusWidget()->softKeys(); if (isSame(old, softkeys )) return; -- cgit v0.12 From 5edc6f4e88aa7896be0e69a6bcf2365adb6b70b4 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 19:38:17 +0200 Subject: Added implementation to get default role names --- src/gui/widgets/qkeyeventsoftkey.cpp | 26 ++++++++++++++++++++++++++ src/gui/widgets/qkeyeventsoftkey.h | 1 + 2 files changed, 27 insertions(+) diff --git a/src/gui/widgets/qkeyeventsoftkey.cpp b/src/gui/widgets/qkeyeventsoftkey.cpp index 08f5c6f..bb236cc 100644 --- a/src/gui/widgets/qkeyeventsoftkey.cpp +++ b/src/gui/widgets/qkeyeventsoftkey.cpp @@ -53,10 +53,36 @@ QKeyEventSoftKey::QKeyEventSoftKey(QAction *softKeyAction, Qt::Key key, QObject } +QString QKeyEventSoftKey::roleText(QAction::SoftKeyRole role) +{ + switch (role) { + case QAction::OptionsSoftKey: + return QAction::tr("Options"); + case QAction::SelectSoftKey: + return QAction::tr("Select"); + case QAction::BackSoftKey: + return QAction::tr("Back"); + case QAction::NextSoftKey: + return QAction::tr("Next"); + case QAction::PreviousSoftKey: + return QAction::tr("Previous"); + case QAction::OkSoftKey: + return QAction::tr("Ok"); + case QAction::CancelSoftKey: + return QAction::tr("Cancel"); + case QAction::EditSoftKey: + return QAction::tr("Edit"); + case QAction::ViewSoftKey: + return QAction::tr("View"); + default: + return QString(); + }; +} void QKeyEventSoftKey::addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget) { QAction *action = new QAction(actionWidget); action->setSoftKeyRole(standardRole); + action->setText(roleText(standardRole)); QKeyEventSoftKey *softKey = new QKeyEventSoftKey(action, key, actionWidget); connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent())); connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater())); diff --git a/src/gui/widgets/qkeyeventsoftkey.h b/src/gui/widgets/qkeyeventsoftkey.h index fd69907..83449c7 100644 --- a/src/gui/widgets/qkeyeventsoftkey.h +++ b/src/gui/widgets/qkeyeventsoftkey.h @@ -57,6 +57,7 @@ class Q_GUI_EXPORT QKeyEventSoftKey : QObject Q_OBJECT public: QKeyEventSoftKey(QAction *softKeyAction, Qt::Key key, QObject *parent); + static QString roleText(QAction::SoftKeyRole role); static void addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget); static void removeSoftkey(QWidget *focussedWidget); private: -- cgit v0.12 From 267891cb23e0e751873f9a6cf5dd951287c0e5e5 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Sat, 6 Jun 2009 19:38:52 +0200 Subject: Changed combobox to use popup as a parent when setting softkeys. This enables the softkeys to actually be visible on the screen --- src/gui/widgets/qcombobox.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index aa90909..01fcf34 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -2438,7 +2438,7 @@ void QComboBox::showPopup() #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) view()->setEditFocus(true); - QKeyEventSoftKey::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, this); + QKeyEventSoftKey::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, view()); #endif } -- cgit v0.12 From 7661082e4c1851ab2fd6409d8689dc8b08d793b9 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Sun, 7 Jun 2009 23:21:47 +0200 Subject: Make the linker happy on non-Q_WS_S60 --- src/gui/kernel/qwidget.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index e82fbd2..69e2d84 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4880,6 +4880,13 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, d->extra->inRenderWithPainter = false; } +#if !defined(Q_WS_S60) +void QWidgetPrivate::setNativeSoftKeys(const QList &softkeys) +{ + Q_UNUSED(softkeys) +} +#endif // !defined(Q_WS_S60) + bool QWidgetPrivate::isAboutToShow() const { if (data.in_show) -- cgit v0.12 From 5d749ad1b67a8d5ba77800567ffa473f5ad1d9f5 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 8 Jun 2009 09:49:05 +0200 Subject: Fixed parsing error when doing configure+compile in clean environment --- src/gui/widgets/widgets.pri | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index d0f981c..f395c76 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -25,7 +25,6 @@ HEADERS += \ widgets/qframe.h \ widgets/qframe_p.h \ widgets/qgroupbox.h \ - widgets/qkeyeventsoftkey.h \ widgets/qlabel.h \ widgets/qlabel_p.h \ widgets/qlcdnumber.h \ @@ -79,8 +78,8 @@ HEADERS += \ widgets/qtoolbararealayout_p.h \ widgets/qplaintextedit.h \ widgets/qplaintextedit_p.h \ - widgets/qprintpreviewwidget.h - + widgets/qprintpreviewwidget.h \ + widgets/qkeyeventsoftkey.h SOURCES += \ widgets/qabstractbutton.cpp \ widgets/qabstractslider.cpp \ @@ -98,7 +97,6 @@ SOURCES += \ widgets/qfontcombobox.cpp \ widgets/qframe.cpp \ widgets/qgroupbox.cpp \ - widgets/qkeyeventsoftkey.cpp \ widgets/qlabel.cpp \ widgets/qlcdnumber.cpp \ widgets/qlineedit.cpp \ @@ -140,7 +138,8 @@ SOURCES += \ widgets/qwidgetanimator.cpp \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp \ - widgets/qprintpreviewwidget.cpp + widgets/qprintpreviewwidget.cpp \ + widgets/qkeyeventsoftkey.cpp !embedded:mac { HEADERS += widgets/qmacnativewidget_mac.h \ -- cgit v0.12 From 8938f242414cc67f8a4081222857bfeb16bb5f37 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 8 Jun 2009 10:33:38 +0200 Subject: Implemented context sensitive menu item --- src/gui/widgets/qmenu_symbian.cpp | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index e422882..ed2ea46 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -90,6 +90,16 @@ bool menuExists() return true; } +static bool hasContextMenu(QWidget* widget) +{ + if (!widget) + return false; + const Qt::ContextMenuPolicy policy = widget->contextMenuPolicy(); + if (policy != Qt::NoContextMenu && policy != Qt::PreventContextMenu ) { + return true; + } + return false; +} // ### FIX THIS, copy/paste of original (faulty) stripped text implementation. // Implementation should be removed from QAction implementation to some generic place static QString qt_strippedText_copy_from_qaction(QString s) @@ -212,24 +222,12 @@ static void rebuildMenu() QMenuBarPrivate *mb = 0; QWidget *w = qApp->activeWindow(); QMainWindow *mainWindow = qobject_cast(w); - /* if ((mainWindow) && mainWindow->hasSoftKeyStack()) { - QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); - if (!softKeyStack->isEmpty()) { - const QSoftkeySet& softKeyTop = softKeyStack->top(); - int index=0; - bool found=false; - while( indexrole(); - if(softAction->role() == QSoftKeyAction::ContextMenu) { - widgetWithContextMenu = softAction->parentWidget(); - found=true; - } - index++; - } - } + QWidget* focusWidget = QApplication::focusWidget(); + if (focusWidget) { + if (hasContextMenu(focusWidget)) + widgetWithContextMenu = focusWidget; } -*/ + if (w) { mb = menubars()->value(w); qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; -- cgit v0.12 From 5b0f60b7eae6daac9ef45726cdc8cde18bcb69f9 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 8 Jun 2009 10:47:00 +0200 Subject: Set empty buttons by default --- src/s60main/qts60mainappui.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/s60main/qts60mainappui.cpp b/src/s60main/qts60mainappui.cpp index 47312af..7d38f33 100644 --- a/src/s60main/qts60mainappui.cpp +++ b/src/s60main/qts60mainappui.cpp @@ -68,6 +68,9 @@ void CQtS60MainAppUi::ConstructL() // even these flags are defined BaseConstructL(CAknAppUi::EAknEnableSkin); + CEikButtonGroupContainer* nativeContainer = Cba(); + nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); + // Create async callback to call Qt main, // this is required to give S60 app FW to finish starting correctly TCallBack callBack( OpenCMainStaticCallBack, this ); -- cgit v0.12 From fb8dccabd68a854c50adfc3f1e77badc3ff50ec8 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 8 Jun 2009 12:00:42 +0200 Subject: Removed QSoftkeySet as it wasn't used anymore --- src/gui/kernel/qwidget_s60.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index cb2fc8f..858320c 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -61,9 +61,7 @@ extern bool qt_nograb(); QWidget *QWidgetPrivate::mouseGrabber = 0; QWidget *QWidgetPrivate::keyboardGrabber = 0; -#define QSoftkeySet QList - -static void mapSoftKeys(const QSoftkeySet &softkeys) +static void mapSoftKeys(const QList &softkeys) { /* if (softkeys.count() == 1 && softkeys.at(0)->menuRole()==QAction::MenuSoftKey) { softkeys.at(0)->setNativePosition(0); -- cgit v0.12 From 46cb3a09f4eedb2d4c612a6d73e9e0f14237350c Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Mon, 8 Jun 2009 17:08:26 +0200 Subject: Fixes from code review --- src/gui/kernel/qaction.cpp | 3 ++- src/gui/kernel/qaction.h | 1 - src/gui/kernel/qapplication_s60.cpp | 6 ++--- src/gui/kernel/qwidget.cpp | 39 ++++++++++++++++++++++++-------- src/gui/kernel/qwidget.h | 2 +- src/gui/kernel/qwidget_p.h | 6 ++--- src/gui/kernel/qwidget_s60.cpp | 7 +++--- src/gui/widgets/qkeyeventsoftkey.cpp | 44 ++++++++++++++++++------------------ src/gui/widgets/qkeyeventsoftkey.h | 4 ++-- src/gui/widgets/qmainwindow.cpp | 2 +- src/gui/widgets/qmenu_symbian.cpp | 11 ++++----- src/gui/widgets/qmenubar_p.h | 2 +- 12 files changed, 70 insertions(+), 57 deletions(-) diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index e32416a..8263cbc 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -1353,7 +1353,7 @@ QAction::MenuRole QAction::menuRole() const \since 4.6 This indicates what softkey action this action is. Usually used on mobile - platforms to map QActions no hardware keys. + platforms to map QActions to hardware keys. The softkey role can be changed any time. */ @@ -1372,6 +1372,7 @@ QAction::SoftKeyRole QAction::softKeyRole() const Q_D(const QAction); return d->softKeyRole; } + /*! \property QAction::iconVisibleInMenu \brief Whether or not an action should show an icon in a menu diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h index 6725f42..8791a5c 100644 --- a/src/gui/kernel/qaction.h +++ b/src/gui/kernel/qaction.h @@ -96,7 +96,6 @@ public: EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey, MenuSoftKey, ContextMenuSoftKey, Key1SoftKey, Key2SoftKey, Key3SoftKey, Key4SoftKey, CustomSoftKey }; - explicit QAction(QObject* parent); QAction(const QString &text, QObject* parent); QAction(const QIcon &icon, const QString &text, QObject* parent); diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 6ee7899..0ae4c00 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -1** +** ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Qt Software Information (qt-info@nokia.com) ** @@ -1067,9 +1067,7 @@ void QApplication::symbianHandleCommand(int command) int index= command-SOFTKEYSTART; QWidget* focused = QApplication::focusWidget(); const QList& softKeys = focused->softKeys(); - if (index>=softKeys.count()) { - // Assert horrible state error - } + Q_ASSERT(indexactivate(QAction::Trigger); } else diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 9d4f176..3a22ee9 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -4881,7 +4881,7 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, } #if !defined(Q_WS_S60) -void QWidgetPrivate::setNativeSoftKeys(const QList &softkeys) +void QWidgetPrivate::setSoftKeys_sys(const QList &softkeys) { Q_UNUSED(softkeys) } @@ -5723,7 +5723,7 @@ bool QWidget::hasFocus() const void QWidget::setFocus(Qt::FocusReason reason) { Q_D(QWidget); - d->setNativeSoftKeys(softKeys()); + d->setSoftKeys_sys(softKeys()); if (!isEnabled()) return; @@ -11520,19 +11520,33 @@ void QWidget::clearMask() setMask(QRegion()); } +/*! + Returns the (possibly empty) list of this widget's softkeys. + Returned list cannot be changed. Softkeys should be added + and removed via method called setSoftKeys + + \sa setSoftKey(), setSoftKeys() +*/ const QList& QWidget::softKeys() const { Q_D(const QWidget); if( d->softKeys.count() > 0) return d->softKeys; - if (isWindow() || !parentWidget()) return d->softKeys; - + return parentWidget()->softKeys(); } -void QWidget::setSoftKeys(QAction *softKey) +/*! + Sets the softkey \a softkey to this widget's list of softkeys, + Setting 0 as softkey will clear all the existing softkeys set + to the widget + A QWidget can have 0 or more softkeys + + \sa softKeys(), setSoftKeys() +*/ +void QWidget::setSoftKey(QAction *softKey) { Q_D(QWidget); qDeleteAll(d->softKeys); @@ -11540,19 +11554,24 @@ void QWidget::setSoftKeys(QAction *softKey) if (softKey) d->softKeys.append(softKey); if (QApplication::focusWidget() == this) - d->setNativeSoftKeys(this->softKeys()); + d->setSoftKeys_sys(this->softKeys()); } +/*! + Sets the list of softkeys \a softkeys to this widget's list of softkeys, + A QWidget can have 0 or more softkeys + + \sa softKeys(), setSoftKey() +*/ void QWidget::setSoftKeys(const QList &softKeys) { Q_D(QWidget); qDeleteAll(d->softKeys); d->softKeys.clear(); - for(int i = 0; i < softKeys.count(); i++) - d->softKeys.append(softKeys.at(i)); - + d->softKeys = softKeys; + if (QApplication::focusWidget() == this) - d->setNativeSoftKeys(this->softKeys()); + d->setSoftKeys_sys(this->softKeys()); } /*! \fn const QX11Info &QWidget::x11Info() const diff --git a/src/gui/kernel/qwidget.h b/src/gui/kernel/qwidget.h index 36a30ac..3f9caee 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -555,7 +555,7 @@ public: QList actions() const; #endif const QList& softKeys() const; - void setSoftKeys(QAction *softKey); + void setSoftKey(QAction *softKey); void setSoftKeys(const QList &softKeys); QWidget *parentWidget() const; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 2119849..084439c 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -85,8 +85,8 @@ class CCoeControl; class CAknTitlePane; class CAknContextPane; // The following 2 defines may only be needed for s60. To be seen. -#define SOFTKEYSTART 5000 -#define SOFTKEYEND (5000 + Qt::Key_Context4-Qt::Key_Context1) +const int SOFTKEYSTART=5000; +const int SOFTKEYEND=5004; #endif QT_BEGIN_NAMESPACE @@ -227,7 +227,7 @@ public: explicit QWidgetPrivate(int version = QObjectPrivateVersion); ~QWidgetPrivate(); - void setNativeSoftKeys(const QList &softkeys); + void setSoftKeys_sys(const QList &softkeys); QWExtra *extraData() const; QTLWExtra *topData() const; QTLWExtra *maybeTopData() const; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 858320c..2a83fc7 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -86,9 +86,8 @@ static void mapSoftKeys(const QList &softkeys) */ } -static bool isSame(const QList& a, const QList& b) +static bool isEqual(const QList& a, const QList& b) { - bool isSame=true; if ( a.count() != b.count()) return false; int index=0; @@ -103,12 +102,12 @@ static bool isSame(const QList& a, const QList& b) } -void QWidgetPrivate::setNativeSoftKeys(const QList &softkeys) +void QWidgetPrivate::setSoftKeys_sys(const QList &softkeys) { Q_Q(QWidget); if (QApplication::focusWidget() && q!=QApplication::focusWidget()) { QList old = QApplication::focusWidget()->softKeys(); - if (isSame(old, softkeys )) + if (isEqual(old, softkeys )) return; } diff --git a/src/gui/widgets/qkeyeventsoftkey.cpp b/src/gui/widgets/qkeyeventsoftkey.cpp index bb236cc..f5f10fc 100644 --- a/src/gui/widgets/qkeyeventsoftkey.cpp +++ b/src/gui/widgets/qkeyeventsoftkey.cpp @@ -56,26 +56,26 @@ QKeyEventSoftKey::QKeyEventSoftKey(QAction *softKeyAction, Qt::Key key, QObject QString QKeyEventSoftKey::roleText(QAction::SoftKeyRole role) { switch (role) { - case QAction::OptionsSoftKey: - return QAction::tr("Options"); - case QAction::SelectSoftKey: - return QAction::tr("Select"); - case QAction::BackSoftKey: - return QAction::tr("Back"); - case QAction::NextSoftKey: - return QAction::tr("Next"); - case QAction::PreviousSoftKey: - return QAction::tr("Previous"); - case QAction::OkSoftKey: - return QAction::tr("Ok"); - case QAction::CancelSoftKey: - return QAction::tr("Cancel"); - case QAction::EditSoftKey: - return QAction::tr("Edit"); - case QAction::ViewSoftKey: - return QAction::tr("View"); - default: - return QString(); + case QAction::OptionsSoftKey: + return QAction::tr("Options"); + case QAction::SelectSoftKey: + return QAction::tr("Select"); + case QAction::BackSoftKey: + return QAction::tr("Back"); + case QAction::NextSoftKey: + return QAction::tr("Next"); + case QAction::PreviousSoftKey: + return QAction::tr("Previous"); + case QAction::OkSoftKey: + return QAction::tr("Ok"); + case QAction::CancelSoftKey: + return QAction::tr("Cancel"); + case QAction::EditSoftKey: + return QAction::tr("Edit"); + case QAction::ViewSoftKey: + return QAction::tr("View"); + default: + return QString(); }; } void QKeyEventSoftKey::addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget) @@ -86,12 +86,12 @@ void QKeyEventSoftKey::addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key QKeyEventSoftKey *softKey = new QKeyEventSoftKey(action, key, actionWidget); connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent())); connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater())); - actionWidget->setSoftKeys(action); + actionWidget->setSoftKey(action); } void QKeyEventSoftKey::removeSoftkey(QWidget *focussedWidget) { - focussedWidget->setSoftKeys(0); + focussedWidget->setSoftKey(0); } void QKeyEventSoftKey::sendKeyEvent() diff --git a/src/gui/widgets/qkeyeventsoftkey.h b/src/gui/widgets/qkeyeventsoftkey.h index 83449c7..0b95efb 100644 --- a/src/gui/widgets/qkeyeventsoftkey.h +++ b/src/gui/widgets/qkeyeventsoftkey.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QKEYEVENSOFTKEY_H -#define QKEYEVENSOFTKEY_H +#ifndef QKEYEVENTSOFTKEY_H +#define QKEYEVENTSOFTKEY_H #include #include "QtGui/qaction.h" diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 90c5db9..2f3b412 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -484,7 +484,7 @@ void QMainWindow::setMenuBar(QMenuBar *menuBar) if (menuBar) { QAction* menu = new QAction(QString::fromLatin1("Menu"), this); menu->setSoftKeyRole(QAction::MenuSoftKey); - setSoftKeys(menu); + setSoftKey(menu); } } diff --git a/src/gui/widgets/qmenu_symbian.cpp b/src/gui/widgets/qmenu_symbian.cpp index ed2ea46..49bcc21 100644 --- a/src/gui/widgets/qmenu_symbian.cpp +++ b/src/gui/widgets/qmenu_symbian.cpp @@ -40,8 +40,6 @@ #include "qmenu.h" #include "qapplication.h" -#include "qmainwindow.h" -#include "qtoolbar.h" #include "qevent.h" #include "qstyle.h" #include "qdebug.h" @@ -221,13 +219,12 @@ static void rebuildMenu() widgetWithContextMenu = 0; QMenuBarPrivate *mb = 0; QWidget *w = qApp->activeWindow(); - QMainWindow *mainWindow = qobject_cast(w); QWidget* focusWidget = QApplication::focusWidget(); if (focusWidget) { if (hasContextMenu(focusWidget)) widgetWithContextMenu = focusWidget; } - + if (w) { mb = menubars()->value(w); qt_symbian_menu_static_cmd_id = QT_FIRST_MENU_ITEM; @@ -389,7 +386,7 @@ void QMenuBarPrivate::QSymbianMenuBarPrivate::removeAction(QSymbianMenuAction *a rebuild(); } -void QMenuBarPrivate::QSymbianMenuBarPrivate::InsertNativeMenuItems(const QList &actions) +void QMenuBarPrivate::QSymbianMenuBarPrivate::insertNativeMenuItems(const QList &actions) { for (int i = 0; i actions); + insertNativeMenuItems(d->actions); contextMenuActionList.clear(); if (widgetWithContextMenu) { contexMenuCommand = qt_symbian_menu_static_cmd_id; contextAction.setText(QString("Actions")); contextMenuActionList.append(&contextAction); - InsertNativeMenuItems(contextMenuActionList); + insertNativeMenuItems(contextMenuActionList); } } diff --git a/src/gui/widgets/qmenubar_p.h b/src/gui/widgets/qmenubar_p.h index 429605a..9e7d511 100644 --- a/src/gui/widgets/qmenubar_p.h +++ b/src/gui/widgets/qmenubar_p.h @@ -257,7 +257,7 @@ public: } return 0; } - void InsertNativeMenuItems(const QList &actions); + void insertNativeMenuItems(const QList &actions); } *symbian_menubar; static void symbianCommands(int command); -- cgit v0.12 From 9bdd939c508dfe784402c5c3e85e26d135f7643c Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Tue, 9 Jun 2009 14:40:56 +0200 Subject: Fixes from code review --- src/gui/itemviews/qabstractitemview.cpp | 6 +- src/gui/kernel/qwidget_s60.cpp | 41 ----------- src/gui/widgets/qactiontokeyeventmapper.cpp | 103 +++++++++++++++++++++++++++ src/gui/widgets/qactiontokeyeventmapper_p.h | 70 +++++++++++++++++++ src/gui/widgets/qcombobox.cpp | 8 +-- src/gui/widgets/qkeyeventsoftkey.cpp | 105 ---------------------------- src/gui/widgets/qkeyeventsoftkey.h | 74 -------------------- src/gui/widgets/qmenu.cpp | 8 +-- src/gui/widgets/widgets.pri | 4 +- 9 files changed, 186 insertions(+), 233 deletions(-) create mode 100644 src/gui/widgets/qactiontokeyeventmapper.cpp create mode 100644 src/gui/widgets/qactiontokeyeventmapper_p.h delete mode 100644 src/gui/widgets/qkeyeventsoftkey.cpp delete mode 100644 src/gui/widgets/qkeyeventsoftkey.h diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 69e630e..af84ea6 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -61,7 +61,7 @@ #ifndef QT_NO_ACCESSIBILITY #include #endif -#include +#include QT_BEGIN_NAMESPACE @@ -2004,14 +2004,14 @@ void QAbstractItemView::keyPressEvent(QKeyEvent *event) if (QApplication::keypadNavigationEnabled()) { if (!hasEditFocus()) { setEditFocus(true); - QKeyEventSoftKey::addSoftKey(QAction::BackSoftKey, Qt::Key_Back, this); + QActionToKeyEventMapper::addSoftKey(QAction::BackSoftKey, Qt::Key_Back, this); return; } } break; case Qt::Key_Back: if (QApplication::keypadNavigationEnabled() && hasEditFocus()) { - QKeyEventSoftKey::removeSoftkey(this); + QActionToKeyEventMapper::removeSoftkey(this); setEditFocus(false); } else { event->ignore(); diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 2a83fc7..cc6f794 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -61,31 +61,6 @@ extern bool qt_nograb(); QWidget *QWidgetPrivate::mouseGrabber = 0; QWidget *QWidgetPrivate::keyboardGrabber = 0; -static void mapSoftKeys(const QList &softkeys) -{ -/* if (softkeys.count() == 1 && softkeys.at(0)->menuRole()==QAction::MenuSoftKey) { - softkeys.at(0)->setNativePosition(0); - softkeys.at(0)->setQtContextKey(Qt::Key_Context1); - } - else if(softkeys.count() == 1 && softkeys.at(0)->menuRole()!=QAction::MenuSoftKey) { - softkeys.at(0)->setNativePosition(2); - softkeys.at(0)->setQtContextKey(Qt::Key_Context1); - } - 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 < softkeys.count(); index++) { - softkeys.at(index)->setNativePosition(index + veryWeirdMagic); - softkeys.at(index)->setQtContextKey(Qt::Key_Context1 + index); - if (veryWeirdMagic == 0) - veryWeirdMagic = 1; - } - } -*/ -} - static bool isEqual(const QList& a, const QList& b) { if ( a.count() != b.count()) @@ -110,15 +85,12 @@ void QWidgetPrivate::setSoftKeys_sys(const QList &softkeys) if (isEqual(old, softkeys )) return; } - CCoeAppUi* appui = CEikonEnv::Static()->AppUi(); CAknAppUi* aknAppUi = static_cast (appui); CEikButtonGroupContainer* nativeContainer = aknAppUi->Cba(); nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS); - mapSoftKeys(softkeys); int placeInScreen=0; - for (int index = 0; index < softkeys.count(); index++) { const QAction* softKeyAction = softkeys.at(index); if (softKeyAction->softKeyRole() != QAction::ContextMenuSoftKey) { @@ -135,7 +107,6 @@ void QWidgetPrivate::setSoftKeys_sys(const QList &softkeys) } if (placeInScreen==1) placeInScreen=2; - } } @@ -1083,16 +1054,4 @@ void QWidget::activateWindow() rw->SetOrdinalPosition(0); } } -/* -void QWidget::setSoftKeys(QSoftKeyAction *softKey) -{ - Q_D(QWidget); - d-> -} - -void QWidget::setSoftKeys(const QList &softkeys) -{ - Q_D(QWidget); -} -*/ QT_END_NAMESPACE diff --git a/src/gui/widgets/qactiontokeyeventmapper.cpp b/src/gui/widgets/qactiontokeyeventmapper.cpp new file mode 100644 index 0000000..5cce415 --- /dev/null +++ b/src/gui/widgets/qactiontokeyeventmapper.cpp @@ -0,0 +1,103 @@ +/**************************************************************************** +** +** 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 "qapplication.h" +#include "qevent.h" +#include "QActionToKeyEventMapper_p.h" + +QT_BEGIN_NAMESPACE + +QActionToKeyEventMapper::QActionToKeyEventMapper(QAction *softKeyAction, Qt::Key key, QObject *parent) + : QObject(parent) + , m_softKeyAction(softKeyAction) + , m_key(key) +{ + +} + +QString QActionToKeyEventMapper::roleText(QAction::SoftKeyRole role) +{ + switch (role) { + case QAction::OptionsSoftKey: + return QAction::tr("Options"); + case QAction::SelectSoftKey: + return QAction::tr("Select"); + case QAction::BackSoftKey: + return QAction::tr("Back"); + case QAction::NextSoftKey: + return QAction::tr("Next"); + case QAction::PreviousSoftKey: + return QAction::tr("Previous"); + case QAction::OkSoftKey: + return QAction::tr("Ok"); + case QAction::CancelSoftKey: + return QAction::tr("Cancel"); + case QAction::EditSoftKey: + return QAction::tr("Edit"); + case QAction::ViewSoftKey: + return QAction::tr("View"); + default: + return QString(); + }; +} +void QActionToKeyEventMapper::addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget) +{ + QAction *action = new QAction(actionWidget); + action->setSoftKeyRole(standardRole); + action->setText(roleText(standardRole)); + QActionToKeyEventMapper *softKey = new QActionToKeyEventMapper(action, key, actionWidget); + connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent())); + connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater())); + actionWidget->setSoftKey(action); +} + +void QActionToKeyEventMapper::removeSoftkey(QWidget *focussedWidget) +{ + focussedWidget->setSoftKey(0); +} + +void QActionToKeyEventMapper::sendKeyEvent() +{ + QApplication::postEvent(parent(), new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier)); +} + +QT_END_NAMESPACE + diff --git a/src/gui/widgets/qactiontokeyeventmapper_p.h b/src/gui/widgets/qactiontokeyeventmapper_p.h new file mode 100644 index 0000000..da336e8 --- /dev/null +++ b/src/gui/widgets/qactiontokeyeventmapper_p.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** 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 QACTIONTOKEYEVENTMAPPER_P_H +#define QACTIONTOKEYEVENTMAPPER_P_H + +#include +#include "QtGui/qaction.h" +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QActionToKeyEventMapper : public QObject +{ + Q_OBJECT +public: + QActionToKeyEventMapper(QAction *softKeyAction, Qt::Key key, QObject *parent); + static QString roleText(QAction::SoftKeyRole role); + static void addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget); + static void removeSoftkey(QWidget *focussedWidget); +private: + QAction *m_softKeyAction; + Qt::Key m_key; +private Q_SLOTS: + void sendKeyEvent(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif //QACTIONTOKEYEVENTMAPPER_H diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index 01fcf34..2da5cd0 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -63,7 +63,7 @@ #include #include #include -#include +#include #ifdef Q_WS_X11 #include #endif @@ -629,7 +629,7 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) #endif if (view->currentIndex().isValid() && (view->currentIndex().flags() & Qt::ItemIsEnabled) ) { #ifdef QT_KEYPAD_NAVIGATION - QKeyEventSoftKey::removeSoftkey(this); + QActionToKeyEventMapper::removeSoftkey(this); #endif combo->hidePopup(); emit itemSelected(view->currentIndex()); @@ -643,7 +643,7 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e) case Qt::Key_Escape: #ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Back: - QKeyEventSoftKey::removeSoftkey(this); + QActionToKeyEventMapper::removeSoftkey(this); #endif combo->hidePopup(); return true; @@ -2438,7 +2438,7 @@ void QComboBox::showPopup() #ifdef QT_KEYPAD_NAVIGATION if (QApplication::keypadNavigationEnabled()) view()->setEditFocus(true); - QKeyEventSoftKey::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, view()); + QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, view()); #endif } diff --git a/src/gui/widgets/qkeyeventsoftkey.cpp b/src/gui/widgets/qkeyeventsoftkey.cpp deleted file mode 100644 index f5f10fc..0000000 --- a/src/gui/widgets/qkeyeventsoftkey.cpp +++ /dev/null @@ -1,105 +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 "qapplication.h" -#include "qevent.h" -#include "qkeyeventsoftkey.h" - -QT_BEGIN_NAMESPACE - -QKeyEventSoftKey::QKeyEventSoftKey(QAction *softKeyAction, Qt::Key key, QObject *parent) - : QObject(parent) - , m_softKeyAction(softKeyAction) - , m_key(key) -{ - -} - -QString QKeyEventSoftKey::roleText(QAction::SoftKeyRole role) -{ - switch (role) { - case QAction::OptionsSoftKey: - return QAction::tr("Options"); - case QAction::SelectSoftKey: - return QAction::tr("Select"); - case QAction::BackSoftKey: - return QAction::tr("Back"); - case QAction::NextSoftKey: - return QAction::tr("Next"); - case QAction::PreviousSoftKey: - return QAction::tr("Previous"); - case QAction::OkSoftKey: - return QAction::tr("Ok"); - case QAction::CancelSoftKey: - return QAction::tr("Cancel"); - case QAction::EditSoftKey: - return QAction::tr("Edit"); - case QAction::ViewSoftKey: - return QAction::tr("View"); - default: - return QString(); - }; -} -void QKeyEventSoftKey::addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget) -{ - QAction *action = new QAction(actionWidget); - action->setSoftKeyRole(standardRole); - action->setText(roleText(standardRole)); - QKeyEventSoftKey *softKey = new QKeyEventSoftKey(action, key, actionWidget); - connect(action, SIGNAL(triggered()), softKey, SLOT(sendKeyEvent())); - connect(action, SIGNAL(destroyed()), softKey, SLOT(deleteLater())); - actionWidget->setSoftKey(action); -} - -void QKeyEventSoftKey::removeSoftkey(QWidget *focussedWidget) -{ - focussedWidget->setSoftKey(0); -} - -void QKeyEventSoftKey::sendKeyEvent() -{ - QApplication::postEvent(parent(), new QKeyEvent(QEvent::KeyPress, m_key, Qt::NoModifier)); -} - -QT_END_NAMESPACE - -#include "moc_qkeyeventsoftkey.cpp" - diff --git a/src/gui/widgets/qkeyeventsoftkey.h b/src/gui/widgets/qkeyeventsoftkey.h deleted file mode 100644 index 0b95efb..0000000 --- a/src/gui/widgets/qkeyeventsoftkey.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 QKEYEVENTSOFTKEY_H -#define QKEYEVENTSOFTKEY_H - -#include -#include "QtGui/qaction.h" -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - - - -class Q_GUI_EXPORT QKeyEventSoftKey : QObject -{ - Q_OBJECT -public: - QKeyEventSoftKey(QAction *softKeyAction, Qt::Key key, QObject *parent); - static QString roleText(QAction::SoftKeyRole role); - static void addSoftKey(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget); - static void removeSoftkey(QWidget *focussedWidget); -private: - QAction *m_softKeyAction; - Qt::Key m_key; -private Q_SLOTS: - void sendKeyEvent(); -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif //QKEYEVENSOFTKEY_H diff --git a/src/gui/widgets/qmenu.cpp b/src/gui/widgets/qmenu.cpp index d713081..3486574 100644 --- a/src/gui/widgets/qmenu.cpp +++ b/src/gui/widgets/qmenu.cpp @@ -60,7 +60,7 @@ #ifndef QT_NO_WHATSTHIS # include #endif -#include +#include #include "qmenu_p.h" #include "qmenubar_p.h" @@ -584,7 +584,7 @@ void QMenuPrivate::setCurrentAction(QAction *action, int popup, SelectionReason #ifdef QT_KEYPAD_NAVIGATION // TODO: aportale, remove KEYPAD_NAVIGATION_HACK when softkey stack // handles focus related and user related actions separately... - QKeyEventSoftKey::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, q); + QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, q); #endif } } @@ -1945,7 +1945,7 @@ void QMenu::popup(const QPoint &p, QAction *atAction) QAccessible::updateAccessibility(this, 0, QAccessible::PopupMenuStart); #endif #ifdef QT_KEYPAD_NAVIGATION - QKeyEventSoftKey::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, this); + QActionToKeyEventMapper::addSoftKey(QAction::CancelSoftKey, Qt::Key_Back, this); #endif } @@ -2597,7 +2597,7 @@ void QMenu::keyPressEvent(QKeyEvent *e) case Qt::Key_Escape: #ifdef QT_KEYPAD_NAVIGATION case Qt::Key_Back: - QKeyEventSoftKey::removeSoftkey(this); + QActionToKeyEventMapper::removeSoftkey(this); #endif key_consumed = true; if (d->tornoff) { diff --git a/src/gui/widgets/widgets.pri b/src/gui/widgets/widgets.pri index f395c76..9e226e2 100644 --- a/src/gui/widgets/widgets.pri +++ b/src/gui/widgets/widgets.pri @@ -79,7 +79,7 @@ HEADERS += \ widgets/qplaintextedit.h \ widgets/qplaintextedit_p.h \ widgets/qprintpreviewwidget.h \ - widgets/qkeyeventsoftkey.h + widgets/qactiontokeyeventmapper_p.h SOURCES += \ widgets/qabstractbutton.cpp \ widgets/qabstractslider.cpp \ @@ -139,7 +139,7 @@ SOURCES += \ widgets/qtoolbararealayout.cpp \ widgets/qplaintextedit.cpp \ widgets/qprintpreviewwidget.cpp \ - widgets/qkeyeventsoftkey.cpp + widgets/qactiontokeyeventmapper.cpp !embedded:mac { HEADERS += widgets/qmacnativewidget_mac.h \ -- cgit v0.12 From 4df7621c7ab1b38416002430377a451a4c416100 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 9 Jun 2009 17:50:13 +0200 Subject: Itemviews have go their focus frame back. Got lost with dc177883bf98a68e61c9a9cda7e1ba9464079275 --- src/gui/styles/qs60style.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 6d24d54..3236928 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -1880,11 +1880,11 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, } break; #endif //QT_NO_TOOLBAR - case CE_ShapedFrame: { - const QTextEdit *txt = qobject_cast(widget); - if (txt) + case CE_ShapedFrame: + if (qobject_cast(widget)) QS60StylePrivate::drawSkinElement(QS60StylePrivate::SE_Editor, painter, option->rect, flags); - } + if (option->state & State_HasFocus) + drawPrimitive(PE_FrameFocusRect, option, painter, widget); break; default: QCommonStyle::drawControl(element, option, painter, widget); -- cgit v0.12 From 37524a8b9ffa41f960fcc595039def4ae4167f3e Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 10 Jun 2009 12:02:27 +0200 Subject: Call DrawDeferred() after setting softkeys SDK 3.1 and maybe also 3.2 need an extra invitation. RevvBy: maluukka --- src/gui/kernel/qwidget_s60.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index cc6f794..a912b64 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -108,6 +108,7 @@ void QWidgetPrivate::setSoftKeys_sys(const QList &softkeys) if (placeInScreen==1) placeInScreen=2; } + nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation } void QWidgetPrivate::setWSGeometry(bool dontShow) -- cgit v0.12 From 29189c3112cbfb24d9e5855240e352af18088db9 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 10 Jun 2009 12:06:31 +0200 Subject: Better handling for setting softkeys --- src/gui/kernel/qwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 3a22ee9..eaa9491 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -11570,7 +11570,7 @@ void QWidget::setSoftKeys(const QList &softKeys) d->softKeys.clear(); d->softKeys = softKeys; - if (QApplication::focusWidget() == this) + if ((QApplication::focusWidget() == this) || (QApplication::focusWidget()==0)) d->setSoftKeys_sys(this->softKeys()); } -- cgit v0.12 From 5d924cb69ea03921a9b4bc5f701063cf45ded508 Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 10 Jun 2009 12:07:36 +0200 Subject: Skeleton implementation for softkeys example --- src/gui/softkeys/main.cpp | 108 +----------------------------------------- src/gui/softkeys/softkeys.cpp | 61 ++++++++++++++++++++++++ src/gui/softkeys/softkeys.h | 79 ++++++++++++++++++++++++++++++ src/gui/softkeys/softkeys.pro | 4 +- 4 files changed, 145 insertions(+), 107 deletions(-) create mode 100644 src/gui/softkeys/softkeys.cpp create mode 100644 src/gui/softkeys/softkeys.h diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp index a92e2c2..a355f93 100644 --- a/src/gui/softkeys/main.cpp +++ b/src/gui/softkeys/main.cpp @@ -10,116 +10,12 @@ ****************************************************************************/ #include - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - -private slots: - void context1Slot(); - void context3Slot(); - void softKeySlot(); -public: - - MainWindow(QWidget *parent = 0); - ~MainWindow(); - QMenu *contextMenu; - QAction* context1; - QAction* context2; - QAction* context3; - QSoftKeyAction *action1; - QSoftKeyAction *action2; - QSoftKeyAction *action3; - QSoftKeyAction *action4; - QSoftKeyAction *action5; -}; - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), - contextMenu(0), - context1(0), context2(0), context3(0), - action1(0),action2(0),action3(0),action4(0),action5(0) - -{ - QWidget *central = new QWidget(this); - contextMenu = new QMenu(); - - central->setLayout(new QVBoxLayout); - central->layout()->addWidget(new QPushButton); - central->layout()->addWidget(new QPushButton); - central->layout()->addWidget(new QPushButton); - context1 = new QAction(QString("Context1"), central); - context2 = new QAction(QString("Context2"), central); - - context3 = new QAction(QString("Context3"), contextMenu); - central->addAction(context1); - central->addAction(context2); - QMenuBar* menuBar = new QMenuBar(this); - menuBar->addAction("MyMenuItem1"); - this->setMenuBar(menuBar); - context2->setMenu(contextMenu); - contextMenu->addAction(context3); - - connect(context1, SIGNAL(triggered()), this, SLOT(context1Slot())); - connect(context3, SIGNAL(triggered()), this, SLOT(context3Slot())); - action1 = new QSoftKeyAction(QSoftKeyAction::Ok, QString("Ok"), central); - action2 = new QSoftKeyAction(QSoftKeyAction::Back, QString("Back"), central); - action3 = new QSoftKeyAction(QSoftKeyAction::Cancel, QString("Cancel"), central); - action4 = new QSoftKeyAction(QSoftKeyAction::Menu, QString("Menu"), central); - action5 = new QSoftKeyAction(QSoftKeyAction::ContextMenu,QString("ContextMenu"), central); - - connect(action2, SIGNAL(triggered()), this, SLOT(softKeySlot())); - - QList myActionList; - myActionList.append(action1); - myActionList.append(action2); - myActionList.append(action3); - softKeyStack()->push(myActionList); - softKeyStack()->pop(); - softKeyStack()->push(action1); - softKeyStack()->pop(); - - QList myActionList2; - myActionList2.append(action4); - myActionList2.append(action2); - myActionList2.append(action5); - softKeyStack()->push(myActionList2); - - - setCentralWidget(central); -} -MainWindow::~MainWindow() -{ - delete context1; - delete context2; - delete context3; - delete action1; - delete action2; - delete action3; - delete action4; - delete action5; - delete contextMenu; -} - -void MainWindow::context1Slot() - { - } -void MainWindow::context3Slot() - { - } - -void MainWindow::softKeySlot() -{ - -} +#include "softkeys.h" int main(int argc, char *argv[]) { QApplication app(argc, argv); MainWindow mw; - mw.show(); + mw.showMaximized(); return app.exec(); } - -#include "main.moc" diff --git a/src/gui/softkeys/softkeys.cpp b/src/gui/softkeys/softkeys.cpp new file mode 100644 index 0000000..edf38b9 --- /dev/null +++ b/src/gui/softkeys/softkeys.cpp @@ -0,0 +1,61 @@ +#include "softkeys.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + fileMenu = menuBar()->addMenu(tr("&File")); + openDialogAct = new QAction(tr("&Open Dialog"), this); + addSoftKeysAct = new QAction(tr("&Add Softkeys"), this); + clearSoftKeysAct = new QAction(tr("&Clear Softkeys"), this); + fileMenu->addAction(openDialogAct); + fileMenu->addAction(addSoftKeysAct); + fileMenu->addAction(clearSoftKeysAct); + connect(openDialogAct, SIGNAL(triggered()), this, SLOT(openDialog())); + connect(addSoftKeysAct, SIGNAL(triggered()), this, SLOT(addSoftKeys())); + connect(clearSoftKeysAct, SIGNAL(triggered()), this, SLOT(clearSoftKeys())); + QWidget *central = new QWidget(this); + central->setLayout(new QVBoxLayout); +// central->setFocus(); + setCentralWidget(central); + QPushButton button1; +// QAction* menuAction = +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::openDialog() +{ + QFileDialog::getOpenFileName(this); +} + +void MainWindow::addSoftKeys() +{ + ok = new QAction(tr("Ok"), this); + ok->setSoftKeyRole(QAction::OkSoftKey); + connect(ok, SIGNAL(triggered()), this, SLOT(okPressed())); + + cancel = new QAction(tr("Cancel"), this); + cancel->setSoftKeyRole(QAction::OkSoftKey); + connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); + + QList softkeys; + softkeys.append(ok); + softkeys.append(cancel); + setSoftKeys(softkeys); + +} + +void MainWindow::clearSoftKeys() +{ + setSoftKey(0); +} + +void MainWindow::okPressed() +{ +} + +void MainWindow::cancelPressed() +{ +} diff --git a/src/gui/softkeys/softkeys.h b/src/gui/softkeys/softkeys.h new file mode 100644 index 0000000..2bc74ba --- /dev/null +++ b/src/gui/softkeys/softkeys.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples 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 SOFTKEYS_H +#define SOFTKEYS_H + +#include + +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + +private slots: + void openDialog(); + void addSoftKeys(); + void clearSoftKeys(); + void okPressed(); + void cancelPressed(); +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); +private: + QMenu* fileMenu; + QAction* openDialogAct; + QAction* addSoftKeysAct; + QAction* clearSoftKeysAct; + QAction* ok; + QAction* cancel; +}; + +//! [0] +class SoftKey : public QWidget +{ + Q_OBJECT +public: + SoftKey(QWidget *parent = 0); +}; +//! [0] + +#endif diff --git a/src/gui/softkeys/softkeys.pro b/src/gui/softkeys/softkeys.pro index a16103e..4cb8672 100644 --- a/src/gui/softkeys/softkeys.pro +++ b/src/gui/softkeys/softkeys.pro @@ -1,2 +1,4 @@ +HEADERS = softkeys.h SOURCES += \ - main.cpp + main.cpp \ + softkeys.cpp \ No newline at end of file -- cgit v0.12 From 39c796e57be1830133e6189abe8f796b6846904f Mon Sep 17 00:00:00 2001 From: Markku Luukkainen Date: Wed, 10 Jun 2009 12:08:47 +0200 Subject: Moved softkeys example to a better place --- examples/widgets/softkeys/main.cpp | 21 +++++++++ examples/widgets/softkeys/softkeys.cpp | 61 ++++++++++++++++++++++++++ examples/widgets/softkeys/softkeys.h | 79 ++++++++++++++++++++++++++++++++++ examples/widgets/softkeys/softkeys.pro | 4 ++ src/gui/softkeys/main.cpp | 21 --------- src/gui/softkeys/softkeys.cpp | 61 -------------------------- src/gui/softkeys/softkeys.h | 79 ---------------------------------- src/gui/softkeys/softkeys.pro | 4 -- 8 files changed, 165 insertions(+), 165 deletions(-) create mode 100644 examples/widgets/softkeys/main.cpp create mode 100644 examples/widgets/softkeys/softkeys.cpp create mode 100644 examples/widgets/softkeys/softkeys.h create mode 100644 examples/widgets/softkeys/softkeys.pro delete mode 100644 src/gui/softkeys/main.cpp delete mode 100644 src/gui/softkeys/softkeys.cpp delete mode 100644 src/gui/softkeys/softkeys.h delete mode 100644 src/gui/softkeys/softkeys.pro diff --git a/examples/widgets/softkeys/main.cpp b/examples/widgets/softkeys/main.cpp new file mode 100644 index 0000000..a355f93 --- /dev/null +++ b/examples/widgets/softkeys/main.cpp @@ -0,0 +1,21 @@ +/**************************************************************************** +** +** 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 "softkeys.h" + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + MainWindow mw; + mw.showMaximized(); + return app.exec(); +} diff --git a/examples/widgets/softkeys/softkeys.cpp b/examples/widgets/softkeys/softkeys.cpp new file mode 100644 index 0000000..edf38b9 --- /dev/null +++ b/examples/widgets/softkeys/softkeys.cpp @@ -0,0 +1,61 @@ +#include "softkeys.h" + +MainWindow::MainWindow(QWidget *parent) + : QMainWindow(parent) +{ + fileMenu = menuBar()->addMenu(tr("&File")); + openDialogAct = new QAction(tr("&Open Dialog"), this); + addSoftKeysAct = new QAction(tr("&Add Softkeys"), this); + clearSoftKeysAct = new QAction(tr("&Clear Softkeys"), this); + fileMenu->addAction(openDialogAct); + fileMenu->addAction(addSoftKeysAct); + fileMenu->addAction(clearSoftKeysAct); + connect(openDialogAct, SIGNAL(triggered()), this, SLOT(openDialog())); + connect(addSoftKeysAct, SIGNAL(triggered()), this, SLOT(addSoftKeys())); + connect(clearSoftKeysAct, SIGNAL(triggered()), this, SLOT(clearSoftKeys())); + QWidget *central = new QWidget(this); + central->setLayout(new QVBoxLayout); +// central->setFocus(); + setCentralWidget(central); + QPushButton button1; +// QAction* menuAction = +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::openDialog() +{ + QFileDialog::getOpenFileName(this); +} + +void MainWindow::addSoftKeys() +{ + ok = new QAction(tr("Ok"), this); + ok->setSoftKeyRole(QAction::OkSoftKey); + connect(ok, SIGNAL(triggered()), this, SLOT(okPressed())); + + cancel = new QAction(tr("Cancel"), this); + cancel->setSoftKeyRole(QAction::OkSoftKey); + connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); + + QList softkeys; + softkeys.append(ok); + softkeys.append(cancel); + setSoftKeys(softkeys); + +} + +void MainWindow::clearSoftKeys() +{ + setSoftKey(0); +} + +void MainWindow::okPressed() +{ +} + +void MainWindow::cancelPressed() +{ +} diff --git a/examples/widgets/softkeys/softkeys.h b/examples/widgets/softkeys/softkeys.h new file mode 100644 index 0000000..2bc74ba --- /dev/null +++ b/examples/widgets/softkeys/softkeys.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (qt-info@nokia.com) +** +** This file is part of the examples 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 SOFTKEYS_H +#define SOFTKEYS_H + +#include + +class MainWindow : public QMainWindow +{ + Q_OBJECT +public: + +private slots: + void openDialog(); + void addSoftKeys(); + void clearSoftKeys(); + void okPressed(); + void cancelPressed(); +public: + MainWindow(QWidget *parent = 0); + ~MainWindow(); +private: + QMenu* fileMenu; + QAction* openDialogAct; + QAction* addSoftKeysAct; + QAction* clearSoftKeysAct; + QAction* ok; + QAction* cancel; +}; + +//! [0] +class SoftKey : public QWidget +{ + Q_OBJECT +public: + SoftKey(QWidget *parent = 0); +}; +//! [0] + +#endif diff --git a/examples/widgets/softkeys/softkeys.pro b/examples/widgets/softkeys/softkeys.pro new file mode 100644 index 0000000..4cb8672 --- /dev/null +++ b/examples/widgets/softkeys/softkeys.pro @@ -0,0 +1,4 @@ +HEADERS = softkeys.h +SOURCES += \ + main.cpp \ + softkeys.cpp \ No newline at end of file diff --git a/src/gui/softkeys/main.cpp b/src/gui/softkeys/main.cpp deleted file mode 100644 index a355f93..0000000 --- a/src/gui/softkeys/main.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/**************************************************************************** -** -** 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 "softkeys.h" - -int main(int argc, char *argv[]) -{ - QApplication app(argc, argv); - MainWindow mw; - mw.showMaximized(); - return app.exec(); -} diff --git a/src/gui/softkeys/softkeys.cpp b/src/gui/softkeys/softkeys.cpp deleted file mode 100644 index edf38b9..0000000 --- a/src/gui/softkeys/softkeys.cpp +++ /dev/null @@ -1,61 +0,0 @@ -#include "softkeys.h" - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent) -{ - fileMenu = menuBar()->addMenu(tr("&File")); - openDialogAct = new QAction(tr("&Open Dialog"), this); - addSoftKeysAct = new QAction(tr("&Add Softkeys"), this); - clearSoftKeysAct = new QAction(tr("&Clear Softkeys"), this); - fileMenu->addAction(openDialogAct); - fileMenu->addAction(addSoftKeysAct); - fileMenu->addAction(clearSoftKeysAct); - connect(openDialogAct, SIGNAL(triggered()), this, SLOT(openDialog())); - connect(addSoftKeysAct, SIGNAL(triggered()), this, SLOT(addSoftKeys())); - connect(clearSoftKeysAct, SIGNAL(triggered()), this, SLOT(clearSoftKeys())); - QWidget *central = new QWidget(this); - central->setLayout(new QVBoxLayout); -// central->setFocus(); - setCentralWidget(central); - QPushButton button1; -// QAction* menuAction = -} - -MainWindow::~MainWindow() -{ -} - -void MainWindow::openDialog() -{ - QFileDialog::getOpenFileName(this); -} - -void MainWindow::addSoftKeys() -{ - ok = new QAction(tr("Ok"), this); - ok->setSoftKeyRole(QAction::OkSoftKey); - connect(ok, SIGNAL(triggered()), this, SLOT(okPressed())); - - cancel = new QAction(tr("Cancel"), this); - cancel->setSoftKeyRole(QAction::OkSoftKey); - connect(cancel, SIGNAL(triggered()), this, SLOT(cancelPressed())); - - QList softkeys; - softkeys.append(ok); - softkeys.append(cancel); - setSoftKeys(softkeys); - -} - -void MainWindow::clearSoftKeys() -{ - setSoftKey(0); -} - -void MainWindow::okPressed() -{ -} - -void MainWindow::cancelPressed() -{ -} diff --git a/src/gui/softkeys/softkeys.h b/src/gui/softkeys/softkeys.h deleted file mode 100644 index 2bc74ba..0000000 --- a/src/gui/softkeys/softkeys.h +++ /dev/null @@ -1,79 +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 examples 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 SOFTKEYS_H -#define SOFTKEYS_H - -#include - -class MainWindow : public QMainWindow -{ - Q_OBJECT -public: - -private slots: - void openDialog(); - void addSoftKeys(); - void clearSoftKeys(); - void okPressed(); - void cancelPressed(); -public: - MainWindow(QWidget *parent = 0); - ~MainWindow(); -private: - QMenu* fileMenu; - QAction* openDialogAct; - QAction* addSoftKeysAct; - QAction* clearSoftKeysAct; - QAction* ok; - QAction* cancel; -}; - -//! [0] -class SoftKey : public QWidget -{ - Q_OBJECT -public: - SoftKey(QWidget *parent = 0); -}; -//! [0] - -#endif diff --git a/src/gui/softkeys/softkeys.pro b/src/gui/softkeys/softkeys.pro deleted file mode 100644 index 4cb8672..0000000 --- a/src/gui/softkeys/softkeys.pro +++ /dev/null @@ -1,4 +0,0 @@ -HEADERS = softkeys.h -SOURCES += \ - main.cpp \ - softkeys.cpp \ No newline at end of file -- cgit v0.12