]> git.lyx.org Git - features.git/commitdiff
Add a pref to disable OS keyboard language support
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 19 Jul 2019 15:23:20 +0000 (17:23 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:37 +0000 (15:48 +0200)
By default, the behavior is the same as before, except that the
language of new document is not unconditionally en_US anymore.

The new checkbox "Respect OS keyboard language" (off by default)
governs this behavior.

Update prefs format to 30.

lib/configure.py
lib/scripts/prefs2prefs_prefs.py
src/Cursor.cpp
src/LyXRC.cpp
src/LyXRC.h
src/frontends/qt4/GuiPrefs.cpp
src/frontends/qt4/ui/PrefLanguageUi.ui

index ac3b15f0a70e2002853fd1d7e77762d96854aed5..a8a0da6bb378437960f2b703a973916f6f55c3a7 100644 (file)
@@ -1799,7 +1799,7 @@ if __name__ == '__main__':
     lyx_check_config = True
     lyx_kpsewhich = True
     outfile = 'lyxrc.defaults'
-    lyxrc_fileformat = 29
+    lyxrc_fileformat = 30
     rc_entries = ''
     lyx_keep_temps = False
     version_suffix = ''
index 06790723768a21f8a368ae934f2fe6b90201310b..a3665b634e0b833f7060a2085907f2cd4f2017ac 100644 (file)
@@ -10,9 +10,9 @@
 
 # This file houses conversion information for the preferences file.
 
-# The converter functions take a line as argument and return a list: 
-#      (Bool, NewLine), 
-# where the Bool says if  we've modified anything and the NewLine is 
+# The converter functions take a line as argument and return a list:
+#      (Bool, NewLine),
+# where the Bool says if  we've modified anything and the NewLine is
 # the new line, if so, which will be used to replace the old line.
 
 # Incremented to format 2, r39670 by jrioux
 # Incremented to format 29, by lasgouttes
 #   Remove use_pixmap_cache
 
+# Incremented to format 30, by lasgouttes
+#   Add respect_os_kbd_language.
+#   No convergence necessary.
+
 # NOTE: The format should also be updated in LYXRC.cpp and
 # in configure.py.
 
@@ -464,5 +468,6 @@ conversions = [
        [ 26, [remove_font_encoding]],
        [ 27, []],
        [ 28, [remove_date_insert_format]],
-       [ 29, [remove_use_pixmap_cache]]
+       [ 29, [remove_use_pixmap_cache]],
+       [ 30, []]
 ]
index 947eeb1d536dd9141a9b59dfe74ce0a6d5677656..431aa16c5aafc9ccba35873d970ffd6637b102f1 100644 (file)
@@ -2401,6 +2401,8 @@ bool notifyCursorLeavesOrEnters(Cursor const & old, Cursor & cur)
 
 void Cursor::setLanguageFromInput()
 {
+       if (!lyxrc.respect_os_kbd_language)
+               return;
        string const & code = theApp()->inputLanguageCode();
        Language const * lang = languages.getFromCode(code, buffer()->getLanguages());
        if (lang) {
index cfd296a9858ed17f803a4f6b972221558d4132d9..55efe9c7cade62811393853aea2e7ee3e29220bd 100644 (file)
@@ -61,7 +61,7 @@ namespace {
 
 // The format should also be updated in configure.py, and conversion code
 // should be added to prefs2prefs_prefs.py.
-static unsigned int const LYXRC_FILEFORMAT = 29; // spitz: remove \\date_insert_format
+static unsigned int const LYXRC_FILEFORMAT = 30; // lasgouttes: add \respect_os_kbd_language
 // when adding something to this array keep it sorted!
 LexerKeyword lyxrcTags[] = {
        { "\\accept_compound", LyXRC::RC_ACCEPT_COMPOUND },
@@ -159,6 +159,7 @@ LexerKeyword lyxrcTags[] = {
        { "\\print_paper_dimension_flag", LyXRC::RC_PRINTPAPERDIMENSIONFLAG },
        { "\\print_paper_flag", LyXRC::RC_PRINTPAPERFLAG },
        { "\\pygmentize_command", LyXRC::RC_PYGMENTIZE_COMMAND },
+       { "\\respect_os_kbd_language", LyXRC::RC_RESPECT_OS_KBD_LANGUAGE },
        { "\\save_compressed", LyXRC::RC_SAVE_COMPRESSED },
        { "\\save_origin", LyXRC::RC_SAVE_ORIGIN },
        { "\\screen_dpi", LyXRC::RC_SCREEN_DPI },
@@ -797,6 +798,9 @@ LyXRC::ReturnValues LyXRC::read(Lexer & lexrc, bool check_format)
                case RC_LANGUAGE_COMMAND_LOCAL:
                        lexrc >> language_command_local;
                        break;
+               case RC_RESPECT_OS_KBD_LANGUAGE:
+                       lexrc >> respect_os_kbd_language;
+                       break;
                case RC_VISUAL_CURSOR:
                        lexrc >> visual_cursor;
                        break;
@@ -2421,6 +2425,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
                        os << "\\mark_foreign_language " <<
                                convert<string>(mark_foreign_language) << '\n';
                }
+               // fall through
+       case RC_RESPECT_OS_KBD_LANGUAGE:
+               if (ignore_system_lyxrc ||
+                   respect_os_kbd_language
+                   != system_lyxrc.respect_os_kbd_language) {
+                       os << "\\respect_os_kbd_language " <<
+                               convert<string>(respect_os_kbd_language) << '\n';
+               }
+               //fall through
                if (tag != RC_LAST)
                        break;
 
@@ -2778,6 +2791,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
        case LyXRC::RC_MACRO_EDIT_STYLE:
        case LyXRC::RC_MAKE_BACKUP:
        case LyXRC::RC_MARK_FOREIGN_LANGUAGE:
+       case LyXRC::RC_RESPECT_OS_KBD_LANGUAGE:
        case LyXRC::RC_MOUSE_WHEEL_SPEED:
        case LyXRC::RC_MOUSE_MIDDLEBUTTON_PASTE:
        case LyXRC::RC_NUMLASTFILES:
@@ -3099,6 +3113,10 @@ string const LyXRC::getDescription(LyXRCTags tag)
                str = _("Select to control the highlighting of words with a language foreign to that of the document.");
                break;
 
+       case RC_RESPECT_OS_KBD_LANGUAGE:
+               str = _("Select to use the current keyboard language, as set from the operating system, as default input language.");
+               break;
+
        case RC_MOUSE_WHEEL_SPEED:
                str = _("The scrolling speed of the mouse wheel.");
                break;
index ab6a590d20fd8d5fa4004ba0e82e05146f70c10f..ba5020cf20b370e6241f75a95b3a0abf04a610e5 100644 (file)
@@ -135,6 +135,7 @@ public:
                RC_PRINTPAPERDIMENSIONFLAG,
                RC_PRINTPAPERFLAG,
                RC_PYGMENTIZE_COMMAND,
+               RC_RESPECT_OS_KBD_LANGUAGE,
                RC_SAVE_COMPRESSED,
                RC_SAVE_ORIGIN,
                RC_SCREEN_DPI,
@@ -399,6 +400,8 @@ public:
        ///
        std::string gui_language = "auto";
        ///
+       bool respect_os_kbd_language = false;
+       ///
        std::string default_otf_view_format = "pdf4";
        ///
        std::string default_platex_view_format = "pdf3";
index 82073bcbe7cbb07e6d9786e6b31184e6ecec89a6..9af8ea4c552b1d38faf077aa0921dc515d277201 100644 (file)
@@ -2394,6 +2394,8 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
                this, SIGNAL(changed()));
        connect(markForeignCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
+       connect(respectOSkbdCB, SIGNAL(clicked()),
+               this, SIGNAL(changed()));
        connect(autoBeginCB, SIGNAL(clicked()),
                this, SIGNAL(changed()));
        connect(autoEndCB, SIGNAL(clicked()),
@@ -2469,6 +2471,7 @@ void PrefLanguage::applyRC(LyXRC & rc) const
 {
        rc.visual_cursor = visualCursorRB->isChecked();
        rc.mark_foreign_language = markForeignCB->isChecked();
+       rc.respect_os_kbd_language = respectOSkbdCB->isChecked();
        rc.language_auto_begin = autoBeginCB->isChecked();
        rc.language_auto_end = autoEndCB->isChecked();
        int const p = languagePackageCO->currentIndex();
@@ -2498,6 +2501,7 @@ void PrefLanguage::updateRC(LyXRC const & rc)
        else
                logicalCursorRB->setChecked(true);
        markForeignCB->setChecked(rc.mark_foreign_language);
+       respectOSkbdCB->setChecked(rc.respect_os_kbd_language);
        autoBeginCB->setChecked(rc.language_auto_begin);
        autoEndCB->setChecked(rc.language_auto_end);
        languagePackageCO->setCurrentIndex(rc.language_package_selection);
index 5e7a03fa98c17782b41cb34397b5306316092a2a..63616c8050aef8e11a70c89d78c7d8e4de1e1f48 100644 (file)
      </property>
     </widget>
    </item>
-   <item row="10" column="0" colspan="3">
+   <item row="10" column="0" colspan="2">
+    <widget class="QCheckBox" name="respectOSkbdCB">
+     <property name="toolTip">
+      <string>Select to use the current keyboard language, as set from the operating system, as default input language.</string>
+     </property>
+     <property name="text">
+      <string>Respect &amp;OS keyboard language</string>
+     </property>
+    </widget>
+   </item>
+   <item row="11" column="0" colspan="3">
     <widget class="QGroupBox" name="rtlGB2">
      <property name="toolTip">
       <string/>
      </layout>
     </widget>
    </item>
-   <item row="11" column="0">
+   <item row="12" column="0">
     <spacer>
      <property name="orientation">
       <enum>Qt::Vertical</enum>
   <tabstop>startCommandED</tabstop>
   <tabstop>endCommandED</tabstop>
   <tabstop>defaultDecimalPointLE</tabstop>
+  <tabstop>defaultLengthUnitCO</tabstop>
   <tabstop>globalCB</tabstop>
   <tabstop>autoBeginCB</tabstop>
   <tabstop>autoEndCB</tabstop>
   <tabstop>markForeignCB</tabstop>
+  <tabstop>respectOSkbdCB</tabstop>
   <tabstop>logicalCursorRB</tabstop>
   <tabstop>visualCursorRB</tabstop>
  </tabstops>