diff libgui/src/octave-dock-widget.cc @ 29754:4c569e386e9b

improve behavior of dockable widgets (bug #60750) * main-window.h, main-window.cc (main_window::set_window_layout): Don't reset geometry of adopted dock_widgets. (main_window::construct): Don't connect qt_link edit_variable_signal to main_window edit_variable slot. (main_window::reset_windows): Force reset of all windows. (main_window::do_reset_windows): New argument, FORCE_ALL. Skip adoped dock_widgets unless force_all is true. * octave-dock-widget.h, octave-dock-widget.cc (octave_dock_widget::make_widget): If m_main_window is nonnull, set m_adopted to false. Disconnect any existing m_dock_action signals that are connected to the octave_dock_widget object before connecting the m_dock_action triggered signal to the octave_dock_widget make_window slot. (octave_dock_widget::m_adopted): New data member. (octave_dock_widget::set_adopted, (octave_dock_widget::adopted): New functions. * octave-qobject.h, octave-qobject.cc (base_qobject::documentation_widget, base_qobject::file_browser_widget, base_qobject::history_widget, base_qobject::workspace_widget, base_qobject::variable_editor_widget): Call set_main_window and set_adopted for widget if it already exists and main_window argument is nonnull. Otherwise, create widget if it doesn't already exist. (base_qobject::show_variable_editor_window): Rename slot from edit_variable. Change all uses. Acquire pointer to widget and forward to the widget's edit_variable method. * variable-editor.cc (variable_editor::variable_editor): Call make_window if parent is nullptr. (variable_editor::edit_variable): Don't call make_window.
author John W. Eaton <jwe@octave.org>
date Mon, 14 Jun 2021 12:39:51 -0400
parents 3f61913fdee4
children d79f65e37e89
line wrap: on
line diff
--- a/libgui/src/octave-dock-widget.cc	Mon Jun 14 10:42:08 2021 -0400
+++ b/libgui/src/octave-dock-widget.cc	Mon Jun 14 12:39:51 2021 -0400
@@ -184,7 +184,8 @@
 
   octave_dock_widget::octave_dock_widget (const QString& obj_name, QWidget *p,
                                           base_qobject& oct_qobj)
-    : label_dock_widget (p, oct_qobj), m_focus_follows_mouse (false),
+    : label_dock_widget (p, oct_qobj), m_adopted (false),
+      m_custom_style (false), m_focus_follows_mouse (false),
       m_recent_float_geom (), m_recent_dock_geom (),
       m_waiting_for_mouse_button_release (false)
   {
@@ -345,11 +346,13 @@
     if (m_main_window)
       {
         settings->setValue (mw_state.key, m_main_window->saveState ());
+
         // Stay window, otherwise will bounce back to window by default
         // because there is no layout information for this widget in the
         // saved settings.
         setParent (m_main_window, Qt::Window);
         m_main_window->addDockWidget (Qt::BottomDockWidgetArea, this);
+        m_adopted = false;
         // recover old window states, hide and re-show new added widget
         m_main_window->restoreState (settings->value (mw_state.key).toByteArray ());
         setFloating (false);
@@ -360,6 +363,7 @@
       }
 
     // adjust the (un)dock icon
+    disconnect (m_dock_action, 0, this, 0);
     connect (m_dock_action, &QAction::triggered,
              this, &octave_dock_widget::make_window);
     if (titleBarWidget ())