diff libgui/src/main-window.cc @ 25702:bd30c6f8cfb7

update internal __mfile_encoding__ when gui default encoding changes (bug #54310) * gui-preferences.h: define constants for editor default encoding prefs * main-window.cc (main_window): initialize new class variable storing the default encoding; (notice_settings): check for changes in default encoding and update __mfile_encoding__ via worker thread if required; (gui_preference_adjust): use constants for pref key; * main-window.h: new class variable storing the default encoding * resource-manager.cc: include gui-preferences.h; (do_combo_encoding): use constants for key and default of encoding
author Torsten <mttl@mailbox.org>
date Sun, 29 Jul 2018 12:57:07 +0200
parents ba8227df92ae
children 7b4e99fbe9d4
line wrap: on
line diff
--- a/libgui/src/main-window.cc	Sun Jul 29 11:30:33 2018 +0200
+++ b/libgui/src/main-window.cc	Sun Jul 29 12:57:07 2018 +0200
@@ -211,6 +211,8 @@
           = settings->value ("news/last_time_checked", QDateTime ()).toDateTime ();
 
         serial = settings->value ("news/last_news_item", 0).toInt ();
+        m_default_encoding = settings->value (ed_default_enc.key,
+                                              ed_default_enc.def).toString ();
       }
 
     QDateTime current = QDateTime::currentDateTime ();
@@ -758,6 +760,17 @@
     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
+    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;
+        octave_cmd_builtin *cmd = new octave_cmd_builtin (
+                                    &F__mfile_encoding__,
+                                    ovl (m_default_encoding.toStdString ()));
+        m_cmd_queue.add_cmd (cmd);
+      }
 
     // Set cursor blinking depending on the settings
     // Cursor blinking: consider old terminal related setting if not yet set
@@ -2503,7 +2516,7 @@
 
     // Not all encodings are available. Encodings are uppercase and do not
     // use CPxxx but IBMxxx or WINDOWS-xxx.
-    if (key == "editor/default_encoding")
+    if (key == ed_default_enc.key)
       {
         adjusted_value = adjusted_value.toUpper ();