From: Stephan Witt Date: Thu, 11 Aug 2011 11:25:01 +0000 (+0000) Subject: Backport of r39360, r39361 and r39363: X-Git-Tag: 2.0.1~32 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=91eb9c8c68329342bb9c7d8cb0351943819fe0fc;p=features.git Backport of r39360, r39361 and r39363: - move spellchecker backend change action to actOnUpdatedPrefs where it belongs to - add missing action for change of spellchecker_accept_compound preference - care for a change of accept_compound and reconfigure the aspell backend accordingly - only aspell is using spellchecker_accept_compound rc variable git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@39471 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/AspellChecker.cpp b/src/AspellChecker.cpp index 284bcace70..62eb29f6d7 100644 --- a/src/AspellChecker.cpp +++ b/src/AspellChecker.cpp @@ -41,6 +41,7 @@ namespace { struct Speller { AspellConfig * config; AspellCanHaveError * e_speller; + bool accept_compound; docstring_list ignored_words_; }; @@ -255,6 +256,7 @@ AspellSpeller * AspellChecker::Private::addSpeller(Language const * lang) // Report run-together words as errors aspell_config_replace(m.config, "run-together", "false"); + m.accept_compound = lyxrc.spellchecker_accept_compound; m.e_speller = new_aspell_speller(m.config); if (aspell_error_number(m.e_speller) != 0) { // FIXME: We should indicate somehow that this language is not supported. @@ -278,9 +280,25 @@ AspellSpeller * AspellChecker::Private::addSpeller(Language const * lang) AspellSpeller * AspellChecker::Private::speller(Language const * lang) { Spellers::iterator it = spellers_.find(lang->lang()); - if (it != spellers_.end()) - return to_aspell_speller(it->second.e_speller); - + if (it != spellers_.end()) { + Speller aspell = it->second; + if (lyxrc.spellchecker_accept_compound != aspell.accept_compound) { + // spell checker setting changed... adjust run-together + aspell.accept_compound = lyxrc.spellchecker_accept_compound; + if (aspell.accept_compound) + // Consider run-together words as legal compounds + aspell_config_replace(aspell.config, "run-together", "true"); + else + // Report run-together words as errors + aspell_config_replace(aspell.config, "run-together", "false"); + AspellCanHaveError * e_speller = aspell.e_speller; + aspell.e_speller = new_aspell_speller(aspell.config); + delete_aspell_speller(to_aspell_speller(e_speller)); + spellers_[lang->lang()] = aspell; + } + return to_aspell_speller(aspell.e_speller); + } + return addSpeller(lang); } diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index 1d7b3c3d8e..4211685313 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -26,6 +26,7 @@ #include "LyX.h" #include "Mover.h" #include "Session.h" +#include "SpellChecker.h" #include "version.h" #include "graphics/GraphicsTypes.h" @@ -2903,6 +2904,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) switch (tag) { case LyXRC::RC_LAST: case LyXRC::RC_ACCEPT_COMPOUND: + if (lyxrc_orig.spellchecker_accept_compound != lyxrc_new.spellchecker_accept_compound) + if (theSpellChecker()) theSpellChecker()->advanceChangeNumber(); case LyXRC::RC_ALT_LANG: case LyXRC::RC_PLAINTEXT_LINELEN: case LyXRC::RC_AUTOCORRECTION_MATH: @@ -3024,6 +3027,8 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_SHOW_BANNER: case LyXRC::RC_OPEN_BUFFERS_IN_TABS: case LyXRC::RC_SPELLCHECKER: + if (lyxrc_orig.spellchecker != lyxrc_new.spellchecker) + setSpellChecker(); case LyXRC::RC_SPELLCHECK_CONTINUOUSLY: case LyXRC::RC_SPELLCHECK_NOTES: case LyXRC::RC_SPLITINDEX_COMMAND: diff --git a/src/frontends/qt4/GuiApplication.cpp b/src/frontends/qt4/GuiApplication.cpp index fa31c5c468..ed60ecc18b 100644 --- a/src/frontends/qt4/GuiApplication.cpp +++ b/src/frontends/qt4/GuiApplication.cpp @@ -1439,7 +1439,6 @@ void GuiApplication::dispatch(FuncRequest const & cmd, DispatchResult & dr) } actOnUpdatedPrefs(lyxrc_orig, lyxrc); - setSpellChecker(); resetGui(); break; diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 51494fb44d..e4939a9057 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1526,7 +1526,7 @@ void PrefSpellchecker::on_spellcheckerCB_currentIndexChanged(int index) { QString spellchecker = spellcheckerCB->itemData(index).toString(); - compoundWordCB->setEnabled(spellchecker != QString("native")); + compoundWordCB->setEnabled(spellchecker == QString("aspell")); } diff --git a/status.20x b/status.20x index 64e7b15d79..fa24103429 100644 --- a/status.20x +++ b/status.20x @@ -60,6 +60,9 @@ What's new - Sort entries in the "More Formats and Options" dialog (bug 7714). +- Enable "Accept compound" preference setting for Aspell backend only. + Reconfigure the aspell backend when "Accept compound" preference is + changed immediately. * DOCUMENTATION AND LOCALIZATION