From 5b271858ac6acf349fe5329404239b28bca80802 Mon Sep 17 00:00:00 2001 From: Brian <18603393+brian6932@users.noreply.github.com> Date: Sat, 23 Aug 2025 16:39:00 -0400 Subject: [PATCH] feat: Add `Open in custom player` to `twitch.tv/` link context menus (#6403) --- CHANGELOG.md | 1 + src/widgets/helper/ChannelView.cpp | 10 +++++++++- src/widgets/helper/ChannelView.hpp | 1 + src/widgets/splits/Split.cpp | 10 ++++++++-- src/widgets/splits/Split.hpp | 10 +++++++--- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5c6f4faf..ae03ab0e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Unversioned +- Minor: Added `Open in custom player` to `twitch.tv/` link context menus. (#6403) - Minor: Added user notes to the user info dialog (when clicking a username). (#6122, #6318) - Minor: Added cached emotes fallback when fetching from a provider fails. (#6125, #6229) - Minor: Add an option for the reduced opacity of message history. (#6121) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 3b80cd72..7b24c631 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -2816,13 +2816,21 @@ void ChannelView::addTwitchLinkContextMenuItems( this->openChannelIn.invoke(twitchUsername, FromTwitchLinkOpenChannelIn::Streamlink); }); + + if (!getSettings()->customURIScheme.getValue().isEmpty()) + { + menu->addAction("Open in custom &player", [twitchUsername, this] { + this->openChannelIn.invoke( + twitchUsername, FromTwitchLinkOpenChannelIn::CustomPlayer); + }); + } } } void ChannelView::addCommandExecutionContextMenuItems( QMenu *menu, const MessageLayoutPtr &layout) { - /* Get commands to be displayed in context menu; + /* Get commands to be displayed in context menu; * only those that had the showInMsgContextMenu check box marked in the Commands page */ std::vector cmds; for (const auto &cmd : getApp()->getCommands()->items) diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 61a5333c..096e5e1c 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -61,6 +61,7 @@ enum class FromTwitchLinkOpenChannelIn { Tab, BrowserPlayer, Streamlink, + CustomPlayer, }; using SteadyClock = std::chrono::steady_clock; diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 8a50aaf0..8123d0aa 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -151,6 +151,8 @@ Split::Split(QWidget *parent) case FromTwitchLinkOpenChannelIn::Streamlink: this->openChannelInStreamlink(twitchChannel); break; + case FromTwitchLinkOpenChannelIn::CustomPlayer: + this->openChannelInCustomPlayer(twitchChannel); default: qCWarning(chatterinoWidget) << "Unhandled \"FromTwitchLinkOpenChannelIn\" enum " @@ -804,6 +806,11 @@ void Split::openChannelInStreamlink(const QString channelName) } } +void Split::openChannelInCustomPlayer(const QString channelName) +{ + openInCustomPlayer(channelName); +} + IndirectChannel Split::getIndirectChannel() { return this->channel_; @@ -1137,10 +1144,9 @@ void Split::openInStreamlink() void Split::openWithCustomScheme() { auto *const channel = this->getChannel().get(); - if (auto *const twitchChannel = dynamic_cast(channel)) { - openInCustomPlayer(twitchChannel->getName()); + this->openChannelInCustomPlayer(twitchChannel->getName()); } } diff --git a/src/widgets/splits/Split.hpp b/src/widgets/splits/Split.hpp index bd2b044a..2173cad4 100644 --- a/src/widgets/splits/Split.hpp +++ b/src/widgets/splits/Split.hpp @@ -123,15 +123,19 @@ private: void addShortcuts() override; /** - * @brief Opens Twitch channel stream in a browser player (opens a formatted link) + * @brief Opens a Twitch channel's stream in your default browser's player (opens a formatted link) */ void openChannelInBrowserPlayer(ChannelPtr channel); /** - * @brief Opens Twitch channel stream in streamlink app (if stream is live and streamlink is installed) + * @brief Opens a Twitch channel's stream in streamlink (if the stream's live, and streamlink's installed) */ void openChannelInStreamlink(const QString channelName); /** - * @brief Opens Twitch channel chat in a new Chatterino tab + * @brief Opens a Twitch channel's stream in your custom player (if the stream's live, and the custom player protocol's set) + */ + void openChannelInCustomPlayer(QString channelName); + /** + * @brief Opens a Twitch channel's chat in a new tab */ void joinChannelInNewTab(const ChannelPtr &channel);