changeset 29611:d64ad3b93372

eliminate direct parent to child connection in terminal dock widget * terminal-dock-widget.h (terminal_dock_widget::settings_changed): New signal. (terminal_dock_widget::notice_settings): New slot. * main-window.cc (main_window::main_window): Connect main_window settings_changed signal to terminal_dock_widget notice_settings slot.
author John W. Eaton <jwe@octave.org>
date Tue, 04 May 2021 13:55:28 -0400
parents a46084c73b6d
children 9c04fea333ca
files libgui/src/main-window.cc libgui/src/terminal-dock-widget.cc libgui/src/terminal-dock-widget.h
diffstat 3 files changed, 22 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Tue May 04 11:56:47 2021 -0400
+++ b/libgui/src/main-window.cc	Tue May 04 13:55:28 2021 -0400
@@ -166,6 +166,9 @@
 
     m_command_window = new terminal_dock_widget (this, m_octave_qobj);
 
+    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);
 
     connect (m_history_window, &history_dock_widget::command_create_script,
--- a/libgui/src/terminal-dock-widget.cc	Tue May 04 11:56:47 2021 -0400
+++ b/libgui/src/terminal-dock-widget.cc	Tue May 04 13:55:28 2021 -0400
@@ -64,7 +64,11 @@
     setWidget (m_terminal);
     setFocusProxy (m_terminal);
 
-    connect (p, SIGNAL (settings_changed (const gui_settings *)),
+    // FIXME: The new terminal needs to be a more specific type than
+    // QWidget for this to work properly and to be able to use the new
+    // signal/slot connection style.  Probably the new terminal widget
+    // should be derived from QTerminal.
+    connect (this, SIGNAL (settings_changed (const gui_settings *)),
              m_terminal, SLOT (notice_settings (const gui_settings *)));
 
     if (m_experimental_terminal_widget)
@@ -80,6 +84,11 @@
       }
     else
       {
+        // FIXME: As with the settings_changed signal above, the
+        // following connections won't work with the new signal/slot
+        // connection style because m_terminal is a pointer to QWidget
+        // instead of QTerminal.
+
         // Connect the interrupt signal (emitted by Ctrl-C)
         connect (m_terminal, SIGNAL (interrupt_signal (void)),
                  &oct_qobj, SLOT (interpreter_interrupt (void)));
@@ -125,6 +134,11 @@
     return w->hasFocus ();
   }
 
+  void terminal_dock_widget::notice_settings (const gui_settings *settings)
+  {
+    emit settings_changed (settings);
+  }
+
   void terminal_dock_widget::interpreter_output (const QString& msg)
   {
     if (m_experimental_terminal_widget)
--- a/libgui/src/terminal-dock-widget.h	Tue May 04 11:56:47 2021 -0400
+++ b/libgui/src/terminal-dock-widget.h	Tue May 04 13:55:28 2021 -0400
@@ -48,6 +48,8 @@
 
   signals:
 
+    void settings_changed (const gui_settings *settings);
+
     // Note: UPDATE_PROMPT_SIGNAL and INTERPRETER_OUTPUT_SIGNAL are
     // currently only used by the new experimental terminal widget.
 
@@ -57,6 +59,8 @@
 
   public slots:
 
+    void notice_settings (const gui_settings *settings);
+
     // Note: INTERPRETER_OUTPUT and UPDATE_PROMPT are currently only
     // used by the new experimental terminal widget.