mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
stuff does compile
This commit is contained in:
parent
54166ec130
commit
05d5709bb9
|
@ -32,18 +32,16 @@ void NotificationController::initialize(Settings &settings, Paths &paths)
|
|||
}
|
||||
|
||||
void NotificationController::updateChannelNotification(
|
||||
const QString &channelName, int &i)
|
||||
const QString &channelName, Platform p)
|
||||
{
|
||||
if (i == 0) {
|
||||
int j = 0;
|
||||
if (isChannelNotified(channelName, j)) {
|
||||
if (p == Platform::Twitch) {
|
||||
if (isChannelNotified(channelName, Platform::Twitch)) {
|
||||
removeChannelNotification(channelName, twitchVector);
|
||||
} else {
|
||||
addChannelNotification(channelName, twitchVector);
|
||||
}
|
||||
} else if (i == 1) {
|
||||
int k = 1;
|
||||
if (isChannelNotified(channelName, k)) {
|
||||
} else if (p == Platform::Mixer) {
|
||||
if (isChannelNotified(channelName, Platform::Mixer)) {
|
||||
removeChannelNotification(channelName, mixerVector);
|
||||
} else {
|
||||
addChannelNotification(channelName, mixerVector);
|
||||
|
@ -52,7 +50,7 @@ void NotificationController::updateChannelNotification(
|
|||
}
|
||||
|
||||
bool NotificationController::isChannelNotified(const QString &channelName,
|
||||
int &i)
|
||||
Platform p)
|
||||
{
|
||||
/*
|
||||
for (std::vector<int>::size_type i = 0;
|
||||
|
@ -62,15 +60,15 @@ bool NotificationController::isChannelNotified(const QString &channelName,
|
|||
<< " vectorsize:" << notificationVector.getVector().size();
|
||||
}
|
||||
*/
|
||||
qDebug() << channelName << " channel and now i: " << i;
|
||||
if (i == 0) {
|
||||
// qDebug() << channelName << " channel and now i: " << i;
|
||||
if (p == Platform::Twitch) {
|
||||
for (std::vector<int>::size_type i = 0;
|
||||
i != twitchVector.getVector().size(); i++) {
|
||||
if (twitchVector.getVector()[i] == channelName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
} else if (i == 1) {
|
||||
} else if (p == Platform::Mixer) {
|
||||
for (std::vector<int>::size_type i = 0;
|
||||
i != mixerVector.getVector().size(); i++) {
|
||||
if (mixerVector.getVector()[i] == channelName) {
|
||||
|
@ -164,12 +162,13 @@ void NotificationController::removeChannelNotification(
|
|||
}
|
||||
}
|
||||
|
||||
NotificationModel *NotificationController::createModel(QObject *parent, int &i)
|
||||
NotificationModel *NotificationController::createModel(QObject *parent,
|
||||
Platform p)
|
||||
{
|
||||
NotificationModel *model = new NotificationModel(parent);
|
||||
if (i == 0) {
|
||||
if (p == Platform::Twitch) {
|
||||
model->init(&this->twitchVector);
|
||||
} else if (i == 1) {
|
||||
} else if (p == Platform::Mixer) {
|
||||
model->init(&this->mixerVector);
|
||||
}
|
||||
return model;
|
||||
|
|
|
@ -10,25 +10,31 @@ class Paths;
|
|||
|
||||
class NotificationModel;
|
||||
|
||||
enum class Platform : uint8_t {
|
||||
Twitch = 0, // 0
|
||||
Mixer = 1, // 1
|
||||
HitBox = 2, // 2
|
||||
};
|
||||
|
||||
class NotificationController final : public Singleton
|
||||
{
|
||||
public:
|
||||
virtual void initialize(Settings &settings, Paths &paths) override;
|
||||
|
||||
bool isChannelNotified(const QString &channelName, int &i);
|
||||
bool isChannelNotified(const QString &channelName, Platform p);
|
||||
|
||||
void updateChannelNotification(const QString &channelName, int &i);
|
||||
void updateChannelNotification(const QString &channelName, Platform p);
|
||||
void addChannelNotification(const QString &channelName,
|
||||
UnsortedSignalVector<QString> &vector);
|
||||
void removeChannelNotification(const QString &channelName,
|
||||
UnsortedSignalVector<QString> &vector);
|
||||
|
||||
UnsortedSignalVector<QString> getVector(int &i);
|
||||
UnsortedSignalVector<QString> getVector(Platform p);
|
||||
|
||||
UnsortedSignalVector<QString> twitchVector;
|
||||
UnsortedSignalVector<QString> mixerVector;
|
||||
|
||||
NotificationModel *createModel(QObject *parent, int &i);
|
||||
NotificationModel *createModel(QObject *parent, Platform p);
|
||||
|
||||
private:
|
||||
bool initialized_ = false;
|
||||
|
|
|
@ -305,19 +305,6 @@ const QString &TwitchChannel::getPopoutPlayerUrl()
|
|||
return this->popoutPlayerUrl_;
|
||||
}
|
||||
|
||||
bool Toasts::isEnabled(const QString &channelName)
|
||||
{
|
||||
int i = 0;
|
||||
return getApp()->notifications->isChannelNotified(channelName, i);
|
||||
}
|
||||
/*
|
||||
bool toastIsEnabled()
|
||||
{
|
||||
QString channelName = this->getName();
|
||||
return getApp()->notifications->isChannelNotified(channelName);
|
||||
}
|
||||
*/
|
||||
|
||||
void TwitchChannel::setLive(bool newLiveStatus)
|
||||
{
|
||||
bool gotNewLiveStatus = false;
|
||||
|
@ -325,41 +312,21 @@ void TwitchChannel::setLive(bool newLiveStatus)
|
|||
auto guard = this->streamStatus_.access();
|
||||
if (guard->live != newLiveStatus) {
|
||||
gotNewLiveStatus = true;
|
||||
guard->live = newLiveStatus;
|
||||
}
|
||||
}
|
||||
|
||||
if (gotNewLiveStatus) {
|
||||
this->liveStatusChanged.invoke();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void TwitchChannel::setLive(bool newLiveStatus)
|
||||
{
|
||||
// auto guard = this->streamStatus_.access();
|
||||
|
||||
if (toastIsEnabled() && guard->live != newLiveStatus && guard->live !=
|
||||
newLiveStatus) { Toasts::show
|
||||
}
|
||||
|
||||
// int i = 0;
|
||||
// getApp()->toasts->sendChannelNotification(this->getName(), i);
|
||||
qDebug() << "setLive called here and channel: " << this->getName()
|
||||
<< " status: " << newLiveStatus;
|
||||
|
||||
bool gotNewLiveStatus = false;
|
||||
{
|
||||
auto guard = this->streamStatus_.access();
|
||||
if (guard->live != newLiveStatus) {
|
||||
gotNewLiveStatus = true;
|
||||
guard->live = newLiveStatus;
|
||||
|
||||
if (getApp()->toasts->isEnabled(this->getName()) &&
|
||||
guard->live == true) {
|
||||
int i = 0;
|
||||
getApp()->toasts->sendChannelNotification(this->getName(), i);
|
||||
if (Toasts::isEnabled() &&
|
||||
getApp()->notifications->isChannelNotified(this->getName(),
|
||||
Platform::Twitch)) {
|
||||
getApp()->toasts->sendChannelNotification(this->getName(),
|
||||
Platform::Twitch);
|
||||
}
|
||||
/*
|
||||
if (!guard->live && Toasts::isEnabled() &&
|
||||
getApp()->notifications->isChannelNotified( this->getName(),
|
||||
Platform::Twitch)) {
|
||||
getApp()->toasts->sendChannelNotification(this->getName(),
|
||||
Platform::Twitch);
|
||||
}
|
||||
*/
|
||||
guard->live = newLiveStatus;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -367,7 +334,7 @@ void TwitchChannel::setLive(bool newLiveStatus)
|
|||
this->liveStatusChanged.invoke();
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void TwitchChannel::refreshLiveStatus()
|
||||
{
|
||||
auto roomID = this->getRoomId();
|
||||
|
@ -441,15 +408,13 @@ Outcome TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
|
|||
{
|
||||
auto status = this->streamStatus_.access();
|
||||
/*
|
||||
if (!status->live == false &&
|
||||
getApp()->toasts->isEnabled(this->getName())) {
|
||||
if (!(status->live) && getApp()->toasts->isEnabled(this->getName())) {
|
||||
qDebug() << " NaM xd NaM ";
|
||||
int i = 0;
|
||||
getApp()->toasts->sendChannelNotification(this->getName(), i);
|
||||
// notifcation send
|
||||
}
|
||||
status->live = true;
|
||||
*/
|
||||
this->setLive(true);
|
||||
*/
|
||||
// status->live = true;
|
||||
status->viewerCount = stream["viewers"].GetUint();
|
||||
status->game = stream["game"].GetString();
|
||||
|
@ -479,7 +444,7 @@ Outcome TwitchChannel::parseLiveStatus(const rapidjson::Document &document)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
setLive(true);
|
||||
// Signal all listeners that the stream status has been updated
|
||||
this->liveStatusChanged.invoke();
|
||||
|
||||
|
|
|
@ -144,6 +144,7 @@ public:
|
|||
false};
|
||||
BoolSetting notificationPlaySound = {"/notifications/enablePlaySound",
|
||||
false};
|
||||
BoolSetting notificationToast = {"/notifications/enableToast", false};
|
||||
|
||||
/// External tools
|
||||
// Streamlink
|
||||
|
|
|
@ -5,8 +5,12 @@
|
|||
#include "providers/twitch/TwitchChannel.hpp"
|
||||
#include "providers/twitch/TwitchServer.hpp"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
|
||||
#include <wintoastlib.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <QDesktopServices>
|
||||
#include <QUrl>
|
||||
|
||||
|
@ -70,12 +74,19 @@ bool Toasts::wasChannelLive(const QString &channelName)
|
|||
return false;
|
||||
}
|
||||
*/
|
||||
void Toasts::sendChannelNotification(const QString &channelName, int &platform)
|
||||
bool Toasts::isEnabled()
|
||||
{
|
||||
return WinToastLib::WinToast::isCompatible() &&
|
||||
getApp()->settings->notificationToast;
|
||||
}
|
||||
|
||||
void Toasts::sendChannelNotification(const QString &channelName, Platform p)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
if (WinToastLib::WinToast::isCompatible()) {
|
||||
sendWindowsNotification(channelName, platform);
|
||||
}
|
||||
|
||||
sendWindowsNotification(channelName, p);
|
||||
return;
|
||||
|
||||
#endif
|
||||
// OSX
|
||||
|
||||
|
@ -127,7 +138,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
void Toasts::sendWindowsNotification(const QString &channelName, int &platform)
|
||||
void Toasts::sendWindowsNotification(const QString &channelName, Platform p)
|
||||
{
|
||||
WinToastLib::WinToastTemplate templ = WinToastLib::WinToastTemplate(
|
||||
WinToastLib::WinToastTemplate::ImageAndText02);
|
||||
|
|
|
@ -7,18 +7,20 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
enum class Platform : uint8_t;
|
||||
|
||||
class Toasts final : public Singleton
|
||||
{
|
||||
public:
|
||||
void sendChannelNotification(const QString &channelName, int &platform);
|
||||
bool isEnabled(const QString &channelName);
|
||||
void sendChannelNotification(const QString &channelName, Platform p);
|
||||
/*
|
||||
Toasts();
|
||||
virtual void initialize(Settings &settings, Paths &paths) override final;
|
||||
*/
|
||||
static bool isEnabled();
|
||||
|
||||
private:
|
||||
void sendWindowsNotification(const QString &channelName, int &platform);
|
||||
void sendWindowsNotification(const QString &channelName, Platform p);
|
||||
/*
|
||||
void updateLiveChannels(const QString &channelName);
|
||||
void removeFromLiveChannels(const QString &channelName);
|
||||
|
|
|
@ -35,16 +35,19 @@ NotificationPage::NotificationPage()
|
|||
getApp()->settings->notificationFlashTaskbar));
|
||||
settings.append(this->createCheckBox(
|
||||
"Playsound", getApp()->settings->notificationPlaySound));
|
||||
settings.append(this->createCheckBox(
|
||||
"Enable toasts (currently only for windows)",
|
||||
getApp()->settings->notificationToast));
|
||||
|
||||
settings->addStretch(1);
|
||||
}
|
||||
auto twitchChannels = tabs.appendTab(new QVBoxLayout, "Twitch");
|
||||
{
|
||||
int i = 0;
|
||||
EditableModelView *view =
|
||||
twitchChannels
|
||||
.emplace<EditableModelView>(
|
||||
getApp()->notifications->createModel(nullptr, i))
|
||||
getApp()->notifications->createModel(
|
||||
nullptr, Platform::Twitch))
|
||||
.getElement();
|
||||
view->setTitles({"Twitch channels"});
|
||||
|
||||
|
@ -64,11 +67,11 @@ NotificationPage::NotificationPage()
|
|||
}
|
||||
auto mixerChannels = tabs.appendTab(new QVBoxLayout, "Mixer");
|
||||
{
|
||||
int i = 1;
|
||||
EditableModelView *view =
|
||||
mixerChannels
|
||||
.emplace<EditableModelView>(
|
||||
getApp()->notifications->createModel(nullptr, i))
|
||||
getApp()->notifications->createModel(
|
||||
nullptr, Platform::Mixer))
|
||||
.getElement();
|
||||
view->setTitles({"Mixer channels"});
|
||||
|
||||
|
|
|
@ -161,14 +161,12 @@ std::unique_ptr<QMenu> SplitHeader::createMainMenu()
|
|||
action->setCheckable(true);
|
||||
|
||||
QObject::connect(menu.get(), &QMenu::aboutToShow, this, [action, this]() {
|
||||
int i = 0;
|
||||
action->setChecked(getApp()->notifications->isChannelNotified(
|
||||
this->split_->getChannel()->getName(), i));
|
||||
this->split_->getChannel()->getName(), Platform::Twitch));
|
||||
});
|
||||
action->connect(action, &QAction::triggered, this, [this]() {
|
||||
int i = 0;
|
||||
getApp()->notifications->updateChannelNotification(
|
||||
this->split_->getChannel()->getName(), i);
|
||||
this->split_->getChannel()->getName(), Platform::Twitch);
|
||||
});
|
||||
menu->addAction(action);
|
||||
|
||||
|
|
Loading…
Reference in a new issue