use a SettingListener for word type mask updating

This commit is contained in:
Rasmus Karlsson 2017-12-19 02:31:06 +01:00
parent e39b9093f9
commit ba1c9598a4
2 changed files with 12 additions and 26 deletions

View file

@ -20,33 +20,16 @@ SettingsManager::SettingsManager()
QMap<QString, QPair<bool, bool>>())
, highlightUserBlacklist(this->settingsItems, "highlightUserBlacklist", "")
{
this->showTimestamps.connectSimple([this](auto) {
this->wordMaskListener.addSetting(this->showTimestamps);
this->wordMaskListener.addSetting(this->showTimestampSeconds);
this->wordMaskListener.addSetting(this->showBadges);
this->wordMaskListener.addSetting(this->enableBttvEmotes);
this->wordMaskListener.addSetting(this->enableEmojis);
this->wordMaskListener.addSetting(this->enableFfzEmotes);
this->wordMaskListener.addSetting(this->enableTwitchEmotes);
this->wordMaskListener.cb = [this](auto) {
this->updateWordTypeMask(); //
});
this->showTimestampSeconds.connectSimple([this](auto) {
this->updateWordTypeMask(); //
});
this->showBadges.connectSimple([this](auto) {
this->updateWordTypeMask(); //
});
this->enableBttvEmotes.connectSimple([this](auto) {
this->updateWordTypeMask(); //
});
this->enableEmojis.connectSimple([this](auto) {
this->updateWordTypeMask(); //
});
this->enableFfzEmotes.connectSimple([this](auto) {
this->updateWordTypeMask(); //
});
this->enableTwitchEmotes.connectSimple([this](auto) {
this->updateWordTypeMask(); //
});
};
}
void SettingsManager::save()

View file

@ -6,6 +6,7 @@
#include <QSettings>
#include <pajlada/settings/setting.hpp>
#include <pajlada/settings/settinglistener.hpp>
namespace chatterino {
@ -94,6 +95,8 @@ private:
QSettings settings;
std::vector<std::reference_wrapper<BaseSetting>> settingsItems;
messages::Word::Type wordTypeMask = messages::Word::Default;
pajlada::Settings::SettingListener wordMaskListener;
};
} // namespace chatterino