summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Markmann <tm@ayena.de>2016-05-11 08:45:10 (GMT)
committerTobias Markmann <tm@ayena.de>2016-06-23 14:55:10 (GMT)
commite5d57519f573ef3718ec207c6f81006b4a0e0244 (patch)
treee42ff13628a63b67a2c08c5f96312bbc3033a869 /Swift/QtUI/QtTextEdit.cpp
parent7f0fe603be200c09c74cf9cc295a972f3c3dbdfd (diff)
downloadswift-e5d57519f573ef3718ec207c6f81006b4a0e0244.zip
swift-e5d57519f573ef3718ec207c6f81006b4a0e0244.tar.bz2
Improve Linux spell checking UX and enable it by default
This removes support for user dictionaries for now. The new UI shows a list human readable languages (in their native spelling) where the user can select one to use for spell checking. Updated our InstallSwiftDependencies.sh based on the package names in their repositories. Test-Information: Tested on Ubuntu 16.04 with Hunspell and tested it still builds on OS X 10.11.4. Did not test InstallSwiftDependencies.sh. Change-Id: I24fc705b1495f7c39a8da149cbd7116e41609998
Diffstat (limited to 'Swift/QtUI/QtTextEdit.cpp')
-rw-r--r--Swift/QtUI/QtTextEdit.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index 846dcbc..3143192 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -179,17 +179,17 @@ void QtTextEdit::addSuggestions(QMenu* menu, QContextMenuEvent* event)
#ifdef HAVE_SPELLCHECKER
-void QtTextEdit::setUpSpellChecker()
-{
+void QtTextEdit::setUpSpellChecker() {
delete highlighter_;
highlighter_ = nullptr;
delete checker_;
checker_ = nullptr;
if (settings_->getSetting(SettingConstants::SPELL_CHECKER)) {
- std::string dictPath = settings_->getSetting(SettingConstants::DICT_PATH);
- std::string dictFile = settings_->getSetting(SettingConstants::DICT_FILE);
- checker_ = SpellCheckerFactory().createSpellChecker(dictPath + dictFile);
+ checker_ = SpellCheckerFactory().createSpellChecker();
if (checker_) {
+ if (!checker_->isAutomaticallyDetectingLanguage()) {
+ checker_->setActiveLanguage(settings_->getSetting(SettingConstants::SPELL_CHECKER_LANGUAGE));
+ }
highlighter_ = new QtSpellCheckHighlighter(document(), checker_);
}
else {
@@ -213,12 +213,18 @@ void QtTextEdit::spellCheckerSettingsWindow() {
spellCheckerWindow_->raise();
spellCheckerWindow_->activateWindow();
}
+ if (checker_) {
+ spellCheckerWindow_->setAutomaticallyIdentifiesLanguage(checker_->isAutomaticallyDetectingLanguage());
+ if (!checker_->isAutomaticallyDetectingLanguage()) {
+ spellCheckerWindow_->setSupportedLanguages(checker_->supportedLanguages());
+ spellCheckerWindow_->setActiveLanguage(checker_->activeLanguage());
+ }
+ }
}
void QtTextEdit::handleSettingChanged(const std::string& settings) {
- if (settings == SettingConstants::SPELL_CHECKER.getKey()
- || settings == SettingConstants::DICT_PATH.getKey()
- || settings == SettingConstants::DICT_FILE.getKey()) {
+ if (settings == SettingConstants::SPELL_CHECKER.getKey() ||
+ settings == SettingConstants::SPELL_CHECKER_LANGUAGE.getKey()) {
#ifdef HAVE_SPELLCHECKER
setUpSpellChecker();
if (highlighter_) {