changeset 31690:1a1f47f17ed4

eliminate resource_manager class * gui-settings.cc, gui-settings.h (gui_settings::get_gui_translation_dir, gui_settings::config_translators, gui_settings::get_valid_lexer_styles, gui_settings::read_lexer_settings, gui_settings::update_settings_key, gui_settings::update_network_settings, gui_settings::get_codecs, gui_settings::combo_encoding): Move here from resource_manager class. * file-editor-tab.cc, find-dialog.cc, main-window.cc, octave-qobject.h, octave-qobject.cc, qt-interpreter-events.cc, settings-dialog.cc: Change all uses of resource_manager class to use gui_settings instead. * octave-qscintilla.h, octave-qscintilla.cc (octave_qscintilla::create_tmp_file): Move here from resource_manager class. (octave_qscintilla::ctx_menu_run_finished_signal, octave_qscintilla::ctx_menu_run_finished): Use QPointer<QTemporaryFile> instead of bare pointer in signal/slot functions. * octave-qobject.h, octave-qobject.cc (octave_base_qobject::m_resource_manager): Delete data member. (octave_base_qobject::get_resource_manager): Delete. * resource-manager.h, resource-manager.cc: Delete. * libgui/src/module.mk: Update.
author John W. Eaton <jwe@octave.org>
date Tue, 27 Dec 2022 14:55:03 -0500
parents a8a7207a7341
children fc3bc1402b0d
files libgui/qterminal/libqterminal/QTerminal.cc libgui/src/gui-settings.cc libgui/src/gui-settings.h libgui/src/m-editor/file-editor-tab.cc libgui/src/m-editor/find-dialog.cc libgui/src/m-editor/octave-qscintilla.cc libgui/src/m-editor/octave-qscintilla.h libgui/src/main-window.cc libgui/src/module.mk libgui/src/octave-qobject.cc libgui/src/octave-qobject.h libgui/src/qt-interpreter-events.cc libgui/src/resource-manager.cc libgui/src/resource-manager.h libgui/src/settings-dialog.cc
diffstat 15 files changed, 463 insertions(+), 640 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/qterminal/libqterminal/QTerminal.cc	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/qterminal/libqterminal/QTerminal.cc	Tue Dec 27 14:55:03 2022 -0500
@@ -40,7 +40,6 @@
 #include "gui-preferences-sc.h"
 #include "gui-settings.h"
 #include "octave-qobject.h"
-#include "resource-manager.h"
 
 #include "QTerminal.h"
 #if defined (Q_OS_WIN32)
--- a/libgui/src/gui-settings.cc	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/gui-settings.cc	Tue Dec 27 14:55:03 2022 -0500
@@ -33,17 +33,22 @@
 #include <QFile>
 #include <QFileInfo>
 #include <QFontDatabase>
+#include <QLibraryInfo>
 #include <QMessageBox>
+#include <QNetworkProxy>
 #include <QSettings>
 #include <QString>
 #include <QStringList>
 
 #include "gui-preferences-cs.h"
+#include "gui-preferences-ed.h"
 #include "gui-preferences-global.h"
 #include "gui-settings.h"
 
 #include "oct-env.h"
 
+#include "defaults.h"
+
 OCTAVE_BEGIN_NAMESPACE(octave)
 
   QString gui_settings::file_name (void) const
@@ -280,6 +285,360 @@
     return result;
   }
 
