Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
feat(ui): Add ui to setup spell checking
Browse files Browse the repository at this point in the history
  • Loading branch information
Diadlo authored and sudden6 committed Jul 19, 2018
1 parent 671b945 commit 8d10fe4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 1 deletion.
18 changes: 18 additions & 0 deletions src/persistence/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,7 @@ void Settings::loadGlobal()
lightTrayIcon = s.value("lightTrayIcon", false).toBool();
useEmoticons = s.value("useEmoticons", true).toBool();
statusChangeNotificationEnabled = s.value("statusChangeNotificationEnabled", false).toBool();
spellCheckingEnabled = s.value("spellCheckingEnabled", true).toBool();
themeColor = s.value("themeColor", 0).toInt();
style = s.value("style", "").toString();
if (style == "") // Default to Fusion if available, otherwise no style
Expand Down Expand Up @@ -547,6 +548,7 @@ void Settings::saveGlobal()
s.setValue("themeColor", themeColor);
s.setValue("style", style);
s.setValue("statusChangeNotificationEnabled", statusChangeNotificationEnabled);
s.setValue("spellCheckingEnabled", spellCheckingEnabled);
}
s.endGroup();

Expand Down Expand Up @@ -1046,6 +1048,22 @@ void Settings::setStatusChangeNotificationEnabled(bool newValue)
}
}

bool Settings::getSpellCheckingEnabled() const
{
const QMutexLocker locker{&bigLock};
return spellCheckingEnabled;
}

void Settings::setSpellCheckingEnabled(bool newValue)
{
QMutexLocker locker{&bigLock};

if (newValue != spellCheckingEnabled) {
spellCheckingEnabled = newValue;
emit statusChangeNotificationEnabledChanged(statusChangeNotificationEnabled);
}
}

bool Settings::getShowInFront() const
{
QMutexLocker locker{&bigLock};
Expand Down
7 changes: 7 additions & 0 deletions src/persistence/settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class Settings : public QObject, public ICoreSettings, public IFriendSettings,
Q_PROPERTY(QString dateFormat READ getDateFormat WRITE setDateFormat NOTIFY dateFormatChanged FINAL)
Q_PROPERTY(bool statusChangeNotificationEnabled READ getStatusChangeNotificationEnabled WRITE
setStatusChangeNotificationEnabled NOTIFY statusChangeNotificationEnabledChanged FINAL)
Q_PROPERTY(bool spellCheckingEnabled READ getSpellCheckingEnabled WRITE
setSpellCheckingEnabled NOTIFY spellCheckingEnabledChanged FINAL)

// Privacy
Q_PROPERTY(bool typingNotification READ getTypingNotification WRITE setTypingNotification NOTIFY
Expand Down Expand Up @@ -212,6 +214,7 @@ public slots:
void timestampFormatChanged(const QString& format);
void dateFormatChanged(const QString& format);
void statusChangeNotificationEnabledChanged(bool enabled);
void spellCheckingEnabledChanged(bool enabled);
void fauxOfflineMessagingChanged(bool enabled);

// Privacy
Expand Down Expand Up @@ -449,6 +452,9 @@ public slots:
bool getStatusChangeNotificationEnabled() const;
void setStatusChangeNotificationEnabled(bool newValue);

bool getSpellCheckingEnabled() const;
void setSpellCheckingEnabled(bool newValue);

// Privacy
bool getTypingNotification() const;
void setTypingNotification(bool enabled);
Expand Down Expand Up @@ -641,6 +647,7 @@ public slots:
QString timestampFormat;
QString dateFormat;
bool statusChangeNotificationEnabled;
bool spellCheckingEnabled;

// Privacy
bool typingNotification;
Expand Down
4 changes: 3 additions & 1 deletion src/widget/form/genericchatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ GenericChatForm::GenericChatForm(const Contact* contact, QWidget* parent)

msgEdit = new ChatTextEdit();
#ifdef SPELL_CHECKING
decorator = new Sonnet::SpellCheckDecorator(msgEdit);
if (s.getSpellCheckingEnabled()) {
decorator = new Sonnet::SpellCheckDecorator(msgEdit);
}
#endif

sendButton = createButton("sendButton", this, &GenericChatForm::onSendTriggered);
Expand Down
11 changes: 11 additions & 0 deletions src/widget/form/settings/generalform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ GeneralForm::GeneralForm(SettingsWidget* myParent)
#else
bodyUI->checkUpdates->setVisible(false);
#endif

#ifndef SPELL_CHECKING
bodyUI->cbSpellChecking->setVisible(false);
#endif

bodyUI->checkUpdates->setChecked(s.getCheckUpdates());

for (int i = 0; i < locales.size(); ++i) {
Expand All @@ -126,6 +131,7 @@ GeneralForm::GeneralForm(SettingsWidget* myParent)

bodyUI->cbAutorun->setChecked(s.getAutorun());

bodyUI->cbSpellChecking->setChecked(s.getSpellCheckingEnabled());
bodyUI->lightTrayIcon->setChecked(s.getLightTrayIcon());
bool showSystemTray = s.getShowSystemTray();

Expand Down Expand Up @@ -172,6 +178,11 @@ void GeneralForm::on_cbAutorun_stateChanged()
Settings::getInstance().setAutorun(bodyUI->cbAutorun->isChecked());
}

void GeneralForm::on_cbSpellChecking_stateChanged()
{
Settings::getInstance().setSpellCheckingEnabled(bodyUI->cbSpellChecking->isChecked());
}

void GeneralForm::on_showSystemTray_stateChanged()
{
Settings::getInstance().setShowSystemTray(bodyUI->showSystemTray->isChecked());
Expand Down
1 change: 1 addition & 0 deletions src/widget/form/settings/generalform.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class GeneralForm : public GenericForm
private slots:
void on_transComboBox_currentIndexChanged(int index);
void on_cbAutorun_stateChanged();
void on_cbSpellChecking_stateChanged();
void on_showSystemTray_stateChanged();
void on_startInTray_stateChanged();
void on_closeToTray_stateChanged();
Expand Down
7 changes: 7 additions & 0 deletions src/widget/form/settings/generalsettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout_6">
<item>
<widget class="QCheckBox" name="cbSpellChecking">
<property name="text">
<string>Spell checking</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="lightTrayIcon">
<property name="sizePolicy">
Expand Down

0 comments on commit 8d10fe4

Please sign in to comment.