Merge pull request #1007 from pphop/pphop-show-ignored

Show ignored users messages anyway setting
This commit is contained in:
pajlada 2019-04-14 16:59:40 +02:00 committed by GitHub
commit 695d200d79
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 2 deletions

View file

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

View file

@ -80,6 +80,19 @@ bool TwitchMessageBuilder::isIgnored() const
{
if (sourceUserID == user.id)
{
switch (static_cast<ShowIgnoredUsersMessages>(
getSettings()->showIgnoredUsersMessages.getValue()))
{
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);
}