+  QString gui_settings::get_gui_translation_dir (void)
+  {
+    // get environment variable for the locale dir (e.g. from run-octave)
+    std::string dldir = sys::env::getenv ("OCTAVE_LOCALE_DIR");
+    if (dldir.empty ())
+      dldir = config::oct_locale_dir ();  // env-var empty, load the default location
+    return QString::fromStdString (dldir);
+  }
+
+  void gui_settings::config_translators (QTranslator *qt_tr,
+                                         QTranslator *qsci_tr,
+                                         QTranslator *gui_tr)
+  {
+    bool loaded;
+
+    QString qt_trans_dir
+      = QLibraryInfo::location (QLibraryInfo::TranslationsPath);
+
+    QString language = "SYSTEM";  // take system language per default
+
+    // FIXME: can we somehow ensure that the settings object will always
+    // be initialize and valid?
+
+    // get the locale from the settings if already available
+    language = value (global_language.key, global_language.def).toString ();
+
+    // load the translations depending on the settings
+    if (language == "SYSTEM")
+      {
+        // get the system locale and pass it to the translators for loading
+        // the suitable translation files
+        QLocale sys_locale = QLocale::system ();
+
+        qt_tr->load (sys_locale, "qt", "_", qt_trans_dir);
+        qsci_tr->load (sys_locale, "qscintilla", "_", qt_trans_dir);
+        gui_tr->load (sys_locale, "", "", get_gui_translation_dir ());
+      }
+    else
+      {
+        // load the translation files depending on the given locale name
+        loaded = qt_tr->load ("qt_" + language, qt_trans_dir);
+        if (! loaded)  // try lower case
+          qt_tr->load ("qt_" + language.toLower (), qt_trans_dir);
+
+        loaded = qsci_tr->load ("qscintilla_" + language, qt_trans_dir);
+        if (! loaded)  // try lower case
+          qsci_tr->load ("qscintilla_" + language.toLower (), qt_trans_dir);
+
+        gui_tr->load (language, get_gui_translation_dir ());
+      }
+
+  }
+
+#if defined (HAVE_QSCINTILLA)
+  int gui_settings::get_valid_lexer_styles (QsciLexer *lexer, int *styles)
+  {
+    int max_style = 0;
+    int actual_style = 0;
+    while (actual_style < ed_max_style_number && max_style < ed_max_lexer_styles)
+      {
+        if ((lexer->description (actual_style)) != "")  // valid style
+          styles[max_style++] = actual_style;
+        actual_style++;
+      }
+    return max_style;
+  }
+#endif
+
+  /*!
+   * Copys the attributes bold, italic and underline from QFont
+   * @p attr to the font @p base and returns the result without
+   * changing @p base,
+   * @param attr QFont with the desired attributes
+   * @param base QFont with desired family and size
+   */
+  static QFont copy_font_attributes (const QFont& attr, const QFont& base)
+  {
+    QFont dest (base);
+
+    dest.setBold (attr.bold ());
+    dest.setItalic (attr.italic ());
+    dest.setUnderline (attr.underline ());
+
+    return dest;
+  }
+
+#if defined (HAVE_QSCINTILLA)
+  void gui_settings::read_lexer_settings (QsciLexer *lexer, int mode, int def)
+  {
+    // Test whether the settings for lexer is already contained in the
+    // given gui settings file. If yes, load them, if not copy them from the
+    // default settings file.
+    // This is useful when a new language support is implemented and the
+    // existing settings file is used (which is of course the common case).
+    int m = mode;
+    if (m > 1)
+      m = 1;
+
+    QString group ("Scintilla" + settings_color_modes_ext[m]);
+
+    beginGroup (group);
+    beginGroup (lexer->language ());
+
+    QStringList lexer_keys = allKeys ();
+
+    endGroup ();
+    endGroup ();
+
+    if (def == settings_reload_default_colors_flag || lexer_keys.count () == 0)
+      {
+        // We have to reload the default values or no Lexer keys found:
+        // If mode == 0, take all settings except font from default lexer
+        // If Mode == 1, take all settings except font from default lexer
+        //               and convert the color by inverting the lightness
+
+        // Get the default font
+        QStringList def_font = get_default_font ();
+        QFont df (def_font[0], def_font[1].toInt ());
+        QFont dfa = copy_font_attributes (lexer->defaultFont (), df);
+        lexer->setDefaultFont (dfa);
+
+        QColor c, p;
+
+        int styles[ed_max_lexer_styles];  // array for saving valid styles
+        int max_style = get_valid_lexer_styles (lexer, styles);
+
+        for (int i = 0; i < max_style; i++)
+          {
+            c = get_color_value (QVariant (lexer->color (styles[i])), m);
+            lexer->setColor (c, styles[i]);
+            p = get_color_value (QVariant (lexer->paper (styles[i])), m);
+            lexer->setPaper (p, styles[i]);
+            dfa = copy_font_attributes (lexer->font (styles[i]), df);
+            lexer->setFont (dfa, styles[i]);
+          }
+        // Set defaults last for not changing the defaults of the styles
+        lexer->setDefaultColor (lexer->color (styles[0]));
+        lexer->setDefaultPaper (lexer->paper (styles[0]));
+
+        // Write settings if not just reload the default values
+        if (def != settings_reload_default_colors_flag)
+          {
+            const std::string group_str = group.toStdString ();
+            lexer->writeSettings (*this, group_str.c_str ());
+            sync ();
+          }
+      }
+    else
+      {
+        // Found lexer keys, read the settings
+        const std::string group_str = group.toStdString ();
+        lexer->readSettings (*this, group_str.c_str ());
+      }
+  }
+#endif
+
+  bool gui_settings::update_settings_key (const QString& old_key,
+                                          const QString& new_key)
+  {
+    if (contains (old_key))
+      {
+        QVariant preference = value (old_key);
+        setValue (new_key, preference);
+        remove (old_key);
+        return true;
+      }
+
+    return false;
+  }
+
+  void gui_settings::update_network_settings (void)
+  {
+    QNetworkProxy proxy;
+
+    // Assume no proxy and empty proxy data
+    QNetworkProxy::ProxyType proxy_type = QNetworkProxy::NoProxy;
+    QString scheme;
+    QString host;
+    int port = 0;
+    QString user;
+    QString pass;
+    QUrl proxy_url = QUrl ();
+
+    if (value (global_use_proxy.key, global_use_proxy.def).toBool ())
+      {
+        // Use a proxy, collect all required information
+        QString proxy_type_string
+          = value (global_proxy_type.key, global_proxy_type.def).toString ();
+
+        // The proxy type for the Qt proxy settings
+        if (proxy_type_string == "Socks5Proxy")
+          proxy_type = QNetworkProxy::Socks5Proxy;
+        else if (proxy_type_string == "HttpProxy")
+          proxy_type = QNetworkProxy::HttpProxy;
+
+        // The proxy data from the settings
+        if (proxy_type_string == "HttpProxy"
+            || proxy_type_string == "Socks5Proxy")
+          {
+            host = value (global_proxy_host.key,
+                          global_proxy_host.def).toString ();
+            port = value (global_proxy_port.key,
+                          global_proxy_port.def).toInt ();
+            user = value (global_proxy_user.key,
+                          global_proxy_user.def).toString ();
+            pass = value (global_proxy_pass.key,
+                          global_proxy_pass.def).toString ();
+            if (proxy_type_string == "HttpProxy")
+              scheme = "http";
+            else if (proxy_type_string == "Socks5Proxy")
+              scheme = "socks5";
+
+            QUrl env_var_url = QUrl ();
+            proxy_url.setScheme (scheme);
+            proxy_url.setHost (host);
+            proxy_url.setPort (port);
+            if (! user.isEmpty ())
+              proxy_url.setUserName (user);
+            if (! pass.isEmpty ())
+              proxy_url.setPassword (pass);
+          }
+
+        // The proxy data from environment variables
+        if (proxy_type_string == global_proxy_all_types.at (2))
+          {
+            const std::array<std::string, 6> env_vars =
+            {
+              "ALL_PROXY", "all_proxy",
+              "HTTP_PROXY", "http_proxy",
+              "HTTPS_PROXY", "https_proxy"
+            };
+
+            unsigned int count = 0;
+            while (! proxy_url.isValid () && count < env_vars.size ())
+              {
+                proxy_url = QUrl (QString::fromStdString
+                                    (sys::env::getenv (env_vars[count])));
+                count++;
+              }
+
+            if (proxy_url.isValid ())
+              {
+                // Found an entry, get the data from the string
+                scheme = proxy_url.scheme ();
+
+                if (scheme.contains ("socks", Qt::CaseInsensitive))
+                  proxy_type = QNetworkProxy::Socks5Proxy;
+                else
+                  proxy_type = QNetworkProxy::HttpProxy;
+
+                host = proxy_url.host ();
+                port = proxy_url.port ();
+                user = proxy_url.userName ();
+                pass = proxy_url.password ();
+              }
+          }
+      }
+
+    // Set proxy for Qt framework
+    proxy.setType (proxy_type);
+    proxy.setHostName (host);
+    proxy.setPort (port);
+    proxy.setUser (user);
+    proxy.setPassword (pass);
+
+    QNetworkProxy::setApplicationProxy (proxy);
+
+    // Set proxy for curl library if not based on environment variables
+    std::string proxy_url_str = proxy_url.toString().toStdString ();
+    sys::env::putenv ("http_proxy", proxy_url_str);
+    sys::env::putenv ("HTTP_PROXY", proxy_url_str);
+    sys::env::putenv ("https_proxy", proxy_url_str);
+    sys::env::putenv ("HTTPS_PROXY", proxy_url_str);
+  }
+
+  // get a list of all available encodings
+  void gui_settings::get_codecs (QStringList *codecs)
+  {
+    // get the codec name for each mib
+    QList<int> all_mibs = QTextCodec::availableMibs ();
+    for (auto mib : all_mibs)
+      {
+        QTextCodec *c = QTextCodec::codecForMib (mib);
+        codecs->append (c->name ().toUpper ());
+      }
+
+    // Append SYSTEM
+    codecs->append (QString ("SYSTEM (") +
+                    QString (octave_locale_charset_wrapper ()).toUpper () +
+                    QString (")"));
+
+    // Clean up and sort list of codecs
+    codecs->removeDuplicates ();
+    std::sort (codecs->begin (), codecs->end ());
+  }
+
+  // initialize a given combo box with available text encodings
+  void gui_settings::combo_encoding (QComboBox *combo, const QString& current)
+  {
+    QStringList all_codecs;
+    get_codecs (&all_codecs);
+
+    // get the value from the settings file if no current encoding is given
+    QString enc = current;
+
+    // Check for valid codec for the default.  If this fails, "SYSTEM" (i.e.
+    // locale_charset) will be chosen.
+    // FIXME: The default is "SYSTEM" on all platforms.  So can this fallback
+    // logic be removed completely?
+    bool default_exists = false;
+    bool show_system = false;
+    if (ed_default_enc.def.toString ().startsWith ("SYSTEM"))
+      show_system = true;
+    else if (QTextCodec::codecForName (ed_default_enc.def.toString ().toLatin1 ()))
+      default_exists = true;
+
+    QString default_enc =
+      QString ("SYSTEM (") +
+      QString (octave_locale_charset_wrapper ()).toUpper () + QString (")");
+
+    if (enc.isEmpty ())
+      {
+        enc = value (ed_default_enc).toString ();
+
+        if (enc.isEmpty ())  // still empty?
+          {
+            if (default_exists)
+              enc = ed_default_enc.def.toString ();
+            else
+              enc = default_enc;
+          }
+      }
+
+    // fill the combo box
+    for (const auto& c : all_codecs)
+      combo->addItem (c);
+
+    // prepend the default item
+    combo->insertSeparator (0);
+    if (show_system || ! default_exists)
+      combo->insertItem (0, default_enc);
+    else
+      combo->insertItem (0, ed_default_enc.def.toString ());
+
+    // select the default or the current one
+    int idx = combo->findText (enc, Qt::MatchExactly);
+    if (idx >= 0)
+      combo->setCurrentIndex (idx);
+    else
+      combo->setCurrentIndex (0);
+
+    combo->setMaxVisibleItems (12);
+  }
+
   void gui_settings::reload (void)
   {
     // Declare some empty options, which may be set at first startup for
--- a/libgui/src/gui-settings.h	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/gui-settings.h	Tue Dec 27 14:55:03 2022 -0500
@@ -26,9 +26,16 @@
 #if ! defined (octave_gui_settings_h)
 #define octave_gui_settings_h 1
 
+#include <QComboBox>
 #include <QIcon>
 #include <QString>
 #include <QSettings>
+#include <QShortcut>
+#include <QString>
+#include <QTranslator>
+#if defined (HAVE_QSCINTILLA)
+#  include <Qsci/qscilexer.h>
+#endif
 
 #include "gui-preferences.h"
 
@@ -151,6 +158,24 @@
 
     QStringList get_default_font (void);
 
+    QString get_gui_translation_dir (void);
+
+    void config_translators (QTranslator *qt_tr, QTranslator *qsci_tr,
+                             QTranslator *gui_tr);
+
+#if defined (HAVE_QSCINTILLA)
+    int get_valid_lexer_styles (QsciLexer *lexer, int *styles);
+    void read_lexer_settings (QsciLexer *lexer, int mode = 0, int def = 0);
+#endif
+
+    bool update_settings_key (const QString& new_key, const QString& old_key);
+
+    void update_network_settings (void);
+
+    void get_codecs (QStringList *codecs);
+
+    void combo_encoding (QComboBox *combo, const QString& current = QString ());
+
     void reload (void);
 
   private:
--- a/libgui/src/m-editor/file-editor-tab.cc	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/m-editor/file-editor-tab.cc	Tue Dec 27 14:55:03 2022 -0500
@@ -881,8 +881,7 @@
       return;   // We are done here
 
     int mode = settings.value (ed_color_mode).toInt ();
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-    rmgr.read_lexer_settings (lexer, mode);
+    settings.read_lexer_settings (lexer, mode);
 
     m_edit_area->setCaretForegroundColor (lexer->color (0));
     m_edit_area->setIndentationGuidesForegroundColor (lexer->color (0));
@@ -1912,8 +1911,8 @@
                             "This does not change the default encoding.\n"));
 
         QComboBox *enc_combo = new QComboBox ();
