summaryrefslogtreecommitdiffstats
path: root/Swift
diff options
context:
space:
mode:
authorVlad Voicu <vladv@rosedu.org>2012-03-04 21:46:37 (GMT)
committerKevin Smith <git@kismith.co.uk>2012-03-09 15:04:07 (GMT)
commit157f45722a42a066cf6fde8eb6919668c355dd7c (patch)
tree2acc11be87f852c8de8a0ee0980743208676b3d9 /Swift
parent424d19ec5f9c7ab6ca28a532540d140a22fafeb9 (diff)
downloadswift-contrib-157f45722a42a066cf6fde8eb6919668c355dd7c.zip
swift-contrib-157f45722a42a066cf6fde8eb6919668c355dd7c.tar.bz2
Imporoved Spell Checker Settings
Diffstat (limited to 'Swift')
-rw-r--r--Swift/Controllers/SettingConstants.cpp3
-rw-r--r--Swift/Controllers/SettingConstants.h3
-rw-r--r--Swift/QtUI/QtSpellCheckerWindow.cpp69
-rw-r--r--Swift/QtUI/QtSpellCheckerWindow.h7
-rw-r--r--Swift/QtUI/QtSpellCheckerWindow.ui16
5 files changed, 86 insertions, 12 deletions
diff --git a/Swift/Controllers/SettingConstants.cpp b/Swift/Controllers/SettingConstants.cpp
index 3180b6a..6f147a7 100644
--- a/Swift/Controllers/SettingConstants.cpp
+++ b/Swift/Controllers/SettingConstants.cpp
@@ -20,4 +20,7 @@ const SettingsProvider::Setting<bool> SettingConstants::SHOW_OFFLINE("showOfflin
const SettingsProvider::Setting<std::string> SettingConstants::EXPANDED_ROSTER_GROUPS("GroupExpandiness", "");
const SettingsProvider::Setting<bool> SettingConstants::PLAY_SOUNDS("playSounds", true);
const SettingsProvider::Setting<bool> SettingConstants::SPELL_CHECKER("spellChecker", false);
+const SettingsProvider::Setting<std::string> SettingConstants::DICT_PATH("dictPath", "/usr/share/myspell/dicts/");
+const SettingsProvider::Setting<std::string> SettingConstants::PERSONAL_DICT_PATH("personaldictPath", "/home");
+const SettingsProvider::Setting<std::string> SettingConstants::DICT_FILE("dictFile", "en_US.dic");
}
diff --git a/Swift/Controllers/SettingConstants.h b/Swift/Controllers/SettingConstants.h
index 4c354f2..afef6ca 100644
--- a/Swift/Controllers/SettingConstants.h
+++ b/Swift/Controllers/SettingConstants.h
@@ -23,5 +23,8 @@ namespace Swift {
static const SettingsProvider::Setting<std::string> EXPANDED_ROSTER_GROUPS;
static const SettingsProvider::Setting<bool> PLAY_SOUNDS;
static const SettingsProvider::Setting<bool> SPELL_CHECKER;
+ static const SettingsProvider::Setting<std::string> DICT_PATH;
+ static const SettingsProvider::Setting<std::string> PERSONAL_DICT_PATH;
+ static const SettingsProvider::Setting<std::string> DICT_FILE;
};
}
diff --git a/Swift/QtUI/QtSpellCheckerWindow.cpp b/Swift/QtUI/QtSpellCheckerWindow.cpp
index 45aa32f..c6fcc2c 100644
--- a/Swift/QtUI/QtSpellCheckerWindow.cpp
+++ b/Swift/QtUI/QtSpellCheckerWindow.cpp
@@ -9,22 +9,83 @@
#include <Swift/Controllers/Settings/SettingsProvider.h>
#include <Swift/Controllers/SettingConstants.h>
#include <Swift/QtUI/QtUISettingConstants.h>
+#include <Swift/QtUI/QtSwiftUtil.h>
#include <QCoreApplication>
#include <QFileDialog>
+#include <QDir>
+#include <QStringList>
namespace Swift {
QtSpellCheckerWindow::QtSpellCheckerWindow(SettingsProvider* settings, QWidget* parent) : QDialog(parent) {
settings_ = settings;
ui_.setupUi(this);
- connect(ui_.spellCheckerEnabled, SIGNAL(toggled(bool)), this, SLOT(handleChecker(bool)));
- ui_.spellCheckerEnabled->setChecked(settings_->getSetting(SettingConstants::SPELL_CHECKER));
- //QString filename = QFileDialog::getOpenFileName(this, tr("Select Dictionaries"), "/home", tr("Images (*.aff, *.dic"));
+ connect(ui_.spellChecker, SIGNAL(toggled(bool)), this, SLOT(handleChecker(bool)));
+ connect(ui_.cancel, SIGNAL(clicked()), this, SLOT(handleCancel()));
+ connect(ui_.apply, SIGNAL(clicked()), this, SLOT(handleApply()));
+ 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)));
}
void QtSpellCheckerWindow::handleChecker(bool state) {
- settings_->storeSetting(SettingConstants::SPELL_CHECKER, state);
+ setEnabled(state);
+}
+
+void QtSpellCheckerWindow::setEnabled(bool state) {
+ ui_.pathContent->setEnabled(state);
+ ui_.personalPathContent->setEnabled(state);
+ ui_.languageView->setEnabled(state);
+ ui_.pathButton->setEnabled(state);
+ ui_.personalPathButton->setEnabled(state);
+ ui_.pathLabel->setEnabled(state);
+ ui_.personalDictionaryLabel->setEnabled(state);
+ ui_.language->setEnabled(state);
+}
+
+void QtSpellCheckerWindow::handleApply() {
+ settings_->storeSetting(SettingConstants::SPELL_CHECKER, ui_.spellChecker->isChecked());
+ QList<QListWidgetItem* > selectedLanguage = ui_.languageView->selectedItems();
+ if (!selectedLanguage.empty()) {
+ settings_->storeSetting(SettingConstants::DICT_FILE, Q2PSTRING(selectedLanguage[0]->text()));
+ }
+ this->done(0);
+}
+
+void QtSpellCheckerWindow::handleCancel() {
+ this->done(0);
+}
+
+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);
+ settings_->storeSetting(SettingConstants::DICT_PATH, Q2PSTRING(dirpath));
+ ui_.personalPathContent->insert(dirpath);
+ QString filename = "*.dic";
+ QStringList files = dictDirectory.entryList(QStringList(filename), QDir::Files);
+ showFiles(files);
+ }
+}
+
+void QtSpellCheckerWindow::handlePersonalPathButton() {
+ std::string currentPath = settings_->getSetting(SettingConstants::PERSONAL_DICT_PATH);
+ QString filename = QFileDialog::getOpenFileName(this, tr("Select Personal Dictionary"), P2QSTRING(currentPath), tr("(*.dic"));
+}
+
+void QtSpellCheckerWindow::showFiles(const QStringList& files) {
+ for (int i = 0; i < files.size(); ++i) {
+ ui_.languageView->insertItem(i, files[i]);
+ }
}
}
diff --git a/Swift/QtUI/QtSpellCheckerWindow.h b/Swift/QtUI/QtSpellCheckerWindow.h
index 0d6ac60..ad94907 100644
--- a/Swift/QtUI/QtSpellCheckerWindow.h
+++ b/Swift/QtUI/QtSpellCheckerWindow.h
@@ -18,8 +18,15 @@ namespace Swift {
QtSpellCheckerWindow(SettingsProvider* settings, QWidget* parent = NULL);
public slots:
void handleChecker(bool state);
+ void handleCancel();
+ void handlePathButton();
+ void handlePersonalPathButton();
+ void handleApply();
private:
+ void setEnabled(bool state);
+ void setFromSettings();
+ void showFiles(const QStringList& files);
SettingsProvider* settings_;
Ui::QtSpellCheckerWindow ui_;
};
diff --git a/Swift/QtUI/QtSpellCheckerWindow.ui b/Swift/QtUI/QtSpellCheckerWindow.ui
index d09edfe..619ed88 100644
--- a/Swift/QtUI/QtSpellCheckerWindow.ui
+++ b/Swift/QtUI/QtSpellCheckerWindow.ui
@@ -15,7 +15,7 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
- <widget class="QCheckBox" name="spellCheckerEnabled">
+ <widget class="QCheckBox" name="spellChecker">
<property name="text">
<string>Spell Checker Enabled</string>
</property>
@@ -32,24 +32,24 @@
<widget class="QLineEdit" name="pathContent"/>
</item>
<item row="1" column="2">
- <widget class="QPushButton" name="changePathButton">
+ <widget class="QPushButton" name="pathButton">
<property name="text">
<string>Change</string>
</property>
</widget>
</item>
<item row="2" column="0">
- <widget class="QLabel" name="perosnalDictionaryLabel">
+ <widget class="QLabel" name="personalDictionaryLabel">
<property name="text">
<string>Personal Dictionary</string>
</property>
</widget>
</item>
<item row="2" column="1">
- <widget class="QLineEdit" name="personalDictionaryContent"/>
+ <widget class="QLineEdit" name="personalPathContent"/>
</item>
<item row="2" column="2">
- <widget class="QPushButton" name="changePersonalButton">
+ <widget class="QPushButton" name="personalPathButton">
<property name="text">
<string>Change</string>
</property>
@@ -62,9 +62,6 @@
</property>
</widget>
</item>
- <item row="3" column="1">
- <widget class="QListView" name="languagesView"/>
- </item>
<item row="4" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
@@ -96,6 +93,9 @@
</item>
</layout>
</item>
+ <item row="3" column="1">
+ <widget class="QListWidget" name="languageView"/>
+ </item>
</layout>
</widget>
<resources/>