mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Added setting for opening streams from toast
Implemented #710 Added options for opening streams from clicking the toas notficiation: (according to options in splits) - open in browser - open player in browser - open in streamlink (needs to be tested, but should in theory work, since I only use the already existing function) - don't open the stream (in case someone wants to prevent opening streams "by accident")
This commit is contained in:
parent
4cf656fe62
commit
ad38d0ca1c
|
@ -172,6 +172,7 @@ public:
|
||||||
"qrc:/sounds/ping3.wav"};
|
"qrc:/sounds/ping3.wav"};
|
||||||
|
|
||||||
BoolSetting notificationToast = {"/notifications/enableToast", false};
|
BoolSetting notificationToast = {"/notifications/enableToast", false};
|
||||||
|
QStringSetting openFromToast = {"/notifications/openFromToast", "in browser"};
|
||||||
|
|
||||||
/// External tools
|
/// External tools
|
||||||
// Streamlink
|
// Streamlink
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/Paths.hpp"
|
#include "singletons/Paths.hpp"
|
||||||
|
#include "util/StreamLink.hpp"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
||||||
|
@ -85,12 +86,30 @@ public:
|
||||||
}
|
}
|
||||||
void toastActivated() const
|
void toastActivated() const
|
||||||
{
|
{
|
||||||
|
QString openingMode = getSettings()->openFromToast;
|
||||||
QString link;
|
QString link;
|
||||||
if (platform_ == Platform::Twitch)
|
if (openingMode == "in browser")
|
||||||
{
|
{
|
||||||
link = "http://www.twitch.tv/" + channelName_;
|
if (platform_ == Platform::Twitch)
|
||||||
|
{
|
||||||
|
link = "http://www.twitch.tv/" + channelName_;
|
||||||
|
}
|
||||||
|
QDesktopServices::openUrl(QUrl(link));
|
||||||
}
|
}
|
||||||
QDesktopServices::openUrl(QUrl(link));
|
else if (openingMode == "player in browser")
|
||||||
|
{
|
||||||
|
if (platform_ == Platform::Twitch)
|
||||||
|
{
|
||||||
|
link = "https://player.twitch.tv/?channel=" + channelName_;
|
||||||
|
}
|
||||||
|
QDesktopServices::openUrl(QUrl(link));
|
||||||
|
}
|
||||||
|
else if (openingMode == "in streamlink")
|
||||||
|
{
|
||||||
|
openStreamlinkForChannel(channelName_);
|
||||||
|
}
|
||||||
|
//the fourth and last option is "don't open"
|
||||||
|
//in this case obviously nothing should happen
|
||||||
}
|
}
|
||||||
|
|
||||||
void toastActivated(int actionIndex) const
|
void toastActivated(int actionIndex) const
|
||||||
|
@ -115,8 +134,14 @@ void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
|
||||||
std::wstring widestr = std::wstring(utf8_text.begin(), utf8_text.end());
|
std::wstring widestr = std::wstring(utf8_text.begin(), utf8_text.end());
|
||||||
|
|
||||||
templ.setTextField(widestr, WinToastLib::WinToastTemplate::FirstLine);
|
templ.setTextField(widestr, WinToastLib::WinToastTemplate::FirstLine);
|
||||||
templ.setTextField(L"Click here to open in browser",
|
|
||||||
WinToastLib::WinToastTemplate::SecondLine);
|
if (getSettings()->openFromToast != "don't open") {
|
||||||
|
QString mode = getSettings()->openFromToast ;
|
||||||
|
|
||||||
|
templ.setTextField(L"Click here to open " + mode.toStdWString(),
|
||||||
|
WinToastLib::WinToastTemplate::SecondLine);
|
||||||
|
}
|
||||||
|
|
||||||
QString Path;
|
QString Path;
|
||||||
if (p == Platform::Twitch)
|
if (p == Platform::Twitch)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,6 +17,10 @@
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
|
|
||||||
|
#define TOAST_REACTIONS \
|
||||||
|
"in browser", "player in browser", "in streamlink", "don't open"
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
NotificationPage::NotificationPage()
|
NotificationPage::NotificationPage()
|
||||||
|
@ -39,6 +43,18 @@ NotificationPage::NotificationPage()
|
||||||
settings.append(
|
settings.append(
|
||||||
this->createCheckBox("Enable toasts (Windows 8 or later)",
|
this->createCheckBox("Enable toasts (Windows 8 or later)",
|
||||||
getSettings()->notificationToast));
|
getSettings()->notificationToast));
|
||||||
|
auto openIn =
|
||||||
|
settings.emplace<QHBoxLayout>().withoutMargin();
|
||||||
|
{
|
||||||
|
openIn.emplace<QLabel>("Open stream from Toast: ")->setSizePolicy(
|
||||||
|
QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||||
|
openIn.append(
|
||||||
|
this->createComboBox({TOAST_REACTIONS},
|
||||||
|
getSettings()->openFromToast))->setSizePolicy(
|
||||||
|
QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||||
|
}
|
||||||
|
openIn->setContentsMargins(40,0,0,0);
|
||||||
|
openIn->setSizeConstraint(QLayout::SetMaximumSize);
|
||||||
#endif
|
#endif
|
||||||
auto customSound =
|
auto customSound =
|
||||||
layout.emplace<QHBoxLayout>().withoutMargin();
|
layout.emplace<QHBoxLayout>().withoutMargin();
|
||||||
|
|
Loading…
Reference in a new issue