summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtTextEdit.cpp')
-rw-r--r--Swift/QtUI/QtTextEdit.cpp19
1 files changed, 11 insertions, 8 deletions
diff --git a/Swift/QtUI/QtTextEdit.cpp b/Swift/QtUI/QtTextEdit.cpp
index f115d1c..75bc292 100644
--- a/Swift/QtUI/QtTextEdit.cpp
+++ b/Swift/QtUI/QtTextEdit.cpp
@@ -6,6 +6,7 @@
#include <boost/tuple/tuple.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/filesystem/operations.hpp>
#include <SwifTools/SpellCheckerFactory.h>
#include <SwifTools/SpellChecker.h>
@@ -24,6 +25,7 @@ namespace Swift {
QtTextEdit::QtTextEdit(SettingsProvider* settings, QWidget* parent) : QTextEdit(parent) {
connect(this, SIGNAL(textChanged()), this, SLOT(handleTextChanged()));
+ checker_ = NULL;
settings_ = settings;
setUpSpellChecker();
handleTextChanged();
@@ -184,19 +186,19 @@ void QtTextEdit::addSuggestions(QMenu* menu, QContextMenuEvent* event)
void QtTextEdit::setUpSpellChecker()
{
SpellCheckerFactory *checkerFactory = new SpellCheckerFactory();
- std::string dictFile = settings_->getSetting(SettingConstants::DICT_FILE);
- if (dictFile.empty()) {
- // Disable the dictionary to force the user to select a dictionary
- settings_->storeSetting(SettingConstants::SPELL_CHECKER, false);
- }
+ delete checker_;
if (settings_->getSetting(SettingConstants::SPELL_CHECKER)) {
std::string dictPath = settings_->getSetting(SettingConstants::DICT_PATH);
+ std::string dictFile = settings_->getSetting(SettingConstants::DICT_FILE);
std::string affixFile(dictFile);
boost::replace_all(affixFile, ".dic", ".aff");
- if (checker_ != NULL) {
- delete checker_;
+ if ((boost::filesystem::exists(dictPath + dictFile)) && (boost::filesystem::exists(dictPath + affixFile))) {
+ checker_ = checkerFactory->createSpellChecker((dictPath + affixFile).c_str(), (dictPath + dictFile).c_str());
+ }
+ else {
+ // If dictionaries don't exist disable the checker
+ checker_ = NULL;
}
- checker_ = checkerFactory->createSpellChecker((dictPath + affixFile).c_str(), (dictPath + dictFile).c_str());
delete checkerFactory;
}
else {
@@ -219,6 +221,7 @@ void QtTextEdit::spellCheckerSettingsWindow() {
void QtTextEdit::handleModifiedSettings() {
delete checker_;
+ checker_ = NULL;
setUpSpellChecker();
underlineMisspells();
}