Mercurial > octave
changeset 29450:6448a10a642a stable
fix restoring the horizontal position of docked gui widgets (bug #59426)
* main-window.cc (set_window_layout): reset the window layout before
restoring it from the settings file, do not save layout after reset;
(do_reset_windows): new second argument whether the new layout is saved
in the settings
* main-window.h: new argument for do_reset_windows
author | Torsten Lilge <ttl-octave@mailbox.org> |
---|---|
date | Sat, 20 Mar 2021 11:17:09 +0100 |
parents | f526f28f1aa4 |
children | 75ba68c686ab |
files | libgui/src/main-window.cc libgui/src/main-window.h |
diffstat | 2 files changed, 15 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Thu Mar 18 21:45:09 2021 +0100 +++ b/libgui/src/main-window.cc Sat Mar 20 11:17:09 2021 +0100 @@ -1465,6 +1465,10 @@ void main_window::set_window_layout (gui_settings *settings) { + // For resetting from some inconsistent state, first reset layout + // without saving or showing it + do_reset_windows (true, false); + // Restore main window state and geometry from settings file or, in case // of an error (no pref values yet), from the default layout. if (! restoreGeometry (settings->value (mw_geometry).toByteArray ())) @@ -2833,7 +2837,7 @@ // Create the default layout of the main window. Do not use // restoreState () and restoreGeometry () with default values since // this might lead to problems when the Qt version changes - void main_window::do_reset_windows (bool show_it) + void main_window::do_reset_windows (bool show, bool save) { // Set main window default geometry and store its width for // later resizing the command window @@ -2875,7 +2879,7 @@ // Show main wibdow, save state and geometry of main window and // all dock widgets - if (show_it) + if (show) { // Show all dock widgets for (auto *widget : dock_widget_list ()) @@ -2884,11 +2888,14 @@ // Show main window and store size and state showNormal (); - resource_manager& rmgr = m_octave_qobj.get_resource_manager (); - gui_settings *settings = rmgr.get_settings (); - - settings->setValue (mw_geometry.key, saveGeometry ()); - settings->setValue (mw_state.key, saveState ()); + if (save) + { + resource_manager& rmgr = m_octave_qobj.get_resource_manager (); + gui_settings *settings = rmgr.get_settings (); + + settings->setValue (mw_geometry.key, saveGeometry ()); + settings->setValue (mw_state.key, saveState ()); + } focus_command_window (); }
--- a/libgui/src/main-window.h Thu Mar 18 21:45:09 2021 +0100 +++ b/libgui/src/main-window.h Sat Mar 20 11:17:09 2021 +0100 @@ -162,7 +162,7 @@ void prepare_to_exit (void); void go_to_previous_widget (void); void reset_windows (void); - void do_reset_windows (bool show_it = true); + void do_reset_windows (bool show = true, bool save = true); void update_octave_directory (const QString& dir); void browse_for_directory (void);