mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
Enhance LyX by fixing #6760. New preference to set minimum length of
automatically spellchecked words. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34889 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
f27ea2457d
commit
e611cc2d4a
@ -180,6 +180,7 @@ LexerKeyword lyxrcTags[] = {
|
||||
{ "\\sort_layouts", LyXRC::RC_SORT_LAYOUTS },
|
||||
{ "\\spell_command", LyXRC::RC_SPELL_COMMAND },
|
||||
{ "\\spellcheck_continuously", LyXRC::RC_SPELLCHECK_CONTINUOUSLY },
|
||||
{ "\\spellcheck_minlength", LyXRC::RC_SPELL_MINLENGTH },
|
||||
{ "\\spellcheck_notes", LyXRC::RC_SPELLCHECK_NOTES },
|
||||
{ "\\spellchecker", LyXRC::RC_SPELLCHECKER },
|
||||
{ "\\splitindex_command", LyXRC::RC_SPLITINDEX_COMMAND },
|
||||
@ -297,6 +298,7 @@ void LyXRC::setDefaults()
|
||||
#endif
|
||||
spellchecker_accept_compound = false;
|
||||
spellcheck_continuously = false;
|
||||
spellcheck_minlength = 6;
|
||||
spellcheck_notes = true;
|
||||
use_kbmap = false;
|
||||
rtl_support = true;
|
||||
@ -921,6 +923,19 @@ int LyXRC::read(Lexer & lexrc)
|
||||
case RC_SPELLCHECKER:
|
||||
lexrc >> spellchecker;
|
||||
break;
|
||||
case RC_SPELL_MINLENGTH: {
|
||||
int len;
|
||||
lexrc >> len;
|
||||
// make sure we have a sensible value
|
||||
// these should be kept in sync with the min and max
|
||||
// values for the spinbox in PrefSpellcheckerUi.ui
|
||||
if (len < 5)
|
||||
len = 5;
|
||||
else if (len > 15)
|
||||
len = 15;
|
||||
spellcheck_minlength = len;
|
||||
break;
|
||||
}
|
||||
case RC_ALT_LANG:
|
||||
lexrc >> spellchecker_alt_lang;
|
||||
break;
|
||||
@ -2421,6 +2436,15 @@ void LyXRC::write(ostream & os, bool ignore_system_lyxrc, string const & name) c
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
|
||||
case RC_SPELL_MINLENGTH:
|
||||
if (ignore_system_lyxrc ||
|
||||
spellcheck_minlength != system_lyxrc.spellcheck_minlength) {
|
||||
os << "\\spellcheck_minlength " << convert<string>(spellcheck_minlength)
|
||||
<< '\n';
|
||||
}
|
||||
if (tag != RC_LAST)
|
||||
break;
|
||||
|
||||
case RC_SPELLCHECK_NOTES:
|
||||
if (ignore_system_lyxrc ||
|
||||
spellcheck_notes != system_lyxrc.spellcheck_notes) {
|
||||
@ -2872,6 +2896,7 @@ void actOnUpdatedPrefs(LyXRC const & lyxrc_orig, LyXRC const & lyxrc_new)
|
||||
case LyXRC::RC_SPELLCHECKER:
|
||||
case LyXRC::RC_SPELLCHECK_CONTINUOUSLY:
|
||||
case LyXRC::RC_SPELLCHECK_NOTES:
|
||||
case LyXRC::RC_SPELL_MINLENGTH:
|
||||
case LyXRC::RC_SPLITINDEX_COMMAND:
|
||||
case LyXRC::RC_TEMPDIRPATH:
|
||||
case LyXRC::RC_TEMPLATEPATH:
|
||||
|
@ -165,6 +165,7 @@ public:
|
||||
RC_SPELLCHECK_CONTINUOUSLY,
|
||||
RC_SPELLCHECK_NOTES,
|
||||
RC_SPELLCHECKER,
|
||||
RC_SPELL_MINLENGTH,
|
||||
RC_SPLITINDEX_COMMAND,
|
||||
RC_TEMPDIRPATH,
|
||||
RC_TEMPLATEPATH,
|
||||
@ -362,6 +363,8 @@ public:
|
||||
bool spellcheck_continuously;
|
||||
/// spellcheck notes and comments?
|
||||
bool spellcheck_notes;
|
||||
/// minimum length of words to complete
|
||||
unsigned int spellcheck_minlength;
|
||||
///
|
||||
bool use_kbmap;
|
||||
///
|
||||
|
@ -3126,16 +3126,13 @@ void Paragraph::locateWord(pos_type & from, pos_type & to,
|
||||
|
||||
void Paragraph::collectWords()
|
||||
{
|
||||
// This is the value that needs to be exposed in the preferences
|
||||
// to resolve bug #6760.
|
||||
static int minlength = 6;
|
||||
pos_type n = size();
|
||||
for (pos_type pos = 0; pos < n; ++pos) {
|
||||
if (isWordSeparator(pos))
|
||||
continue;
|
||||
pos_type from = pos;
|
||||
locateWord(from, pos, WHOLE_WORD);
|
||||
if (pos - from >= minlength) {
|
||||
if (pos - from >= lyxrc.spellcheck_minlength) {
|
||||
docstring word = asString(from, pos, AS_STR_NONE);
|
||||
FontList::const_iterator cit = d->fontlist_.fontIterator(pos);
|
||||
if (cit == d->fontlist_.end())
|
||||
|
@ -1365,6 +1365,7 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
|
||||
this, SIGNAL(changed()));
|
||||
connect(spellcheckNotesCB, SIGNAL(clicked()),
|
||||
this, SIGNAL(changed()));
|
||||
connect(minlengthSB, SIGNAL(changed()), this, SIGNAL(changed()));
|
||||
#else
|
||||
spellcheckerCB->setEnabled(false);
|
||||
altLanguageED->setEnabled(false);
|
||||
@ -1372,6 +1373,7 @@ PrefSpellchecker::PrefSpellchecker(GuiPreferences * form)
|
||||
compoundWordCB->setEnabled(false);
|
||||
spellcheckContinuouslyCB->setEnabled(false);
|
||||
spellcheckNotesCB->setEnabled(false);
|
||||
minlengthSB->setEnabled(false);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1384,6 +1386,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_minlength = minlengthSB->value();
|
||||
rc.spellcheck_notes = spellcheckNotesCB->isChecked();
|
||||
}
|
||||
|
||||
@ -1395,7 +1398,10 @@ void PrefSpellchecker::update(LyXRC const & rc)
|
||||
altLanguageED->setText(toqstr(rc.spellchecker_alt_lang));
|
||||
escapeCharactersED->setText(toqstr(rc.spellchecker_esc_chars));
|
||||
compoundWordCB->setChecked(rc.spellchecker_accept_compound);
|
||||
spellcheckContinuouslyCB->setChecked(rc.spellcheck_continuously);
|
||||
bool const continuous = rc.spellcheck_continuously;
|
||||
spellcheckContinuouslyCB->setChecked(continuous);
|
||||
minlengthSB->setValue(rc.spellcheck_minlength);
|
||||
minlengthSB->setEnabled(continuous);
|
||||
spellcheckNotesCB->setChecked(rc.spellcheck_notes);
|
||||
}
|
||||
|
||||
|
@ -1,33 +1,33 @@
|
||||
<ui version="4.0" >
|
||||
<ui version="4.0">
|
||||
<class>PrefSpellcheckerUi</class>
|
||||
<widget class="QWidget" name="PrefSpellcheckerUi" >
|
||||
<property name="geometry" >
|
||||
<widget class="QWidget" name="PrefSpellcheckerUi">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>519</width>
|
||||
<height>224</height>
|
||||
<height>241</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle" >
|
||||
<property name="windowTitle">
|
||||
<string/>
|
||||
</property>
|
||||
<layout class="QGridLayout" >
|
||||
<property name="margin" >
|
||||
<layout class="QGridLayout">
|
||||
<property name="margin">
|
||||
<number>9</number>
|
||||
</property>
|
||||
<property name="spacing" >
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="6" column="0" colspan="3" >
|
||||
<item row="8" column="0" colspan="3">
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>501</width>
|
||||
<height>21</height>
|
||||
@ -35,58 +35,48 @@
|
||||
</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>Spellcheck &notes and comments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" >
|
||||
<widget class="QLabel" name="spellcheckerLA" >
|
||||
<property name="text" >
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="spellcheckerLA">
|
||||
<property name="text">
|
||||
<string>&Spellchecker engine:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>altLanguageED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1" >
|
||||
<widget class="QComboBox" name="spellcheckerCB" />
|
||||
<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>Accept words such as "diskdrive"</string>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<widget class="QCheckBox" name="compoundWordCB">
|
||||
<property name="toolTip">
|
||||
<string>Accept words such as "diskdrive"</string>
|
||||
</property>
|
||||
<property name="text" >
|
||||
<property name="text">
|
||||
<string>Accept compound &words</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0" colspan="2" >
|
||||
<widget class="QCheckBox" name="spellcheckContinuouslyCB" >
|
||||
<property name="toolTip" >
|
||||
<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" >
|
||||
<property name="text">
|
||||
<string>S&pellcheck continuously</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2" >
|
||||
<item row="3" column="2">
|
||||
<spacer>
|
||||
<property name="orientation" >
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeType" >
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Expanding</enum>
|
||||
</property>
|
||||
<property name="sizeHint" >
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>41</width>
|
||||
<height>22</height>
|
||||
@ -94,40 +84,73 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="2" column="1" >
|
||||
<widget class="QLineEdit" name="escapeCharactersED" >
|
||||
<property name="toolTip" >
|
||||
<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>
|
||||
<item row="2" column="0" >
|
||||
<widget class="QLabel" name="escapeCharactersLA" >
|
||||
<property name="text" >
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="escapeCharactersLA">
|
||||
<property name="text">
|
||||
<string>&Escape characters:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>escapeCharactersED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" >
|
||||
<widget class="QLineEdit" name="altLanguageED" >
|
||||
<property name="toolTip" >
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="altLanguageED">
|
||||
<property name="toolTip">
|
||||
<string>Override the language used for the spellchecker</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" >
|
||||
<widget class="QLabel" name="altLanguageLA" >
|
||||
<property name="text" >
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="altLanguageLA">
|
||||
<property name="text">
|
||||
<string>Al&ternative language:</string>
|
||||
</property>
|
||||
<property name="buddy" >
|
||||
<property name="buddy">
|
||||
<cstring>altLanguageED</cstring>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Minimum word length for completion</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<widget class="QSpinBox" name="minlengthSB">
|
||||
<property name="toolTip">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>15</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>6</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<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>Spellcheck &notes and comments</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
@ -136,7 +159,7 @@
|
||||
<tabstop>compoundWordCB</tabstop>
|
||||
</tabstops>
|
||||
<includes>
|
||||
<include location="local" >qt_i18n.h</include>
|
||||
<include location="local">qt_i18n.h</include>
|
||||
</includes>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
Loading…
Reference in New Issue
Block a user