Better Highlights (#1320)

* Support for user-defined sounds and colors

* Make color & sound columns selectable

* Add custom row for subscription highlights

* Add subscriptions to custom highlights and centrally manage highlight colors

* Dynamically update message highlight colors
This commit is contained in:
Leon Richardt
2020-01-25 11:03:10 +01:00
committed by pajlada
parent 00414eb779
commit 5957551d06
29 changed files with 1822 additions and 187 deletions
+8 -3
View File
@@ -1,6 +1,9 @@
#include "messages/Message.hpp"
#include "Application.hpp"
#include "MessageElement.hpp"
#include "providers/twitch/PubsubActions.hpp"
#include "singletons/Theme.hpp"
#include "util/DebugCount.hpp"
#include "util/IrcHelpers.hpp"
@@ -24,11 +27,13 @@ SBHighlight Message::getScrollBarHighlight() const
if (this->flags.has(MessageFlag::Highlighted) ||
this->flags.has(MessageFlag::HighlightedWhisper))
{
return SBHighlight(SBHighlight::Highlight);
return SBHighlight(this->highlightColor);
}
else if (this->flags.has(MessageFlag::Subscription))
else if (this->flags.has(MessageFlag::Subscription) &&
getSettings()->enableSubHighlight)
{
return SBHighlight(SBHighlight::Subscription);
return SBHighlight(
ColorProvider::instance().color(ColorType::Subscription));
}
return SBHighlight();
}
+1
View File
@@ -55,6 +55,7 @@ struct Message : boost::noncopyable {
QString displayName;
QString localizedName;
QString timeoutUser;
std::shared_ptr<QColor> highlightColor;
uint32_t count = 1;
std::vector<std::unique_ptr<MessageElement>> elements;
+34 -9
View File
@@ -25,6 +25,19 @@
namespace chatterino {
namespace {
QColor blendColors(const QColor &base, const QColor &apply)
{
const qreal &alpha = apply.alphaF();
QColor result;
result.setRgbF(base.redF() * (1 - alpha) + apply.redF() * alpha,
base.greenF() * (1 - alpha) + apply.greenF() * alpha,
base.blueF() * (1 - alpha) + apply.blueF() * alpha);
return result;
}
} // namespace
MessageLayout::MessageLayout(MessagePtr message)
: message_(message)
, container_(std::make_shared<MessageLayoutContainer>())
@@ -249,21 +262,33 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/,
painter.setRenderHint(QPainter::SmoothPixmapTransform);
// draw background
QColor backgroundColor = app->themes->messages.backgrounds.regular;
QColor backgroundColor = [this, &app] {
if (getSettings()->alternateMessages.getValue() &&
this->flags.has(MessageLayoutFlag::AlternateBackground))
{
return app->themes->messages.backgrounds.alternate;
}
else
{
return app->themes->messages.backgrounds.regular;
}
}();
if ((this->message_->flags.has(MessageFlag::Highlighted) ||
this->message_->flags.has(MessageFlag::HighlightedWhisper)) &&
!this->flags.has(MessageLayoutFlag::IgnoreHighlights))
{
backgroundColor = app->themes->messages.backgrounds.highlighted;
// Blend highlight color with usual background color
backgroundColor =
blendColors(backgroundColor, *this->message_->highlightColor);
}
else if (this->message_->flags.has(MessageFlag::Subscription))
else if (this->message_->flags.has(MessageFlag::Subscription) &&
getSettings()->enableSubHighlight)
{
backgroundColor = app->themes->messages.backgrounds.subscription;
}
else if (getSettings()->alternateMessages.getValue() &&
this->flags.has(MessageLayoutFlag::AlternateBackground))
{
backgroundColor = app->themes->messages.backgrounds.alternate;
// Blend highlight color with usual background color
backgroundColor = blendColors(
backgroundColor,
*ColorProvider::instance().color(ColorType::Subscription));
}
else if (this->message_->flags.has(MessageFlag::AutoMod))
{