diff options
author | Vlad Voicu <vladv@rosedu.org> | 2012-03-05 18:28:47 (GMT) |
---|---|---|
committer | vlad <vlad@tyrion.(none)> | 2012-10-13 13:55:45 (GMT) |
commit | 5ca749621b991e6a1e10d7a809d0fe1f0680ca74 (patch) | |
tree | 0b9683d47ce43376a48103d7e7381f207681cd2c /Swift/QtUI/QtSpellCheckerWindow.cpp | |
parent | a74153f0af0149b445eb5fd18f616e8a3e7f8462 (diff) | |
download | swift-contrib-5ca749621b991e6a1e10d7a809d0fe1f0680ca74.zip swift-contrib-5ca749621b991e6a1e10d7a809d0fe1f0680ca74.tar.bz2 |
Improved settings for Spell Checker
Diffstat (limited to 'Swift/QtUI/QtSpellCheckerWindow.cpp')
-rw-r--r-- | Swift/QtUI/QtSpellCheckerWindow.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Swift/QtUI/QtSpellCheckerWindow.cpp b/Swift/QtUI/QtSpellCheckerWindow.cpp index c6fcc2c..ef1985e 100644 --- a/Swift/QtUI/QtSpellCheckerWindow.cpp +++ b/Swift/QtUI/QtSpellCheckerWindow.cpp @@ -27,13 +27,19 @@ QtSpellCheckerWindow::QtSpellCheckerWindow(SettingsProvider* settings, QWidget* connect(ui_.pathButton, SIGNAL(clicked()), this, SLOT(handlePathButton())); connect(ui_.personalPathButton, SIGNAL(clicked()), this, SLOT(handlePersonalPathButton())); setFromSettings(); - setEnabled(settings_->getSetting(SettingConstants::SPELL_CHECKER)); } void QtSpellCheckerWindow::setFromSettings() { ui_.spellChecker->setChecked(settings_->getSetting(SettingConstants::SPELL_CHECKER)); ui_.personalPathContent->insert(P2QSTRING(settings_->getSetting(SettingConstants::PERSONAL_DICT_PATH))); ui_.pathContent->insert(P2QSTRING(settings_->getSetting(SettingConstants::DICT_PATH))); + ui_.currentLanguageValue->setText(P2QSTRING(settings_->getSetting(SettingConstants::DICT_FILE))); + std::string currentPath = settings_->getSetting(SettingConstants::DICT_PATH); + QString filename = "*.dic"; + QDir dictDirectory = QDir(P2QSTRING(currentPath)); + QStringList files = dictDirectory.entryList(QStringList(filename), QDir::Files); + showFiles(files); + setEnabled(settings_->getSetting(SettingConstants::SPELL_CHECKER)); } void QtSpellCheckerWindow::handleChecker(bool state) { @@ -48,6 +54,8 @@ void QtSpellCheckerWindow::setEnabled(bool state) { ui_.personalPathButton->setEnabled(state); ui_.pathLabel->setEnabled(state); ui_.personalDictionaryLabel->setEnabled(state); + ui_.currentLanguage->setEnabled(state); + ui_.currentLanguageValue->setEnabled(state); ui_.language->setEnabled(state); } @@ -56,6 +64,8 @@ void QtSpellCheckerWindow::handleApply() { QList<QListWidgetItem* > selectedLanguage = ui_.languageView->selectedItems(); if (!selectedLanguage.empty()) { settings_->storeSetting(SettingConstants::DICT_FILE, Q2PSTRING(selectedLanguage[0]->text())); + } else { + settings_->storeSetting(SettingConstants::SPELL_CHECKER, false); } this->done(0); } @@ -67,10 +77,13 @@ void QtSpellCheckerWindow::handleCancel() { void QtSpellCheckerWindow::handlePathButton() { std::string currentPath = settings_->getSetting(SettingConstants::DICT_PATH); QString dirpath = QFileDialog::getExistingDirectory(this, tr("Dictionary Path"), P2QSTRING(currentPath)); - if (dirpath != NULL) { - QDir dictDirectory = QDir(dirpath); + if (!dirpath.isEmpty()) { + if (!dirpath.endsWith("/")) { + dirpath.append("/"); + } settings_->storeSetting(SettingConstants::DICT_PATH, Q2PSTRING(dirpath)); - ui_.personalPathContent->insert(dirpath); + QDir dictDirectory = QDir(dirpath); + ui_.pathContent->insert(dirpath); QString filename = "*.dic"; QStringList files = dictDirectory.entryList(QStringList(filename), QDir::Files); showFiles(files); |