Skip to content

Commit b9f5a99

Browse files
committed
fix: expose home page of badges (if available)
1 parent 117d06b commit b9f5a99

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unversioned
44

5+
- Minor: Badges now link to their home page like emotes. (#6437)
6+
57
## 2.5.4
68

79
- Bugfix: Fixed crashes that could occur when Lua functions errored with values other than strings. (#6441)

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ find_package(Qt${MAJOR_QT_VERSION} REQUIRED
126126
Core
127127
Widgets
128128
Gui
129+
GuiPrivate
129130
Network
130131
Svg
131132
Concurrent

src/widgets/helper/ChannelView.cpp

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ using namespace chatterino;
7878

7979
constexpr int SCROLLBAR_PADDING = 8;
8080

81-
void addEmoteContextMenuItems(QMenu *menu, const Emote &emote,
82-
MessageElementFlags creatorFlags)
81+
void addEmoteContextMenuItems(QMenu *menu, const Emote &emote, QStringView kind)
8382
{
8483
auto *openAction = menu->addAction("&Open");
8584
auto *openMenu = new QMenu(menu);
@@ -116,31 +115,19 @@ void addEmoteContextMenuItems(QMenu *menu, const Emote &emote,
116115
addImageLink(emote.images.getImage3());
117116

118117
// Copy and open emote page link
119-
auto addPageLink = [&](const QString &name) {
118+
if (!emote.homePage.string.isEmpty())
119+
{
120120
copyMenu->addSeparator();
121121
openMenu->addSeparator();
122122

123-
copyMenu->addAction("Copy " + name + " &emote link",
123+
copyMenu->addAction(u"Copy &" % kind % u" link",
124124
[url = emote.homePage] {
125125
crossPlatformCopy(url.string);
126126
});
127-
openMenu->addAction("Open " + name + " &emote link",
127+
openMenu->addAction(u"Open &" % kind % u" link",
128128
[url = emote.homePage] {
129129
QDesktopServices::openUrl(QUrl(url.string));
130130
});
131-
};
132-
133-
if (creatorFlags.has(MessageElementFlag::BttvEmote))
134-
{
135-
addPageLink("BTTV");
136-
}
137-
else if (creatorFlags.has(MessageElementFlag::FfzEmote))
138-
{
139-
addPageLink("FFZ");
140-
}
141-
else if (creatorFlags.has(MessageElementFlag::SevenTVEmote))
142-
{
143-
addPageLink("7TV");
144131
}
145132
}
146133

@@ -161,8 +148,7 @@ void addImageContextMenuItems(QMenu *menu,
161148
if (const auto *badgeElement =
162149
dynamic_cast<const BadgeElement *>(&creator))
163150
{
164-
addEmoteContextMenuItems(menu, *badgeElement->getEmote(),
165-
creatorFlags);
151+
addEmoteContextMenuItems(menu, *badgeElement->getEmote(), u"badge");
166152
}
167153
}
168154

@@ -173,8 +159,7 @@ void addImageContextMenuItems(QMenu *menu,
173159
if (const auto *emoteElement =
174160
dynamic_cast<const EmoteElement *>(&creator))
175161
{
176-
addEmoteContextMenuItems(menu, *emoteElement->getEmote(),
177-
creatorFlags);
162+
addEmoteContextMenuItems(menu, *emoteElement->getEmote(), u"emote");
178163
}
179164
else if (const auto *layeredElement =
180165
dynamic_cast<const LayeredEmoteElement *>(&creator))
@@ -185,7 +170,7 @@ void addImageContextMenuItems(QMenu *menu,
185170
auto *emoteAction = menu->addAction(emote.ptr->name.string);
186171
auto *emoteMenu = new QMenu(menu);
187172
emoteAction->setMenu(emoteMenu);
188-
addEmoteContextMenuItems(emoteMenu, *emote.ptr, emote.flags);
173+
addEmoteContextMenuItems(emoteMenu, *emote.ptr, u"emote");
189174
}
190175
}
191176
}

0 commit comments

Comments
 (0)