* 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 },
{ "\\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<string>(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:

View File

@ -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;
///

View File

@ -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);
}

View File

@ -6,7 +6,7 @@
<x>0</x>
<y>0</y>
<width>519</width>
<height>208</height>
<height>224</height>
</rect>
</property>
<property name="windowTitle" >
@ -19,20 +19,85 @@
<property name="spacing" >
<number>6</number>
</property>
<item row="1" column="0" >
<widget class="QLabel" name="altLanguageLA" >
<item row="6" column="0" colspan="3" >
<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" >
<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 name="buddy" >
<cstring>altLanguageED</cstring>
</property>
</widget>
</item>
<item row="1" column="1" >
<widget class="QLineEdit" name="altLanguageED" >
<item row="0" column="1" >
<widget class="QComboBox" name="spellcheckerCB" />
</item>
<item row="3" column="0" colspan="2" >
<widget class="QCheckBox" name="compoundWordCB" >
<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>
</widget>
</item>
@ -46,72 +111,17 @@
</property>
</widget>
</item>
<item row="2" column="1" >
<widget class="QLineEdit" name="escapeCharactersED" >
<item row="1" column="1" >
<widget class="QLineEdit" name="altLanguageED" >
<property name="toolTip" >
<string>The characters inserted here are ignored by the spellchecker. </string>
<string>Override the language used for the spellchecker</string>
</property>
</widget>
</item>
<item row="3" column="3" >
<spacer>
<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>
<item row="1" column="0" >
<widget class="QLabel" name="altLanguageLA" >
<property name="text" >
<string>S&amp;pellcheck continuously</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>
<string>Al&amp;ternative language:</string>
</property>
<property name="buddy" >
<cstring>altLanguageED</cstring>

View File

@ -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)
{

View File

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