refactor: fix clang-tidy auto*, const&, and curly braces (#5083)

This commit is contained in:
pajlada
2024-01-14 17:54:52 +01:00
committed by GitHub
parent 292f9b9734
commit 5b6675abb4
78 changed files with 647 additions and 228 deletions
+2
View File
@@ -20,7 +20,9 @@ EmotePtr cachedOrMakeEmotePtr(Emote &&emote, const EmoteMap &cache)
// reuse old shared_ptr if nothing changed
auto it = cache.find(emote.name);
if (it != cache.end() && *it->second == emote)
{
return it->second;
}
return std::make_shared<Emote>(std::move(emote));
}
+2
View File
@@ -208,7 +208,9 @@ namespace detail {
// https://github.com/SevenTV/chatterino7/issues/46#issuecomment-1010595231
int duration = reader.nextImageDelay();
if (duration <= 10)
{
duration = 100;
}
duration = std::max(20, duration);
frames.push_back(Frame<QImage>{std::move(image), duration});
}
+14
View File
@@ -66,9 +66,13 @@ const std::shared_ptr<Image> &getImagePriv(const ImageSet &set, float scale)
int quality = 1;
if (scale > 2.001f)
{
quality = 3;
}
else if (scale > 1.001f)
{
quality = 2;
}
if (!set.getImage3()->isEmpty() && quality == 3)
{
@@ -92,17 +96,27 @@ const ImagePtr &ImageSet::getImageOrLoaded(float scale) const
// prefer other image if selected image is not loaded yet
if (result->loaded())
{
return result;
}
else if (this->imageX3_ && !this->imageX3_->isEmpty() &&
this->imageX3_->loaded())
{
return this->imageX3_;
}
else if (this->imageX2_ && !this->imageX2_->isEmpty() &&
this->imageX2_->loaded())
{
return this->imageX2_;
}
else if (this->imageX1_->loaded())
{
return this->imageX1_;
}
else
{
return result;
}
}
const ImagePtr &ImageSet::getImage(float scale) const
+2 -2
View File
@@ -637,11 +637,11 @@ void MessageBuilder::addLink(const ParsedLink &parsedLink)
auto linkElement = Link(Link::Url, matchedLink);
auto textColor = MessageColor(MessageColor::Link);
auto linkMELowercase =
auto *linkMELowercase =
this->emplace<TextElement>(lowercaseLinkString,
MessageElementFlag::LowercaseLink, textColor)
->setLink(linkElement);
auto linkMEOriginal =
auto *linkMEOriginal =
this->emplace<TextElement>(origLink, MessageElementFlag::OriginalLink,
textColor)
->setLink(linkElement);
+26 -16
View File
@@ -212,7 +212,9 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container,
auto image =
this->emote_->images.getImageOrLoaded(container.getScale());
if (image->isEmpty())
{
return;
}
auto emoteScale = getSettings()->emoteScale.getValue();
@@ -420,7 +422,9 @@ void BadgeElement::addToContainer(MessageLayoutContainer &container,
auto image =
this->emote_->images.getImageOrLoaded(container.getScale());
if (image->isEmpty())
{
return;
}
auto size = QSize(int(container.getScale() * image->width()),
int(container.getScale() * image->height()));
@@ -437,7 +441,7 @@ EmotePtr BadgeElement::getEmote() const
MessageLayoutElement *BadgeElement::makeImageLayoutElement(
const ImagePtr &image, const QSize &size)
{
auto element =
auto *element =
(new ImageLayoutElement(*this, image, size))->setLink(this->getLink());
return element;
@@ -455,9 +459,9 @@ MessageLayoutElement *ModBadgeElement::makeImageLayoutElement(
{
static const QColor modBadgeBackgroundColor("#34AE0A");
auto element = (new ImageWithBackgroundLayoutElement(
*this, image, size, modBadgeBackgroundColor))
->setLink(this->getLink());
auto *element = (new ImageWithBackgroundLayoutElement(
*this, image, size, modBadgeBackgroundColor))
->setLink(this->getLink());
return element;
}
@@ -472,7 +476,7 @@ VipBadgeElement::VipBadgeElement(const EmotePtr &data,
MessageLayoutElement *VipBadgeElement::makeImageLayoutElement(
const ImagePtr &image, const QSize &size)
{
auto element =
auto *element =
(new ImageLayoutElement(*this, image, size))->setLink(this->getLink());
return element;
@@ -489,7 +493,7 @@ FfzBadgeElement::FfzBadgeElement(const EmotePtr &data,
MessageLayoutElement *FfzBadgeElement::makeImageLayoutElement(
const ImagePtr &image, const QSize &size)
{
auto element =
auto *element =
(new ImageWithBackgroundLayoutElement(*this, image, size, this->color))
->setLink(this->getLink());
@@ -513,7 +517,7 @@ TextElement::TextElement(const QString &text, MessageElementFlags flags,
void TextElement::addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags)
{
auto app = getApp();
auto *app = getApp();
if (flags.hasAny(this->getFlags()))
{
@@ -527,10 +531,10 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
auto color = this->color_.getColor(*app->themes);
app->themes->normalizeColor(color);
auto e = (new TextLayoutElement(
*this, text, QSize(width, metrics.height()),
color, this->style_, container.getScale()))
->setLink(this->getLink());
auto *e = (new TextLayoutElement(
*this, text, QSize(width, metrics.height()),
color, this->style_, container.getScale()))
->setLink(this->getLink());
e->setTrailingSpace(hasTrailingSpace);
e->setText(text);
@@ -596,14 +600,18 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
width = charWidth;
if (isSurrogate)
{
i++;
}
continue;
}
width += charWidth;
if (isSurrogate)
{
i++;
}
}
//add the final piece of wrapped text
container.addElementNoLineBreak(getTextLayoutElement(
@@ -629,7 +637,7 @@ SingleLineTextElement::SingleLineTextElement(const QString &text,
void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
MessageElementFlags flags)
{
auto app = getApp();
auto *app = getApp();
if (flags.hasAny(this->getFlags()))
{
@@ -641,10 +649,10 @@ void SingleLineTextElement::addToContainer(MessageLayoutContainer &container,
auto color = this->color_.getColor(*app->themes);
app->themes->normalizeColor(color);
auto e = (new TextLayoutElement(
*this, text, QSize(width, metrics.height()), color,
this->style_, container.getScale()))
->setLink(this->getLink());
auto *e = (new TextLayoutElement(
*this, text, QSize(width, metrics.height()), color,
this->style_, container.getScale()))
->setLink(this->getLink());
e->setTrailingSpace(hasTrailingSpace);
e->setText(text);
@@ -837,7 +845,9 @@ void ScalingImageElement::addToContainer(MessageLayoutContainer &container,
const auto &image =
this->images_.getImageOrLoaded(container.getScale());
if (image->isEmpty())
{
return;
}
auto size = QSize(image->width() * container.getScale(),
image->height() * container.getScale());
+1 -1
View File
@@ -78,7 +78,7 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags)
{
// BenchmarkGuard benchmark("MessageLayout::layout()");
auto app = getApp();
auto *app = getApp();
bool layoutRequired = false;
@@ -433,7 +433,7 @@ size_t TextLayoutElement::getSelectionIndexCount() const
void TextLayoutElement::paint(QPainter &painter,
const MessageColors & /*messageColors*/)
{
auto app = getApp();
auto *app = getApp();
QString text = this->getText();
if (text.isRightToLeft() || this->reversedNeutral)
{
@@ -461,7 +461,7 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
return 0;
}
auto app = getApp();
auto *app = getApp();
auto metrics = app->fonts->getFontMetrics(this->style_, this->scale_);
auto x = this->getRect().left();
@@ -495,7 +495,7 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
int TextLayoutElement::getXFromIndex(size_t index)
{
auto app = getApp();
auto *app = getApp();
QFontMetrics metrics =
app->fonts->getFontMetrics(this->style_, this->scale_);