changeset 27270:47f42ad90b0b

Restore mfile_encoding on startup from GUI settings. * main-window.cc (update_default_encoding): New function. (handle_octave_ready): Post mfile_encoding to interpreter when it is ready. (notice_settings): Use new function.
author Markus Mützel <markus.muetzel@gmx.de>
date Sat, 20 Jul 2019 17:57:23 +0200
parents 6a6b5ae3d58d
children a4416cd6bb4f
files libgui/src/main-window.cc libgui/src/main-window.h
diffstat 2 files changed, 29 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Sat Jul 20 17:08:11 2019 +0200
+++ b/libgui/src/main-window.cc	Sat Jul 20 17:57:23 2019 +0200
@@ -884,28 +884,11 @@
     set_global_shortcuts (m_active_dock == m_command_window);
     disable_menu_shortcuts (m_active_dock == m_editor_window);
 
-    // Ckeck whether some octave internal preferences have to be updated
+    // Check whether some octave internal preferences have to be updated
     QString new_default_encoding
       = settings->value (ed_default_enc.key, ed_default_enc.def).toString ();
     if (new_default_encoding != m_default_encoding)
-      {
-        m_default_encoding = new_default_encoding;
-
-        event_manager& evmgr
-          = __get_event_manager__ ("main_window::notice_settings");
-
-        evmgr.post_event
-          ([this] (void)
-           {
-             // INTERPRETER THREAD
-
-             interpreter& interp
-               = __get_interpreter__ ("main_window::notice_settings");
-
-             F__mfile_encoding__ (interp,
-                                  ovl (m_default_encoding.toStdString ()));
-           });
-      }
+      update_default_encoding (new_default_encoding);
 
     // Set cursor blinking depending on the settings
     // Cursor blinking: consider old terminal related setting if not yet set
@@ -1699,6 +1682,10 @@
             startup_dir
               = QDir (settings->value ("octave_startup_dir").toString ());
           }
+
+        update_default_encoding
+          (settings->value (ed_default_enc.key,
+                            ed_default_enc.def).toString ());
       }
 
     if (! startup_dir.exists ())
@@ -2864,4 +2851,25 @@
     list.append (static_cast<octave_dock_widget *> (m_variable_editor_window));
     return list;
   }
+
+  void main_window::update_default_encoding (const QString& default_encoding)
+  {
+    m_default_encoding = default_encoding;
+
+    event_manager& evmgr
+      = __get_event_manager__ ("main_window::notice_settings");
+
+    evmgr.post_event
+      ([this] (void)
+       {
+         // INTERPRETER THREAD
+
+         interpreter& interp
+           = __get_interpreter__ ("main_window::notice_settings");
+
+         F__mfile_encoding__ (interp,
+                              ovl (m_default_encoding.toStdString ()));
+       });
+  }
+
 }
--- a/libgui/src/main-window.h	Sat Jul 20 17:08:11 2019 +0200
+++ b/libgui/src/main-window.h	Sat Jul 20 17:57:23 2019 +0200
@@ -279,6 +279,8 @@
     void configure_shortcuts (void);
 
     QList<octave_dock_widget *> dock_widget_list (void);
+    
+    void update_default_encoding (const QString& default_encoding);
 
     base_qobject& m_octave_qobj;