Mercurial > octave
changeset 29612:9c04fea333ca
avoid connecting to parent slots in octave_dock_widget
* main-window.h, main-window.cc
(main_window::make_dock_widget_connections): New function.
(main_window::main_window): Call make_dock_widget_connections to
connect common octave_dock_widget signals to main_window slots and
signals here.
* octave-dock-widget.cc (octave_dock_widget::octave_dock_widget):
Don't connect signals to parent object slots and signals.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Tue, 04 May 2021 15:33:58 -0400 |
parents | d64ad3b93372 |
children | 9367cba2a6d5 |
files | libgui/src/main-window.cc libgui/src/main-window.h libgui/src/octave-dock-widget.cc |
diffstat | 3 files changed, 33 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/libgui/src/main-window.cc Tue May 04 13:55:28 2021 -0400 +++ b/libgui/src/main-window.cc Tue May 04 15:33:58 2021 -0400 @@ -166,11 +166,15 @@ m_command_window = new terminal_dock_widget (this, m_octave_qobj); + make_dock_widget_connections (m_command_window); + connect (this, &main_window::settings_changed, m_command_window, &terminal_dock_widget::notice_settings); m_history_window = new history_dock_widget (this, m_octave_qobj); + make_dock_widget_connections (m_history_window); + connect (m_history_window, &history_dock_widget::command_create_script, this, &main_window::new_file_signal); @@ -181,6 +185,9 @@ this, &main_window::execute_command_in_terminal); m_file_browser_window = new files_dock_widget (this, m_octave_qobj); + + make_dock_widget_connections (m_file_browser_window); + connect (m_file_browser_window, &files_dock_widget::open_file, this, QOverload<const QString&>::of (&main_window::open_file_signal)); connect (m_file_browser_window, @@ -193,9 +200,13 @@ m_doc_browser_window = new documentation_dock_widget (this, m_octave_qobj); + make_dock_widget_connections (m_doc_browser_window); + #if defined (HAVE_QSCINTILLA) file_editor *editor = new file_editor (this, m_octave_qobj); + make_dock_widget_connections (editor); + connect (editor, &file_editor::request_settings_dialog, this, QOverload<const QString&>::of (&main_window::process_settings_dialog_request)); @@ -227,11 +238,15 @@ m_variable_editor_window = new variable_editor (this, m_octave_qobj); + make_dock_widget_connections (m_variable_editor_window); + connect (m_variable_editor_window, &variable_editor::command_signal, this, &main_window::execute_command_in_terminal); m_workspace_window = new workspace_view (this, m_octave_qobj); + make_dock_widget_connections (m_workspace_window); + connect (m_workspace_window, &workspace_view::command_requested, this, &main_window::execute_command_in_terminal); @@ -307,6 +322,18 @@ focus_command_window (); } + void main_window::make_dock_widget_connections (octave_dock_widget *dw) + { + connect (this, &main_window::init_window_menu, + dw, &octave_dock_widget::init_window_menu_entry); + + connect (this, &main_window::settings_changed, + dw, &octave_dock_widget::handle_settings); + + connect (this, &main_window::active_dock_changed, + dw, &octave_dock_widget::handle_active_dock_changed); + } + bool main_window::command_window_has_focus (void) const { return m_command_window->has_focus ();
--- a/libgui/src/main-window.h Tue May 04 13:55:28 2021 -0400 +++ b/libgui/src/main-window.h Tue May 04 15:33:58 2021 -0400 @@ -86,6 +86,8 @@ ~main_window (void) = default; + void make_dock_widget_connections (octave_dock_widget *dw); + bool command_window_has_focus (void) const; void focus_command_window (void);
--- a/libgui/src/octave-dock-widget.cc Tue May 04 13:55:28 2021 -0400 +++ b/libgui/src/octave-dock-widget.cc Tue May 04 15:33:58 2021 -0400 @@ -197,17 +197,6 @@ connect (this, &octave_dock_widget::visibilityChanged, this, &octave_dock_widget::handle_visibility); - connect (p, SIGNAL (init_window_menu (void)), - this, SLOT (init_window_menu_entry (void))); - - connect (p, SIGNAL (settings_changed (const gui_settings *)), - this, SLOT (handle_settings (const gui_settings *))); - - connect (p, SIGNAL (active_dock_changed (octave_dock_widget*, - octave_dock_widget*)), - this, SLOT (handle_active_dock_changed (octave_dock_widget*, - octave_dock_widget*))); - if (m_default_float_button != nullptr) { disconnect (m_default_float_button, 0, 0, 0); @@ -232,14 +221,11 @@ connect (m_close_action, &QAction::triggered, this, &octave_dock_widget::change_visibility); - // Any interpreter_event signal from an octave_dock_widget object is - // handled the same as for the parent main_window object. + connect (this, QOverload<const fcn_callback&>::of (&octave_dock_widget::interpreter_event), + &oct_qobj, QOverload<const fcn_callback&>::of (&base_qobject::interpreter_event)); - connect (this, SIGNAL (interpreter_event (const fcn_callback&)), - p, SIGNAL (interpreter_event (const fcn_callback&))); - - connect (this, SIGNAL (interpreter_event (const meth_callback&)), - p, SIGNAL (interpreter_event (const meth_callback&))); + connect (this, QOverload<const meth_callback&>::of (&octave_dock_widget::interpreter_event), + &oct_qobj, QOverload<const meth_callback&>::of (&base_qobject::interpreter_event)); m_close_action->setToolTip (tr ("Hide widget"));