diff libgui/qterminal/libqterminal/QTerminal.h @ 27648:2952471e29a7

eliminate global access to resource_manager in qterminal widget * QTerminal.h, QTerminal.cc (QTerminal::create): Accept reference to octave_qobject. Change all uses. Call construct to set up signal/slot connections and context menu after creating object. (QTerminal::construct): New function. Move body of QTerminal constructor here. * libgui/qterminal/module.mk: Use full list of CPPFLAGS for interpreter directories.
author John W. Eaton <jwe@octave.org>
date Wed, 06 Nov 2019 14:29:42 -0500
parents 45bb5bbaf291
children 27dc4dae6826
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/QTerminal.h	Wed Nov 06 12:42:12 2019 -0500
+++ b/libgui/qterminal/libqterminal/QTerminal.h	Wed Nov 06 14:29:42 2019 -0500
@@ -24,20 +24,25 @@
 #ifndef QTERMINAL_H
 #define QTERMINAL_H
 
-#include <QKeySequence>
-#include <QWidget>
-#include <QStringList>
 #include <QColor>
 #include <QList>
-#include <QMenu>
-#include <QClipboard>
-#include <QApplication>
-#include <QAction>
+#include <QPoint>
+#include <QString>
+#include <QWidget>
 
+// For now, we need to use the following #include and using statement
+// for the signal/slot macros.  Could maybe change later when using
+// Qt5-style signal/slot connections.
 #include "gui-settings.h"
-#include "resource-manager.h"
+using octave::gui_settings;
 
-using octave::gui_settings;
+namespace octave
+{
+  class base_qobject;
+}
+
+class QMenu;
+class QAction;
 
 class QTerminal : public QWidget
 {
@@ -45,7 +50,8 @@
 
 public:
 
-  static QTerminal *create (QWidget *xparent = nullptr);
+  static QTerminal *
+  create (octave::base_qobject& oct_qobj, QWidget *xparent = nullptr);
 
   virtual ~QTerminal (void) = default;
 
@@ -133,96 +139,9 @@
 
 protected:
 
-  QTerminal (QWidget *xparent = nullptr) : QWidget (xparent)
-  {
-    octave::resource_manager& rmgr
-      = octave::__get_resource_manager__ ("QTerminal::QTerminal");
-
-    // context menu
-    setContextMenuPolicy (Qt::CustomContextMenu);
-
-    _contextMenu = new QMenu (this);
-
-    _copy_action
-      = _contextMenu->addAction (rmgr.icon ("edit-copy"), tr ("Copy"), this,
-                                 SLOT (copyClipboard ()));
-
-    _paste_action
-      = _contextMenu->addAction (rmgr.icon ("edit-paste"), tr ("Paste"), this,
-                                 SLOT (pasteClipboard ()));
-
-    _contextMenu->addSeparator ();
-
-    _selectall_action
-      = _contextMenu->addAction (tr ("Select All"), this, SLOT (selectAll ()));
-
-    _run_selection_action
-      = _contextMenu->addAction (tr ("Run Selection"), this,
-                                 SLOT (run_selection ()));
-
-    m_edit_selected_action
-      = _contextMenu->addAction (tr ("Edit selection"), this,
-                                 SLOT (edit_selected ()));
-    m_help_selected_action
-      = _contextMenu->addAction (tr ("Help on selection"), this,
-                                 SLOT (help_on_expression ()));
-    m_doc_selected_action
-      = _contextMenu->addAction (tr ("Documentation on selection"), this,
-                                 SLOT (doc_on_expression ()));
-
-    _edit_action = _contextMenu->addAction (tr (""), this, SLOT (edit_file ()));
-
-    _contextMenu->addSeparator ();
-
-    _contextMenu->addAction (tr ("Clear Window"), parent (),
-                             SLOT (handle_clear_command_window_request ()));
+  QTerminal (QWidget *xparent = nullptr) : QWidget (xparent) { }
 
-    connect (this, SIGNAL (customContextMenuRequested (QPoint)),
-             this, SLOT (handleCustomContextMenuRequested (QPoint)));
-
-    connect (this, SIGNAL (report_status_message (const QString&)),
-             xparent, SLOT (report_status_message (const QString&)));
-
-    connect (this, SIGNAL (show_doc_signal (const QString&)),
-             xparent, SLOT (handle_show_doc (const QString&)));
-
-    connect (this, SIGNAL (edit_mfile_request (const QString&, int)),
-             xparent, SLOT (edit_mfile (const QString&, int)));
-
-    connect (this, SIGNAL (execute_command_in_terminal_signal (const QString&)),
-             xparent, SLOT (execute_command_in_terminal (const QString&)));
-
-    connect (xparent, SIGNAL (settings_changed (const gui_settings *)),
-             this, SLOT (notice_settings (const gui_settings *)));
-
-    connect (xparent, SIGNAL (init_terminal_size_signal ()),
-             this, SLOT (init_terminal_size ()));
-
-    connect (xparent, SIGNAL (copyClipboard_signal ()),
-             this, SLOT (copyClipboard ()));
-
-    connect (xparent, SIGNAL (pasteClipboard_signal ()),
-             this, SLOT (pasteClipboard ()));
-
-    connect (xparent, SIGNAL (selectAll_signal ()),
-             this, SLOT (selectAll ()));
-
-    // extra interrupt action
-    _interrupt_action = new QAction (this);
-    addAction (_interrupt_action);
-
-    _interrupt_action->setShortcut
-      (QKeySequence (Qt::ControlModifier + Qt::Key_C));
-
-    connect (_interrupt_action, SIGNAL (triggered ()),
-             this, SLOT (terminal_interrupt ()));
-
-    // dummy (nop) action catching Ctrl-D in terminal, no connection
-    _nop_action = new QAction (this);
-    addAction (_nop_action);
-
-    _nop_action->setShortcut (QKeySequence (Qt::ControlModifier + Qt::Key_D));
-  }
+  void construct (octave::base_qobject& oct_qobj, QWidget *xparent);
 
 private: