feat: add "Open in custom player" to toast options (#5880)

This commit is contained in:
nerix
2025-03-05 16:29:28 +01:00
committed by GitHub
parent 54793f1496
commit 72369b1611
9 changed files with 67 additions and 11 deletions
+19
View File
@@ -11,6 +11,7 @@
#include "singletons/Paths.hpp"
#include "singletons/Settings.hpp"
#include "singletons/StreamerMode.hpp"
#include "util/CustomPlayer.hpp"
#include "util/StreamLink.hpp"
#include "widgets/helper/CommonTexts.hpp"
@@ -78,6 +79,10 @@ void performReaction(const ToastReaction &reaction, const QString &channelName)
openStreamlinkForChannel(channelName);
break;
}
case ToastReaction::OpenInCustomPlayer: {
openInCustomPlayer(channelName);
break;
}
case ToastReaction::DontOpen:
// nothing should happen
break;
@@ -106,6 +111,10 @@ void onAction(NotifyNotification *notif, const char *actionRaw, void *userData)
{
toastReaction = ToastReaction::OpenInStreamlink;
}
else if (action == OPEN_IN_CUSTOM_PLAYER)
{
toastReaction = ToastReaction::OpenInCustomPlayer;
}
performReaction(toastReaction, *channelName);
@@ -172,6 +181,9 @@ QString Toasts::findStringFromReaction(const ToastReaction &reaction)
case ToastReaction::OpenInStreamlink:
return OPEN_IN_STREAMLINK;
case ToastReaction::DontOpen:
return DONT_OPEN;
case ToastReaction::OpenInCustomPlayer:
return OPEN_IN_CUSTOM_PLAYER;
default:
return DONT_OPEN;
}
@@ -372,6 +384,13 @@ void Toasts::sendLibnotify(const QString &channelName,
notif, OPEN_IN_STREAMLINK.toUtf8().constData(),
OPEN_IN_STREAMLINK.toUtf8().constData(), (NotifyActionCallback)onAction,
channelNameHeap, nullptr);
if (!getSettings()->customURIScheme.getValue().isEmpty())
{
notify_notification_add_action(
notif, OPEN_IN_CUSTOM_PLAYER.toUtf8().constData(),
OPEN_IN_CUSTOM_PLAYER.toUtf8().constData(),
(NotifyActionCallback)onAction, channelNameHeap, nullptr);
}
auto defaultToastReaction =
static_cast<ToastReaction>(getSettings()->openFromToast.getValue());