2017-06-13 21:13:58 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <QApplication>
|
2018-08-02 14:23:27 +02:00
|
|
|
#include <memory>
|
2017-06-13 21:13:58 +02:00
|
|
|
|
2020-02-23 21:18:40 +01:00
|
|
|
#include "common/SignalVector.hpp"
|
2019-09-22 10:53:39 +02:00
|
|
|
#include "common/Singleton.hpp"
|
|
|
|
#include "singletons/NativeMessaging.hpp"
|
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
namespace chatterino {
|
|
|
|
|
2019-09-15 13:02:02 +02:00
|
|
|
class TwitchIrcServer;
|
2018-04-28 15:48:40 +02:00
|
|
|
class PubSub;
|
2018-04-28 15:20:18 +02:00
|
|
|
|
2018-04-30 23:30:05 +02:00
|
|
|
class CommandController;
|
2018-05-26 20:25:00 +02:00
|
|
|
class AccountController;
|
2018-08-09 15:41:03 +02:00
|
|
|
class NotificationController;
|
2022-06-05 17:40:57 +02:00
|
|
|
class HighlightController;
|
2021-11-21 18:46:21 +01:00
|
|
|
class HotkeyController;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-06-28 20:03:04 +02:00
|
|
|
class Theme;
|
2018-04-27 22:11:19 +02:00
|
|
|
class WindowManager;
|
2018-06-28 19:51:07 +02:00
|
|
|
class Logging;
|
|
|
|
class Paths;
|
2018-04-27 22:11:19 +02:00
|
|
|
class AccountManager;
|
2018-06-28 19:51:07 +02:00
|
|
|
class Emotes;
|
2022-11-05 11:04:35 +01:00
|
|
|
class IEmotes;
|
2018-06-28 19:51:07 +02:00
|
|
|
class Settings;
|
|
|
|
class Fonts;
|
2018-08-11 12:47:03 +02:00
|
|
|
class Toasts;
|
2018-09-16 17:27:51 +02:00
|
|
|
class ChatterinoBadges;
|
2020-10-25 10:36:00 +01:00
|
|
|
class FfzBadges;
|
2022-10-16 13:22:17 +02:00
|
|
|
class SeventvBadges;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2022-05-22 15:00:18 +02:00
|
|
|
class IApplication
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
IApplication();
|
|
|
|
virtual ~IApplication() = default;
|
|
|
|
|
|
|
|
static IApplication *instance;
|
|
|
|
|
|
|
|
virtual Theme *getThemes() = 0;
|
|
|
|
virtual Fonts *getFonts() = 0;
|
2022-11-05 11:04:35 +01:00
|
|
|
virtual IEmotes *getEmotes() = 0;
|
2022-05-22 15:00:18 +02:00
|
|
|
virtual AccountController *getAccounts() = 0;
|
|
|
|
virtual HotkeyController *getHotkeys() = 0;
|
|
|
|
virtual WindowManager *getWindows() = 0;
|
|
|
|
virtual Toasts *getToasts() = 0;
|
|
|
|
virtual CommandController *getCommands() = 0;
|
2022-06-09 16:37:52 +02:00
|
|
|
virtual HighlightController *getHighlights() = 0;
|
2022-05-22 15:00:18 +02:00
|
|
|
virtual NotificationController *getNotifications() = 0;
|
|
|
|
virtual TwitchIrcServer *getTwitch() = 0;
|
|
|
|
virtual ChatterinoBadges *getChatterinoBadges() = 0;
|
|
|
|
virtual FfzBadges *getFfzBadges() = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Application : public IApplication
|
2017-06-13 21:13:58 +02:00
|
|
|
{
|
2018-08-02 14:23:27 +02:00
|
|
|
std::vector<std::unique_ptr<Singleton>> singletons_;
|
|
|
|
int argc_;
|
|
|
|
char **argv_;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
public:
|
2018-08-02 14:23:27 +02:00
|
|
|
static Application *instance;
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
Application(Settings &settings, Paths &paths);
|
2018-04-27 22:11:19 +02:00
|
|
|
|
2018-08-02 14:23:27 +02:00
|
|
|
void initialize(Settings &settings, Paths &paths);
|
2018-04-27 22:11:19 +02:00
|
|
|
void load();
|
2018-08-02 14:23:27 +02:00
|
|
|
void save();
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
int run(QApplication &qtApp);
|
|
|
|
|
2018-04-28 15:20:18 +02:00
|
|
|
friend void test();
|
|
|
|
|
2018-08-07 01:35:24 +02:00
|
|
|
Theme *const themes{};
|
|
|
|
Fonts *const fonts{};
|
|
|
|
Emotes *const emotes{};
|
2020-12-06 14:07:33 +01:00
|
|
|
AccountController *const accounts{};
|
2021-11-21 18:46:21 +01:00
|
|
|
HotkeyController *const hotkeys{};
|
2018-08-07 01:35:24 +02:00
|
|
|
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
|
|
|
CommandController *const commands{};
|
2018-08-09 15:41:03 +02:00
|
|
|
NotificationController *const notifications{};
|
2022-06-05 17:40:57 +02:00
|
|
|
HighlightController *const highlights{};
|
2022-03-19 12:02:29 +01:00
|
|
|
TwitchIrcServer *const twitch{};
|
2018-09-16 17:27:51 +02:00
|
|
|
ChatterinoBadges *const chatterinoBadges{};
|
2020-10-25 10:36:00 +01:00
|
|
|
FfzBadges *const ffzBadges{};
|
2022-10-16 13:22:17 +02:00
|
|
|
SeventvBadges *const seventvBadges{};
|
2018-08-02 14:23:27 +02:00
|
|
|
|
2018-08-07 01:35:24 +02:00
|
|
|
/*[[deprecated]]*/ Logging *const logging{};
|
2018-04-28 15:20:18 +02:00
|
|
|
|
2022-05-22 15:00:18 +02:00
|
|
|
Theme *getThemes() override
|
|
|
|
{
|
|
|
|
return this->themes;
|
|
|
|
}
|
|
|
|
Fonts *getFonts() override
|
|
|
|
{
|
|
|
|
return this->fonts;
|
|
|
|
}
|
2022-11-05 11:04:35 +01:00
|
|
|
IEmotes *getEmotes() override;
|
2022-05-22 15:00:18 +02:00
|
|
|
AccountController *getAccounts() override
|
|
|
|
{
|
|
|
|
return this->accounts;
|
|
|
|
}
|
|
|
|
HotkeyController *getHotkeys() override
|
|
|
|
{
|
|
|
|
return this->hotkeys;
|
|
|
|
}
|
|
|
|
WindowManager *getWindows() override
|
|
|
|
{
|
|
|
|
return this->windows;
|
|
|
|
}
|
|
|
|
Toasts *getToasts() override
|
|
|
|
{
|
|
|
|
return this->toasts;
|
|
|
|
}
|
|
|
|
CommandController *getCommands() override
|
|
|
|
{
|
|
|
|
return this->commands;
|
|
|
|
}
|
|
|
|
NotificationController *getNotifications() override
|
|
|
|
{
|
|
|
|
return this->notifications;
|
|
|
|
}
|
2022-06-09 16:37:52 +02:00
|
|
|
HighlightController *getHighlights() override
|
|
|
|
{
|
|
|
|
return this->highlights;
|
|
|
|
}
|
2022-05-22 15:00:18 +02:00
|
|
|
TwitchIrcServer *getTwitch() override
|
|
|
|
{
|
|
|
|
return this->twitch;
|
|
|
|
}
|
|
|
|
ChatterinoBadges *getChatterinoBadges() override
|
|
|
|
{
|
|
|
|
return this->chatterinoBadges;
|
|
|
|
}
|
|
|
|
FfzBadges *getFfzBadges() override
|
|
|
|
{
|
|
|
|
return this->ffzBadges;
|
|
|
|
}
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
private:
|
2018-07-07 11:41:01 +02:00
|
|
|
void addSingleton(Singleton *singleton);
|
2022-05-07 17:22:39 +02:00
|
|
|
void initPubSub();
|
2022-11-13 12:07:41 +01:00
|
|
|
void initSeventvEventAPI();
|
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{};
|
2017-06-13 21:13:58 +02:00
|
|
|
};
|
|
|
|
|
2018-04-27 22:11:19 +02:00
|
|
|
Application *getApp();
|
|
|
|
|
2022-05-22 15:00:18 +02:00
|
|
|
// Get an interface version of the Application class - should be preferred when possible for new code
|
|
|
|
IApplication *getIApp();
|
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
} // namespace chatterino
|