diff libgui/src/m-editor/file-editor-tab.cc @ 27629:8b6e928e0705

in GUI objects, store reference to base_qobject instead of resource_manager We'll need access to both the resource_manager and the shortcut_manager in many objects. The shortcut_manager will be moved to be a member of the base_qobject class instead of being a singleton, so this change will make it easier to access both of these as well as any other core GUI properties in any of the Octave-specific widgets that make up the GUI. Once again, may files are affecte but the changes are straightforward: store a reference to the base_qobject object and access the resource_manager object from that instead of storing a reference to the resource_manager directly.
author John W. Eaton <jwe@octave.org>
date Mon, 04 Nov 2019 13:34:44 -0500
parents 45bb5bbaf291
children fd009322dd9f
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Mon Nov 04 11:18:28 2019 -0500
+++ b/libgui/src/m-editor/file-editor-tab.cc	Mon Nov 04 13:34:44 2019 -0500
@@ -64,8 +64,8 @@
 #include "file-editor.h"
 #include "gui-preferences-ed.h"
 #include "marker.h"
+#include "octave-qobject.h"
 #include "octave-txt-lexer.h"
-#include "resource-manager.h"
 
 #include "cmd-edit.h"
 #include "file-ops.h"
@@ -95,9 +95,9 @@
 
   // Make parent null for the file editor tab so that warning WindowModal
   // messages don't affect grandparents.
-  file_editor_tab::file_editor_tab (resource_manager& rmgr,
+  file_editor_tab::file_editor_tab (base_qobject& oct_qobj,
                                     const QString& directory_arg)
-    : m_resource_manager (rmgr)
+    : m_octave_qobj (oct_qobj)
   {
     m_lexer_apis = nullptr;
     m_is_octave_file = true;
@@ -108,7 +108,7 @@
     m_file_name = "";
     m_file_system_watcher.setObjectName ("_qt_autotest_force_engine_poller");
 
-    m_edit_area = new octave_qscintilla (this, m_resource_manager);
+    m_edit_area = new octave_qscintilla (this, m_octave_qobj);
     m_line = 0;
     m_col  = 0;
 
@@ -256,7 +256,8 @@
     connect (this, SIGNAL (do_save_file_signal (const QString&, bool, bool)),
              this, SLOT (do_save_file (const QString&, bool, bool)));
 
-    gui_settings *settings = m_resource_manager.get_settings ();
+    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+    gui_settings *settings = rmgr.get_settings ();
     if (settings)
       notice_settings (settings, true);
 
@@ -698,7 +699,8 @@
   {
     QsciLexer *lexer = m_edit_area->lexer ();
 
-    gui_settings *settings = m_resource_manager.get_settings ();
+    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+    gui_settings *settings = rmgr.get_settings ();
 
     if (m_lexer_apis)
       {
@@ -1658,7 +1660,8 @@
         if (input_str)
           {
             bool ok;
-            gui_settings *settings = m_resource_manager.get_settings ();
+            resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+            gui_settings *settings = rmgr.get_settings ();
 
             used_comment_str
               = QInputDialog::getText (this, tr ("Comment selected text"),
@@ -2042,7 +2045,8 @@
                             "This does not change the default encoding.\n"));
 
         QComboBox *enc_combo = new QComboBox ();
-        m_resource_manager.combo_encoding (enc_combo);
+        resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+        rmgr.combo_encoding (enc_combo);
         m_new_encoding = enc_combo->currentText ();
         connect (enc_combo, SIGNAL (currentTextChanged (const QString&)),
                  this , SLOT (handle_current_enc_changed (const QString&)));
@@ -2099,7 +2103,8 @@
 #else
     int os_eol_mode = QsciScintilla::EolUnix;
 #endif
-    gui_settings *settings = m_resource_manager.get_settings ();
+    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+    gui_settings *settings = rmgr.get_settings ();
     QsciScintilla::EolMode eol_mode
       = static_cast<QsciScintilla::EolMode> (settings->value ("editor/default_eol_mode",os_eol_mode).toInt ());
 
@@ -2182,7 +2187,8 @@
   {
     update_window_title (false); // window title (no modification)
 
-    gui_settings *settings = m_resource_manager.get_settings ();
+    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+    gui_settings *settings = rmgr.get_settings ();
 
     // set the eol mode from the settings or depending on the OS if the entry is
     // missing in the settings
@@ -2484,8 +2490,9 @@
     fileDialog->setViewMode (QFileDialog::Detail);
 
     // FIXME: Remove, if for all common KDE versions (bug #54607) is resolved.
-    if (! m_resource_manager.get_settings ()->value ("use_native_file_dialogs",
-                                                    true).toBool ())
+    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+    gui_settings *settings = rmgr.get_settings ();
+    if (! settings->value ("use_native_file_dialogs", true).toBool ())
       fileDialog->setOption(QFileDialog::DontUseNativeDialog);
 
     connect (fileDialog, SIGNAL (filterSelected (const QString&)),