diff options
author | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-06-06 12:11:53 (GMT) |
---|---|---|
committer | Markku Luukkainen <markku.luukkainen@digia.com> | 2009-06-06 12:11:53 (GMT) |
commit | 449d4b00c6e3d8a277821e5fb5837e3da2e6b920 (patch) | |
tree | 60ffd2f79f3e94e89812c7b4df3ed0f8a4db9e88 | |
parent | f87e69fcb26387e8d22546778bb1f5d43ba8e200 (diff) | |
download | Qt-449d4b00c6e3d8a277821e5fb5837e3da2e6b920.zip Qt-449d4b00c6e3d8a277821e5fb5837e3da2e6b920.tar.gz Qt-449d4b00c6e3d8a277821e5fb5837e3da2e6b920.tar.bz2 |
Replaced usage of QSoftKeyActions with QActions+SoftKeyRoles
-rw-r--r-- | src/gui/kernel/qwidget.cpp | 6 | ||||
-rw-r--r-- | src/gui/kernel/qwidget.h | 7 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_p.h | 5 | ||||
-rw-r--r-- | src/gui/kernel/qwidget_s60.cpp | 33 | ||||
-rw-r--r-- | 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<QSoftKeyAction*>& QWidget::softKeys() const +const QList<QAction*>& QWidget::softKeys() const { Q_D(const QWidget); if( d->softKeys.count() > 0) @@ -11524,7 +11524,7 @@ const QList<QSoftKeyAction*>& 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<QSoftKeyAction*> &softKeys) +void QWidget::setSoftKeys(const QList<QAction*> &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<QAction*> actions() const; #endif - const QList<QSoftKeyAction*>& softKeys() const; - void setSoftKeys(QSoftKeyAction *softKey); - void setSoftKeys(const QList<QSoftKeyAction*> &softKeys); + const QList<QAction*>& softKeys() const; + void setSoftKeys(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 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<QSoftKeyAction*> &softkeys); + void setNativeSoftKeys(const QList<QAction*> &softkeys); QWExtra *extraData() const; QTLWExtra *topData() const; QTLWExtra *maybeTopData() const; @@ -514,7 +513,7 @@ public: #ifndef QT_NO_ACTION QList<QAction*> actions; #endif - QList<QSoftKeyAction*> softKeys; + QList<QAction*> 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 <qinputcontext.h> #include <aknappui.h> -#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 <QSoftKeyAction*> +#define QSoftkeySet QList <QAction*> // 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<QSoftKeyAction*>& a, const QList<QSoftKeyAction*>& b) +static bool isSame(const QList<QAction*>& a, const QList<QAction*>& 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()) + 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<QSoftKeyAction*>& a, const QList<QSoftKeyAction*> } -void QWidgetPrivate::setNativeSoftKeys(const QList<QSoftKeyAction*> &softkeys) +void QWidgetPrivate::setNativeSoftKeys(const QList<QAction*> &softkeys) { if (QApplication::focusWidget()) { - QList<QSoftKeyAction*> old = QApplication::focusWidget()->softKeys(); + QList<QAction *> old = QApplication::focusWidget()->softKeys(); if (isSame(old, softkeys )) return; } @@ -122,20 +122,25 @@ void QWidgetPrivate::setNativeSoftKeys(const QList<QSoftKeyAction*> &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); } } |