-        resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-        rmgr.combo_encoding (enc_combo);
+        gui_settings settings;
+        settings.combo_encoding (enc_combo);
         m_new_encoding = enc_combo->currentText ();
         connect (enc_combo, &QComboBox::currentTextChanged,
                  this, &file_editor_tab::handle_current_enc_changed);
--- a/libgui/src/m-editor/find-dialog.cc	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/m-editor/find-dialog.cc	Tue Dec 27 14:55:03 2022 -0500
@@ -83,7 +83,6 @@
 #include "find-dialog.h"
 #include "gui-preferences-ed.h"
 #include "gui-utils.h"
-#include "resource-manager.h"
 
 OCTAVE_BEGIN_NAMESPACE(octave)
 
--- a/libgui/src/m-editor/octave-qscintilla.cc	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/m-editor/octave-qscintilla.cc	Tue Dec 27 14:55:03 2022 -0500
@@ -36,6 +36,8 @@
 #include <QMessageBox>
 #include <QMimeData>
 #include <QShortcut>
+#include <QPointer>
+#include <QTemporaryFile>
 #include <QToolTip>
 #include <QVBoxLayout>
 #if defined (HAVE_QSCI_QSCILEXEROCTAVE_H)
@@ -66,6 +68,7 @@
 #include "cmd-edit.h"
 #include "interpreter-private.h"
 #include "interpreter.h"
+#include "oct-env.h"
 
 // Return true if CANDIDATE is a "closing" that matches OPENING,
 // such as "end" or "endif" for "if", or "catch" for "try".
