From bd57d5ea563c2ae6327fe3026c6c9748fefb1af9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Spitzm=C3=BCller?= Date: Sat, 13 Feb 2010 16:22:39 +0000 Subject: [PATCH] * add pref option to exclude notes and comments from spell checking (bug 1509). git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@33468 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/LyXRC.cpp | 15 +++ src/LyXRC.h | 3 + src/frontends/qt4/GuiPrefs.cpp | 5 + src/frontends/qt4/ui/PrefSpellcheckerUi.ui | 146 +++++++++++---------- src/insets/InsetNote.cpp | 6 + src/insets/InsetNote.h | 2 + 6 files changed, 109 insertions(+), 68 deletions(-) diff --git a/src/LyXRC.cpp b/src/LyXRC.cpp index ece84acc8e..b320d9c316 100644 --- a/src/LyXRC.cpp +++ b/src/LyXRC.cpp @@ -174,6 +174,7 @@ LexerKeyword lyxrcTags[] = { { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS }, { "\\spell_command", LyXRC::RC_SPELL_COMMAND }, { "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY }, + { "\\spellcheck_notes", LyXRC::RC_SPELLCHECK_NOTES }, { "\\spellchecker", LyXRC::RC_SPELLCHECKER }, { "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND }, { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH }, @@ -286,6 +287,7 @@ void LyXRC::setDefaults() #endif spellchecker_accept_compound = false; spellcheck_continuously = false; + spellcheck_notes = true; use_kbmap = false; rtl_support = true; visual_cursor = false; @@ -915,6 +917,9 @@ int LyXRC::read(Lexer & lexrc) case RC_SPELLCHECK_CONTINUOUSLY: lexrc >> spellcheck_continuously; break; + case RC_SPELLCHECK_NOTES: + lexrc >> spellcheck_notes; + break; case RC_MAKE_BACKUP: lexrc >> make_backup; break; @@ -2333,6 +2338,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c if (tag != RC_LAST) break; + case RC_SPELLCHECK_NOTES: + if (ignore_system_lyxrc || + spellcheck_notes != system_lyxrc.spellcheck_notes) { + os << "\\spellcheck_notes " << convert(spellcheck_notes) + << '\n'; + } + if (tag != RC_LAST) + break; + case RC_RTL_SUPPORT: if (ignore_system_lyxrc || rtl_support != system_lyxrc.rtl_support) { @@ -2755,6 +2769,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new) case LyXRC::RC_SPELL_COMMAND: case LyXRC::RC_SPELLCHECKER: case LyXRC::RC_SPELLCHECK_CONTINUOUSLY: + case LyXRC::RC_SPELLCHECK_NOTES: case LyXRC::RC_SPLITINDEX_COMMAND: case LyXRC::RC_TEMPDIRPATH: case LyXRC::RC_TEMPLATEPATH: diff --git a/src/LyXRC.h b/src/LyXRC.h index af28ce0129..3847f96c78 100644 --- a/src/LyXRC.h +++ b/src/LyXRC.h @@ -159,6 +159,7 @@ public: RC_SORT_LAYOUTS, RC_SPELL_COMMAND, RC_SPELLCHECK_CONTINUOUSLY, + RC_SPELLCHECK_NOTES, RC_SPELLCHECKER, RC_SPLITINDEX_COMMAND, RC_TEMPDIRPATH, @@ -353,6 +354,8 @@ public: std::string spellchecker_esc_chars; /// spellcheck continuously? bool spellcheck_continuously; + /// spellcheck notes and comments? + bool spellcheck_notes; /// bool use_kbmap; /// diff --git a/src/frontends/qt4/GuiPrefs.cpp b/src/frontends/qt4/GuiPrefs.cpp index 4518838456..d75184f9f7 100644 --- a/src/frontends/qt4/GuiPrefs.cpp +++ b/src/frontends/qt4/GuiPrefs.cpp @@ -1332,12 +1332,15 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form) this, SIGNAL(changed())); connect(spellcheckContinuouslyCB, SIGNAL(clicked()), this, SIGNAL(changed())); + connect(spellcheckNotesCB, SIGNAL(clicked()), + this, SIGNAL(changed())); } else { spellcheckerCB->setEnabled(false); altLanguageED->setEnabled(false); escapeCharactersED->setEnabled(false); compoundWordCB->setEnabled(false); spellcheckContinuouslyCB->setEnabled(false); + spellcheckNotesCB->setEnabled(false); } } @@ -1350,6 +1353,7 @@ void PrefSpellchecker::apply(LyXRC & rc) const rc.spellchecker_esc_chars = fromqstr(escapeCharactersED->text()); rc.spellchecker_accept_compound = compoundWordCB->isChecked(); rc.spellcheck_continuously = spellcheckContinuouslyCB->isChecked(); + rc.spellcheck_notes = spellcheckNotesCB->isChecked(); } @@ -1361,6 +1365,7 @@ void PrefSpellchecker::update(LyXRC const & rc) escapeCharactersED->setText(toqstr(rc.spellchecker_esc_chars)); compoundWordCB->setChecked(rc.spellchecker_accept_compound); spellcheckContinuouslyCB->setChecked(rc.spellcheck_continuously); + spellcheckNotesCB->setChecked(rc.spellcheck_notes); } diff --git a/src/frontends/qt4/ui/PrefSpellcheckerUi.ui b/src/frontends/qt4/ui/PrefSpellcheckerUi.ui index 6c77e7270a..9a8f1dfb09 100644 --- a/src/frontends/qt4/ui/PrefSpellcheckerUi.ui +++ b/src/frontends/qt4/ui/PrefSpellcheckerUi.ui @@ -6,7 +6,7 @@ 0 0 519 - 208 + 224 @@ -19,20 +19,85 @@ 6 - - + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 501 + 21 + + + + + + + + If unchecked, notes and comments will be excluded from spell checking + - Al&ternative language: + Spellcheck &notes and comments + + + + + + + &Spellchecker engine: altLanguageED - - + + + + + - Override the language used for the spellchecker + Accept words such as "diskdrive" + + + Accept compound &words + + + + + + + Mark misspelled words with a wavy underline. + + + S&pellcheck continuously + + + + + + + Qt::Horizontal + + + QSizePolicy::Expanding + + + + 41 + 22 + + + + + + + + The characters inserted here are ignored by the spellchecker. @@ -46,72 +111,17 @@ - - + + - The characters inserted here are ignored by the spellchecker. + Override the language used for the spellchecker - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 41 - 22 - - - - - - - - Mark misspelled words with a wavy underline. - + + - S&pellcheck continuously - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 20 - - - - - - - - Accept words such as "diskdrive" - - - Accept compound &words - - - - - - - - - - &Spellchecker engine: + Al&ternative language: altLanguageED diff --git a/src/insets/InsetNote.cpp b/src/insets/InsetNote.cpp index 8a0f657ac5..ff6efb3a86 100644 --- a/src/insets/InsetNote.cpp +++ b/src/insets/InsetNote.cpp @@ -27,6 +27,7 @@ #include "InsetIterator.h" #include "LaTeXFeatures.h" #include "Lexer.h" +#include "LyXRC.h" #include "MetricsInfo.h" #include "OutputParams.h" #include "ParIterator.h" @@ -351,6 +352,11 @@ docstring InsetNote::contextMenu(BufferView const &, int, int) const return from_ascii("context-note"); } +bool InsetNote::allowSpellCheck() const +{ + return (params_.type == InsetNoteParams::Greyedout || lyxrc.spellcheck_notes); +} + string InsetNote::params2string(InsetNoteParams const & params) { diff --git a/src/insets/InsetNote.h b/src/insets/InsetNote.h index 4de8d5cd54..dde3a48cb2 100644 --- a/src/insets/InsetNote.h +++ b/src/insets/InsetNote.h @@ -73,6 +73,8 @@ private: */ bool producesOutput() const { return false; } /// + bool allowSpellCheck() const; + /// void write(std::ostream &) const; /// void read(Lexer & lex);