Added stream titles to windows toast notifications (#2044)

Co-authored-by: 23rd <23rd@vivaldi.net>
Co-authored-by: David Myers <dave-myers@outlook.com>
Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
yodax 2022-10-30 08:29:43 -04:00 committed by GitHub
parent fa93d63383
commit d23d5c142e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 9 deletions

View file

@ -67,6 +67,7 @@
- Minor: Migrated /vips to Helix API. Chat command will continue to be used until February 11th 2023. (#4053)
- Minor: Migrated /uniquechat and /r9kbeta to Helix API. (#4057)
- Minor: Migrated /uniquechatoff and /r9kbetaoff to Helix API. (#4057)
- Minor: Added stream titles to windows live toast notifications. (#1297)
- Minor: Make menus and placeholders display appropriate custom key combos. (#4045)
- Minor: Add settings tooltips. (#3437)
- Bugfix: Connection to Twitch PubSub now recovers more reliably. (#3643, #3716)

View file

@ -187,7 +187,7 @@ void NotificationController::checkStream(bool live, QString channelName)
if (Toasts::isEnabled())
{
getApp()->toasts->sendChannelNotification(channelName,
getApp()->toasts->sendChannelNotification(channelName, QString(),
Platform::Twitch);
}
if (getSettings()->notificationPlaySound &&

View file

@ -640,7 +640,7 @@ void TwitchChannel::setLive(bool newLiveStatus)
if (Toasts::isEnabled())
{
getApp()->toasts->sendChannelNotification(
this->getName(), Platform::Twitch);
this->getName(), guard->title, Platform::Twitch);
}
if (getSettings()->notificationPlaySound)
{

View file

@ -66,11 +66,12 @@ QString Toasts::findStringFromReaction(
return Toasts::findStringFromReaction(static_cast<ToastReaction>(i));
}
void Toasts::sendChannelNotification(const QString &channelName, Platform p)
void Toasts::sendChannelNotification(const QString &channelName,
const QString &channelTitle, Platform p)
{
#ifdef Q_OS_WIN
auto sendChannelNotification = [this, channelName, p] {
this->sendWindowsNotification(channelName, p);
auto sendChannelNotification = [this, channelName, channelTitle, p] {
this->sendWindowsNotification(channelName, channelTitle, p);
};
#else
auto sendChannelNotification = [] {
@ -164,7 +165,8 @@ public:
}
};
void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
void Toasts::sendWindowsNotification(const QString &channelName,
const QString &channelTitle, Platform p)
{
WinToastLib::WinToastTemplate templ = WinToastLib::WinToastTemplate(
WinToastLib::WinToastTemplate::ImageAndText03);
@ -180,7 +182,10 @@ void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
Toasts::findStringFromReaction(getSettings()->openFromToast);
mode = mode.toLower();
templ.setTextField(L"Click here to " + mode.toStdWString(),
templ.setTextField(QString("%1 \nClick to %2")
.arg(channelTitle)
.arg(mode)
.toStdWString(),
WinToastLib::WinToastTemplate::SecondLine);
}

View file

@ -19,7 +19,8 @@ enum class ToastReaction {
class Toasts final : public Singleton
{
public:
void sendChannelNotification(const QString &channelName, Platform p);
void sendChannelNotification(const QString &channelName,
const QString &channelTitle, Platform p);
static QString findStringFromReaction(const ToastReaction &reaction);
static QString findStringFromReaction(
const pajlada::Settings::Setting<int> &reaction);
@ -29,7 +30,8 @@ public:
private:
#ifdef Q_OS_WIN
void sendWindowsNotification(const QString &channelName, Platform p);
void sendWindowsNotification(const QString &channelName,
const QString &channelTitle, Platform p);
#endif
};
} // namespace chatterino