@@ -825,8 +828,6 @@
 
   void octave_qscintilla::contextmenu_run (bool)
   {
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-
     // Take selected code and extend it by commands for echoing each
     // evaluated line and for adding the line to the history (use script)
     QString code = QString ();
@@ -867,33 +868,29 @@
     octave_stdout << hist.toStdString ();
 
     // Create tmp file with the code to be executed by the interpreter
-    QPointer<QTemporaryFile> tmp_file
-      = rmgr.create_tmp_file ("m", code);
+    QPointer<QTemporaryFile> tmp_file = create_tmp_file ("m", code);
 
-    bool tmp = (tmp_file && tmp_file->open ());
-    if (! tmp)
+    if (tmp_file && tmp_file->open ())
+      tmp_file->close ();
+    else
       {
         // tmp files not working: use old way to run selection
         contextmenu_run_temp_error ();
         return;
       }
 
-    tmp_file->close ();
+    // Create tmp file required for adding command to history
+    QPointer<QTemporaryFile> tmp_hist = create_tmp_file ("", hist);
 
-    // Create tmp file required for adding command to history
-    QPointer<QTemporaryFile> tmp_hist
-      = rmgr.create_tmp_file ("", hist); // empty tmp file for history
-
-    tmp = (tmp_hist && tmp_hist->open ());
-    if (! tmp)
+    if (tmp_hist && tmp_hist->open ())
+      tmp_hist->close ();
+    else
       {
         // tmp files not working: use old way to run selection
         contextmenu_run_temp_error ();
         return;
       }
 
-    tmp_hist->close ();
-
     // Add commands to the history
     emit interpreter_event
       ([=] (interpreter& interp)
@@ -1024,9 +1021,9 @@
        });
   }
 
