fix: expose home page of badges (if available) (#6437)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
## Unversioned
|
||||
|
||||
- Minor: Badges now link to their home page like emotes in the context menu. (#6437)
|
||||
- Minor: Fixed usercard resizing improperly without recent messages. (#6496)
|
||||
- Minor: Added setting for character limit of deleted messages. (#6491)
|
||||
- Dev: Update release documentation. (#6498)
|
||||
|
||||
@@ -62,6 +62,7 @@
|
||||
#include <QMessageBox>
|
||||
#include <QPainter>
|
||||
#include <QScreen>
|
||||
#include <QStringBuilder>
|
||||
#include <QVariantAnimation>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -78,8 +79,7 @@ using namespace chatterino;
|
||||
|
||||
constexpr int SCROLLBAR_PADDING = 8;
|
||||
|
||||
void addEmoteContextMenuItems(QMenu *menu, const Emote &emote,
|
||||
MessageElementFlags creatorFlags)
|
||||
void addEmoteContextMenuItems(QMenu *menu, const Emote &emote, QStringView kind)
|
||||
{
|
||||
auto *openAction = menu->addAction("&Open");
|
||||
auto *openMenu = new QMenu(menu);
|
||||
@@ -116,31 +116,19 @@ void addEmoteContextMenuItems(QMenu *menu, const Emote &emote,
|
||||
addImageLink(emote.images.getImage3());
|
||||
|
||||
// Copy and open emote page link
|
||||
auto addPageLink = [&](const QString &name) {
|
||||
if (!emote.homePage.string.isEmpty())
|
||||
{
|
||||
copyMenu->addSeparator();
|
||||
openMenu->addSeparator();
|
||||
|
||||
copyMenu->addAction("Copy " + name + " &emote link",
|
||||
copyMenu->addAction(u"Copy &" % kind % u" link",
|
||||
[url = emote.homePage] {
|
||||
crossPlatformCopy(url.string);
|
||||
});
|
||||
openMenu->addAction("Open " + name + " &emote link",
|
||||
openMenu->addAction(u"Open &" % kind % u" link",
|
||||
[url = emote.homePage] {
|
||||
QDesktopServices::openUrl(QUrl(url.string));
|
||||
});
|
||||
};
|
||||
|
||||
if (creatorFlags.has(MessageElementFlag::BttvEmote))
|
||||
{
|
||||
addPageLink("BTTV");
|
||||
}
|
||||
else if (creatorFlags.has(MessageElementFlag::FfzEmote))
|
||||
{
|
||||
addPageLink("FFZ");
|
||||
}
|
||||
else if (creatorFlags.has(MessageElementFlag::SevenTVEmote))
|
||||
{
|
||||
addPageLink("7TV");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,8 +149,7 @@ void addImageContextMenuItems(QMenu *menu,
|
||||
if (const auto *badgeElement =
|
||||
dynamic_cast<const BadgeElement *>(&creator))
|
||||
{
|
||||
addEmoteContextMenuItems(menu, *badgeElement->getEmote(),
|
||||
creatorFlags);
|
||||
addEmoteContextMenuItems(menu, *badgeElement->getEmote(), u"badge");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,8 +160,7 @@ void addImageContextMenuItems(QMenu *menu,
|
||||
if (const auto *emoteElement =
|
||||
dynamic_cast<const EmoteElement *>(&creator))
|
||||
{
|
||||
addEmoteContextMenuItems(menu, *emoteElement->getEmote(),
|
||||
creatorFlags);
|
||||
addEmoteContextMenuItems(menu, *emoteElement->getEmote(), u"emote");
|
||||
}
|
||||
else if (const auto *layeredElement =
|
||||
dynamic_cast<const LayeredEmoteElement *>(&creator))
|
||||
@@ -185,7 +171,7 @@ void addImageContextMenuItems(QMenu *menu,
|
||||
auto *emoteAction = menu->addAction(emote.ptr->name.string);
|
||||
auto *emoteMenu = new QMenu(menu);
|
||||
emoteAction->setMenu(emoteMenu);
|
||||
addEmoteContextMenuItems(emoteMenu, *emote.ptr, emote.flags);
|
||||
addEmoteContextMenuItems(emoteMenu, *emote.ptr, u"emote");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user