From 320d74b287cdf55de971b5a74f1f4dd8f75c3f19 Mon Sep 17 00:00:00 2001 From: pphop <1um6okote@gmail.com> Date: Sat, 13 Apr 2019 01:12:39 +0500 Subject: [PATCH 1/2] implement show ignored users setting --- src/controllers/ignores/IgnoreController.hpp | 2 ++ src/providers/twitch/TwitchMessageBuilder.cpp | 12 +++++++++++ src/singletons/Settings.hpp | 1 + src/widgets/settingspages/IgnoresPage.cpp | 20 +++++++++++++++++-- 4 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/controllers/ignores/IgnoreController.hpp b/src/controllers/ignores/IgnoreController.hpp index 10c83ac10..59efc4a47 100644 --- a/src/controllers/ignores/IgnoreController.hpp +++ b/src/controllers/ignores/IgnoreController.hpp @@ -12,6 +12,8 @@ class Paths; class IgnoreModel; +enum ShowIgnoredUsersMessages { Never, IfModerator, IfBroadcaster }; + class IgnoreController final : public Singleton { public: diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index b8c34cc65..aad1228bd 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -80,6 +80,18 @@ bool TwitchMessageBuilder::isIgnored() const { if (sourceUserID == user.id) { + switch (getSettings()->showIgnoredUsersMessages) + { + case ShowIgnoredUsersMessages::IfModerator: + if (this->channel->isMod() || + this->channel->isBroadcaster()) + return false; + break; + case ShowIgnoredUsersMessages::IfBroadcaster: + if (this->channel->isBroadcaster()) + return false; + break; + } log("Blocking message because it's from blocked user {}", user.name); return true; diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index 953374193..ff71733cb 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -128,6 +128,7 @@ public: /// Ingored Users BoolSetting enableTwitchIgnoredUsers = {"/ignore/enableTwitchIgnoredUsers", true}; + IntSetting showIgnoredUsersMessages = {"/ignore/showIgnoredUsers", 0}; /// Moderation QStringSetting timeoutAction = {"/moderation/timeoutAction", "Disable"}; diff --git a/src/widgets/settingspages/IgnoresPage.cpp b/src/widgets/settingspages/IgnoresPage.cpp index 122dc1109..daf941cf6 100644 --- a/src/widgets/settingspages/IgnoresPage.cpp +++ b/src/widgets/settingspages/IgnoresPage.cpp @@ -77,8 +77,24 @@ void addUsersTab(IgnoresPage &page, LayoutCreator users, auto anyways = users.emplace().withoutMargin(); { - anyways.emplace("Show anyways if:"); - anyways.emplace(); + anyways.emplace("Show messages from ignored users anyways:"); + + auto combo = anyways.emplace().getElement(); + combo->addItems( + {"Never", "If you are Moderator", "If you are Broadcaster"}); + + auto &setting = getSettings()->showIgnoredUsersMessages; + + setting.connect( + [combo](const int value) { combo->setCurrentIndex(value); }); + + QObject::connect(combo, + QOverload::of(&QComboBox::currentIndexChanged), + [&setting](int index) { + if (index != -1) + setting = index; + }); + anyways->addStretch(1); } From e4d3e6de7f28cf14efd57c858f411864e3305b45 Mon Sep 17 00:00:00 2001 From: pphop <1um6okote@gmail.com> Date: Sun, 14 Apr 2019 19:57:41 +0500 Subject: [PATCH 2/2] requested changes --- src/controllers/ignores/IgnoreController.hpp | 2 +- src/providers/twitch/TwitchMessageBuilder.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controllers/ignores/IgnoreController.hpp b/src/controllers/ignores/IgnoreController.hpp index 59efc4a47..1279f4a88 100644 --- a/src/controllers/ignores/IgnoreController.hpp +++ b/src/controllers/ignores/IgnoreController.hpp @@ -12,7 +12,7 @@ class Paths; class IgnoreModel; -enum ShowIgnoredUsersMessages { Never, IfModerator, IfBroadcaster }; +enum class ShowIgnoredUsersMessages { Never, IfModerator, IfBroadcaster }; class IgnoreController final : public Singleton { diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index aad1228bd..cd1d78cb4 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -80,7 +80,8 @@ bool TwitchMessageBuilder::isIgnored() const { if (sourceUserID == user.id) { - switch (getSettings()->showIgnoredUsersMessages) + switch (static_cast( + getSettings()->showIgnoredUsersMessages.getValue())) { case ShowIgnoredUsersMessages::IfModerator: if (this->channel->isMod() ||