fix: replace defines with constexpr/const and use more absolute paths for includes (#5527)

bye bye nuuls
This commit is contained in:
nerix
2024-08-03 12:00:58 +02:00
committed by GitHub
parent 5ee5abf5b2
commit aed55ac1ba
83 changed files with 386 additions and 380 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
#include "IvrApi.hpp"
#include "providers/IvrApi.hpp"
#include "common/network/NetworkResult.hpp"
#include "common/QLogging.hpp"
+1 -3
View File
@@ -64,9 +64,7 @@ struct IvrEmote {
: code(root.value("code").toString())
, id(root.value("id").toString())
, setId(root.value("setID").toString())
, url(QString(TWITCH_EMOTE_TEMPLATE)
.replace("{id}", this->id)
.replace("{scale}", "3.0"))
, url(TWITCH_EMOTE_TEMPLATE.arg(this->id, u"3.0"))
, emoteType(root.value("type").toString())
, imageType(root.value("assetType").toString())
{
+1 -1
View File
@@ -1,4 +1,4 @@
#include "AbstractIrcServer.hpp"
#include "providers/irc/AbstractIrcServer.hpp"
#include "common/Channel.hpp"
#include "common/QLogging.hpp"
+1 -1
View File
@@ -1,4 +1,4 @@
#include "Irc2.hpp"
#include "providers/irc/Irc2.hpp"
#include "Application.hpp"
#include "common/Credentials.hpp"
+1 -1
View File
@@ -1,4 +1,4 @@
#include "IrcAccount.hpp"
#include "providers/irc/IrcAccount.hpp"
// namespace chatterino {
//
+1 -1
View File
@@ -1,4 +1,4 @@
#include "IrcChannel2.hpp"
#include "providers/irc/IrcChannel2.hpp"
#include "common/Channel.hpp"
#include "debug/AssertInGuiThread.hpp"
+1 -1
View File
@@ -1,4 +1,4 @@
#include "IrcCommands.hpp"
#include "providers/irc/IrcCommands.hpp"
#include "messages/MessageBuilder.hpp"
#include "providers/irc/IrcChannel2.hpp"
+2 -2
View File
@@ -1,4 +1,4 @@
#include "IrcConnection2.hpp"
#include "providers/irc/IrcConnection2.hpp"
#include "common/QLogging.hpp"
#include "common/Version.hpp"
@@ -11,7 +11,7 @@ namespace chatterino {
namespace {
const auto payload = QString("chatterino/" CHATTERINO_VERSION);
const auto payload = "chatterino/" + CHATTERINO_VERSION;
} // namespace
+1 -1
View File
@@ -1,4 +1,4 @@
#include "IrcServer.hpp"
#include "providers/irc/IrcServer.hpp"
#include "Application.hpp"
#include "common/QLogging.hpp"
+15 -6
View File
@@ -1,8 +1,18 @@
#include "ChannelPointReward.hpp"
#include "providers/twitch/ChannelPointReward.hpp"
#include "common/QLogging.hpp"
#include "messages/Image.hpp"
#include <QStringBuilder>
namespace {
QString twitchChannelPointRewardUrl(const QString &file)
{
return u"https://static-cdn.jtvnw.net/custom-reward-images/default-" % file;
}
} // namespace
namespace chatterino {
ChannelPointReward::ChannelPointReward(const QJsonObject &redemption)
@@ -94,11 +104,10 @@ ChannelPointReward::ChannelPointReward(const QJsonObject &redemption)
else
{
static const ImageSet defaultImage{
Image::fromUrl({TWITCH_CHANNEL_POINT_REWARD_URL("1.png")}, 1,
baseSize),
Image::fromUrl({TWITCH_CHANNEL_POINT_REWARD_URL("2.png")}, 0.5,
Image::fromUrl({twitchChannelPointRewardUrl("1.png")}, 1, baseSize),
Image::fromUrl({twitchChannelPointRewardUrl("2.png")}, 0.5,
baseSize * 2),
Image::fromUrl({TWITCH_CHANNEL_POINT_REWARD_URL("4.png")}, 0.25,
Image::fromUrl({twitchChannelPointRewardUrl("4.png")}, 0.25,
baseSize * 4)};
this->image = defaultImage;
}
+1 -5
View File
@@ -1,15 +1,11 @@
#pragma once
#include "common/Aliases.hpp"
#include "messages/ImageSet.hpp"
#include <QJsonObject>
#define TWITCH_CHANNEL_POINT_REWARD_URL(x) \
QString("https://static-cdn.jtvnw.net/custom-reward-images/default-%1") \
.arg(x)
namespace chatterino {
struct ChannelPointReward {
ChannelPointReward(const QJsonObject &redemption);
ChannelPointReward() = delete;
+1 -3
View File
@@ -11,9 +11,7 @@ using namespace chatterino;
Url getEmoteLink(const EmoteId &id, const QString &emoteScale)
{
return {QString(TWITCH_EMOTE_TEMPLATE)
.replace("{id}", id.string)
.replace("{scale}", emoteScale)};
return {TWITCH_EMOTE_TEMPLATE.arg(id.string, emoteScale)};
}
QSize getEmoteExpectedBaseSize(const EmoteId &id)
+6 -3
View File
@@ -10,12 +10,15 @@
#include <memory>
#include <unordered_map>
namespace chatterino {
// NB: "default" can be replaced with "static" to always get a non-animated
// variant
#define TWITCH_EMOTE_TEMPLATE \
"https://static-cdn.jtvnw.net/emoticons/v2/{id}/default/dark/{scale}"
/// %1 <-> {id}
/// %2 <-> {scale} (1.0, 2.0, 3.0)
constexpr QStringView TWITCH_EMOTE_TEMPLATE =
u"https://static-cdn.jtvnw.net/emoticons/v2/%1/default/dark/%2";
namespace chatterino {
struct Emote;
using EmotePtr = std::shared_ptr<const Emote>;
+1 -3
View File
@@ -276,9 +276,7 @@ struct HelixChannelEmote {
, name(jsonObject.value("name").toString())
, type(jsonObject.value("emote_type").toString())
, setId(jsonObject.value("emote_set_id").toString())
, url(QString(TWITCH_EMOTE_TEMPLATE)
.replace("{id}", this->emoteId)
.replace("{scale}", "3.0"))
, url(TWITCH_EMOTE_TEMPLATE.arg(this->emoteId, u"3.0"))
{
}
};