diff options
author | Thierry Bastian <thierry.bastian@nokia.com> | 2010-04-13 09:41:21 (GMT) |
---|---|---|
committer | Thierry Bastian <thierry.bastian@nokia.com> | 2010-04-13 09:46:38 (GMT) |
commit | 6433302cf96b64460cbcd770d8cb703f29a001ad (patch) | |
tree | 2e838343c8d7510bab5590467aaf8a6320184486 /src | |
parent | be16b3def01783e693883c0990f73c815042b1e7 (diff) | |
download | Qt-6433302cf96b64460cbcd770d8cb703f29a001ad.zip Qt-6433302cf96b64460cbcd770d8cb703f29a001ad.tar.gz Qt-6433302cf96b64460cbcd770d8cb703f29a001ad.tar.bz2 |
Improve handling of QAction in soft key manager
It also reduces QActionPrivate by 16 bytes.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/kernel/qaction.cpp | 1 | ||||
-rw-r--r-- | src/gui/kernel/qaction_p.h | 17 | ||||
-rw-r--r-- | src/gui/kernel/qsoftkeymanager.cpp | 12 | ||||
-rw-r--r-- | src/gui/kernel/qsoftkeymanager_p.h | 3 | ||||
-rw-r--r-- | src/gui/kernel/qsoftkeymanager_s60.cpp | 5 |
5 files changed, 22 insertions, 16 deletions
diff --git a/src/gui/kernel/qaction.cpp b/src/gui/kernel/qaction.cpp index 8ddd051..a6d2594 100644 --- a/src/gui/kernel/qaction.cpp +++ b/src/gui/kernel/qaction.cpp @@ -81,6 +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), + forceEnabledInSoftkeys(false), menuActionSoftkeys(false), menuRole(QAction::TextHeuristicRole), softKeyRole(QAction::NoSoftKey), priority(QAction::NormalPriority), iconVisibleInMenu(-1) { diff --git a/src/gui/kernel/qaction_p.h b/src/gui/kernel/qaction_p.h index b57e5d2..899b01b 100644 --- a/src/gui/kernel/qaction_p.h +++ b/src/gui/kernel/qaction_p.h @@ -75,6 +75,11 @@ public: QActionPrivate(); ~QActionPrivate(); + static QActionPrivate *get(QAction *q) + { + return q->d_func(); + } + bool showStatusText(QWidget *w, const QString &str); QPointer<QActionGroup> group; @@ -103,10 +108,16 @@ public: uint checked : 1; uint separator : 1; uint fontSet : 1; - QAction::MenuRole menuRole; - QAction::SoftKeyRole softKeyRole; - QAction::Priority priority; + + //for soft keys management + uint forceEnabledInSoftkeys : 1; + uint menuActionSoftkeys : 1; + + QAction::MenuRole menuRole : 3; + QAction::SoftKeyRole softKeyRole : 2; + QAction::Priority priority : 14; int iconVisibleInMenu : 3; // Only has values -1, 0, and 1 + QList<QWidget *> widgets; #ifndef QT_NO_GRAPHICSVIEW QList<QGraphicsWidget *> graphicsWidgets; diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 23f1481..04e4685 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -43,7 +43,7 @@ #include "qevent.h" #include "qbitmap.h" #include "private/qsoftkeymanager_p.h" -#include "private/qobject_p.h" +#include "private/qaction_p.h" #include "private/qsoftkeymanager_common_p.h" #ifdef Q_WS_S60 @@ -104,7 +104,7 @@ QAction *QSoftKeyManager::createAction(StandardSoftKey standardKey, QWidget *act QAction::SoftKeyRole softKeyRole = QAction::NoSoftKey; switch (standardKey) { case MenuSoftKey: // FALL-THROUGH - action->setProperty(MENU_ACTION_PROPERTY, QVariant(true)); // TODO: can be refactored away to use _q_action_menubar + QActionPrivate::get(action)->menuActionSoftkeys = true; case OkSoftKey: case SelectSoftKey: case DoneSoftKey: @@ -255,16 +255,12 @@ bool QSoftKeyManager::handleUpdateSoftKeys() void QSoftKeyManager::setForceEnabledInSoftkeys(QAction *action) { - action->setProperty(FORCE_ENABLED_PROPERTY, QVariant(true)); + QActionPrivate::get(action)->forceEnabledInSoftkeys = true; } bool QSoftKeyManager::isForceEnabledInSofkeys(QAction *action) { - bool ret = false; - QVariant property = action->property(FORCE_ENABLED_PROPERTY); - if (property.isValid() && property.toBool()) - ret = true; - return ret; + return QActionPrivate::get(action)->forceEnabledInSoftkeys; } bool QSoftKeyManager::event(QEvent *e) diff --git a/src/gui/kernel/qsoftkeymanager_p.h b/src/gui/kernel/qsoftkeymanager_p.h index a5b258b..6eedfa8 100644 --- a/src/gui/kernel/qsoftkeymanager_p.h +++ b/src/gui/kernel/qsoftkeymanager_p.h @@ -63,9 +63,6 @@ QT_BEGIN_NAMESPACE class QSoftKeyManagerPrivate; -const char MENU_ACTION_PROPERTY[] = "_q_menuAction"; -const char FORCE_ENABLED_PROPERTY[] = "_q_forceEnabledInSoftkeys"; - class Q_AUTOTEST_EXPORT QSoftKeyManager : public QObject { Q_OBJECT diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp index c0761f0..fbe5888 100644 --- a/src/gui/kernel/qsoftkeymanager_s60.cpp +++ b/src/gui/kernel/qsoftkeymanager_s60.cpp @@ -46,6 +46,7 @@ #include "qmenubar.h" #include "private/qt_s60_p.h" #include "private/qmenu_p.h" +#include "private/qaction_p.h" #include "private/qsoftkeymanager_p.h" #include "private/qsoftkeymanager_s60_p.h" #include "private/qobject_p.h" @@ -382,8 +383,8 @@ bool QSoftKeyManagerPrivateS60::handleCommand(int command) { QAction *action = realSoftKeyActions.value(command); if (action) { - QVariant property = action->property(MENU_ACTION_PROPERTY); - if (property.isValid() && property.toBool()) { + bool property = QActionPrivate(action)->menuActionSoftkeys; + if (property) { QT_TRAP_THROWING(tryDisplayMenuBarL()); } else if (action->menu()) { // TODO: This is hack, in order to use exising QMenuBar implementation for Symbian |