Mercurial > octave
diff libgui/graphics/Figure.cc @ 25888:6109f302cf43
Fix regression with "menubar" figure property handling (bug #54678)
* Figure.cc/h (Figure::showMenuBar, Figure::updateMenuBar): Remove methods.
(Figure::update): Don't call showMenuBar.
(Figure::updateFigureHeight): New method. Adjust the figure size by a given
delta h and update the figure's "outerposition" property.
(Figure::eventNotifyAfter): Call updateFigureHeight when the menubar height
changed.
* Menu.cc (Menu::Menu): No need to set the QMenu objectName anymore.
* __add_default_menu__.m: Add second optionnal argument to provide existing
uimenu. Add figure listener to toggle the visibility of builtin menu.
* clf.m: Call __add_default_menu__ with existing menu.
author | Pantxo Diribarne <pantxo.diribarne@gmail.com> |
---|---|
date | Tue, 18 Sep 2018 21:53:14 +0200 |
parents | d3f5d021255d |
children | 2da65009cc7f |
line wrap: on
line diff
--- a/libgui/graphics/Figure.cc Mon Sep 17 20:15:27 2018 +0200 +++ b/libgui/graphics/Figure.cc Tue Sep 18 21:53:14 2018 +0200 @@ -144,9 +144,6 @@ m_statusBar->hide (); } - if (! fp.menubar_is ("figure")) - m_menuBar->hide (); - m_innerRect = boundingBoxToRect (fp.get_boundingbox (true)); m_outerRect = boundingBoxToRect (fp.get_boundingbox (false)); @@ -472,7 +469,6 @@ break; case figure::properties::ID_MENUBAR: - showMenuBar (fp.menubar_is ("figure")); if (fp.toolbar_is ("auto")) showFigureToolBar (fp.menubar_is ("figure")); break; @@ -545,51 +541,23 @@ } void - Figure::showMenuBar (bool visible, int h1) - { - // Get the height before and after toggling the visibility of builtin menus - if (h1 < 0) - h1 = m_menuBar->sizeHint ().height (); - - // Keep the menubar visible if it contains custom menus - bool keep_visible = visible; - foreach (QAction *a, m_menuBar->actions ()) - if (a->objectName () == "builtinMenu") - a->setVisible (visible); - else if ((a->objectName () == "customMenu") && a->isVisible ()) - keep_visible = true; - - visible = keep_visible; - - int h2 = m_menuBar->sizeHint ().height (); - - if (h1 != h2 || (m_menuBar->isVisible () && ! visible) - || (! m_menuBar->isVisible () && visible)) - { - int dy = h2 - h1; - - QRect r = qWidget<QWidget> ()->geometry (); - - r.adjust (0, -dy, 0, 0); - - m_blockUpdates = true; - qWidget<QWidget> ()->setGeometry (r); - m_menuBar->setVisible (visible); - m_blockUpdates = false; - } - - updateBoundingBox (false); - } - - void - Figure::updateMenuBar (int height) + Figure::updateFigureHeight (int dh) { gh_manager::auto_lock lock; graphics_object go = object (); - if (go.valid_object ()) - showMenuBar (Utils::properties<figure> (go).menubar_is ("figure"), - height); + if (go.valid_object () && dh != 0) + { + QRect r = qWidget<QWidget> ()->geometry (); + + r.adjust (0, dh, 0, 0); + + m_blockUpdates = true; + qWidget<QWidget> ()->setGeometry (r); + m_blockUpdates = false; + + updateBoundingBox (false); + } } void @@ -798,9 +766,10 @@ // The menubar may have been resized if no action is visible { QAction *a = dynamic_cast<QActionEvent *> (xevent)->action (); - if (m_menuBar->sizeHint ().height () != m_previousHeight + int currentHeight = m_menuBar->sizeHint ().height (); + if (currentHeight != m_previousHeight && ! a->isSeparator ()) - updateMenuBar (m_previousHeight); + updateFigureHeight (m_previousHeight - currentHeight); } break;