diff options
author | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-06-06 14:17:01 (GMT) |
---|---|---|
committer | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-06-06 14:17:01 (GMT) |
commit | 7749376ff1536c703d223e16506eed1a61132a41 (patch) | |
tree | 2fd25759abe44aa64d349a673b27c7cfad205159 /src | |
parent | 934ebcd3e3c1c568ac8371dbb1d96cd06385883d (diff) | |
download | Qt-7749376ff1536c703d223e16506eed1a61132a41.zip Qt-7749376ff1536c703d223e16506eed1a61132a41.tar.gz Qt-7749376ff1536c703d223e16506eed1a61132a41.tar.bz2 |
Removed QSoftKeyStack and replaced places using it with the
new improved softkey interface in QWidget
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemviews/qabstractitemview.cpp | 5 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 3 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_p.h | 1 | ||||
-rw-r--r-- | src/gui/widgets/qcombobox.cpp | 7 | ||||
-rw-r--r-- | src/gui/widgets/qmenu.cpp | 8 | ||||
-rw-r--r-- | src/gui/widgets/qmenu_symbian.cpp | 2 | ||||
-rw-r--r-- | src/gui/widgets/qsoftkeyaction.cpp | 234 | ||||
-rw-r--r-- | src/gui/widgets/qsoftkeyaction.h | 106 | ||||
-rw-r--r-- | src/gui/widgets/qsoftkeystack.cpp | 306 | ||||
-rw-r--r-- | src/gui/widgets/qsoftkeystack.h | 89 | ||||
-rw-r--r-- | src/gui/widgets/qsoftkeystack_p.h | 111 | ||||
-rw-r--r-- | src/gui/widgets/qsoftkeystack_s60.cpp | 120 | ||||
-rw-r--r-- | src/gui/widgets/widgets.pri | 8 |
14 files changed, 10 insertions, 991 deletions
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 <qaccessible.h> #endif -#ifdef QT_KEYPAD_NAVIGATION -#include <private/qsoftkeystack_p.h> -#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 <private/qabstractitemmodel_p.h> #include <private/qabstractscrollarea_p.h> #include <qdebug.h> - +#include <qkeyeventsoftkey.h> #ifdef Q_WS_X11 #include <private/qt_x11_p.h> #endif @@ -75,9 +75,6 @@ #ifndef QT_NO_EFFECTS # include <private/qeffects_p.h> #endif -#ifdef QT_KEYPAD_NAVIGATION -# include <private/qsoftkeystack_p.h> -#endif QT_BEGIN_NAMESPACE extern QHash<QByteArray, QFont> *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 <qwhatsthis.h> #endif -#ifdef QT_KEYPAD_NAVIGATION -# include <private/qsoftkeystack_p.h> -#endif +#include <qkeyeventsoftkey.h> #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 <eikbtgpc.h> #include <QtCore/qlibrary.h> #include <avkon.rsg> -#include <qsoftkeystack.h> -#include <qsoftkeyaction.h> #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 <QtGui/private/qaction_p.h> - -/*! - \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 <QtGui/qaction.h> - -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 (index<a.count()) { - if (a.at(index)->role() != 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<QSoftKeyAction*> &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<QSoftKeyAction*> &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<QSoftKeyAction*> &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<QSoftKeyAction*> &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<QSoftKeyAction*> menuActionList(QWidget *widget) -{ - QList<QSoftKeyAction*> 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<QMainWindow*>(w); - if( !mainWindow) - return; - if (!mainWindow->hasSoftKeyStack()) - return; - QSoftKeyStack* softKeyStack = mainWindow->softKeyStack(); - if (mainWindow->menuWidget()) { - QList<QSoftKeyAction*> 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<QMainWindow*>(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<QToolBar*>(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<QMainWindow*>(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<QSoftKeyAction*> 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 <QtGui/qwidget.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Gui) - -#define QSoftkeySet QList <QSoftKeyAction*> - -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<QSoftKeyAction*> &softkeys); - void pop(); - void popandPush(QSoftKeyAction *softKey); - void popandPush(const QList<QSoftKeyAction*> &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 <QtCore/private/qobject_p.h> - -#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 <QSoftKeyAction*> - -class QSoftKeyStackPrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QSoftKeyStack) -public: - QSoftKeyStackPrivate(); - ~QSoftKeyStackPrivate(); - - void push(QSoftKeyAction *softKey); - void push(const QList<QSoftKeyAction*> &softKeys); - void pop(); - void popandPush(QSoftKeyAction *softKey); - void popandPush(const QList<QSoftKeyAction*> &softkeys); - const QSoftkeySet& top(); - bool isEmpty(); - static void handleSoftKeyPress(int command); - -private: - void mapSoftKeys(const QSoftkeySet &top); - void setNativeSoftKeys(); - -private: - QStack <QSoftkeySet> 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 <eikenv.h> -#include <eikbtgpc.h> -#include <eikappui.h> -#include <aknappui.h> -#include <avkon.rsg> - -#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 <CAknAppUi*>(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<const QMainWindow*>(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 } |