fix: add more image sizes to shared chat badge (#6146)

This commit is contained in:
nerix
2025-04-13 11:48:13 +02:00
committed by GitHub
parent f56b7c05bf
commit e1863d64ee
5 changed files with 73 additions and 5 deletions
+11 -5
View File
@@ -391,8 +391,10 @@ EmotePtr makeSharedChatBadge(const QString &sourceName,
{
if (!sourceProfileURL.isEmpty())
{
QString modifiedUrl = sourceProfileURL;
modifiedUrl.replace("300x300", "28x28");
auto [urlBegin, urlEnd] = splitOnce(sourceProfileURL, u"300x300");
QString url28px = urlBegin % u"28x28" % urlEnd;
QString url70px = urlBegin % u"70x70" % urlEnd;
QString url150px = urlBegin % u"150x150" % urlEnd;
auto badgeLink = [&] {
if (sourceLogin.isEmpty())
@@ -405,9 +407,13 @@ EmotePtr makeSharedChatBadge(const QString &sourceName,
return std::make_shared<Emote>(Emote{
.name = EmoteName{},
.images = ImageSet{Image::fromUrl(
Url{modifiedUrl},
18.F / 28.F)}, // get as close to 18x18 as possible
.images =
ImageSet{
// The images should be displayed like an 18x18 image
Image::fromUrl({url28px}, 18.F / 28.F),
Image::fromUrl({url70px}, 18.F / 70.F),
Image::fromUrl({url150px}, 18.F / 150.F),
},
.tooltip =
Tooltip{"Shared Message" +
(sourceName.isEmpty() ? "" : " from " + sourceName)},