diff options
author | Michael Weghorn <m.weghorn@posteo.de> | 2022-09-14 10:40:18 +0200 |
---|---|---|
committer | Michael Weghorn <m.weghorn@posteo.de> | 2022-09-14 14:18:46 +0200 |
commit | ea9de214311780119a0974e03b38fd835b5074f5 (patch) | |
tree | bea5be8ebe64af30b12b72a920c12fa0e49a15f7 /vcl | |
parent | 5510a77f2c926770dbc312db252a035c7afbe7b3 (diff) |
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.weghorn@posteo.de>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/qt5/QtMenu.cxx | 2 |
1 files changed, 1 insertions, 1 deletions
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(); } |