mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
renamed *Manager classes
This commit is contained in:
parent
2df142bd50
commit
8ced5a1e25
|
@ -45,19 +45,19 @@ void Application::construct()
|
||||||
|
|
||||||
// 1. Instantiate all classes
|
// 1. Instantiate all classes
|
||||||
this->settings = getSettings();
|
this->settings = getSettings();
|
||||||
this->paths = PathManager::getInstance();
|
this->paths = Paths::getInstance();
|
||||||
|
|
||||||
this->themes = new ThemeManager;
|
this->themes = new Themes;
|
||||||
this->windows = new WindowManager;
|
this->windows = new WindowManager;
|
||||||
this->logging = new LoggingManager;
|
this->logging = new Logging;
|
||||||
this->commands = new CommandController;
|
this->commands = new CommandController;
|
||||||
this->highlights = new HighlightController;
|
this->highlights = new HighlightController;
|
||||||
this->ignores = new IgnoreController;
|
this->ignores = new IgnoreController;
|
||||||
this->taggedUsers = new TaggedUsersController;
|
this->taggedUsers = new TaggedUsersController;
|
||||||
this->accounts = new AccountController;
|
this->accounts = new AccountController;
|
||||||
this->emotes = new EmoteManager;
|
this->emotes = new Emotes;
|
||||||
this->fonts = new FontManager;
|
this->fonts = new Fonts;
|
||||||
this->resources = new ResourceManager;
|
this->resources = new Resources;
|
||||||
this->moderationActions = new ModerationActions;
|
this->moderationActions = new ModerationActions;
|
||||||
|
|
||||||
this->twitch.server = new TwitchServer;
|
this->twitch.server = new TwitchServer;
|
||||||
|
|
|
@ -17,16 +17,16 @@ class TaggedUsersController;
|
||||||
class AccountController;
|
class AccountController;
|
||||||
class ModerationActions;
|
class ModerationActions;
|
||||||
|
|
||||||
class ThemeManager;
|
class Themes;
|
||||||
class WindowManager;
|
class WindowManager;
|
||||||
class LoggingManager;
|
class Logging;
|
||||||
class PathManager;
|
class Paths;
|
||||||
class AccountManager;
|
class AccountManager;
|
||||||
class EmoteManager;
|
class Emotes;
|
||||||
class NativeMessagingManager;
|
class NativeMessaging;
|
||||||
class SettingManager;
|
class Settings;
|
||||||
class FontManager;
|
class Fonts;
|
||||||
class ResourceManager;
|
class Resources;
|
||||||
|
|
||||||
class Application
|
class Application
|
||||||
{
|
{
|
||||||
|
@ -45,20 +45,20 @@ public:
|
||||||
|
|
||||||
friend void test();
|
friend void test();
|
||||||
|
|
||||||
PathManager *paths = nullptr;
|
Paths *paths = nullptr;
|
||||||
ThemeManager *themes = nullptr;
|
Themes *themes = nullptr;
|
||||||
WindowManager *windows = nullptr;
|
WindowManager *windows = nullptr;
|
||||||
LoggingManager *logging = nullptr;
|
Logging *logging = nullptr;
|
||||||
CommandController *commands = nullptr;
|
CommandController *commands = nullptr;
|
||||||
HighlightController *highlights = nullptr;
|
HighlightController *highlights = nullptr;
|
||||||
IgnoreController *ignores = nullptr;
|
IgnoreController *ignores = nullptr;
|
||||||
TaggedUsersController *taggedUsers = nullptr;
|
TaggedUsersController *taggedUsers = nullptr;
|
||||||
AccountController *accounts = nullptr;
|
AccountController *accounts = nullptr;
|
||||||
EmoteManager *emotes = nullptr;
|
Emotes *emotes = nullptr;
|
||||||
NativeMessagingManager *nativeMessaging = nullptr;
|
NativeMessaging *nativeMessaging = nullptr;
|
||||||
SettingManager *settings = nullptr;
|
Settings *settings = nullptr;
|
||||||
FontManager *fonts = nullptr;
|
Fonts *fonts = nullptr;
|
||||||
ResourceManager *resources = nullptr;
|
Resources *resources = nullptr;
|
||||||
ModerationActions *moderationActions = nullptr;
|
ModerationActions *moderationActions = nullptr;
|
||||||
|
|
||||||
/// Provider-specific
|
/// Provider-specific
|
||||||
|
|
|
@ -49,7 +49,7 @@ int main(int argc, char *argv[])
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
// FOURTF: might get arguments from the commandline passed in the future
|
// FOURTF: might get arguments from the commandline passed in the future
|
||||||
chatterino::PathManager::initInstance();
|
chatterino::Paths::initInstance();
|
||||||
|
|
||||||
// read args
|
// read args
|
||||||
QStringList args;
|
QStringList args;
|
||||||
|
@ -79,7 +79,7 @@ int runGui(QApplication &a, int argc, char *argv[])
|
||||||
chatterino::NetworkManager::init();
|
chatterino::NetworkManager::init();
|
||||||
|
|
||||||
// Check for upates
|
// Check for upates
|
||||||
chatterino::UpdateManager::getInstance().checkForUpdates();
|
chatterino::Updates::getInstance().checkForUpdates();
|
||||||
|
|
||||||
// Initialize application
|
// Initialize application
|
||||||
chatterino::Application::instantiate(argc, argv);
|
chatterino::Application::instantiate(argc, argv);
|
||||||
|
@ -139,7 +139,7 @@ int runGui(QApplication &a, int argc, char *argv[])
|
||||||
|
|
||||||
void runNativeMessagingHost()
|
void runNativeMessagingHost()
|
||||||
{
|
{
|
||||||
auto *nm = new chatterino::NativeMessagingManager;
|
auto *nm = new chatterino::NativeMessaging;
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
_setmode(_fileno(stdin), _O_BINARY);
|
_setmode(_fileno(stdin), _O_BINARY);
|
||||||
|
|
|
@ -13,7 +13,7 @@ MessageColor::MessageColor(Type _type)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const QColor &MessageColor::getColor(ThemeManager &themeManager) const
|
const QColor &MessageColor::getColor(Themes &themeManager) const
|
||||||
{
|
{
|
||||||
switch (this->type) {
|
switch (this->type) {
|
||||||
case Type::Custom:
|
case Type::Custom:
|
||||||
|
|
|
@ -12,7 +12,7 @@ struct MessageColor {
|
||||||
MessageColor(const QColor &color);
|
MessageColor(const QColor &color);
|
||||||
MessageColor(Type type = Text);
|
MessageColor(Type type = Text);
|
||||||
|
|
||||||
const QColor &getColor(ThemeManager &themeManager) const;
|
const QColor &getColor(Themes &themeManager) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type type;
|
Type type;
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
void EmoteManager::initialize()
|
void Emotes::initialize()
|
||||||
{
|
{
|
||||||
getApp()->accounts->twitch.currentUserChanged.connect([this] {
|
getApp()->accounts->twitch.currentUserChanged.connect([this] {
|
||||||
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
auto currentUser = getApp()->accounts->twitch.getCurrent();
|
||||||
|
@ -20,7 +20,7 @@ void EmoteManager::initialize()
|
||||||
this->gifTimer.initialize();
|
this->gifTimer.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool EmoteManager::isIgnoredEmote(const QString &)
|
bool Emotes::isIgnoredEmote(const QString &)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class EmoteManager
|
class Emotes
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
~EmoteManager() = delete;
|
~Emotes() = delete;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
FontManager::FontManager()
|
Fonts::Fonts()
|
||||||
: chatFontFamily("/appearance/currentFontFamily", DEFAULT_FONT_FAMILY)
|
: chatFontFamily("/appearance/currentFontFamily", DEFAULT_FONT_FAMILY)
|
||||||
, chatFontSize("/appearance/currentFontSize", DEFAULT_FONT_SIZE)
|
, chatFontSize("/appearance/currentFontSize", DEFAULT_FONT_SIZE)
|
||||||
{
|
{
|
||||||
|
@ -57,17 +57,17 @@ FontManager::FontManager()
|
||||||
this->fontsByType.resize(size_t(EndType));
|
this->fontsByType.resize(size_t(EndType));
|
||||||
}
|
}
|
||||||
|
|
||||||
QFont FontManager::getFont(FontManager::Type type, float scale)
|
QFont Fonts::getFont(Fonts::Type type, float scale)
|
||||||
{
|
{
|
||||||
return this->getOrCreateFontData(type, scale).font;
|
return this->getOrCreateFontData(type, scale).font;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFontMetrics FontManager::getFontMetrics(FontManager::Type type, float scale)
|
QFontMetrics Fonts::getFontMetrics(Fonts::Type type, float scale)
|
||||||
{
|
{
|
||||||
return this->getOrCreateFontData(type, scale).metrics;
|
return this->getOrCreateFontData(type, scale).metrics;
|
||||||
}
|
}
|
||||||
|
|
||||||
FontManager::FontData &FontManager::getOrCreateFontData(Type type, float scale)
|
Fonts::FontData &Fonts::getOrCreateFontData(Type type, float scale)
|
||||||
{
|
{
|
||||||
assertInGuiThread();
|
assertInGuiThread();
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ FontManager::FontData &FontManager::getOrCreateFontData(Type type, float scale)
|
||||||
return result.first->second;
|
return result.first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
FontManager::FontData FontManager::createFontData(Type type, float scale)
|
Fonts::FontData Fonts::createFontData(Type type, float scale)
|
||||||
{
|
{
|
||||||
// check if it's a chat (scale the setting)
|
// check if it's a chat (scale the setting)
|
||||||
if (type >= ChatStart && type <= ChatEnd) {
|
if (type >= ChatStart && type <= ChatEnd) {
|
||||||
|
|
|
@ -11,10 +11,10 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class FontManager : boost::noncopyable
|
class Fonts : boost::noncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FontManager();
|
Fonts();
|
||||||
|
|
||||||
// font data gets set in createFontData(...)
|
// font data gets set in createFontData(...)
|
||||||
enum Type : uint8_t {
|
enum Type : uint8_t {
|
||||||
|
@ -77,6 +77,6 @@ private:
|
||||||
std::vector<std::unordered_map<float, FontData>> fontsByType;
|
std::vector<std::unordered_map<float, FontData>> fontsByType;
|
||||||
};
|
};
|
||||||
|
|
||||||
using FontStyle = FontManager::Type;
|
using FontStyle = Fonts::Type;
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -12,12 +12,12 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
void LoggingManager::initialize()
|
void Logging::initialize()
|
||||||
{
|
{
|
||||||
this->pathManager = getApp()->paths;
|
this->pathManager = getApp()->paths;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoggingManager::addMessage(const QString &channelName, MessagePtr message)
|
void Logging::addMessage(const QString &channelName, MessagePtr message)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,16 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class PathManager;
|
class Paths;
|
||||||
|
|
||||||
class LoggingManager
|
class Logging
|
||||||
{
|
{
|
||||||
PathManager *pathManager = nullptr;
|
Paths *pathManager = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LoggingManager() = default;
|
Logging() = default;
|
||||||
|
|
||||||
~LoggingManager() = delete;
|
~Logging() = delete;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
|
|
|
@ -32,12 +32,12 @@ namespace ipc = boost::interprocess;
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
// fourtf: don't add this class to the application class
|
// fourtf: don't add this class to the application class
|
||||||
NativeMessagingManager::NativeMessagingManager()
|
NativeMessaging::NativeMessaging()
|
||||||
{
|
{
|
||||||
qDebug() << "init NativeMessagingManager";
|
qDebug() << "init NativeMessagingManager";
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeMessagingManager::writeByteArray(QByteArray a)
|
void NativeMessaging::writeByteArray(QByteArray a)
|
||||||
{
|
{
|
||||||
char *data = a.data();
|
char *data = a.data();
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
@ -47,7 +47,7 @@ void NativeMessagingManager::writeByteArray(QByteArray a)
|
||||||
std::cout.flush();
|
std::cout.flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeMessagingManager::registerHost()
|
void NativeMessaging::registerHost()
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ void NativeMessagingManager::registerHost()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeMessagingManager::openGuiMessageQueue()
|
void NativeMessaging::openGuiMessageQueue()
|
||||||
{
|
{
|
||||||
static ReceiverThread thread;
|
static ReceiverThread thread;
|
||||||
|
|
||||||
|
@ -122,7 +122,7 @@ void NativeMessagingManager::openGuiMessageQueue()
|
||||||
thread.start();
|
thread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeMessagingManager::sendToGuiProcess(const QByteArray &array)
|
void NativeMessaging::sendToGuiProcess(const QByteArray &array)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
ipc::message_queue messageQueue(ipc::open_only, "chatterino_gui");
|
ipc::message_queue messageQueue(ipc::open_only, "chatterino_gui");
|
||||||
|
@ -133,7 +133,7 @@ void NativeMessagingManager::sendToGuiProcess(const QByteArray &array)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeMessagingManager::ReceiverThread::run()
|
void NativeMessaging::ReceiverThread::run()
|
||||||
{
|
{
|
||||||
ipc::message_queue::remove("chatterino_gui");
|
ipc::message_queue::remove("chatterino_gui");
|
||||||
|
|
||||||
|
@ -157,7 +157,7 @@ void NativeMessagingManager::ReceiverThread::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &root)
|
void NativeMessaging::ReceiverThread::handleMessage(const QJsonObject &root)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
|
@ -231,10 +231,10 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string &NativeMessagingManager::getGuiMessageQueueName()
|
std::string &NativeMessaging::getGuiMessageQueueName()
|
||||||
{
|
{
|
||||||
static std::string name =
|
static std::string name =
|
||||||
"chatterino_gui" + PathManager::getInstance()->applicationFilePathHash.toStdString();
|
"chatterino_gui" + Paths::getInstance()->applicationFilePathHash.toStdString();
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,13 +4,13 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class NativeMessagingManager
|
class NativeMessaging
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// fourtf: don't add this class to the application class
|
// fourtf: don't add this class to the application class
|
||||||
NativeMessagingManager();
|
NativeMessaging();
|
||||||
|
|
||||||
~NativeMessagingManager() = delete;
|
~NativeMessaging() = delete;
|
||||||
|
|
||||||
class ReceiverThread : public QThread
|
class ReceiverThread : public QThread
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,9 +10,9 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
PathManager *PathManager::instance = nullptr;
|
Paths *Paths::instance = nullptr;
|
||||||
|
|
||||||
PathManager::PathManager()
|
Paths::Paths()
|
||||||
{
|
{
|
||||||
this->initAppFilePathHash();
|
this->initAppFilePathHash();
|
||||||
|
|
||||||
|
@ -21,31 +21,31 @@ PathManager::PathManager()
|
||||||
this->initSubDirectories();
|
this->initSubDirectories();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathManager::initInstance()
|
void Paths::initInstance()
|
||||||
{
|
{
|
||||||
assert(!instance);
|
assert(!instance);
|
||||||
|
|
||||||
instance = new PathManager();
|
instance = new Paths();
|
||||||
}
|
}
|
||||||
|
|
||||||
PathManager *PathManager::getInstance()
|
Paths *Paths::getInstance()
|
||||||
{
|
{
|
||||||
assert(instance);
|
assert(instance);
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathManager::createFolder(const QString &folderPath)
|
bool Paths::createFolder(const QString &folderPath)
|
||||||
{
|
{
|
||||||
return QDir().mkpath(folderPath);
|
return QDir().mkpath(folderPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PathManager::isPortable()
|
bool Paths::isPortable()
|
||||||
{
|
{
|
||||||
return this->portable.get();
|
return this->portable.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathManager::initAppFilePathHash()
|
void Paths::initAppFilePathHash()
|
||||||
{
|
{
|
||||||
this->applicationFilePathHash =
|
this->applicationFilePathHash =
|
||||||
QCryptographicHash::hash(QCoreApplication::applicationFilePath().toUtf8(),
|
QCryptographicHash::hash(QCoreApplication::applicationFilePath().toUtf8(),
|
||||||
|
@ -56,13 +56,13 @@ void PathManager::initAppFilePathHash()
|
||||||
.replace("/", "x");
|
.replace("/", "x");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathManager::initCheckPortable()
|
void Paths::initCheckPortable()
|
||||||
{
|
{
|
||||||
this->portable =
|
this->portable =
|
||||||
QFileInfo::exists(combinePath(QCoreApplication::applicationDirPath(), "portable"));
|
QFileInfo::exists(combinePath(QCoreApplication::applicationDirPath(), "portable"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathManager::initAppDataDirectory()
|
void Paths::initAppDataDirectory()
|
||||||
{
|
{
|
||||||
assert(this->portable.is_initialized());
|
assert(this->portable.is_initialized());
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ void PathManager::initAppDataDirectory()
|
||||||
}();
|
}();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PathManager::initSubDirectories()
|
void Paths::initSubDirectories()
|
||||||
{
|
{
|
||||||
// required the app data directory to be set first
|
// required the app data directory to be set first
|
||||||
assert(!this->rootAppDataDirectory.isEmpty());
|
assert(!this->rootAppDataDirectory.isEmpty());
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class PathManager
|
class Paths
|
||||||
{
|
{
|
||||||
PathManager();
|
Paths();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void initInstance();
|
static void initInstance();
|
||||||
static PathManager *getInstance();
|
static Paths *getInstance();
|
||||||
|
|
||||||
// Root directory for the configuration files. %APPDATA%/chatterino or ExecutablePath for
|
// Root directory for the configuration files. %APPDATA%/chatterino or ExecutablePath for
|
||||||
// portable mode
|
// portable mode
|
||||||
|
@ -36,7 +36,7 @@ public:
|
||||||
bool isPortable();
|
bool isPortable();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static PathManager *instance;
|
static Paths *instance;
|
||||||
boost::optional<bool> portable;
|
boost::optional<bool> portable;
|
||||||
|
|
||||||
void initAppFilePathHash();
|
void initAppFilePathHash();
|
||||||
|
|
|
@ -75,7 +75,7 @@ inline bool ReadValue<std::vector<QString>>(const rapidjson::Value &object, cons
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse a single cheermote set (or "action") from the twitch api
|
// Parse a single cheermote set (or "action") from the twitch api
|
||||||
inline bool ParseSingleCheermoteSet(ResourceManager::JSONCheermoteSet &set,
|
inline bool ParseSingleCheermoteSet(Resources::JSONCheermoteSet &set,
|
||||||
const rapidjson::Value &action)
|
const rapidjson::Value &action)
|
||||||
{
|
{
|
||||||
if (!action.IsObject()) {
|
if (!action.IsObject()) {
|
||||||
|
@ -122,7 +122,7 @@ inline bool ParseSingleCheermoteSet(ResourceManager::JSONCheermoteSet &set,
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const rapidjson::Value &tierValue : tiersValue.GetArray()) {
|
for (const rapidjson::Value &tierValue : tiersValue.GetArray()) {
|
||||||
ResourceManager::JSONCheermoteSet::CheermoteTier tier;
|
Resources::JSONCheermoteSet::CheermoteTier tier;
|
||||||
|
|
||||||
if (!tierValue.IsObject()) {
|
if (!tierValue.IsObject()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -237,7 +237,7 @@ inline bool ParseSingleCheermoteSet(ResourceManager::JSONCheermoteSet &set,
|
||||||
|
|
||||||
// Look through the results of https://api.twitch.tv/kraken/bits/actions?channel_id=11148817 for
|
// Look through the results of https://api.twitch.tv/kraken/bits/actions?channel_id=11148817 for
|
||||||
// cheermote sets or "Actions" as they are called in the API
|
// cheermote sets or "Actions" as they are called in the API
|
||||||
inline void ParseCheermoteSets(std::vector<ResourceManager::JSONCheermoteSet> &sets,
|
inline void ParseCheermoteSets(std::vector<Resources::JSONCheermoteSet> &sets,
|
||||||
const rapidjson::Document &d)
|
const rapidjson::Document &d)
|
||||||
{
|
{
|
||||||
if (!d.IsObject()) {
|
if (!d.IsObject()) {
|
||||||
|
@ -255,7 +255,7 @@ inline void ParseCheermoteSets(std::vector<ResourceManager::JSONCheermoteSet> &s
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &action : actionsValue.GetArray()) {
|
for (const auto &action : actionsValue.GetArray()) {
|
||||||
ResourceManager::JSONCheermoteSet set;
|
Resources::JSONCheermoteSet set;
|
||||||
bool res = ParseSingleCheermoteSet(set, action);
|
bool res = ParseSingleCheermoteSet(set, action);
|
||||||
|
|
||||||
if (res) {
|
if (res) {
|
||||||
|
@ -265,7 +265,7 @@ inline void ParseCheermoteSets(std::vector<ResourceManager::JSONCheermoteSet> &s
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
ResourceManager::ResourceManager()
|
Resources::Resources()
|
||||||
: badgeStaff(lli(":/images/staff_bg.png"))
|
: badgeStaff(lli(":/images/staff_bg.png"))
|
||||||
, badgeAdmin(lli(":/images/admin_bg.png"))
|
, badgeAdmin(lli(":/images/admin_bg.png"))
|
||||||
, badgeGlobalModerator(lli(":/images/globalmod_bg.png"))
|
, badgeGlobalModerator(lli(":/images/globalmod_bg.png"))
|
||||||
|
@ -302,14 +302,14 @@ ResourceManager::ResourceManager()
|
||||||
qDebug() << "init ResourceManager";
|
qDebug() << "init ResourceManager";
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceManager::initialize()
|
void Resources::initialize()
|
||||||
{
|
{
|
||||||
this->loadDynamicTwitchBadges();
|
this->loadDynamicTwitchBadges();
|
||||||
|
|
||||||
this->loadChatterinoBadges();
|
this->loadChatterinoBadges();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceManager::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
Resources::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
||||||
: badgeImage1x(new Image(root.value("image_url_1x").toString()))
|
: badgeImage1x(new Image(root.value("image_url_1x").toString()))
|
||||||
, badgeImage2x(new Image(root.value("image_url_2x").toString()))
|
, badgeImage2x(new Image(root.value("image_url_2x").toString()))
|
||||||
, badgeImage4x(new Image(root.value("image_url_4x").toString()))
|
, badgeImage4x(new Image(root.value("image_url_4x").toString()))
|
||||||
|
@ -320,7 +320,7 @@ ResourceManager::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache)
|
void Resources::loadChannelData(const QString &roomID, bool bypassCache)
|
||||||
{
|
{
|
||||||
QString url = "https://badges.twitch.tv/v1/badges/channels/" + roomID + "/display?language=en";
|
QString url = "https://badges.twitch.tv/v1/badges/channels/" + roomID + "/display?language=en";
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache)
|
||||||
req.getJSON([this, roomID](QJsonObject &root) {
|
req.getJSON([this, roomID](QJsonObject &root) {
|
||||||
QJsonObject sets = root.value("badge_sets").toObject();
|
QJsonObject sets = root.value("badge_sets").toObject();
|
||||||
|
|
||||||
ResourceManager::Channel &ch = this->channels[roomID];
|
Resources::Channel &ch = this->channels[roomID];
|
||||||
|
|
||||||
for (QJsonObject::iterator it = sets.begin(); it != sets.end(); ++it) {
|
for (QJsonObject::iterator it = sets.begin(); it != sets.end(); ++it) {
|
||||||
QJsonObject versions = it.value().toObject().value("versions").toObject();
|
QJsonObject versions = it.value().toObject().value("versions").toObject();
|
||||||
|
@ -354,7 +354,7 @@ void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache)
|
||||||
|
|
||||||
twitchApiGet2(
|
twitchApiGet2(
|
||||||
cheermoteURL, QThread::currentThread(), true, [this, roomID](const rapidjson::Document &d) {
|
cheermoteURL, QThread::currentThread(), true, [this, roomID](const rapidjson::Document &d) {
|
||||||
ResourceManager::Channel &ch = this->channels[roomID];
|
Resources::Channel &ch = this->channels[roomID];
|
||||||
|
|
||||||
ParseCheermoteSets(ch.jsonCheermoteSets, d);
|
ParseCheermoteSets(ch.jsonCheermoteSets, d);
|
||||||
|
|
||||||
|
@ -393,7 +393,7 @@ void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceManager::loadDynamicTwitchBadges()
|
void Resources::loadDynamicTwitchBadges()
|
||||||
{
|
{
|
||||||
static QString url("https://badges.twitch.tv/v1/badges/global/display?language=en");
|
static QString url("https://badges.twitch.tv/v1/badges/global/display?language=en");
|
||||||
|
|
||||||
|
@ -420,7 +420,7 @@ void ResourceManager::loadDynamicTwitchBadges()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceManager::loadChatterinoBadges()
|
void Resources::loadChatterinoBadges()
|
||||||
{
|
{
|
||||||
this->chatterinoBadges.clear();
|
this->chatterinoBadges.clear();
|
||||||
|
|
||||||
|
|
|
@ -11,12 +11,12 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ResourceManager
|
class Resources
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ResourceManager();
|
Resources();
|
||||||
|
|
||||||
~ResourceManager() = delete;
|
~Resources() = delete;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
||||||
|
|
|
@ -15,19 +15,19 @@ void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> set
|
||||||
_settings.push_back(setting);
|
_settings.push_back(setting);
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingManager::SettingManager()
|
Settings::Settings()
|
||||||
{
|
{
|
||||||
qDebug() << "init SettingManager";
|
qDebug() << "init SettingManager";
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingManager &SettingManager::getInstance()
|
Settings &Settings::getInstance()
|
||||||
{
|
{
|
||||||
static SettingManager instance;
|
static Settings instance;
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingManager::initialize()
|
void Settings::initialize()
|
||||||
{
|
{
|
||||||
this->timestampFormat.connect([](auto, auto) {
|
this->timestampFormat.connect([](auto, auto) {
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
@ -45,7 +45,7 @@ void SettingManager::initialize()
|
||||||
[](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
|
[](auto, auto) { getApp()->windows->forceLayoutChannelViews(); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingManager::load()
|
void Settings::load()
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
QString settingsPath = app->paths->settingsDirectory + "/settings.json";
|
QString settingsPath = app->paths->settingsDirectory + "/settings.json";
|
||||||
|
@ -53,7 +53,7 @@ void SettingManager::load()
|
||||||
pajlada::Settings::SettingManager::load(qPrintable(settingsPath));
|
pajlada::Settings::SettingManager::load(qPrintable(settingsPath));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingManager::saveSnapshot()
|
void Settings::saveSnapshot()
|
||||||
{
|
{
|
||||||
rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType);
|
rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType);
|
||||||
rapidjson::Document::AllocatorType &a = d->GetAllocator();
|
rapidjson::Document::AllocatorType &a = d->GetAllocator();
|
||||||
|
@ -74,7 +74,7 @@ void SettingManager::saveSnapshot()
|
||||||
Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d));
|
Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingManager::restoreSnapshot()
|
void Settings::restoreSnapshot()
|
||||||
{
|
{
|
||||||
if (!this->snapshot) {
|
if (!this->snapshot) {
|
||||||
return;
|
return;
|
||||||
|
@ -100,9 +100,9 @@ void SettingManager::restoreSnapshot()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SettingManager *getSettings()
|
Settings *getSettings()
|
||||||
{
|
{
|
||||||
return &SettingManager::getInstance();
|
return &Settings::getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -12,12 +12,12 @@ namespace chatterino {
|
||||||
|
|
||||||
void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
void _actuallyRegisterSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
|
||||||
|
|
||||||
class SettingManager
|
class Settings
|
||||||
{
|
{
|
||||||
SettingManager();
|
Settings();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static SettingManager &getInstance();
|
static Settings &getInstance();
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
void load();
|
void load();
|
||||||
|
@ -127,6 +127,6 @@ private:
|
||||||
void updateModerationActions();
|
void updateModerationActions();
|
||||||
};
|
};
|
||||||
|
|
||||||
SettingManager *getSettings();
|
Settings *getSettings();
|
||||||
|
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -27,7 +27,7 @@ double getMultiplierByTheme(const QString &themeName)
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
ThemeManager::ThemeManager()
|
Themes::Themes()
|
||||||
: themeName("/appearance/theme/name", "Dark")
|
: themeName("/appearance/theme/name", "Dark")
|
||||||
, themeHue("/appearance/theme/hue", 0.0)
|
, themeHue("/appearance/theme/hue", 0.0)
|
||||||
{
|
{
|
||||||
|
@ -37,14 +37,14 @@ ThemeManager::ThemeManager()
|
||||||
this->themeHue.connectSimple([this](auto) { this->update(); }, false);
|
this->themeHue.connectSimple([this](auto) { this->update(); }, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeManager::update()
|
void Themes::update()
|
||||||
{
|
{
|
||||||
this->actuallyUpdate(this->themeHue, detail::getMultiplierByTheme(this->themeName.getValue()));
|
this->actuallyUpdate(this->themeHue, detail::getMultiplierByTheme(this->themeName.getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// hue: theme color (0 - 1)
|
// hue: theme color (0 - 1)
|
||||||
// multiplier: 1 = white, 0.8 = light, -0.8 dark, -1 black
|
// multiplier: 1 = white, 0.8 = light, -0.8 dark, -1 black
|
||||||
void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
void Themes::actuallyUpdate(double hue, double multiplier)
|
||||||
{
|
{
|
||||||
isLight = multiplier > 0;
|
isLight = multiplier > 0;
|
||||||
bool lightWin = isLight;
|
bool lightWin = isLight;
|
||||||
|
@ -217,7 +217,7 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
||||||
this->updated.invoke();
|
this->updated.invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor ThemeManager::blendColors(const QColor &color1, const QColor &color2, qreal ratio)
|
QColor Themes::blendColors(const QColor &color1, const QColor &color2, qreal ratio)
|
||||||
{
|
{
|
||||||
int r = int(color1.red() * (1 - ratio) + color2.red() * ratio);
|
int r = int(color1.red() * (1 - ratio) + color2.red() * ratio);
|
||||||
int g = int(color1.green() * (1 - ratio) + color2.green() * ratio);
|
int g = int(color1.green() * (1 - ratio) + color2.green() * ratio);
|
||||||
|
@ -226,7 +226,7 @@ QColor ThemeManager::blendColors(const QColor &color1, const QColor &color2, qre
|
||||||
return QColor(r, g, b, 255);
|
return QColor(r, g, b, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ThemeManager::normalizeColor(QColor &color)
|
void Themes::normalizeColor(QColor &color)
|
||||||
{
|
{
|
||||||
if (this->isLight) {
|
if (this->isLight) {
|
||||||
if (color.lightnessF() > 0.5) {
|
if (color.lightnessF() > 0.5) {
|
||||||
|
|
|
@ -10,12 +10,12 @@ namespace chatterino {
|
||||||
|
|
||||||
class WindowManager;
|
class WindowManager;
|
||||||
|
|
||||||
class ThemeManager
|
class Themes
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ThemeManager();
|
Themes();
|
||||||
|
|
||||||
~ThemeManager() = delete;
|
~Themes() = delete;
|
||||||
|
|
||||||
inline bool isLightTheme() const
|
inline bool isLightTheme() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,31 +10,31 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
UpdateManager::UpdateManager()
|
Updates::Updates()
|
||||||
: currentVersion_(CHATTERINO_VERSION)
|
: currentVersion_(CHATTERINO_VERSION)
|
||||||
{
|
{
|
||||||
qDebug() << "init UpdateManager";
|
qDebug() << "init UpdateManager";
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateManager &UpdateManager::getInstance()
|
Updates &Updates::getInstance()
|
||||||
{
|
{
|
||||||
// fourtf: don't add this class to the application class
|
// fourtf: don't add this class to the application class
|
||||||
static UpdateManager instance;
|
static Updates instance;
|
||||||
|
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &UpdateManager::getCurrentVersion() const
|
const QString &Updates::getCurrentVersion() const
|
||||||
{
|
{
|
||||||
return currentVersion_;
|
return currentVersion_;
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &UpdateManager::getOnlineVersion() const
|
const QString &Updates::getOnlineVersion() const
|
||||||
{
|
{
|
||||||
return onlineVersion_;
|
return onlineVersion_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateManager::installUpdates()
|
void Updates::installUpdates()
|
||||||
{
|
{
|
||||||
if (this->status_ != UpdateAvailable) {
|
if (this->status_ != UpdateAvailable) {
|
||||||
assert(false);
|
assert(false);
|
||||||
|
@ -87,7 +87,7 @@ void UpdateManager::installUpdates()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateManager::checkForUpdates()
|
void Updates::checkForUpdates()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/stable";
|
QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/stable";
|
||||||
|
@ -141,12 +141,12 @@ void UpdateManager::checkForUpdates()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateManager::UpdateStatus UpdateManager::getStatus() const
|
Updates::UpdateStatus Updates::getStatus() const
|
||||||
{
|
{
|
||||||
return this->status_;
|
return this->status_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateManager::setStatus_(UpdateStatus status)
|
void Updates::setStatus_(UpdateStatus status)
|
||||||
{
|
{
|
||||||
if (this->status_ != status) {
|
if (this->status_ != status) {
|
||||||
this->status_ = status;
|
this->status_ = status;
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class UpdateManager
|
class Updates
|
||||||
{
|
{
|
||||||
UpdateManager();
|
Updates();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum UpdateStatus {
|
enum UpdateStatus {
|
||||||
|
@ -22,7 +22,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
// fourtf: don't add this class to the application class
|
// fourtf: don't add this class to the application class
|
||||||
static UpdateManager &getInstance();
|
static Updates &getInstance();
|
||||||
|
|
||||||
void checkForUpdates();
|
void checkForUpdates();
|
||||||
const QString &getCurrentVersion() const;
|
const QString &getCurrentVersion() const;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ThemeManager;
|
class Themes;
|
||||||
class BaseWindow;
|
class BaseWindow;
|
||||||
|
|
||||||
class BaseWidget : public QWidget
|
class BaseWidget : public QWidget
|
||||||
|
@ -41,7 +41,7 @@ protected:
|
||||||
|
|
||||||
void setScale(float value);
|
void setScale(float value);
|
||||||
|
|
||||||
ThemeManager *themeManager;
|
Themes *themeManager;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
|
|
|
@ -77,7 +77,7 @@ void TooltipWidget::updateFont()
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
this->setFont(
|
this->setFont(
|
||||||
app->fonts->getFont(FontManager::Type::ChatMediumSmall, this->getScale()));
|
app->fonts->getFont(Fonts::Type::ChatMediumSmall, this->getScale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TooltipWidget::setText(QString text)
|
void TooltipWidget::setText(QString text)
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
class ThemeManager;
|
class Themes;
|
||||||
|
|
||||||
class Window : public BaseWindow
|
class Window : public BaseWindow
|
||||||
{
|
{
|
||||||
|
|
|
@ -16,7 +16,7 @@ LastRunCrashDialog::LastRunCrashDialog()
|
||||||
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
this->setWindowFlag(Qt::WindowContextHelpButtonHint, false);
|
||||||
this->setWindowTitle("Chatterino");
|
this->setWindowTitle("Chatterino");
|
||||||
|
|
||||||
auto &updateManager = UpdateManager::getInstance();
|
auto &updateManager = Updates::getInstance();
|
||||||
|
|
||||||
auto layout = LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
|
auto layout = LayoutCreator<LastRunCrashDialog>(this).setLayoutType<QVBoxLayout>();
|
||||||
|
|
||||||
|
|
|
@ -221,8 +221,8 @@ void NotebookTab::paintEvent(QPaintEvent *)
|
||||||
// int fullHeight = (int)(scale * 48);
|
// int fullHeight = (int)(scale * 48);
|
||||||
|
|
||||||
// select the right tab colors
|
// select the right tab colors
|
||||||
ThemeManager::TabColors colors;
|
Themes::TabColors colors;
|
||||||
ThemeManager::TabColors regular = this->themeManager->tabs.regular;
|
Themes::TabColors regular = this->themeManager->tabs.regular;
|
||||||
|
|
||||||
if (this->selected_) {
|
if (this->selected_) {
|
||||||
colors = this->themeManager->tabs.selected;
|
colors = this->themeManager->tabs.selected;
|
||||||
|
|
|
@ -226,7 +226,7 @@ QLayout *AppearancePage::createFontChanger()
|
||||||
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
||||||
|
|
||||||
QObject::connect(button, &QPushButton::clicked, [=]() {
|
QObject::connect(button, &QPushButton::clicked, [=]() {
|
||||||
QFontDialog dialog(app->fonts->getFont(FontManager::ChatMedium, 1.));
|
QFontDialog dialog(app->fonts->getFont(Fonts::ChatMedium, 1.));
|
||||||
|
|
||||||
dialog.setWindowFlag(Qt::WindowStaysOnTopHint);
|
dialog.setWindowFlag(Qt::WindowStaysOnTopHint);
|
||||||
|
|
||||||
|
|
|
@ -67,11 +67,11 @@ void SplitInput::initLayout()
|
||||||
|
|
||||||
// set edit font
|
// set edit font
|
||||||
this->ui_.textEdit->setFont(
|
this->ui_.textEdit->setFont(
|
||||||
app->fonts->getFont(FontManager::Type::ChatMedium, this->getScale()));
|
app->fonts->getFont(Fonts::Type::ChatMedium, this->getScale()));
|
||||||
|
|
||||||
this->managedConnections_.push_back(app->fonts->fontChanged.connect([=]() {
|
this->managedConnections_.push_back(app->fonts->fontChanged.connect([=]() {
|
||||||
this->ui_.textEdit->setFont(
|
this->ui_.textEdit->setFont(
|
||||||
app->fonts->getFont(FontManager::Type::ChatMedium, this->getScale()));
|
app->fonts->getFont(Fonts::Type::ChatMedium, this->getScale()));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// open emote popup
|
// open emote popup
|
||||||
|
|
Loading…
Reference in a new issue