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