Remove getApp and getSettings calls from Message-Rendering (#4535)
* refactor: remove singletons from message rendering
* chore: add changelog entry
* Disable the `cppcoreguidelines-avoid-const-or-ref-data-members` clang-tidy check
* auto *app
* Selection is a struct, not a class
* Use ChannelView's `signalHolder_` instead of `channelConnections_`
* Remove `applySettings` step, instead just connect & set each setting individually
* rename & constify some context values
* Handle empty "last message color" setting value better (as it was
originally in this pr before I removed that change :-)
* unrelated mini refactor cleanup
* let painSelection handle size_t instead of int
* Add some more comments to the MessageLayoutContext structs
---------
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
#include "Application.hpp"
|
||||
#include "messages/Emote.hpp"
|
||||
#include "messages/Image.hpp"
|
||||
#include "messages/layouts/MessageLayoutContext.hpp"
|
||||
#include "messages/MessageElement.hpp"
|
||||
#include "providers/twitch/TwitchEmotes.hpp"
|
||||
#include "singletons/Theme.hpp"
|
||||
#include "util/DebugCount.hpp"
|
||||
|
||||
#include <QDebug>
|
||||
@@ -137,7 +137,8 @@ int ImageLayoutElement::getSelectionIndexCount() const
|
||||
return this->trailingSpace ? 2 : 1;
|
||||
}
|
||||
|
||||
void ImageLayoutElement::paint(QPainter &painter)
|
||||
void ImageLayoutElement::paint(QPainter &painter,
|
||||
const MessageColors & /*messageColors*/)
|
||||
{
|
||||
if (this->image_ == nullptr)
|
||||
{
|
||||
@@ -228,7 +229,8 @@ int LayeredImageLayoutElement::getSelectionIndexCount() const
|
||||
return this->trailingSpace ? 2 : 1;
|
||||
}
|
||||
|
||||
void LayeredImageLayoutElement::paint(QPainter &painter)
|
||||
void LayeredImageLayoutElement::paint(QPainter &painter,
|
||||
const MessageColors & /*messageColors*/)
|
||||
{
|
||||
auto fullRect = QRectF(this->getRect());
|
||||
|
||||
@@ -329,7 +331,8 @@ ImageWithBackgroundLayoutElement::ImageWithBackgroundLayoutElement(
|
||||
{
|
||||
}
|
||||
|
||||
void ImageWithBackgroundLayoutElement::paint(QPainter &painter)
|
||||
void ImageWithBackgroundLayoutElement::paint(
|
||||
QPainter &painter, const MessageColors & /*messageColors*/)
|
||||
{
|
||||
if (this->image_ == nullptr)
|
||||
{
|
||||
@@ -360,7 +363,8 @@ ImageWithCircleBackgroundLayoutElement::ImageWithCircleBackgroundLayoutElement(
|
||||
{
|
||||
}
|
||||
|
||||
void ImageWithCircleBackgroundLayoutElement::paint(QPainter &painter)
|
||||
void ImageWithCircleBackgroundLayoutElement::paint(
|
||||
QPainter &painter, const MessageColors & /*messageColors*/)
|
||||
{
|
||||
if (this->image_ == nullptr)
|
||||
{
|
||||
@@ -423,7 +427,8 @@ int TextLayoutElement::getSelectionIndexCount() const
|
||||
return this->getText().length() + (this->trailingSpace ? 1 : 0);
|
||||
}
|
||||
|
||||
void TextLayoutElement::paint(QPainter &painter)
|
||||
void TextLayoutElement::paint(QPainter &painter,
|
||||
const MessageColors & /*messageColors*/)
|
||||
{
|
||||
auto app = getApp();
|
||||
QString text = this->getText();
|
||||
@@ -532,13 +537,14 @@ int TextIconLayoutElement::getSelectionIndexCount() const
|
||||
return this->trailingSpace ? 2 : 1;
|
||||
}
|
||||
|
||||
void TextIconLayoutElement::paint(QPainter &painter)
|
||||
void TextIconLayoutElement::paint(QPainter &painter,
|
||||
const MessageColors &messageColors)
|
||||
{
|
||||
auto app = getApp();
|
||||
auto *app = getApp();
|
||||
|
||||
QFont font = app->fonts->getFont(FontStyle::Tiny, this->scale);
|
||||
|
||||
painter.setPen(app->themes->messages.textColors.system);
|
||||
painter.setPen(messageColors.system);
|
||||
painter.setFont(font);
|
||||
|
||||
QTextOption option;
|
||||
@@ -598,7 +604,8 @@ ReplyCurveLayoutElement::ReplyCurveLayoutElement(MessageElement &creator,
|
||||
{
|
||||
}
|
||||
|
||||
void ReplyCurveLayoutElement::paint(QPainter &painter)
|
||||
void ReplyCurveLayoutElement::paint(QPainter &painter,
|
||||
const MessageColors & /*messageColors*/)
|
||||
{
|
||||
QRectF paintRect(this->getRect());
|
||||
QPainterPath path;
|
||||
|
||||
Reference in New Issue
Block a user