fix: show correct scale factor of images (#5201)

This commit is contained in:
nerix 2024-02-26 18:13:21 +01:00 committed by GitHub
parent 0f42df78be
commit 4315c43eac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 13 deletions

View file

@ -39,6 +39,7 @@
- Minor: Updated to Emoji v15.1. Google emojis are now used as the fallback instead of Twitter emojis. (#5182)
- Minor: Allow theming of tab live and rerun indicators. (#5188)
- Minor: Added a fallback theme field to custom themes that will be used in case the custom theme does not contain a color Chatterino needs. If no fallback theme is specified, we'll pull the color from the included Dark or Light theme. (#5198)
- Minor: Image links now reflect the scale of their image instead of an internal label. (#5201)
- Bugfix: Fixed an issue where certain emojis did not send to Twitch chat correctly. (#4840)
- Bugfix: Fixed capitalized channel names in log inclusion list not being logged. (#4848)
- Bugfix: Trimmed custom streamlink paths on all platforms making sure you don't accidentally add spaces at the beginning or end of its path. (#4834)

View file

@ -87,24 +87,31 @@ void addEmoteContextMenuItems(QMenu *menu, const Emote &emote,
auto *copyMenu = new QMenu(menu);
copyAction->setMenu(copyMenu);
// Add copy and open links for 1x, 2x, 3x
auto addImageLink = [&](const ImagePtr &image, char scale) {
// Scale of the smallest image
std::optional<qreal> baseScale;
// Add copy and open links for images
auto addImageLink = [&](const ImagePtr &image) {
if (!image->isEmpty())
{
copyMenu->addAction("&" + QString(scale) + "x link",
[url = image->url()] {
crossPlatformCopy(url.string);
});
openMenu->addAction("&" + QString(scale) + "x link",
[url = image->url()] {
QDesktopServices::openUrl(QUrl(url.string));
});
if (!baseScale)
{
baseScale = image->scale();
}
auto factor =
QString::number(static_cast<int>(*baseScale / image->scale()));
copyMenu->addAction("&" + factor + "x link", [url = image->url()] {
crossPlatformCopy(url.string);
});
openMenu->addAction("&" + factor + "x link", [url = image->url()] {
QDesktopServices::openUrl(QUrl(url.string));
});
}
};
addImageLink(emote.images.getImage1(), '1');
addImageLink(emote.images.getImage2(), '2');
addImageLink(emote.images.getImage3(), '3');
addImageLink(emote.images.getImage1());
addImageLink(emote.images.getImage2());
addImageLink(emote.images.getImage3());
// Copy and open emote page link
auto addPageLink = [&](const QString &name) {