* 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
This commit is contained in:
Jürgen Spitzmüller 2010-02-13 16:22:39 +00:00
parent 8168e27362
commit bd57d5ea56
6 changed files with 109 additions and 68 deletions

View File

@ -174,6 +174,7 @@ LexerKeyword lyxrcTags[] = {
{ "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS }, { "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
{ "\\spell_command", LyXRC::RC_SPELL_COMMAND }, { "\\spell_command", LyXRC::RC_SPELL_COMMAND },
{ "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY }, { "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
{ "\\spellcheck_notes", LyXRC::RC_SPELLCHECK_NOTES },
{ "\\spellchecker", LyXRC::RC_SPELLCHECKER }, { "\\spellchecker", LyXRC::RC_SPELLCHECKER },
{ "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND }, { "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND },
{ "\\tempdir_path", LyXRC::RC_TEMPDIRPATH }, { "\\tempdir_path", LyXRC::RC_TEMPDIRPATH },
@ -286,6 +287,7 @@ void LyXRC::setDefaults()
#endif #endif
spellchecker_accept_compound = false; spellchecker_accept_compound = false;
spellcheck_continuously = false; spellcheck_continuously = false;
spellcheck_notes = true;
use_kbmap = false; use_kbmap = false;
rtl_support = true; rtl_support = true;
visual_cursor = false; visual_cursor = false;
@ -915,6 +917,9 @@ int LyXRC::read(Lexer & lexrc)
case RC_SPELLCHECK_CONTINUOUSLY: case RC_SPELLCHECK_CONTINUOUSLY:
lexrc >> spellcheck_continuously; lexrc >> spellcheck_continuously;
break; break;
case RC_SPELLCHECK_NOTES:
lexrc >> spellcheck_notes;
break;
case RC_MAKE_BACKUP: case RC_MAKE_BACKUP:
lexrc >> make_backup; lexrc >> make_backup;
break; break;
@ -2333,6 +2338,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
if (tag != RC_LAST) if (tag != RC_LAST)
break; break;
case RC_SPELLCHECK_NOTES:
if (ignore_system_lyxrc ||
spellcheck_notes != system_lyxrc.spellcheck_notes) {
os << "\\spellcheck_notes " << convert<string>(spellcheck_notes)
<< '\n';
}
if (tag != RC_LAST)
break;
case RC_RTL_SUPPORT: case RC_RTL_SUPPORT:
if (ignore_system_lyxrc || if (ignore_system_lyxrc ||
rtl_support != system_lyxrc.rtl_support) { 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_SPELL_COMMAND:
case LyXRC::RC_SPELLCHECKER: case LyXRC::RC_SPELLCHECKER:
case LyXRC::RC_SPELLCHECK_CONTINUOUSLY: case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
case LyXRC::RC_SPELLCHECK_NOTES:
case LyXRC::RC_SPLITINDEX_COMMAND: case LyXRC::RC_SPLITINDEX_COMMAND:
case LyXRC::RC_TEMPDIRPATH: case LyXRC::RC_TEMPDIRPATH:
case LyXRC::RC_TEMPLATEPATH: case LyXRC::RC_TEMPLATEPATH:

View File

@ -159,6 +159,7 @@ public:
RC_SORT_LAYOUTS, RC_SORT_LAYOUTS,
RC_SPELL_COMMAND, RC_SPELL_COMMAND,
RC_SPELLCHECK_CONTINUOUSLY, RC_SPELLCHECK_CONTINUOUSLY,
RC_SPELLCHECK_NOTES,
RC_SPELLCHECKER, RC_SPELLCHECKER,
RC_SPLITINDEX_COMMAND, RC_SPLITINDEX_COMMAND,
RC_TEMPDIRPATH, RC_TEMPDIRPATH,
@ -353,6 +354,8 @@ public:
std::string spellchecker_esc_chars; std::string spellchecker_esc_chars;
/// spellcheck continuously? /// spellcheck continuously?
bool spellcheck_continuously; bool spellcheck_continuously;
/// spellcheck notes and comments?
bool spellcheck_notes;
/// ///
bool use_kbmap; bool use_kbmap;
/// ///

View File

@ -1332,12 +1332,15 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(spellcheckContinuouslyCB, SIGNAL(clicked()), connect(spellcheckContinuouslyCB, SIGNAL(clicked()),
this, SIGNAL(changed())); this, SIGNAL(changed()));
connect(spellcheckNotesCB, SIGNAL(clicked()),
this, SIGNAL(changed()));
} else { } else {
spellcheckerCB->setEnabled(false); spellcheckerCB->setEnabled(false);
altLanguageED->setEnabled(false); altLanguageED->setEnabled(false);
escapeCharactersED->setEnabled(false); escapeCharactersED->setEnabled(false);
compoundWordCB->setEnabled(false); compoundWordCB->setEnabled(false);
spellcheckContinuouslyCB->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_esc_chars = fromqstr(escapeCharactersED->text());
rc.spellchecker_accept_compound = compoundWordCB->isChecked(); rc.spellchecker_accept_compound = compoundWordCB->isChecked();
rc.spellcheck_continuously = spellcheckContinuouslyCB->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)); escapeCharactersED->setText(toqstr(rc.spellchecker_esc_chars));
compoundWordCB->setChecked(rc.spellchecker_accept_compound); compoundWordCB->setChecked(rc.spellchecker_accept_compound);
spellcheckContinuouslyCB->setChecked(rc.spellcheck_continuously); spellcheckContinuouslyCB->setChecked(rc.spellcheck_continuously);
spellcheckNotesCB->setChecked(rc.spellcheck_notes);
} }

View File

@ -6,7 +6,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>519</width> <width>519</width>
<height>208</height> <height>224</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle" >
@ -19,20 +19,85 @@
<property name="spacing" > <property name="spacing" >
<number>6</number> <number>6</number>
</property> </property>
<item row="1" column="0" > <item row="6" column="0" colspan="3" >
<widget class="QLabel" name="altLanguageLA" > <spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>501</width>
<height>21</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" colspan="2" >
<widget class="QCheckBox" name="spellcheckNotesCB" >
<property name="toolTip" >
<string>If unchecked, notes and comments will be excluded from spell checking</string>
</property>
<property name="text" > <property name="text" >
<string>Al&amp;ternative language:</string> <string>Spellcheck &amp;notes and comments</string>
</property>
</widget>
</item>
<item row="0" column="0" >
<widget class="QLabel" name="spellcheckerLA" >
<property name="text" >
<string>&amp;Spellchecker engine:</string>
</property> </property>
<property name="buddy" > <property name="buddy" >
<cstring>altLanguageED</cstring> <cstring>altLanguageED</cstring>
</property> </property>
</widget> </widget>
</item> </item>
<item row="1" column="1" > <item row="0" column="1" >
<widget class="QLineEdit" name="altLanguageED" > <widget class="QComboBox" name="spellcheckerCB" />
</item>
<item row="3" column="0" colspan="2" >
<widget class="QCheckBox" name="compoundWordCB" >
<property name="toolTip" > <property name="toolTip" >
<string>Override the language used for the spellchecker</string> <string>Accept words such as "diskdrive"</string>
</property>
<property name="text" >
<string>Accept compound &amp;words</string>
</property>
</widget>
</item>
<item row="4" column="0" colspan="2" >
<widget class="QCheckBox" name="spellcheckContinuouslyCB" >
<property name="toolTip" >
<string>Mark misspelled words with a wavy underline.</string>
</property>
<property name="text" >
<string>S&amp;pellcheck continuously</string>
</property>
</widget>
</item>
<item row="3" column="2" >
<spacer>
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" >
<size>
<width>41</width>
<height>22</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="escapeCharactersED" >
<property name="toolTip" >
<string>The characters inserted here are ignored by the spellchecker. </string>
</property> </property>
</widget> </widget>
</item> </item>
@ -46,72 +111,17 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="2" column="1" > <item row="1" column="1" >
<widget class="QLineEdit" name="escapeCharactersED" > <widget class="QLineEdit" name="altLanguageED" >
<property name="toolTip" > <property name="toolTip" >
<string>The characters inserted here are ignored by the spellchecker. </string> <string>Override the language used for the spellchecker</string>
</property> </property>
</widget> </widget>
</item> </item>
<item row="3" column="3" > <item row="1" column="0" >
<spacer> <widget class="QLabel" name="altLanguageLA" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>41</width>
<height>22</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0" colspan="3" >
<widget class="QCheckBox" name="spellcheckContinuouslyCB" >
<property name="toolTip" >
<string>Mark misspelled words with a wavy underline.</string>
</property>
<property name="text" > <property name="text" >
<string>S&amp;pellcheck continuously</string> <string>Al&amp;ternative language:</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="4" >
<spacer>
<property name="orientation" >
<enum>Qt::Vertical</enum>
</property>
<property name="sizeType" >
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item rowspan="2" row="3" column="0" colspan="4" >
<widget class="QCheckBox" name="compoundWordCB" >
<property name="toolTip" >
<string>Accept words such as "diskdrive"</string>
</property>
<property name="text" >
<string>Accept compound &amp;words</string>
</property>
</widget>
</item>
<item row="0" column="1" >
<widget class="QComboBox" name="spellcheckerCB" />
</item>
<item row="0" column="0" >
<widget class="QLabel" name="spellcheckerLA" >
<property name="text" >
<string>&amp;Spellchecker engine:</string>
</property> </property>
<property name="buddy" > <property name="buddy" >
<cstring>altLanguageED</cstring> <cstring>altLanguageED</cstring>

View File

@ -27,6 +27,7 @@
#include "InsetIterator.h" #include "InsetIterator.h"
#include "LaTeXFeatures.h" #include "LaTeXFeatures.h"
#include "Lexer.h" #include "Lexer.h"
#include "LyXRC.h"
#include "MetricsInfo.h" #include "MetricsInfo.h"
#include "OutputParams.h" #include "OutputParams.h"
#include "ParIterator.h" #include "ParIterator.h"
@ -351,6 +352,11 @@ docstring InsetNote::contextMenu(BufferView const &, int, int) const
return from_ascii("context-note"); return from_ascii("context-note");
} }
bool InsetNote::allowSpellCheck() const
{
return (params_.type == InsetNoteParams::Greyedout || lyxrc.spellcheck_notes);
}
string InsetNote::params2string(InsetNoteParams const & params) string InsetNote::params2string(InsetNoteParams const & params)
{ {

View File

@ -73,6 +73,8 @@ private:
*/ */
bool producesOutput() const { return false; } bool producesOutput() const { return false; }
/// ///
bool allowSpellCheck() const;
///
void write(std::ostream &) const; void write(std::ostream &) const;
/// ///
void read(Lexer & lex); void read(Lexer & lex);