mirror-chatterino2/src/controllers/notifications/NotificationController.hpp

54 lines
1.4 KiB
C++
Raw Normal View History

#pragma once
#include "common/ChatterinoSetting.hpp"
#include "common/SignalVector.hpp"
2018-08-29 19:25:37 +02:00
#include "common/Singleton.hpp"
#include <QTimer>
namespace chatterino {
class Settings;
class Paths;
class NotificationModel;
2018-08-12 18:54:32 +02:00
enum class Platform : uint8_t {
Twitch, // 0
2018-08-12 18:54:32 +02:00
};
2018-08-26 13:19:09 +02:00
class NotificationController final : public Singleton, private QObject
{
public:
void initialize(Settings &settings, Paths &paths) override;
2018-08-12 18:54:32 +02:00
bool isChannelNotified(const QString &channelName, Platform p);
void updateChannelNotification(const QString &channelName, Platform p);
void addChannelNotification(const QString &channelName, Platform p);
void removeChannelNotification(const QString &channelName, Platform p);
void playSound();
SignalVector<QString> getVector(Platform p);
std::map<Platform, SignalVector<QString>> channelMap;
2018-08-12 15:29:40 +02:00
2018-08-12 18:54:32 +02:00
NotificationModel *createModel(QObject *parent, Platform p);
private:
bool initialized_ = false;
2018-08-26 13:19:09 +02:00
void fetchFakeChannels();
void removeFakeChannel(const QString channelName);
void checkStream(bool live, QString channelName);
// fakeTwitchChannels is a list of streams who are live that we have already sent out a notification for
2018-08-26 13:19:09 +02:00
std::vector<QString> fakeTwitchChannels;
QTimer *liveStatusTimer_;
2018-08-12 15:29:40 +02:00
ChatterinoSetting<std::vector<QString>> twitchSetting_ = {
"/notifications/twitch"};
};
} // namespace chatterino