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 <Friedemann.Kleint@digia.com>
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Richard Moe Gustavsen 2014-08-06 14:36:08 +02:00
parent c1d2a04923
commit 1a47595d3a

View File

@ -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);
}