From ba1c9598a46b71d2693cc5068fd9c4c3d5be2357 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Tue, 19 Dec 2017 02:31:06 +0100 Subject: [PATCH] use a SettingListener for word type mask updating --- src/settingsmanager.cpp | 35 +++++++++-------------------------- src/settingsmanager.hpp | 3 +++ 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index 5d89d6fd6..3e77f4940 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -20,33 +20,16 @@ SettingsManager::SettingsManager() QMap>()) , 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() diff --git a/src/settingsmanager.hpp b/src/settingsmanager.hpp index 7cdf144d0..d1a652cf2 100644 --- a/src/settingsmanager.hpp +++ b/src/settingsmanager.hpp @@ -6,6 +6,7 @@ #include #include +#include namespace chatterino { @@ -94,6 +95,8 @@ private: QSettings settings; std::vector> settingsItems; messages::Word::Type wordTypeMask = messages::Word::Default; + + pajlada::Settings::SettingListener wordMaskListener; }; } // namespace chatterino