From 321ddd6c8a1142bc483060b8ae46f9ea094f0862 Mon Sep 17 00:00:00 2001 From: Jean-Marc Lasgouttes Date: Fri, 19 Jul 2019 17:23:20 +0200 Subject: [PATCH] Add a pref to disable OS keyboard language support 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 | 2 +- lib/scripts/prefs2prefs_prefs.py | 13 +++++++++---- src/Cursor.cpp | 2 ++ src/LyXRC.cpp | 20 +++++++++++++++++++- src/LyXRC.h | 3 +++ src/frontends/qt4/GuiPrefs.cpp | 4 ++++ src/frontends/qt4/ui/PrefLanguageUi.ui | 16 ++++++++++++++-- 7 files changed, 52 insertions(+), 8 deletions(-) diff --git a/lib/configure.py b/lib/configure.py index ac3b15f0a7..a8a0da6bb3 100644 --- a/lib/configure.py +++ b/lib/configure.py @@ -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 = '' diff --git a/lib/scripts/prefs2prefs_prefs.py b/lib/scripts/prefs2prefs_prefs.py index 0679072376..a3665b634e 100644 --- a/lib/scripts/prefs2prefs_prefs.py +++ b/lib/scripts/prefs2prefs_prefs.py @@ -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 @@ -117,6 +117,10 @@ # 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, []] ] diff --git a/src/Cursor.cpp b/src/Cursor.cpp index 947eeb1d53..431aa16c5a 100644 --- a/src/Cursor.cpp +++ b/src/Cursor.cpp @@ -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) { diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index cfd296a985..55efe9c7ca 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -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(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(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; diff --git a/src/LyXRC.h b/src/LyXRC.h index ab6a590d20..ba5020cf20 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -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"; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 82073bcbe7..9af8ea4c55 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -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); diff --git a/src/frontends/qt4/ui/PrefLanguageUi.ui b/src/frontends/qt4/ui/PrefLanguageUi.ui index 5e7a03fa98..63616c8050 100644 --- a/src/frontends/qt4/ui/PrefLanguageUi.ui +++ b/src/frontends/qt4/ui/PrefLanguageUi.ui @@ -208,7 +208,17 @@ - + + + + Select to use the current keyboard language, as set from the operating system, as default input language. + + + Respect &OS keyboard language + + + + @@ -276,7 +286,7 @@ - + Qt::Vertical @@ -301,10 +311,12 @@ startCommandED endCommandED defaultDecimalPointLE + defaultLengthUnitCO globalCB autoBeginCB autoEndCB markForeignCB + respectOSkbdCB logicalCursorRB visualCursorRB -- 2.39.5