From c6e1ec3c71f653a5aab9c2ee54f2d08bd1d37922 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 21 Oct 2018 13:29:52 +0200 Subject: [PATCH] disabled red background in #mentions --- src/common/Channel.cpp | 6 ++++++ src/common/Channel.hpp | 1 + src/messages/layouts/MessageLayout.cpp | 9 ++++----- src/messages/layouts/MessageLayout.hpp | 1 + src/widgets/helper/ChannelView.cpp | 3 +++ 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index 84b882c4f..ece3d6ac1 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -226,6 +226,12 @@ bool Channel::isLive() const return false; } +bool Channel::shouldIgnoreHighlights() const +{ + return this->type_ == Type::TwitchMentions || + this->type_ == Type::TwitchWhispers; +} + std::shared_ptr Channel::getEmpty() { static std::shared_ptr channel(new Channel("", Type::None)); diff --git a/src/common/Channel.hpp b/src/common/Channel.hpp index 5d2d96db2..9f4d0c2e0 100644 --- a/src/common/Channel.hpp +++ b/src/common/Channel.hpp @@ -70,6 +70,7 @@ public: virtual bool isBroadcaster() const; virtual bool hasModRights() const; virtual bool isLive() const; + virtual bool shouldIgnoreHighlights() const; static std::shared_ptr getEmpty(); diff --git a/src/messages/layouts/MessageLayout.cpp b/src/messages/layouts/MessageLayout.cpp index fdae4bdc9..4e7343136 100644 --- a/src/messages/layouts/MessageLayout.cpp +++ b/src/messages/layouts/MessageLayout.cpp @@ -209,21 +209,20 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/, auto app = getApp(); QPainter painter(buffer); - painter.setRenderHint(QPainter::SmoothPixmapTransform); // draw background - QColor backgroundColor; - if (this->message_->flags.has(MessageFlag::Highlighted)) { + QColor backgroundColor = app->themes->messages.backgrounds.regular; + if (this->message_->flags.has(MessageFlag::Highlighted) && + !this->flags.has(MessageLayoutFlag::IgnoreHighlights)) { backgroundColor = app->themes->messages.backgrounds.highlighted; } else if (this->message_->flags.has(MessageFlag::Subscription)) { backgroundColor = app->themes->messages.backgrounds.subscription; } else if (getSettings()->alternateMessageBackground.getValue() && this->flags.has(MessageLayoutFlag::AlternateBackground)) { backgroundColor = app->themes->messages.backgrounds.alternate; - } else { - backgroundColor = app->themes->messages.backgrounds.regular; } + painter.fillRect(buffer->rect(), backgroundColor); // draw message diff --git a/src/messages/layouts/MessageLayout.hpp b/src/messages/layouts/MessageLayout.hpp index 00b944a96..d8877ba4d 100644 --- a/src/messages/layouts/MessageLayout.hpp +++ b/src/messages/layouts/MessageLayout.hpp @@ -26,6 +26,7 @@ enum class MessageLayoutFlag : uint8_t { AlternateBackground = 1 << 3, Collapsed = 1 << 4, Expanded = 1 << 5, + IgnoreHighlights = 1 << 6, }; using MessageLayoutFlags = FlagsEnum; diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 41a428925..14d77f2d8 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -421,6 +421,9 @@ void ChannelView::setChannel(ChannelPtr newChannel) if (this->lastMessageHasAlternateBackground_) { messageRef->flags.set(MessageLayoutFlag::AlternateBackground); } + if (this->channel_->shouldIgnoreHighlights()) { + messageRef->flags.set(MessageLayoutFlag::IgnoreHighlights); + } this->lastMessageHasAlternateBackground_ = !this->lastMessageHasAlternateBackground_;