diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-06-24 10:27:04 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2022-07-11 19:04:34 +0200 |
commit | c3ecc9d8c3b81cebf6f707f397f096df3ccecbe4 (patch) | |
tree | ad827901baacf581d109f5b4e4b87fa0d5e99dd2 | |
parent | 7cb6bdfb2a33bbd5c5fdf03c86a5422ea49b9114 (diff) |
tdf#149680 qt: Open native popup menu at given position
Calculate the position at which to open the popup
menu from the passed window and rectangle, rather
than always opening the native popup menu at the
cursor position.
The commit message in
commit 1e0b16f8695498e4eea7c2208aabf7e7664ce749
Date: Wed Feb 12 08:07:42 2020 +0100
tdf#128921 tdf#130341 tdf#122053 qt5: Native PopupMenus
which had implemented native poup menus, already said:
> For now, this always shows the popup menu at cursor position, which
> can be changed by taking the Rectangle passed to
> 'Qt5Menu::ShowNativePopupMenu' into account if there should be any
> need.
Change-Id: If1a44b6d53f3dcd6fa7ceec0738219f11cfc22c4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136356
Tested-by: Jenkins
Reviewed-by: Michael Weghorn <m.weghorn@posteo.de>
(cherry picked from commit ee3976f2c613f9015477ab327996c074e8516f9d)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136707
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
(cherry picked from commit fc5edcf8c02ce81715a3db7c58e9b6d4a9a3b796)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136855
Reviewed-by: Michael Stahl <michael.stahl@allotropia.de>
-rw-r--r-- | vcl/qt5/QtMenu.cxx | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx index 9400f5e129bf..0646c9232d5d 100644 --- a/vcl/qt5/QtMenu.cxx +++ b/vcl/qt5/QtMenu.cxx @@ -676,15 +676,19 @@ void QtMenu::ShowCloseButton(bool bShow) pButton->hide(); } -bool QtMenu::ShowNativePopupMenu(FloatingWindow*, const tools::Rectangle&, +bool QtMenu::ShowNativePopupMenu(FloatingWindow* pWin, const tools::Rectangle& rRect, FloatWinPopupFlags nFlags) { assert(mpQMenu); DoFullMenuUpdate(mpVCLMenu); mpQMenu->setTearOffEnabled(bool(nFlags & FloatWinPopupFlags::AllowTearOff)); - const QPoint aPos = QCursor::pos(); - mpQMenu->exec(aPos); + const VclPtr<vcl::Window> xParent = pWin->ImplGetWindowImpl()->mpRealParent; + const QtFrame* pFrame = static_cast<QtFrame*>(xParent->ImplGetFrame()); + assert(pFrame); + const tools::Rectangle aFloatRect = FloatingWindow::ImplConvertToAbsPos(xParent, rRect); + const QRect aRect = toQRect(aFloatRect, 1 / pFrame->devicePixelRatioF()); + mpQMenu->exec(aRect.topLeft()); return true; } |