-  void octave_qscintilla::ctx_menu_run_finished (bool show_dbg_file, int,
-                      QTemporaryFile* tmp_file, QTemporaryFile* tmp_hist,
-                      bool dbg, bool auto_repeat)
+  void octave_qscintilla::ctx_menu_run_finished
+    (bool show_dbg_file, int, QPointer<QTemporaryFile> tmp_file,
+     QPointer<QTemporaryFile> tmp_hist, bool dbg, bool auto_repeat)
   {
     emit focus_console_after_command_signal ();
 
@@ -1034,13 +1031,16 @@
     //       lines from history that were never executed. For this,
     //       possible lines from commands at a debug prompt must be
     //       taken into consideration.
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+
     gui_settings settings;
 
     settings.setValue (ed_show_dbg_file.key, show_dbg_file);
 
-    rmgr.remove_tmp_file (tmp_file);
-    rmgr.remove_tmp_file (tmp_hist);
+    if (tmp_file && tmp_file->exists ())
+      tmp_file->remove ();
+
+    if (tmp_hist && tmp_hist->exists ())
+      tmp_hist->remove ();
 
     emit interpreter_event
       ([=] (interpreter& interp)
@@ -1366,6 +1366,30 @@
     m_debug_mode = false;
   }
 
+  QPointer<QTemporaryFile>
+  octave_qscintilla::create_tmp_file (const QString& extension,
+                                      const QString& contents)
+  {
+    QString ext = extension;
+    if ((! ext.isEmpty ()) && (! ext.startsWith ('.')))
+      ext = QString (".") + ext;
+
+    // Create octave dir within temp. dir
+    QString tmp_dir = QString::fromStdString (sys::env::get_temp_directory ());
+
+    QString tmp_name = tmp_dir + QDir::separator() + "octave_XXXXXX" + ext;
+
+    QPointer<QTemporaryFile> tmp_file (new QTemporaryFile (tmp_name, this));
+
+    if (! contents.isEmpty () && tmp_file && tmp_file->open ())
+      {
+        tmp_file->write (contents.toUtf8 ());
+        tmp_file->close ();
+      }
+
+    return tmp_file;
+  }
+
 OCTAVE_END_NAMESPACE(octave)
 
 #endif
--- a/libgui/src/m-editor/octave-qscintilla.h	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/m-editor/octave-qscintilla.h	Tue Dec 27 14:55:03 2022 -0500
@@ -30,8 +30,9 @@
 #include <QKeyEvent>
 #include <QLabel>
 #include <QMenu>
+#include <QPointer>
+#include <QTemporaryFile>
 #include <Qsci/qsciscintilla.h>
-#include <QTemporaryFile>
 
 #include "gui-settings.h"
 #include "qt-interpreter-events.h"
@@ -96,8 +97,8 @@
   void show_doc_signal (const QString&);
   void context_menu_break_condition_signal (int);
   void context_menu_break_once (int);
-  void ctx_menu_run_finished_signal (bool, int, QTemporaryFile *,
-                                     QTemporaryFile *, bool, bool);
+  void ctx_menu_run_finished_signal (bool, int, QPointer<QTemporaryFile>,
+                                     QPointer<QTemporaryFile>, bool, bool);
   void focus_console_after_command_signal (void);
 
   void interpreter_event (const fcn_callback& fcn);
@@ -110,8 +111,8 @@
 
 private slots:
 
-  void ctx_menu_run_finished (bool, int, QTemporaryFile *, QTemporaryFile *,
-                              bool, bool);
+  void ctx_menu_run_finished (bool, int, QPointer<QTemporaryFile>,
+                              QPointer<QTemporaryFile>, bool, bool);
 
   void contextmenu_help (bool);
   void contextmenu_doc (bool);
@@ -143,6 +144,9 @@
   void auto_close (int auto_endif, int l,
                    const QString& line, QString& first_word);
 
+  QPointer<QTemporaryFile> create_tmp_file (const QString& extension,
+                                            const QString& contents);
+
   base_qobject& m_octave_qobj;
 
   bool m_debug_mode;
--- a/libgui/src/main-window.cc	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/main-window.cc	Tue Dec 27 14:55:03 2022 -0500
@@ -109,8 +109,6 @@
       m_suppress_dbg_location (true),
       m_closing (false), m_file_encoding (QString ())
   {
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-
     gui_settings settings;
 
     if (! settings.value (global_skip_welcome_wizard).toBool ())
@@ -141,7 +139,7 @@
 
     settings.config_icon_theme ();
 
-    rmgr.update_network_settings ();
+    settings.update_network_settings ();
 
     // We provide specific terminal capabilities, so ensure that
     // TERM is always set appropriately.
@@ -965,8 +963,7 @@
     m_suppress_dbg_location
       = ! settings.value (cs_dbg_location).toBool ();
 
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-    rmgr.update_network_settings ();
+    settings.update_network_settings ();
 
     emit active_dock_changed (nullptr, m_active_dock); // update dock widget styles
 
--- a/libgui/src/module.mk	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/module.mk	Tue Dec 27 14:55:03 2022 -0500
@@ -301,7 +301,6 @@
   %reldir%/moc-color-picker.cc \
   %reldir%/moc-tab-bar.cc \
   %reldir%/moc-qt-interpreter-events.cc \
-  %reldir%/moc-resource-manager.cc \
   %reldir%/moc-shortcut-manager.cc \
   %reldir%/moc-welcome-wizard.cc \
   %reldir%/moc-workspace-model.cc \
@@ -383,7 +382,6 @@
   %reldir%/qt-interpreter-events.h \
   %reldir%/qt-utils.h \
   %reldir%/release-notes.h \
-  %reldir%/resource-manager.h \
   %reldir%/settings-dialog.h \
   %reldir%/shortcut-manager.h \
   %reldir%/tab-bar.h \
@@ -429,7 +427,6 @@
   %reldir%/qt-interpreter-events.cc \
   %reldir%/qt-application.cc \
   %reldir%/release-notes.cc \
-  %reldir%/resource-manager.cc \
   %reldir%/settings-dialog.cc \
   %reldir%/shortcut-manager.cc \
   %reldir%/tab-bar.cc \
--- a/libgui/src/octave-qobject.cc	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/octave-qobject.cc	Tue Dec 27 14:55:03 2022 -0500
@@ -54,7 +54,6 @@
 #include "qt-application.h"
 #include "qt-interpreter-events.h"
 #include "release-notes.h"
-#include "resource-manager.h"
 #include "shortcut-manager.h"
 #include "terminal-dock-widget.h"
 #include "variable-editor.h"
@@ -175,7 +174,6 @@
       m_argc (m_app_context.sys_argc ()),
       m_argv (m_app_context.sys_argv ()),
       m_qapplication (new octave_qapplication (m_argc, m_argv)),
-      m_resource_manager (),
       m_shortcut_manager (),
       m_qt_tr (new QTranslator ()),
       m_gui_tr (new QTranslator ()),
@@ -393,7 +391,9 @@
     if (m_translators_installed)
       return;
 
-    m_resource_manager.config_translators (m_qt_tr, m_qsci_tr, m_gui_tr);
+    gui_settings settings;
+
+    settings.config_translators (m_qt_tr, m_qsci_tr, m_gui_tr);
 
     m_qapplication->installTranslator (m_qt_tr);
     m_qapplication->installTranslator (m_gui_tr);
--- a/libgui/src/octave-qobject.h	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/octave-qobject.h	Tue Dec 27 14:55:03 2022 -0500
@@ -31,11 +31,11 @@
 #include <QApplication>
 #include <QList>
 #include <QObject>
+#include <QPointer>
 #include <QString>
 #include <QStringList>
 
 #include "interpreter-qobject.h"
-#include "resource-manager.h"
 #include "shortcut-manager.h"
 
 OCTAVE_BEGIN_NAMESPACE(octave)
@@ -136,11 +136,6 @@
     return m_main_window;
   }
 
-  resource_manager& get_resource_manager (void)
-  {
-    return m_resource_manager;
-  }
-
   shortcut_manager& get_shortcut_manager (void)
   {
     return m_shortcut_manager;
@@ -268,8 +263,6 @@
 
   octave_qapplication *m_qapplication;
 
-  resource_manager m_resource_manager;
-
   shortcut_manager m_shortcut_manager;
 
   QTranslator *m_qt_tr;
--- a/libgui/src/qt-interpreter-events.cc	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/qt-interpreter-events.cc	Tue Dec 27 14:55:03 2022 -0500
@@ -723,9 +723,9 @@
       {
         adjusted_value = adjusted_value.toUpper ();
 
+        gui_settings settings;
         QStringList codecs;
-        resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-        rmgr.get_codecs (&codecs);
+        settings.get_codecs (&codecs);
 
         QRegExp re ("^CP(\\d+)$");
 
--- a/libgui/src/resource-manager.cc	Mon Jan 02 16:46:01 2023 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,471 +0,0 @@
-////////////////////////////////////////////////////////////////////////
-//
-// Copyright (C) 2011-2022 The Octave Project Developers
-//
-// See the file COPYRIGHT.md in the top-level directory of this
-// distribution or <https://octave.org/copyright/>.
-//
-// This file is part of Octave.
-//
-// Octave is free software: you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Octave is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Octave; see the file COPYING.  If not, see
-// <https://www.gnu.org/licenses/>.
-//
-////////////////////////////////////////////////////////////////////////
-
-#if defined (HAVE_CONFIG_H)
-#  include "config.h"
-#endif
-
-#include <unistd.h>
-
-#include <algorithm>
-#include <array>
-#include <string>
-
-#include <QApplication>
-#include <QDir>
-#include <QFile>
-#include <QLibraryInfo>
-#include <QNetworkProxy>
-#include <QStandardPaths>
-
-#include <QTextCodec>
-
-#include "QTerminal.h"
-#include "gui-preferences-cs.h"
-#include "gui-preferences-ed.h"
-#include "gui-preferences-global.h"
-#include "gui-settings.h"
-#include "resource-manager.h"
-#include "variable-editor.h"
-#include "workspace-model.h"
-
-#include "file-ops.h"
-#include "localcharset-wrapper.h"
-#include "oct-env.h"
-
-#include "defaults.h"
-
-OCTAVE_BEGIN_NAMESPACE(octave)
-
-  resource_manager::resource_manager (void)
-    : m_temporary_files ()
-  { }
-
-  resource_manager::~resource_manager (void)
-  {
-    for (int i = m_temporary_files.count () - 1; i >=0; i--)
-      remove_tmp_file (m_temporary_files.at (i));
-  }
-
-  QString resource_manager::get_gui_translation_dir (void)
-  {
-    // get environment variable for the locale dir (e.g. from run-octave)
-    std::string dldir = sys::env::getenv ("OCTAVE_LOCALE_DIR");
-    if (dldir.empty ())
-      dldir = config::oct_locale_dir ();  // env-var empty, load the default location
-    return QString::fromStdString (dldir);
-  }
-
-  void resource_manager::config_translators (QTranslator *qt_tr,
-                                             QTranslator *qsci_tr,
-                                             QTranslator *gui_tr)
-  {
-    bool loaded;
-
-    QString qt_trans_dir
-      = QLibraryInfo::location (QLibraryInfo::TranslationsPath);
-
-    QString language = "SYSTEM";  // take system language per default
-
-    // FIXME: can we somehow ensure that the settings object will always
-    // be initialize and valid?
-
-    gui_settings settings;
-
-    // get the locale from the settings if already available
-    language = settings.value (global_language.key,
-                               global_language.def).toString ();
-
-    // load the translations depending on the settings
-    if (language == "SYSTEM")
-      {
-        // get the system locale and pass it to the translators for loading
-        // the suitable translation files
-        QLocale sys_locale = QLocale::system ();
-
-        qt_tr->load (sys_locale, "qt", "_", qt_trans_dir);
-        qsci_tr->load (sys_locale, "qscintilla", "_", qt_trans_dir);
-        gui_tr->load (sys_locale, "", "", get_gui_translation_dir ());
-      }
-    else
-      {
-        // load the translation files depending on the given locale name
-        loaded = qt_tr->load ("qt_" + language, qt_trans_dir);
-        if (! loaded)  // try lower case
-          qt_tr->load ("qt_" + language.toLower (), qt_trans_dir);
-
-        loaded = qsci_tr->load ("qscintilla_" + language, qt_trans_dir);
-        if (! loaded)  // try lower case
-          qsci_tr->load ("qscintilla_" + language.toLower (), qt_trans_dir);
-
-        gui_tr->load (language, get_gui_translation_dir ());
-      }
-
-  }
-
-#if defined (HAVE_QSCINTILLA)
-  int resource_manager::get_valid_lexer_styles (QsciLexer *lexer, int *styles)
-  {
-    int max_style = 0;
-    int actual_style = 0;
-    while (actual_style < ed_max_style_number && max_style < ed_max_lexer_styles)
-      {
-        if ((lexer->description (actual_style)) != "")  // valid style
-          styles[max_style++] = actual_style;
-        actual_style++;
-      }
-    return max_style;
-  }
-#endif
-
-  QFont resource_manager::copy_font_attributes (const QFont& attr,
-                                                const QFont& base) const
-  {
-    QFont dest (base);
-
-    dest.setBold (attr.bold ());
-    dest.setItalic (attr.italic ());
-    dest.setUnderline (attr.underline ());
-
-    return dest;
-  }
-
-#if defined (HAVE_QSCINTILLA)
-  void resource_manager::read_lexer_settings (QsciLexer *lexer,
-                                              int mode, int def)
-  {
-    gui_settings settings;
-
-    // Test whether the settings for lexer is already contained in the
-    // given gui settings file. If yes, load them, if not copy them from the
-    // default settings file.
-    // This is useful when a new language support is implemented and the
-    // existing settings file is used (which is of course the common case).
-    int m = mode;
-    if (m > 1)
-      m = 1;
-
-    QString group ("Scintilla" + settings_color_modes_ext[m]);
-
-    settings.beginGroup (group);
-    settings.beginGroup (lexer->language ());
-
-    QStringList lexer_keys = settings.allKeys ();
-
-    settings.endGroup ();
-    settings.endGroup ();
-
-    if (def == settings_reload_default_colors_flag || lexer_keys.count () == 0)
-      {
-        // We have to reload the default values or no Lexer keys found:
-        // If mode == 0, take all settings except font from default lexer
-        // If Mode == 1, take all settings except font from default lexer
-        //               and convert the color by inverting the lightness
-
-        // Get the default font
-        QStringList def_font = settings.get_default_font ();
-        QFont df (def_font[0], def_font[1].toInt ());
-        QFont dfa = copy_font_attributes (lexer->defaultFont (), df);
-        lexer->setDefaultFont (dfa);
-
-        QColor c, p;
-
-        int styles[ed_max_lexer_styles];  // array for saving valid styles
-        int max_style = get_valid_lexer_styles (lexer, styles);
-
-        for (int i = 0; i < max_style; i++)
-          {
-            c = settings.get_color_value (QVariant (lexer->color (styles[i])), m);
-            lexer->setColor (c, styles[i]);
-            p = settings.get_color_value (QVariant (lexer->paper (styles[i])), m);
-            lexer->setPaper (p, styles[i]);
-            dfa = copy_font_attributes (lexer->font (styles[i]), df);
-            lexer->setFont (dfa, styles[i]);
-          }
-        // Set defaults last for not changing the defaults of the styles
-        lexer->setDefaultColor (lexer->color (styles[0]));
-        lexer->setDefaultPaper (lexer->paper (styles[0]));
-
-        // Write settings if not just reload the default values
-        if (def != settings_reload_default_colors_flag)
-          {
-            const std::string group_str = group.toStdString ();
-            lexer->writeSettings (settings, group_str.c_str ());
-            settings.sync ();
-          }
-      }
-    else
-      {
-        // Found lexer keys, read the settings
-        const std::string group_str = group.toStdString ();
-        lexer->readSettings (settings, group_str.c_str ());
-      }
-  }
-#endif
-
-  bool resource_manager::update_settings_key (const QString& old_key,
-                                              const QString& new_key)
-  {
-    gui_settings settings;
-
-    if (settings.contains (old_key))
-      {
-        QVariant preference = settings.value (old_key);
-        settings.setValue (new_key, preference);
-        settings.remove (old_key);
-        return true;
-      }
-
-    return false;
-  }
-
-  void resource_manager::update_network_settings (void)
-  {
-    QNetworkProxy proxy;
-
-    // Assume no proxy and empty proxy data
-    QNetworkProxy::ProxyType proxy_type = QNetworkProxy::NoProxy;
-    QString scheme;
-    QString host;
-    int port = 0;
-    QString user;
-    QString pass;
-    QUrl proxy_url = QUrl ();
-
-    gui_settings settings;
-
-    if (settings.value (global_use_proxy.key, global_use_proxy.def).toBool ())
-      {
-        // Use a proxy, collect all required information
-        QString proxy_type_string
-          = settings.value (global_proxy_type.key, global_proxy_type.def).toString ();
-
-        // The proxy type for the Qt proxy settings
-        if (proxy_type_string == "Socks5Proxy")
-          proxy_type = QNetworkProxy::Socks5Proxy;
-        else if (proxy_type_string == "HttpProxy")
-          proxy_type = QNetworkProxy::HttpProxy;
-
-        // The proxy data from the settings
-        if (proxy_type_string == "HttpProxy"
-            || proxy_type_string == "Socks5Proxy")
-          {
-            host = settings.value (global_proxy_host.key,
-                                   global_proxy_host.def).toString ();
-            port = settings.value (global_proxy_port.key,
-                                   global_proxy_port.def).toInt ();
-            user = settings.value (global_proxy_user.key,
-                                   global_proxy_user.def).toString ();
-            pass = settings.value (global_proxy_pass.key,
-                                   global_proxy_pass.def).toString ();
-            if (proxy_type_string == "HttpProxy")
-              scheme = "http";
-            else if (proxy_type_string == "Socks5Proxy")
-              scheme = "socks5";
-
-            QUrl env_var_url = QUrl ();
-            proxy_url.setScheme (scheme);
-            proxy_url.setHost (host);
-            proxy_url.setPort (port);
-            if (! user.isEmpty ())
-              proxy_url.setUserName (user);
-            if (! pass.isEmpty ())
-              proxy_url.setPassword (pass);
-          }
-
-        // The proxy data from environment variables
-        if (proxy_type_string == global_proxy_all_types.at (2))
-          {
-            const std::array<std::string, 6> env_vars =
-            {
-              "ALL_PROXY", "all_proxy",
-              "HTTP_PROXY", "http_proxy",
-              "HTTPS_PROXY", "https_proxy"
-            };
-
-            unsigned int count = 0;
-            while (! proxy_url.isValid () && count < env_vars.size ())
-              {
-                proxy_url = QUrl (QString::fromStdString
-                                    (sys::env::getenv (env_vars[count])));
-                count++;
-              }
-
-            if (proxy_url.isValid ())
-              {
-                // Found an entry, get the data from the string
-                scheme = proxy_url.scheme ();
-
-                if (scheme.contains ("socks", Qt::CaseInsensitive))
-                  proxy_type = QNetworkProxy::Socks5Proxy;
-                else
-                  proxy_type = QNetworkProxy::HttpProxy;
-
-                host = proxy_url.host ();
-                port = proxy_url.port ();
-                user = proxy_url.userName ();
-                pass = proxy_url.password ();
-              }
-          }
-      }
-
-    // Set proxy for Qt framework
-    proxy.setType (proxy_type);
-    proxy.setHostName (host);
-    proxy.setPort (port);
-    proxy.setUser (user);
-    proxy.setPassword (pass);
-
-    QNetworkProxy::setApplicationProxy (proxy);
-
-    // Set proxy for curl library if not based on environment variables
-    std::string proxy_url_str = proxy_url.toString().toStdString ();
-    sys::env::putenv ("http_proxy", proxy_url_str);
-    sys::env::putenv ("HTTP_PROXY", proxy_url_str);
-    sys::env::putenv ("https_proxy", proxy_url_str);
-    sys::env::putenv ("HTTPS_PROXY", proxy_url_str);
-  }
-
-  // get a list of all available encodings
-  void resource_manager::get_codecs (QStringList *codecs)
-  {
-    // get the codec name for each mib
-    QList<int> all_mibs = QTextCodec::availableMibs ();
-    for (auto mib : all_mibs)
-      {
-        QTextCodec *c = QTextCodec::codecForMib (mib);
-        codecs->append (c->name ().toUpper ());
-      }
-
-    // Append SYSTEM
-    codecs->append (QString ("SYSTEM (") +
-                    QString (octave_locale_charset_wrapper ()).toUpper () +
-                    QString (")"));
-
-    // Clean up and sort list of codecs
-    codecs->removeDuplicates ();
-    std::sort (codecs->begin (), codecs->end ());
-  }
-
-  // initialize a given combo box with available text encodings
-  void resource_manager::combo_encoding (QComboBox *combo,
-                                         const QString& current)
-  {
-    QStringList all_codecs;
-    get_codecs (&all_codecs);
-
-    // get the value from the settings file if no current encoding is given
-    QString enc = current;
-
-    // Check for valid codec for the default.  If this fails, "SYSTEM" (i.e.
-    // locale_charset) will be chosen.
-    // FIXME: The default is "SYSTEM" on all platforms.  So can this fallback
-    // logic be removed completely?
-    bool default_exists = false;
-    bool show_system = false;
-    if (ed_default_enc.def.toString ().startsWith ("SYSTEM"))
-      show_system = true;
-    else if (QTextCodec::codecForName (ed_default_enc.def.toString ().toLatin1 ()))
-      default_exists = true;
-
-    QString default_enc =
-      QString ("SYSTEM (") +
-      QString (octave_locale_charset_wrapper ()).toUpper () + QString (")");
-
-    if (enc.isEmpty ())
-      {
-        gui_settings settings;
-
-        enc = settings.value (ed_default_enc).toString ();
-
-        if (enc.isEmpty ())  // still empty?
-          {
-            if (default_exists)
-              enc = ed_default_enc.def.toString ();
-            else
-              enc = default_enc;
-          }
-      }
-
-    // fill the combo box
-    for (const auto& c : all_codecs)
-      combo->addItem (c);
-
-    // prepend the default item
-    combo->insertSeparator (0);
-    if (show_system || ! default_exists)
-      combo->insertItem (0, default_enc);
-    else
-      combo->insertItem (0, ed_default_enc.def.toString ());
-
-    // select the default or the current one
-    int idx = combo->findText (enc, Qt::MatchExactly);
-    if (idx >= 0)
-      combo->setCurrentIndex (idx);
-    else
-      combo->setCurrentIndex (0);
-
-    combo->setMaxVisibleItems (12);
-  }
-
-  QPointer<QTemporaryFile>
-  resource_manager::create_tmp_file (const QString& extension,
-                                     const QString& contents)
-  {
-    QString ext = extension;
-    if ((! ext.isEmpty ()) && (! ext.startsWith ('.')))
-      ext = QString (".") + ext;
-
-    // Create octave dir within temp. dir
-    QString tmp_dir = QString::fromStdString (sys::env::get_temp_directory ());
-
-    // Create temp. file
-    QPointer<QTemporaryFile> tmp_file
-      = new QTemporaryFile (tmp_dir + QDir::separator() +
-                            "octave_XXXXXX" + ext, this);
-
-    if (tmp_file->open ())
-      {
-        tmp_file->write (contents.toUtf8 ());
-        tmp_file->close ();
-
-        m_temporary_files << tmp_file;
-      }
-
-    return tmp_file;
-  }
-
-  void resource_manager::remove_tmp_file (QPointer<QTemporaryFile> tmp_file)
-  {
-    if (tmp_file)
-      {
-        if (tmp_file->exists ())
-          tmp_file->remove ();
-
-        m_temporary_files.removeAll (tmp_file);
-      }
-  }
-
-OCTAVE_END_NAMESPACE(octave)
--- a/libgui/src/resource-manager.h	Mon Jan 02 16:46:01 2023 -0500
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,97 +0,0 @@
-////////////////////////////////////////////////////////////////////////
-//
-// Copyright (C) 2011-2022 The Octave Project Developers
-//
-// See the file COPYRIGHT.md in the top-level directory of this
-// distribution or <https://octave.org/copyright/>.
-//
-// This file is part of Octave.
-//
-// Octave is free software: you can redistribute it and/or modify it
-// under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// Octave is distributed in the hope that it will be useful, but
-// WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with Octave; see the file COPYING.  If not, see
-// <https://www.gnu.org/licenses/>.
-//
-////////////////////////////////////////////////////////////////////////
-
-#if ! defined (octave_resource_manager_h)
-#define octave_resource_manager_h 1
-
-#include <QComboBox>
-#include <QPointer>
-#if defined (HAVE_QSCINTILLA)
-#  include <Qsci/qscilexer.h>
-#endif
-#include <QTranslator>
-#include <QTemporaryFile>
-
-OCTAVE_BEGIN_NAMESPACE(octave)
-
-  class resource_manager : public QObject
-  {
-    Q_OBJECT
-
-  protected:
-
-  public:
-
-    resource_manager (void);
-
-    // No copying!
-
-    resource_manager (const resource_manager&) = delete;
-
-    resource_manager& operator = (const resource_manager&) = delete;
-
-    ~resource_manager ();
-
-    QString get_gui_translation_dir (void);
-
-    void config_translators (QTranslator *qt_tr, QTranslator *qsci_tr,
-                             QTranslator *gui_tr);
-
-    QPointer<QTemporaryFile>
-    create_tmp_file (const QString& extension = QString (),
-                     const QString& contents = QString ());
-
-    void remove_tmp_file (QPointer<QTemporaryFile> tmp_file);
-
-#if defined (HAVE_QSCINTILLA)
-    int get_valid_lexer_styles (QsciLexer *lexer, int *styles);
-    void read_lexer_settings (QsciLexer *lexer, int mode = 0, int def = 0);
-#endif
-
-    bool update_settings_key (const QString& new_key, const QString& old_key);
-
-    void update_network_settings (void);
-
-    void get_codecs (QStringList *codecs);
-
-    void combo_encoding (QComboBox *combo, const QString& current = QString ());
-
-  private:
-
-    /*!
-     * Copys the attributes bold, italic and underline from QFont
-     * @p attr to the font @p base and returns the result without
-     * changing @p base,
-     * @param attr QFont with the desired attributes
-     * @param base QFont with desired family and size
-    */
-    QFont copy_font_attributes (const QFont& attr, const QFont& base) const;
-
-    QList<QTemporaryFile *> m_temporary_files;
-  };
-
-OCTAVE_END_NAMESPACE(octave)
-
-#endif
--- a/libgui/src/settings-dialog.cc	Mon Jan 02 16:46:01 2023 -0500
+++ b/libgui/src/settings-dialog.cc	Tue Dec 27 14:55:03 2022 -0500
@@ -64,6 +64,7 @@
 #endif
 
 #include "gui-preferences-all.h"
+#include "gui-settings.h"
 #include "octave-qobject.h"
 #include "octave-qtutils.h"
 #include "settings-dialog.h"
@@ -81,8 +82,7 @@
     gui_settings settings;
 
     // look for available language files and the actual settings
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-    QString qm_dir_name = rmgr.get_gui_translation_dir ();
+    QString qm_dir_name = settings.get_gui_translation_dir ();
 
     QDir qm_dir (qm_dir_name);
     QFileInfoList qm_files = qm_dir.entryInfoList (QStringList ("*.qm"),
@@ -233,7 +233,7 @@
     editor_showLineNumbers->setChecked (settings.value (ed_show_line_numbers).toBool ());
     editor_linenr_size->setValue (settings.value (ed_line_numbers_size).toInt ());
 
-    rmgr.combo_encoding (editor_combo_encoding);
+    settings.combo_encoding (editor_combo_encoding);
 
     editor_highlightCurrentLine->setChecked (settings.value (ed_highlight_current_line).toBool ());
     editor_long_line_marker->setChecked (settings.value (ed_long_line_marker).toBool ());
@@ -505,12 +505,10 @@
 
   void settings_dialog::show_tab (const QString& tab)
   {
+    gui_settings settings;
+
     if (tab.isEmpty ())
-      {
-        gui_settings settings;
-
-        tabWidget->setCurrentIndex (settings.value (sd_last_tab).toInt ());
-      }
+      tabWidget->setCurrentIndex (settings.value (sd_last_tab).toInt ());
     else
       {
         QHash <QString, QWidget *> tab_hash;
@@ -643,8 +641,6 @@
   {
 #if defined (HAVE_QSCINTILLA)
 
-    gui_settings settings;
-
     QCheckBox *cb_color_mode
       = group_box_editor_styles->findChild <QCheckBox *> (ed_color_mode.key);
 
@@ -655,6 +651,8 @@
     color_picker *c_picker = findChild <color_picker *> (ed_highlight_current_line_color.key);
     if (c_picker)
       {
+        gui_settings settings;
+
         if (def != settings_reload_default_colors_flag)
           {
             // Get current value from settings or the default
@@ -722,8 +720,8 @@
   {
     // Get lexer settings and copy from default settings if not yet
     // available in normal settings file
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-    rmgr.read_lexer_settings (lexer, mode, def);
+    gui_settings settings;
+    settings.read_lexer_settings (lexer, mode, def);
 
     // When reloading default styles, the style tabs do already exists.
     // Otherwise, check if they exist or not.
@@ -749,7 +747,7 @@
 
     // Update the styles elements in all styles
     int styles[ed_max_lexer_styles];  // array for saving valid styles
-    int max_style = rmgr.get_valid_lexer_styles (lexer, styles);
+    int max_style = settings.get_valid_lexer_styles (lexer, styles);
     QWidget *tab = tabs_editor_lexers->widget (index);
     int default_size = 0;
     QString default_family;
@@ -822,11 +820,11 @@
 
   void settings_dialog::get_lexer_settings (QsciLexer *lexer)
   {
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
+    gui_settings settings;
 
     int styles[ed_max_lexer_styles];  // array for saving valid styles
     // (enum is not continuous)
-    int max_style = rmgr.get_valid_lexer_styles (lexer, styles);
+    int max_style = settings.get_valid_lexer_styles (lexer, styles);
     QGridLayout *style_grid = new QGridLayout ();
     QVector<QLabel *> description (max_style);
     QVector<QFontComboBox *> select_font (max_style);
@@ -910,8 +908,6 @@
     scroll_area->setWidget (scroll_area_contents);
     tabs_editor_lexers->addTab (scroll_area, lexer->language ());
 
-    gui_settings settings;
-
     tabs_editor_lexers->setCurrentIndex (settings.value (sd_last_editor_styles_tab).toInt ());
   }
 
@@ -932,8 +928,7 @@
     int styles[ed_max_lexer_styles];  // array for saving valid styles
     // (enum is not continuous)
 
-    resource_manager& rmgr = m_octave_qobj.get_resource_manager ();
-    int max_style = rmgr.get_valid_lexer_styles (lexer, styles);
+    int max_style = settings.get_valid_lexer_styles (lexer, styles);
 
     QFontComboBox *select_font;
     QSpinBox *font_size;