diff options
author | Jason Barron <jbarron@trolltech.com> | 2009-09-18 14:36:16 (GMT) |
---|---|---|
committer | Jason Barron <jbarron@trolltech.com> | 2009-09-21 08:07:37 (GMT) |
commit | 789303e0f80a299eb3cfacc1d84dbdc1d3e4abeb (patch) | |
tree | f04b58f9917d73ebc77292551e2b139de5f5d73f /src/gui/kernel | |
parent | fe55b6083ab6417a83141c719184772d9a375d17 (diff) | |
download | Qt-789303e0f80a299eb3cfacc1d84dbdc1d3e4abeb.zip Qt-789303e0f80a299eb3cfacc1d84dbdc1d3e4abeb.tar.gz Qt-789303e0f80a299eb3cfacc1d84dbdc1d3e4abeb.tar.bz2 |
Refactor soft keys implementation.
Reviewed-by: Alessandro Portale
Squashed commit of the following:
commit dae5eda6996d48c12c4a5efd3f6042eb293bacbf
Author: Jason Barron <jbarron@trolltech.com>
Date: Fri Sep 18 10:32:26 2009 +0200
Only update soft keys when KEYPAD_NAVIGATION is enabled.
For 4.6, let's just call these functions when keypad navigation is
defined to minimize the impact on other platforms. They should
probably get thier own define some day.
commit 30a730553531f0f138de5eddb30413936a34fa36
Author: Jason Barron <jbarron@trolltech.com>
Date: Fri Sep 18 10:30:23 2009 +0200
Add/remove the menu bar action when menu bar is added/removed.
commit a83343a2870b34c228c8bc5e6274607b0e97baf6
Author: Jason Barron <jbarron@trolltech.com>
Date: Fri Sep 18 10:28:55 2009 +0200
Compile fix for other platforms
commit 39c9e3a0a1d3d62bf6ebd3212cfd2a81b86b9b2a
Author: Jason Barron <jbarron@trolltech.com>
Date: Thu Sep 17 21:37:59 2009 +0200
Fix 'softkeys' example after API re-factoring.
Clean up this example and use the simplified soft key API. Now the
actions are only allocated in the constructor and dynamically updated
by calling addAction and removeAction.
commit 314e45c33f40552db74e61755c2a3b0f8c77a41a
Author: Jason Barron <jbarron@trolltech.com>
Date: Thu Sep 17 21:30:32 2009 +0200
Re-factor and simplify the soft keys API.
Several things here:
- Move all the logic into QSoftKeyManager
- Move the files into 'kernel' since it is not a widget
- Remove QWidget::setSoftKey*(). Use addAction/removeAction instead
- Made soft keys update on focus, window activation, and action
changes.
- Fixed several memory leaks where QAction's were created too often
- QAction ownership pushed out to widget's
- Added Select/Cancel soft keys for comboboxes and menus to be more
consistent to platform look-and-feel.
commit fb4c240d970262e9872dc5737df6808879143c75
Author: Jason Barron <jbarron@trolltech.com>
Date: Mon Sep 7 15:49:31 2009 +0200
Merge the Symbian implementation with the other platforms nativeMenuBar
It seems this has been refactored to share more code across the various
platforms that support native menubars so the Symbian code can be
mostly removed.
commit aa55e4bcd1f009ab35c9519e18aa325fd212dd23
Author: Jason Barron <jbarron@trolltech.com>
Date: Wed Aug 26 17:00:34 2009 +0200
Change filenames and move softkey stuff from 'widgets' to 'kernel'.
This thing isn't a widget and therefore should not be in the 'widgets'
subdirectory of gui. Also rename the files in preparation for
refactoring and extending.
Diffstat (limited to 'src/gui/kernel')
-rw-r--r-- | src/gui/kernel/kernel.pri | 6 | ||||
-rw-r--r-- | src/gui/kernel/qaction.cpp | 2 | ||||
-rw-r--r-- | src/gui/kernel/qaction.h | 9 | ||||
-rw-r--r-- | src/gui/kernel/qapplication_s60.cpp | 14 | ||||
-rw-r--r-- | src/gui/kernel/qsoftkeymanager.cpp | 260 | ||||
-rw-r--r-- | src/gui/kernel/qsoftkeymanager_p.h | 95 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 80 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_p.h | 5 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_s60.cpp | 72 |
10 files changed, 380 insertions, 166 deletions
diff --git a/src/gui/kernel/kernel.pri b/src/gui/kernel/kernel.pri index 8489817..7cde384 100644 --- a/src/gui/kernel/kernel.pri +++ b/src/gui/kernel/kernel.pri @@ -46,7 +46,8 @@ HEADERS += \ kernel/qgesture.h \ kernel/qgesture_p.h \ kernel/qstandardgestures.h \ - kernel/qstandardgestures_p.h + kernel/qstandardgestures_p.h \ + kernel/qsoftkeymanager_p.h SOURCES += \ kernel/qaction.cpp \ @@ -77,7 +78,8 @@ SOURCES += \ kernel/qwidgetaction.cpp \ kernel/qkeymapper.cpp \ kernel/qgesture.cpp \ - kernel/qstandardgestures.cpp + kernel/qstandardgestures.cpp \ + kernel/qsoftkeymanager.cpp win32 { DEFINES += QT_NO_DIRECTDRAW diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index c641281..549d07c 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -81,7 +81,7 @@ static QString qt_strippedText(QString s) QActionPrivate::QActionPrivate() : group(0), enabled(1), forceDisabled(0), visible(1), forceInvisible(0), checkable(0), checked(0), separator(0), fontSet(false), - menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::OptionsSoftKey), + menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey), priority(QAction::NormalPriority), iconVisibleInMenu(-1) { #ifdef QT3_SUPPORT diff --git a/src/gui/kernel/qaction.h b/src/gui/kernel/qaction.h index 59c1765..df56d2c 100644 --- a/src/gui/kernel/qaction.h +++ b/src/gui/kernel/qaction.h @@ -93,10 +93,11 @@ class Q_GUI_EXPORT QAction : public QObject public: enum MenuRole { NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, AboutRole, PreferencesRole, QuitRole }; - enum SoftKeyRole { OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, PreviousSoftKey, - OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, BackSpaceSoftKey, - EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, FinishSoftKey, - MenuSoftKey, ContextMenuSoftKey, ExitSoftKey }; + enum SoftKeyRole { + NoSoftKey, OptionsSoftKey, SelectSoftKey, BackSoftKey, NextSoftKey, + PreviousSoftKey, OkSoftKey, CancelSoftKey, EditSoftKey, ViewSoftKey, + BackSpaceSoftKey, EndEditSoftKey, RevertEditSoftKey, DeselectSoftKey, + FinishSoftKey, MenuSoftKey, ContextMenuSoftKey, ExitSoftKey }; enum Priority { LowPriority = 0, NormalPriority = 128, HighPriority = 256}; diff --git a/src/gui/kernel/qapplication_s60.cpp b/src/gui/kernel/qapplication_s60.cpp index 6a381f5..a5d07fd 100644 --- a/src/gui/kernel/qapplication_s60.cpp +++ b/src/gui/kernel/qapplication_s60.cpp @@ -59,6 +59,7 @@ #include "private/qwindowsurface_s60_p.h" #include "qpaintengine.h" #include "private/qmenubar_p.h" +#include "private/qsoftkeymanager_p.h" #include "apgwgnam.h" // For CApaWindowGroupName #include <MdaAudioTonePlayer.h> // For CMdaAudioToneUtility @@ -1348,17 +1349,12 @@ void QApplication::symbianHandleCommand(int command) exit(); break; default: - if (command >= SOFTKEYSTART && command <= SOFTKEYEND) { - int index= command-SOFTKEYSTART; - QWidget *focused = QApplication::focusWidget(); - QWidget *softKeySource = focused ? focused : QApplication::activeWindow(); - const QList<QAction*>& softKeys = softKeySource->softKeys(); - Q_ASSERT(index < softKeys.count()); - softKeys.at(index)->activate(QAction::Trigger); - } + bool handled = QSoftKeyManager::handleCommand(command); #ifdef Q_WS_S60 - else + if (!handled) QMenuBarPrivate::symbianCommands(command); +#else + Q_UNUSED(handled); #endif break; } diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp new file mode 100644 index 0000000..b1ebd38 --- /dev/null +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -0,0 +1,260 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qapplication.h" +#include "qevent.h" +#ifdef Q_WS_S60 +#include "private/qt_s60_p.h" +#endif +#include "private/qsoftkeymanager_p.h" + +QT_BEGIN_NAMESPACE + +#ifdef Q_WS_S60 +static const int s60CommandStart = 6000; +#endif + +QWidget *QSoftKeyManager::softKeySource = 0; +QSoftKeyManager *QSoftKeyManager::self = 0; + +const char *QSoftKeyManager::standardSoftKeyText(QAction::SoftKeyRole role) +{ + const char *softKeyText = 0; + switch (role) { + case QAction::OptionsSoftKey: + softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Options"); + break; + case QAction::SelectSoftKey: + softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Select"); + break; + case QAction::BackSoftKey: + softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Back"); + break; + case QAction::NextSoftKey: + softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Next"); + break; + case QAction::PreviousSoftKey: + softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Previous"); + break; + case QAction::OkSoftKey: + softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Ok"); + break; + case QAction::CancelSoftKey: + softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Cancel"); + break; + case QAction::EditSoftKey: + softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "Edit"); + break; + case QAction::ViewSoftKey: + softKeyText = QT_TRANSLATE_NOOP("QSoftKeyManager", "View"); + break; + default: + ; + }; + + return softKeyText; +} + +QSoftKeyManager *QSoftKeyManager::instance() +{ + if (!QSoftKeyManager::self) + QSoftKeyManager::self = new QSoftKeyManager; + + return self; +} + +QSoftKeyManager::QSoftKeyManager() : QObject() +{ +} + +QAction *QSoftKeyManager::createAction(QAction::SoftKeyRole softKeyRole, QWidget *actionWidget) +{ + const char* text = standardSoftKeyText(softKeyRole); + QAction *action = new QAction(QSoftKeyManager::tr(text), actionWidget); + action->setSoftKeyRole(softKeyRole); + return action; +} + +/*! \internal + + Creates a QAction and registers the 'triggered' signal to send the given key event to + \a actionWidget as a convenience. + +*/ +QAction *QSoftKeyManager::createKeyedAction(QAction::SoftKeyRole softKeyRole, Qt::Key key, QWidget *actionWidget) +{ + QScopedPointer<QAction> action(createAction(softKeyRole, actionWidget)); + + connect(action.data(), SIGNAL(triggered()), QSoftKeyManager::instance(), SLOT(sendKeyEvent())); + + QSoftKeyManager::instance()->keyedActions.insert(action.data(), key); + return action.take(); +} + +void QSoftKeyManager::sendKeyEvent() +{ + QAction *action = qobject_cast<QAction*>(sender()); + + if (!action) + return; + + Qt::Key keyToSend = keyedActions.value(action, Qt::Key_unknown); + + if (keyToSend != Qt::Key_unknown) + QApplication::postEvent(action->parentWidget(), + new QKeyEvent(QEvent::KeyPress, keyToSend, Qt::NoModifier)); +} + +void QSoftKeyManager::updateSoftKeys(bool force) +{ + QList<QAction*> softKeys; + QWidget *source = QApplication::focusWidget(); + do { + if (source) { + QList<QAction*> actions = source->actions(); + for (int i = 0; i < actions.count(); ++i) { + if (actions.at(i)->softKeyRole() != QAction::NoSoftKey) + softKeys.append(actions.at(i)); + } + + QWidget *parent = source->parentWidget(); + if (parent && softKeys.isEmpty()) + source = parent; + else + break; + } else { + source = QApplication::activeWindow(); + } + } while (source); + + if (force || (source != QSoftKeyManager::softKeySource)) { + QSoftKeyManager::softKeySource = source; + QSoftKeyManager::updateSoftKeys_sys(softKeys); + } +} + +#ifdef Q_WS_S60 +void QSoftKeyManager::updateSoftKeys_sys(const QList<QAction*> &softkeys) +{ + + CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer(); + QT_TRAP_THROWING(nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS)); + + int position = -1; + int command; + bool needsExitButton = true; + + for (int index = 0; index < softkeys.count(); index++) { + const QAction* softKeyAction = softkeys.at(index); + switch (softKeyAction->softKeyRole()) { + // Positive Actions go on LSK + case QAction::OptionsSoftKey: + case QAction::MenuSoftKey: + case QAction::ContextMenuSoftKey: + command = EAknSoftkeyOptions; //Calls DynInitMenuPane in AppUI + position = 0; + break; + case QAction::SelectSoftKey: + case QAction::PreviousSoftKey: + case QAction::OkSoftKey: + case QAction::EditSoftKey: + case QAction::ViewSoftKey: + case QAction::EndEditSoftKey: + case QAction::FinishSoftKey: + command = s60CommandStart + index; + position = 0; + break; + // Negative Actions on the RSK + case QAction::BackSoftKey: + case QAction::NextSoftKey: + case QAction::CancelSoftKey: + case QAction::BackSpaceSoftKey: + case QAction::RevertEditSoftKey: + case QAction::DeselectSoftKey: + needsExitButton = false; + command = s60CommandStart + index; + position = 2; + break; + case QAction::ExitSoftKey: + needsExitButton = false; + command = EAknSoftkeyExit; //Calls HandleCommand in AppUI + position = 2; + break; + default: + break; + } + + if (position != -1) { + TPtrC text = qt_QString2TPtrC(softKeyAction->text()); + QT_TRAP_THROWING(nativeContainer->SetCommandL(position, command, text)); + } + } + + if (needsExitButton) + QT_TRAP_THROWING(nativeContainer->SetCommandL(2, EAknSoftkeyExit, qt_QString2TPtrC(QObject::tr("Exit")))); + + nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation +} + +bool QSoftKeyManager::handleCommand(int command) +{ + if (command >= s60CommandStart && QSoftKeyManager::softKeySource) { + int index = command - s60CommandStart; + const QList<QAction*>& softKeys = QSoftKeyManager::softKeySource->actions(); + if (index < softKeys.count()) { + softKeys.at(index)->activate(QAction::Trigger); + return true; + } + } + + return false; +} + +#else + +void QSoftKeyManager::updateSoftKeys_sys(const QList<QAction*> &) +{ +} + +#endif + +QT_END_NAMESPACE + diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h new file mode 100644 index 0000000..630dd9f --- /dev/null +++ b/src/gui/kernel/qsoftkeymanager_p.h @@ -0,0 +1,95 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (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 Technology Preview License Agreement accompanying +** this package. +** +** 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.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QSOFTKEYMANAGER_P_H +#define QSOFTKEYMANAGER_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 <QtCore/qobject.h> +#include "QtGui/qaction.h" +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QSoftKeyManager : public QObject +{ + Q_OBJECT + +public: + static void updateSoftKeys(bool force = false); + static QAction *createAction(QAction::SoftKeyRole standardRole, QWidget *actionWidget); + static QAction *createKeyedAction(QAction::SoftKeyRole standardRole, Qt::Key key, QWidget *actionWidget); + +#ifdef Q_WS_S60 + static bool handleCommand(int); +#endif + +private: + QSoftKeyManager(); + static QSoftKeyManager *instance(); + static const char *standardSoftKeyText(QAction::SoftKeyRole role); + static void updateSoftKeys_sys(const QList<QAction*> &softKeys); + + static QSoftKeyManager *self; + static QWidget *softKeySource; + QHash<QAction*, Qt::Key> keyedActions; + + Q_DISABLE_COPY(QSoftKeyManager) + +private Q_SLOTS: + void sendKeyEvent(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif //QSOFTKEYMANAGER_P_H diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 4f1ab94..461834c 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -82,6 +82,7 @@ #include "private/qstyle_p.h" #include "private/qinputcontext_p.h" #include "qfileinfo.h" +#include "private/qsoftkeymanager_p.h" #if defined (Q_WS_WIN) # include <private/qwininputcontext_p.h> @@ -4971,13 +4972,6 @@ void QWidget::render(QPainter *painter, const QPoint &targetOffset, d->extra->inRenderWithPainter = false; } -#if !defined(Q_OS_SYMBIAN) -void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys) -{ - Q_UNUSED(softkeys) -} -#endif // !defined(Q_OS_SYMBIAN) - /*! Returns a pointer to this widget's effect if it has one; otherwise 0. @@ -7997,7 +7991,9 @@ bool QWidget::event(QEvent *event) } break; case QEvent::FocusIn: - d->setSoftKeys_sys(softKeys()); +#ifdef QT_KEYPAD_NAVIGATION + QSoftKeyManager::updateSoftKeys(); +#endif focusInEvent((QFocusEvent*)event); break; @@ -8148,8 +8144,10 @@ bool QWidget::event(QEvent *event) QApplication::sendEvent(w, event); } +#ifdef QT_KEYPAD_NAVIGATION if (isWindow() && isActiveWindow()) - d->setSoftKeys_sys(softKeys()); + QSoftKeyManager::updateSoftKeys(); +#endif break; } @@ -8258,6 +8256,9 @@ bool QWidget::event(QEvent *event) case QEvent::ActionAdded: case QEvent::ActionRemoved: case QEvent::ActionChanged: +#ifdef QT_KEYPAD_NAVIGATION + QSoftKeyManager::updateSoftKeys(true); +#endif actionEvent((QActionEvent*)event); break; #endif @@ -11938,67 +11939,6 @@ void QWidget::clearMask() setMask(QRegion()); } -/*! - \preliminary - \since 4.6 - - 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<QAction*>& QWidget::softKeys() const -{ - Q_D(const QWidget); - if( d->softKeys.count() > 0) - return d->softKeys; - if (isWindow() || !parentWidget()) - return d->softKeys; - - return parentWidget()->softKeys(); -} - -/*! - \preliminary - \since 4.6 - - 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); - d->softKeys.clear(); - if (softKey) - d->softKeys.append(softKey); - if ((!QApplication::focusWidget() && this == QApplication::activeWindow()) - || QApplication::focusWidget() == this) - 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<QAction*> &softKeys) -{ - Q_D(QWidget); - qDeleteAll(d->softKeys); - d->softKeys.clear(); - d->softKeys = softKeys; - - if ((!QApplication::focusWidget() && this == QApplication::activeWindow()) - || QApplication::focusWidget() == this) - d->setSoftKeys_sys(this->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 8410775..7e250e2 100644 --- a/src/gui/kernel/qwidget.h +++ b/src/gui/kernel/qwidget.h @@ -564,9 +564,6 @@ public: void removeAction(QAction *action); QList<QAction*> actions() const; #endif - const QList<QAction*>& softKeys() const; - void setSoftKey(QAction *softKey); - void setSoftKeys(const QList<QAction*> &softKeys); QWidget *parentWidget() const; diff --git a/src/gui/kernel/qwidget_p.h b/src/gui/kernel/qwidget_p.h index 5e06c29..5a9c48c 100644 --- a/src/gui/kernel/qwidget_p.h +++ b/src/gui/kernel/qwidget_p.h @@ -85,9 +85,6 @@ #if defined(Q_OS_SYMBIAN) class RDrawableWindow; class CCoeControl; -// The following 2 defines may only be needed for s60. To be seen. -const int SOFTKEYSTART=5000; -const int SOFTKEYEND=5004; #endif QT_BEGIN_NAMESPACE @@ -263,7 +260,6 @@ public: explicit QWidgetPrivate(int version = QObjectPrivateVersion); ~QWidgetPrivate(); - void setSoftKeys_sys(const QList<QAction*> &softkeys); QWExtra *extraData() const; QTLWExtra *topData() const; QTLWExtra *maybeTopData() const; @@ -517,7 +513,6 @@ public: QWidget *focus_next; QWidget *focus_prev; QWidget *focus_child; - QList<QAction*> softKeys; QLayout *layout; QRegion *needsFlush; QPaintDevice *redirectDev; diff --git a/src/gui/kernel/qwidget_s60.cpp b/src/gui/kernel/qwidget_s60.cpp index 3744377..4fef020 100644 --- a/src/gui/kernel/qwidget_s60.cpp +++ b/src/gui/kernel/qwidget_s60.cpp @@ -78,78 +78,6 @@ static bool isEqual(const QList<QAction*>& a, const QList<QAction*>& b) return true; } - -void QWidgetPrivate::setSoftKeys_sys(const QList<QAction*> &softkeys) -{ -#ifdef Q_WS_S60 - Q_Q(QWidget); - if (QApplication::focusWidget() && q!=QApplication::focusWidget()) { - QList<QAction *> old = QApplication::focusWidget()->softKeys(); - if (isEqual(old, softkeys )) - return; - } - CEikButtonGroupContainer* nativeContainer = S60->buttonGroupContainer(); - QT_TRAP_THROWING(nativeContainer->SetCommandSetL(R_AVKON_SOFTKEYS_EMPTY_WITH_IDS)); - - int position = -1; - int command; - bool needsExitButton = true; - - for (int index = 0; index < softkeys.count(); index++) { - const QAction* softKeyAction = softkeys.at(index); - switch (softKeyAction->softKeyRole()) { - // Positive Actions go on LSK - case QAction::OptionsSoftKey: - case QAction::MenuSoftKey: - case QAction::ContextMenuSoftKey: - command = EAknSoftkeyOptions; //Calls DynInitMenuPane in AppUI - position = 0; - break; - case QAction::SelectSoftKey: - case QAction::PreviousSoftKey: - case QAction::OkSoftKey: - case QAction::EditSoftKey: - case QAction::ViewSoftKey: - case QAction::EndEditSoftKey: - case QAction::FinishSoftKey: - command = SOFTKEYSTART + index; - position = 0; - break; - // Negative Actions on the RSK - case QAction::BackSoftKey: - case QAction::NextSoftKey: - case QAction::CancelSoftKey: - case QAction::BackSpaceSoftKey: - case QAction::RevertEditSoftKey: - case QAction::DeselectSoftKey: - needsExitButton = false; - command = SOFTKEYSTART + index; - position = 2; - break; - case QAction::ExitSoftKey: - needsExitButton = false; - command = EAknSoftkeyExit; //Calls HandleCommand in AppUI - position = 2; - break; - default: - break; - } - - if (position != -1) { - TPtrC text = qt_QString2TPtrC(softKeyAction->text()); - QT_TRAP_THROWING(nativeContainer->SetCommandL(position, command, text)); - } - } - - if (needsExitButton) - QT_TRAP_THROWING(nativeContainer->SetCommandL(2, EAknSoftkeyExit, qt_QString2TPtrC(QObject::tr("Exit")))); - - nativeContainer->DrawDeferred(); // 3.1 needs an extra invitation -#else - Q_UNUSED(softkeys) -#endif -} - void QWidgetPrivate::setWSGeometry(bool /* dontShow */, const QRect & /* rect */) { |