summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-08-04 11:29:29 +0200
committerRichard Moe Gustavsen <richard.gustavsen@digia.com>2014-08-06 16:17:20 +0200
commit42a5930a75b5b05926da8895faa228da9d1e20e5 (patch)
treeb88736d756ef6c41be1352de25ace2c297a42667
parent6c3d951e14e235477b95bace1e2a2c9e12e7a063 (diff)
downloadqtquickcontrols-42a5930a75b5b05926da8895faa228da9d1e20e5.tar.gz
QQuickMenu: add enum MenuType that reflects QPlatformMenu::MenuType
On mobile platforms several different popup menu types exist. E.g on iOS, you have a special popup just for selecting text. A recent patch added to QtBase added a new enum to QPlatformMenu that lets UI controls select/hint which one to use. This patch adds the same enum to QQuickMenu so that we can control this from Controls as well. Change-Id: Ibf4bdc84577b5a6527021b1cb15578b56bb4a92e Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
-rw-r--r--src/controls/qquickmenu.cpp3
-rw-r--r--src/controls/qquickmenu_p.h6
2 files changed, 7 insertions, 2 deletions
diff --git a/src/controls/qquickmenu.cpp b/src/controls/qquickmenu.cpp
index 385db3c0..f1c4e24b 100644
--- a/src/controls/qquickmenu.cpp
+++ b/src/controls/qquickmenu.cpp
@@ -388,7 +388,7 @@ void QQuickMenu::popup()
__popup(mousePos.x(), mousePos.y());
}
-void QQuickMenu::__popup(qreal x, qreal y, int atItemIndex)
+void QQuickMenu::__popup(qreal x, qreal y, int atItemIndex, MenuType menuType)
{
if (popupVisible()) {
__closeMenu();
@@ -415,6 +415,7 @@ void QQuickMenu::__popup(qreal x, qreal y, int atItemIndex)
screenPosition.rx() -= qMax(static_cast<qreal>(m_minimumWidth), m_menuContentItem->width());
screenPosition = visualItem()->mapToScene(screenPosition);
}
+ m_platformMenu->setMenuType(QPlatformMenu::MenuType(menuType));
m_platformMenu->showPopup(parentWindow, screenPosition.toPoint(), atItem ? atItem->platformItem() : 0);
} else {
m_popupWindow = new QQuickMenuPopupWindow();
diff --git a/src/controls/qquickmenu_p.h b/src/controls/qquickmenu_p.h
index 73f5c505..f20a8734 100644
--- a/src/controls/qquickmenu_p.h
+++ b/src/controls/qquickmenu_p.h
@@ -75,8 +75,12 @@ class QQuickMenu : public QQuickMenuText
Q_PROPERTY(qreal __yOffset READ yOffset WRITE setYOffset)
Q_PROPERTY(QQuickAction *__action READ action CONSTANT)
Q_PROPERTY(QRect __popupGeometry READ popupGeometry NOTIFY __popupGeometryChanged)
+ Q_ENUMS(MenuType)
public:
+ // MenuType must stay in sync with QPlatformMenu::MenuType
+ enum MenuType { DefaultMenu = 0, EditMenu };
+
Q_INVOKABLE void popup();
Q_INVOKABLE QQuickMenuItem *addItem(QString);
Q_INVOKABLE QQuickMenuItem *insertItem(int, QString);
@@ -87,7 +91,7 @@ public:
Q_INVOKABLE void removeItem(QQuickMenuBase *);
Q_INVOKABLE void clear();
- Q_INVOKABLE void __popup(qreal x, qreal y, int atActionIndex = -1);
+ Q_INVOKABLE void __popup(qreal x, qreal y, int atActionIndex = -1, MenuType menuType = DefaultMenu);
public Q_SLOTS:
void __closeMenu();