summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVlad Voicu <vladv@rosedu.org>2012-03-06 16:47:28 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-03-09 15:04:11 (GMT)
commitdbc27f2f163c33366fc9ca31088f0c255963168b (patch)
treeca7990140037fd44c60a92b6e859af973e1663d8 /Swift/QtUI/QtTextEdit.cpp
parent7c868599331a7b4156c3572ba4f3dc75af57ce97 (diff)
downloadswift-contrib-dbc27f2f163c33366fc9ca31088f0c255963168b.zip
swift-contrib-dbc27f2f163c33366fc9ca31088f0c255963168b.tar.bz2
Fixed some bugs with language selection
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();
}