summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'Swift/QtUI/QtSpellCheckerWindow.cpp')
-rw-r--r--Swift/QtUI/QtSpellCheckerWindow.cpp21
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);