mirror-chatterino2/src/Application.hpp

98 lines
2.2 KiB
C++
Raw Normal View History

#pragma once
#include <QApplication>
2018-08-02 14:23:27 +02:00
#include <memory>
2019-09-22 10:53:39 +02:00
#include "common/Singleton.hpp"
#include "singletons/NativeMessaging.hpp"
namespace chatterino {
class TwitchIrcServer;
class PubSub;
class CommandController;
class HighlightController;
2018-05-13 19:24:32 +02:00
class IgnoreController;
class TaggedUsersController;
class AccountController;
class ModerationActions;
class NotificationController;
class PingController;
2018-06-28 20:03:04 +02:00
class Theme;
class WindowManager;
2018-06-28 19:51:07 +02:00
class Logging;
class Paths;
class AccountManager;
2018-06-28 19:51:07 +02:00
class Emotes;
class Settings;
class Fonts;
2018-08-11 12:47:03 +02:00
class Toasts;
class ChatterinoBadges;
class Application
{
2018-08-02 14:23:27 +02:00
std::vector<std::unique_ptr<Singleton>> singletons_;
int argc_;
char **argv_;
public:
2018-08-02 14:23:27 +02:00
static Application *instance;
2018-08-02 14:23:27 +02:00
Application(Settings &settings, Paths &paths);
2018-08-02 14:23:27 +02:00
void initialize(Settings &settings, Paths &paths);
void load();
2018-08-02 14:23:27 +02:00
void save();
int run(QApplication &qtApp);
friend void test();
2018-08-07 01:35:24 +02:00
Theme *const themes{};
Fonts *const fonts{};
Emotes *const emotes{};
WindowManager *const windows{};
2018-08-11 12:47:03 +02:00
Toasts *const toasts{};
2018-08-02 14:23:27 +02:00
2018-08-07 01:35:24 +02:00
AccountController *const accounts{};
CommandController *const commands{};
HighlightController *const highlights{};
NotificationController *const notifications{};
PingController *const pings{};
2018-08-07 01:35:24 +02:00
IgnoreController *const ignores{};
TaggedUsersController *const taggedUsers{};
ModerationActions *const moderationActions{};
TwitchIrcServer *const twitch2{};
ChatterinoBadges *const chatterinoBadges{};
2018-08-02 14:23:27 +02:00
2018-08-07 01:35:24 +02:00
/*[[deprecated]]*/ Logging *const logging{};
/// Provider-specific
struct {
/*[[deprecated("use twitch2 instead")]]*/ TwitchIrcServer *server{};
2018-08-07 01:35:24 +02:00
/*[[deprecated("use twitch2->pubsub instead")]]*/ PubSub *pubsub{};
} twitch;
private:
2018-07-07 11:41:01 +02:00
void addSingleton(Singleton *singleton);
2018-08-02 14:23:27 +02:00
void initPubsub();
2018-09-17 12:51:16 +02:00
void initNm(Paths &paths);
2018-08-02 14:23:27 +02:00
2018-08-06 21:17:03 +02:00
template <typename T,
typename = std::enable_if_t<std::is_base_of<Singleton, T>::value>>
2018-08-02 14:23:27 +02:00
T &emplace()
{
auto t = new T;
this->singletons_.push_back(std::unique_ptr<T>(t));
return *t;
}
2018-09-17 12:51:16 +02:00
NativeMessagingServer nmServer{};
};
Application *getApp();
} // namespace chatterino