implement show ignored users setting

This commit is contained in:
pphop 2019-04-13 01:12:39 +05:00
parent 3f41dfeff9
commit 320d74b287
4 changed files with 33 additions and 2 deletions

View file

@ -12,6 +12,8 @@ class Paths;
class IgnoreModel;
enum ShowIgnoredUsersMessages { Never, IfModerator, IfBroadcaster };
class IgnoreController final : public Singleton
{
public:

View file

@ -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;

View file

@ -128,6 +128,7 @@ public:
/// Ingored Users
BoolSetting enableTwitchIgnoredUsers = {"/ignore/enableTwitchIgnoredUsers",
true};
IntSetting showIgnoredUsersMessages = {"/ignore/showIgnoredUsers", 0};
/// Moderation
QStringSetting timeoutAction = {"/moderation/timeoutAction", "Disable"};

View file

@ -77,8 +77,24 @@ void addUsersTab(IgnoresPage &page, LayoutCreator<QVBoxLayout> users,
auto anyways = users.emplace<QHBoxLayout>().withoutMargin();
{
anyways.emplace<QLabel>("Show anyways if:");
anyways.emplace<QComboBox>();
anyways.emplace<QLabel>("Show messages from ignored users anyways:");
auto combo = anyways.emplace<QComboBox>().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<int>::of(&QComboBox::currentIndexChanged),
[&setting](int index) {
if (index != -1)
setting = index;
});
anyways->addStretch(1);
}