diff libgui/src/octave-qobject.h @ 29153:02ee34a30351

eliminate separate cli_qobject and gui_qobject classes * octave-qobject.h, octave-qobject.cc (base_qobject::m_main_window): New data member. (base_qobject::base_qobject): New arg, GUI_APP. If true, set up GUI app main main_window object, signals, and set gui_running flag to true in application context. Otherwise, set up for CLI app. Start main thread after all other objects are constructed. (base_qobject::~base_qobject): Delete m_main_window. (base_qobject::confirm_shutdown): Ask for confirmation from main_window if it exists. (class cli_qobject, class gui_qobject): Delete. * qt-application.cc (qt_application::execute): Pass result of calling start_gui_p to base_qobject constructor instead of using separate objects for gui and cli interfaces.
author John W. Eaton <jwe@octave.org>
date Thu, 03 Dec 2020 10:02:08 -0500
parents 43ad651cf5a0
children c2f3a0832cf0
line wrap: on
line diff
--- a/libgui/src/octave-qobject.h	Thu Dec 03 12:28:59 2020 -0500
+++ b/libgui/src/octave-qobject.h	Thu Dec 03 10:02:08 2020 -0500
@@ -83,7 +83,7 @@
 
   public:
 
-    base_qobject (qt_application& app_context);
+    base_qobject (qt_application& app_context, bool gui_app = false);
 
     ~base_qobject (void);
 
@@ -131,6 +131,9 @@
 
     QThread *main_thread (void) { return m_main_thread; }
 
+    // Declared virtual so that a derived class may redefine this
+    // method.
+
     virtual bool confirm_shutdown (void);
 
   signals:
@@ -178,38 +181,8 @@
     interpreter_qobject *m_interpreter_qobj;
 
     QThread *m_main_thread;
-  };
 
-  //! This object provides a command-line interface to Octave that may
-  //! use Qt graphics.
-
-  class cli_qobject : public base_qobject
-  {
-    Q_OBJECT
-
-  public:
-
-    cli_qobject (qt_application& app_context);
-
-    ~cli_qobject (void) = default;
-  };
-
-  //! This object provides a full GUI interface to Octave that is
-  //! implemented Qt.
-
-  class gui_qobject : public base_qobject
-  {
-    Q_OBJECT
-
-  public:
-
-    gui_qobject (qt_application& app_context);
-
-    ~gui_qobject (void);
-
-    bool confirm_shutdown (void);
-
-  private:
+    bool m_gui_app;
 
     main_window *m_main_window;
   };