vcl/qt5/QtMenu.cxx |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit ea9de214311780119a0974e03b38fd835b5074f5
Author:     Michael Weghorn <m.wegh...@posteo.de>
AuthorDate: Wed Sep 14 10:40:18 2022 +0200
Commit:     Michael Weghorn <m.wegh...@posteo.de>
CommitDate: Wed Sep 14 14:18:46 2022 +0200

    tdf#150882 qt: Report menu bar height when not hidden
    
    `QWidget::isVisible` only returns `true` if the widget is actually
    visible on screen.
    Therefore, even if the menu itself has been set to be visible
    in `QtMenu::ShowMenuBar`, the call to `mpQMenuBar->isVisible()`
    will still return `false` as long as the corresponding window
    the menu belongs to isn't shown on screen (yet).
    
    However, since the menu bar height may be used to calculate
    the position of other items (e.g. in the macro dialog) before the
    corresponding window gets shown, what should be relevant
    is whether the menu bar itself is meant to be hidden or
    not. Therefore, use `QWidget::isHidden` instead.
    
    Quoting the Qt doc [1] for `QWidget`'s `visible` property:
    
    > This property holds whether the widget is visible
    >
    > Calling setVisible(true) or show() sets the widget to visible status if
    > all its parent widgets up to the window are visible. If an ancestor is
    > not visible, the widget won't become visible until all its ancestors are
    > shown. [...]
    >
    > Calling setVisible(false) or hide() hides a widget explicitly. An
    > explicitly hidden widget will never become visible, even if all its
    > ancestors become visible, unless you show it.
    
    This makes the menu show properly in the macro dialog
    while still not reserving any space for the menu in the
    main window in case of using the "Tabbed" interface (where
    no "traditional" menu is present).
    
    [1] https://doc.qt.io/qt-6/qwidget.html#visible-prop
    
    Change-Id: Ifb6e22db8224013f06320d090a19d80d9e38a990
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139910
    Tested-by: Jenkins
    Reviewed-by: Michael Weghorn <m.wegh...@posteo.de>

diff --git a/vcl/qt5/QtMenu.cxx b/vcl/qt5/QtMenu.cxx
index c1e4cb0e1a29..dd259f32f979 100644
--- a/vcl/qt5/QtMenu.cxx
+++ b/vcl/qt5/QtMenu.cxx
@@ -847,7 +847,7 @@ bool QtMenu::ShowNativePopupMenu(FloatingWindow* pWin, 
const tools::Rectangle& r
 
 int QtMenu::GetMenuBarHeight() const
 {
-    if (!validateQMenuBar() || !mpQMenuBar->isVisible())
+    if (!validateQMenuBar() || mpQMenuBar->isHidden())
         return 0;
     return mpQMenuBar->height() * mpFrame->devicePixelRatioF();
 }

Reply via email to