mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed stuff
This commit is contained in:
parent
df7d256c7f
commit
c5a88f6af3
|
@ -2,11 +2,14 @@
|
||||||
|
|
||||||
#include "Application.hpp"
|
#include "Application.hpp"
|
||||||
#include "common/NetworkRequest.hpp"
|
#include "common/NetworkRequest.hpp"
|
||||||
|
#include "common/Outcome.hpp"
|
||||||
#include "controllers/notifications/NotificationModel.hpp"
|
#include "controllers/notifications/NotificationModel.hpp"
|
||||||
|
#include "debug/Log.hpp"
|
||||||
#include "providers/twitch/TwitchApi.hpp"
|
#include "providers/twitch/TwitchApi.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/Toasts.hpp"
|
#include "singletons/Toasts.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
|
#include "widgets/Window.hpp"
|
||||||
|
|
||||||
#include <wintoastlib.h>
|
#include <wintoastlib.h>
|
||||||
|
|
||||||
|
@ -93,9 +96,9 @@ void NotificationController::playSound()
|
||||||
static QUrl currentPlayerUrl;
|
static QUrl currentPlayerUrl;
|
||||||
|
|
||||||
QUrl highlightSoundUrl;
|
QUrl highlightSoundUrl;
|
||||||
if (getApp()->settings->notificationCustomSound) {
|
if (getSettings()->notificationCustomSound) {
|
||||||
highlightSoundUrl = QUrl::fromLocalFile(
|
highlightSoundUrl = QUrl::fromLocalFile(
|
||||||
getApp()->settings->notificationPathSound.getValue());
|
getSettings()->notificationPathSound.getValue());
|
||||||
} else {
|
} else {
|
||||||
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
|
highlightSoundUrl = QUrl("qrc:/sounds/ping2.wav");
|
||||||
}
|
}
|
||||||
|
@ -134,12 +137,12 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
|
||||||
{
|
{
|
||||||
TwitchApi::findUserId(channelName, [channelName, this](QString roomID) {
|
TwitchApi::findUserId(channelName, [channelName, this](QString roomID) {
|
||||||
if (roomID.isEmpty()) {
|
if (roomID.isEmpty()) {
|
||||||
Log("[TwitchChannel:{}] Refreshing live status (Missing ID)",
|
log("[TwitchChannel:{}] Refreshing live status (Missing ID)",
|
||||||
channelName);
|
channelName);
|
||||||
removeFakeChannel(channelName);
|
removeFakeChannel(channelName);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Log("[TwitchChannel:{}] Refreshing live status", channelName);
|
log("[TwitchChannel:{}] Refreshing live status", channelName);
|
||||||
|
|
||||||
QString url("https://api.twitch.tv/kraken/streams/" + roomID);
|
QString url("https://api.twitch.tv/kraken/streams/" + roomID);
|
||||||
auto request = NetworkRequest::twitchRequest(url);
|
auto request = NetworkRequest::twitchRequest(url);
|
||||||
|
@ -148,12 +151,12 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
|
||||||
request.onSuccess([this, channelName](auto result) -> Outcome {
|
request.onSuccess([this, channelName](auto result) -> Outcome {
|
||||||
rapidjson::Document document = result.parseRapidJson();
|
rapidjson::Document document = result.parseRapidJson();
|
||||||
if (!document.IsObject()) {
|
if (!document.IsObject()) {
|
||||||
Log("[TwitchChannel:refreshLiveStatus] root is not an object");
|
log("[TwitchChannel:refreshLiveStatus]root is not an object");
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!document.HasMember("stream")) {
|
if (!document.HasMember("stream")) {
|
||||||
Log("[TwitchChannel:refreshLiveStatus] Missing stream in root");
|
log("[TwitchChannel:refreshLiveStatus] Missing stream in root");
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +164,7 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
|
||||||
|
|
||||||
if (!stream.IsObject()) {
|
if (!stream.IsObject()) {
|
||||||
// Stream is offline (stream is most likely null)
|
// Stream is offline (stream is most likely null)
|
||||||
removeFakeChannel(channelName);
|
// removeFakeChannel(channelName);
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
// Stream is live
|
// Stream is live
|
||||||
|
@ -174,14 +177,15 @@ void NotificationController::getFakeTwitchChannelLiveStatus(
|
||||||
getApp()->toasts->sendChannelNotification(channelName,
|
getApp()->toasts->sendChannelNotification(channelName,
|
||||||
Platform::Twitch);
|
Platform::Twitch);
|
||||||
}
|
}
|
||||||
if (getApp()->settings->notificationPlaySound) {
|
if (getSettings()->notificationPlaySound) {
|
||||||
getApp()->notifications->playSound();
|
getApp()->notifications->playSound();
|
||||||
}
|
}
|
||||||
if (getApp()->settings->notificationFlashTaskbar) {
|
if (getSettings()->notificationFlashTaskbar) {
|
||||||
QApplication::alert(
|
QApplication::alert(
|
||||||
getApp()->windows->getMainWindow().window(), 2500);
|
getApp()->windows->getMainWindow().window(), 2500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return Success;
|
||||||
});
|
});
|
||||||
|
|
||||||
request.execute();
|
request.execute();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/SignalVector.hpp"
|
#include "common/SignalVector.hpp"
|
||||||
|
#include "common/Singleton.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "providers/twitch/TwitchCommon.hpp"
|
#include "providers/twitch/TwitchCommon.hpp"
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QThread>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
#include "singletons/Toasts.hpp"
|
#include "singletons/Toasts.hpp"
|
||||||
#include "singletons/WindowManager.hpp"
|
#include "singletons/WindowManager.hpp"
|
||||||
#include "util/PostToThread.hpp"
|
#include "util/PostToThread.hpp"
|
||||||
|
#include "widgets/Window.hpp"
|
||||||
|
|
||||||
#include <IrcConnection>
|
#include <IrcConnection>
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
|
@ -400,10 +401,10 @@ void TwitchChannel::setLive(bool newLiveStatus)
|
||||||
getApp()->toasts->sendChannelNotification(this->getName(),
|
getApp()->toasts->sendChannelNotification(this->getName(),
|
||||||
Platform::Twitch);
|
Platform::Twitch);
|
||||||
}
|
}
|
||||||
if (getApp()->settings->notificationPlaySound) {
|
if (getSettings()->notificationPlaySound) {
|
||||||
getApp()->notifications->playSound();
|
getApp()->notifications->playSound();
|
||||||
}
|
}
|
||||||
if (getApp()->settings->notificationFlashTaskbar) {
|
if (getSettings()->notificationFlashTaskbar) {
|
||||||
QApplication::alert(
|
QApplication::alert(
|
||||||
getApp()->windows->getMainWindow().window(), 2500);
|
getApp()->windows->getMainWindow().window(), 2500);
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
enum class HighlightState;
|
||||||
|
|
||||||
struct Emote;
|
struct Emote;
|
||||||
using EmotePtr = std::shared_ptr<const Emote>;
|
using EmotePtr = std::shared_ptr<const Emote>;
|
||||||
class EmoteMap;
|
class EmoteMap;
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace chatterino {
|
||||||
bool Toasts::isEnabled()
|
bool Toasts::isEnabled()
|
||||||
{
|
{
|
||||||
return WinToastLib::WinToast::isCompatible() &&
|
return WinToastLib::WinToast::isCompatible() &&
|
||||||
getApp()->settings->notificationToast;
|
getSettings()->notificationToast;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Toasts::sendChannelNotification(const QString &channelName, Platform p)
|
void Toasts::sendChannelNotification(const QString &channelName, Platform p)
|
||||||
|
@ -115,13 +115,13 @@ void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
|
||||||
WinToastLib::WinToastTemplate::SecondLine);
|
WinToastLib::WinToastTemplate::SecondLine);
|
||||||
QString Path;
|
QString Path;
|
||||||
if (p == Platform::Twitch) {
|
if (p == Platform::Twitch) {
|
||||||
Path = getApp()->paths->cacheDirectory() + "/" +
|
Path = Path = getPaths()->cacheDirectory() + "/" +
|
||||||
"profileAvatars/twitch/" + channelName + ".png";
|
"profileAvatars/twitch/" + channelName + ".png";
|
||||||
}
|
}
|
||||||
std::string temp_Utf8 = Path.toUtf8().constData();
|
std::string temp_Utf8 = Path.toUtf8().constData();
|
||||||
std::wstring imagePath = std::wstring(temp_Utf8.begin(), temp_Utf8.end());
|
std::wstring imagePath = std::wstring(temp_Utf8.begin(), temp_Utf8.end());
|
||||||
templ.setImagePath(imagePath);
|
templ.setImagePath(imagePath);
|
||||||
if (getApp()->settings->notificationPlaySound) {
|
if (getSettings()->notificationPlaySound) {
|
||||||
templ.setAudioOption(
|
templ.setAudioOption(
|
||||||
WinToastLib::WinToastTemplate::AudioOption::Silent);
|
WinToastLib::WinToastTemplate::AudioOption::Silent);
|
||||||
}
|
}
|
||||||
|
@ -154,28 +154,30 @@ void Toasts::fetchChannelAvatar(const QString channelName,
|
||||||
request.onSuccess([successCallback](auto result) mutable -> Outcome {
|
request.onSuccess([successCallback](auto result) mutable -> Outcome {
|
||||||
auto root = result.parseJson();
|
auto root = result.parseJson();
|
||||||
if (!root.value("users").isArray()) {
|
if (!root.value("users").isArray()) {
|
||||||
Log("API Error while getting user id, users is not an array");
|
// log("API Error while getting user id, users is not an array");
|
||||||
successCallback("");
|
successCallback("");
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
auto users = root.value("users").toArray();
|
auto users = root.value("users").toArray();
|
||||||
if (users.size() != 1) {
|
if (users.size() != 1) {
|
||||||
Log("API Error while getting user id, users array size is not 1");
|
// log("API Error while getting user id, users array size is not
|
||||||
|
// 1");
|
||||||
successCallback("");
|
successCallback("");
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
if (!users[0].isObject()) {
|
if (!users[0].isObject()) {
|
||||||
Log("API Error while getting user id, first user is not an object");
|
// log("API Error while getting user id, first user is not an
|
||||||
|
// object");
|
||||||
successCallback("");
|
successCallback("");
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
auto firstUser = users[0].toObject();
|
auto firstUser = users[0].toObject();
|
||||||
auto avatar = firstUser.value("logo");
|
auto avatar = firstUser.value("logo");
|
||||||
if (!avatar.isString()) {
|
if (!avatar.isString()) {
|
||||||
Log("API Error: while getting user avatar, first user object "
|
// log("API Error: while getting user avatar, first user object "
|
||||||
"`avatar` key "
|
// "`avatar` key "
|
||||||
"is not a "
|
// "is not a "
|
||||||
"string");
|
// "string");
|
||||||
successCallback("");
|
successCallback("");
|
||||||
return Failure;
|
return Failure;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,21 +33,21 @@ NotificationPage::NotificationPage()
|
||||||
settings.emplace<QLabel>("Enable for selected channels");
|
settings.emplace<QLabel>("Enable for selected channels");
|
||||||
settings.append(this->createCheckBox(
|
settings.append(this->createCheckBox(
|
||||||
"Flash taskbar",
|
"Flash taskbar",
|
||||||
getApp()->settings->notificationFlashTaskbar));
|
getSettings()->notificationFlashTaskbar));
|
||||||
settings.append(this->createCheckBox(
|
settings.append(this->createCheckBox(
|
||||||
"Playsound (doesn't mute the Windows 8.x sound of toasts)",
|
"Playsound (doesn't mute the Windows 8.x sound of toasts)",
|
||||||
getApp()->settings->notificationPlaySound));
|
getSettings()->notificationPlaySound));
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
settings.append(this->createCheckBox(
|
settings.append(this->createCheckBox(
|
||||||
"Enable toasts (currently only for windows 8.x or 10)",
|
"Enable toasts (currently only for windows 8.x or 10)",
|
||||||
getApp()->settings->notificationToast));
|
getSettings()->notificationToast));
|
||||||
#endif
|
#endif
|
||||||
auto customSound =
|
auto customSound =
|
||||||
layout.emplace<QHBoxLayout>().withoutMargin();
|
layout.emplace<QHBoxLayout>().withoutMargin();
|
||||||
{
|
{
|
||||||
customSound.append(this->createCheckBox(
|
customSound.append(this->createCheckBox(
|
||||||
"Custom sound",
|
"Custom sound",
|
||||||
getApp()->settings->notificationCustomSound));
|
getSettings()->notificationCustomSound));
|
||||||
auto selectFile = customSound.emplace<QPushButton>(
|
auto selectFile = customSound.emplace<QPushButton>(
|
||||||
"Select custom sound file");
|
"Select custom sound file");
|
||||||
QObject::connect(
|
QObject::connect(
|
||||||
|
@ -56,7 +56,7 @@ NotificationPage::NotificationPage()
|
||||||
auto fileName = QFileDialog::getOpenFileName(
|
auto fileName = QFileDialog::getOpenFileName(
|
||||||
this, tr("Open Sound"), "",
|
this, tr("Open Sound"), "",
|
||||||
tr("Audio Files (*.mp3 *.wav)"));
|
tr("Audio Files (*.mp3 *.wav)"));
|
||||||
getApp()->settings->notificationPathSound =
|
getSettings()->notificationPathSound =
|
||||||
fileName;
|
fileName;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue