From 1a47595d3a836c3c783dc3dbf85ce5b24f7ecf03 Mon Sep 17 00:00:00 2001 From: Richard Moe Gustavsen Date: Wed, 6 Aug 2014 14:36:08 +0200 Subject: [PATCH] QPlatformMenu: add overloaded function 'showPopup' that takes a target rect When showing an edit menu on touch platforms, you need to specify a target rect for where to place the menu. The target rect is normally a rectangle that encompasses the whole text selection. Using this information the OS will place the menu so that is doesn't obscure the selection itself, or fall outside the screen (or overlaps e.g the keyboard). Since we don't know the size of the menu, or if the OS will end up placing the menu above or below the pos we give it, we need to do it the correct way and forward the whole target rect instead. Change-Id: I638586e9d0dd14c430a22c403c6dce099192a075 Reviewed-by: Friedemann Kleint Reviewed-by: Gabriel de Dietrich --- src/gui/kernel/qplatformmenu.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gui/kernel/qplatformmenu.h b/src/gui/kernel/qplatformmenu.h index f95fd4603e..39184826df 100644 --- a/src/gui/kernel/qplatformmenu.h +++ b/src/gui/kernel/qplatformmenu.h @@ -117,9 +117,14 @@ public: virtual void setMenuType(MenuType type) { Q_UNUSED(type); } virtual void showPopup(const QWindow *parentWindow, QPoint pos, const QPlatformMenuItem *item) + { + showPopup(parentWindow, QRect(pos, QSize()), item); + } + + virtual void showPopup(const QWindow *parentWindow, const QRect &targetRect, const QPlatformMenuItem *item) { Q_UNUSED(parentWindow); - Q_UNUSED(pos); + Q_UNUSED(targetRect); Q_UNUSED(item); setVisible(true); }