Mercurial > octave
diff libgui/src/resource-manager.cc @ 27271:a4416cd6bb4f
Append name of actual encoding used if "SYSTEM" is selected.
* gui-preferences.h: Add name of actual encoding used for "SYSTEM".
* resource-manager.cc (do_get_codecs, do_combo_encoding): Add name of actual
encoding used for "SYSTEM".
* file-editor-tab.cc (file_editor_tab): Add name of actual encoding used for
"SYSTEM".
(check_valid_codec): Check if _encoding starts with "SYSTEM".
* main-window.cc (gui_preference_adjust): Add name of actual encoding used for
"SYSTEM".
(update_default_encoding): Strip actual encoding from "SYSTEM" before passing
it to F__mfile_encoding__.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Sun, 21 Jul 2019 12:16:09 +0200 |
parents | 3ed8955dcdf9 |
children | 9de4741a896e |
line wrap: on
line diff
--- a/libgui/src/resource-manager.cc Sat Jul 20 17:57:23 2019 +0200 +++ b/libgui/src/resource-manager.cc Sun Jul 21 12:16:09 2019 +0200 @@ -421,9 +421,10 @@ codecs->append (c->name ().toUpper ()); } - // If on windows append SYSTEM even if not supported - if (ed_default_enc.def.toString () == "SYSTEM") - codecs->append (ed_default_enc.def.toString ()); + // If on Windows, append "SYSTEM" + if (ed_default_enc.def.toString ().startsWith("SYSTEM")) + codecs->append (QTextCodec::codecForLocale ()->name ().toUpper ().prepend + ("SYSTEM (").append (")")); // Clean up and sort list of codecs codecs->removeDuplicates (); @@ -439,13 +440,16 @@ // get the value from the settings file if no current encoding is given QString enc = current; - // Check for valid codec for the default. Allow "SYSTEM" even no valid - // codec exists, since codecForLocale will be chosen in this case + // Check for valid codec for the default. If this fails, "SYSTEM" (i.e. + // codecForLocale) will be chosen. bool default_exists = false; if (QTextCodec::codecForName (ed_default_enc.def.toString ().toLatin1 ()) - || (ed_default_enc.def.toString () == "SYSTEM")) + || (ed_default_enc.def.toString ().startsWith ("SYSTEM"))) default_exists = true; + QString default_enc = + QTextCodec::codecForLocale ()->name ().toUpper ().prepend + ("SYSTEM (").append (")"); if (enc.isEmpty ()) { enc = m_settings->value (ed_default_enc.key, ed_default_enc.def).toString (); @@ -455,7 +459,7 @@ if (default_exists) enc = ed_default_enc.def.toString (); else - enc = QTextCodec::codecForLocale ()->name ().toUpper (); + enc = default_enc; } } @@ -468,7 +472,7 @@ if (default_exists) combo->insertItem (0, ed_default_enc.def.toString ()); else - combo->insertItem (0, QTextCodec::codecForLocale ()->name ().toUpper ()); + combo->insertItem (0, default_enc); // select the default or the current one int idx = combo->findText (enc, Qt::MatchExactly);