diff --git a/src/ui/highlighter.h b/src/ui/highlighter.h --- a/src/ui/highlighter.h +++ b/src/ui/highlighter.h @@ -103,6 +103,25 @@ */ void setAutomatic(bool automatic); + /** + * Returns whether the automatic language detection is disabled, + * overriding the Sonnet settings. + * + * @return true if the automatic language detection is disabled + * @since 5.66 + */ + bool autoDetectLanguageDisabled() const; + + /** + * Sets whether to disable the automatic language detection. + * + * @param autoDetectDisabled if true, the language will not be + * detected automatically by the spell checker, even if the option + * is enabled in the Sonnet settings. + * @since 5.66 + */ + void setAutoDetectLanguageDisabled(bool autoDetectDisabled); + /** * Adds the given word permanently to the dictionary. It will never * be marked as misspelled again, even after restarting the application. diff --git a/src/ui/highlighter.cpp b/src/ui/highlighter.cpp --- a/src/ui/highlighter.cpp +++ b/src/ui/highlighter.cpp @@ -92,6 +92,7 @@ tokenizer = new WordTokenizer(); active = true; automatic = false; + autoDetectLanguageDisabled = false; connected = false; wordCount = 0; errorCount = 0; @@ -131,6 +132,7 @@ QPlainTextEdit *plainTextEdit = nullptr; bool active; bool automatic; + bool autoDetectLanguageDisabled; bool completeRehighlightRequired; bool intraWordEditing; bool spellCheckerFound; //cached d->dict->isValid() value @@ -208,6 +210,11 @@ return d->automatic; } +bool Highlighter::autoDetectLanguageDisabled() const +{ + return d->autoDetectLanguageDisabled; +} + bool Highlighter::intraWordEditing() const { return d->intraWordEditing; @@ -230,6 +237,11 @@ } } +void Highlighter::setAutoDetectLanguageDisabled(bool autoDetectDisabled) +{ + d->autoDetectLanguageDisabled = autoDetectDisabled; +} + void Highlighter::slotAutoDetection() { bool savedActive = d->active; @@ -339,7 +351,7 @@ const bool autodetectLanguage = d->spellchecker->testAttribute(Speller::AutoDetectLanguage); while (d->languageFilter->hasNext()) { QStringRef sentence = d->languageFilter->next(); - if (autodetectLanguage) { + if (autodetectLanguage && !d->autoDetectLanguageDisabled) { QString lang; QPair spos = QPair(sentence.position(), sentence.length()); // try cache first