Mercurial > hg > octave-nkf
changeset 16811:81344ade678f
fix resetting the window layout when some widgets are floating
* main-window.cc(set_window_layout): use dock_widget list instead of children
of the main-window, check for floating widgets that shouldn't be floating
from the settings and reparent them before restoring geometry
author | Torsten <ttl@justmail.de> |
---|---|
date | Sat, 22 Jun 2013 22:25:20 +0200 |
parents | 62fa28af2842 |
children | 366a13bd71d5 |
files | libgui/src/main-window.cc |
diffstat | 1 files changed, 14 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc +++ b/libgui/src/main-window.cc @@ -542,33 +542,33 @@ void main_window::set_window_layout (QSettings *settings) { - restoreState (settings->value ("MainWindow/windowState").toByteArray ()); - // Restore the geometry of all dock-widgets - foreach (QObject *obj, children ()) + foreach (octave_dock_widget *widget, dock_widget_list ()) { - QString name = obj->objectName (); + QString name = widget->objectName (); - if (obj->inherits ("QDockWidget") && ! name.isEmpty ()) + if (! name.isEmpty ()) { - octave_dock_widget *widget = qobject_cast<octave_dock_widget *> (obj); - QVariant val = settings->value (name); - - widget->restoreGeometry (val.toByteArray ()); - // If floating, make window from widget. bool floating = settings->value ("DockWidgets/" + name + "Floating", false).toBool (); + if (floating) + widget->make_window (false); + else if (! widget->parent ()) // should not be floating but is + widget->setParent (this); // reparent + + // restore geometry + QVariant val = settings->value (name); + widget->restoreGeometry (val.toByteArray ()); + + // make widget visible if desired bool visible = settings->value ("DockWidgets/" + name + "Visible", true).toBool (); - if (floating) - widget->make_window (visible); - - // make widget visible if desired widget->setVisible (visible); } } + restoreState (settings->value ("MainWindow/windowState").toByteArray ()); restoreGeometry (settings->value ("MainWindow/geometry").toByteArray ()); }