Perform initial refactoring work
Things that were once singletons are no longer singletons, but are instead stored in the "Application" singleton Some singletons still remain, and some renaming/renamespacing is left
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "util/completionmodel.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
#include "common.hpp"
|
||||
#include "debug/log.hpp"
|
||||
#include "singletons/emotemanager.hpp"
|
||||
@@ -19,11 +20,11 @@ void CompletionModel::refresh()
|
||||
{
|
||||
debug::Log("[CompletionModel:{}] Refreshing...]", this->channelName);
|
||||
|
||||
auto &emoteManager = singletons::EmoteManager::getInstance();
|
||||
auto app = getApp();
|
||||
|
||||
// User-specific: Twitch Emotes
|
||||
// TODO: Fix this so it properly updates with the proper api. oauth token needs proper scope
|
||||
for (const auto &m : emoteManager.twitchAccountEmotes) {
|
||||
for (const auto &m : app->emotes->twitchAccountEmotes) {
|
||||
for (const auto &emoteName : m.second.emoteCodes) {
|
||||
// XXX: No way to discern between a twitch global emote and sub emote right now
|
||||
this->addString(emoteName, TaggedString::Type::TwitchGlobalEmote);
|
||||
@@ -31,33 +32,33 @@ void CompletionModel::refresh()
|
||||
}
|
||||
|
||||
// Global: BTTV Global Emotes
|
||||
std::vector<std::string> &bttvGlobalEmoteCodes = emoteManager.bttvGlobalEmoteCodes;
|
||||
std::vector<std::string> &bttvGlobalEmoteCodes = app->emotes->bttvGlobalEmoteCodes;
|
||||
for (const auto &m : bttvGlobalEmoteCodes) {
|
||||
this->addString(m, TaggedString::Type::BTTVGlobalEmote);
|
||||
}
|
||||
|
||||
// Global: FFZ Global Emotes
|
||||
std::vector<std::string> &ffzGlobalEmoteCodes = emoteManager.ffzGlobalEmoteCodes;
|
||||
std::vector<std::string> &ffzGlobalEmoteCodes = app->emotes->ffzGlobalEmoteCodes;
|
||||
for (const auto &m : ffzGlobalEmoteCodes) {
|
||||
this->addString(m, TaggedString::Type::FFZGlobalEmote);
|
||||
}
|
||||
|
||||
// Channel-specific: BTTV Channel Emotes
|
||||
std::vector<std::string> &bttvChannelEmoteCodes =
|
||||
emoteManager.bttvChannelEmoteCodes[this->channelName.toStdString()];
|
||||
app->emotes->bttvChannelEmoteCodes[this->channelName.toStdString()];
|
||||
for (const auto &m : bttvChannelEmoteCodes) {
|
||||
this->addString(m, TaggedString::Type::BTTVChannelEmote);
|
||||
}
|
||||
|
||||
// Channel-specific: FFZ Channel Emotes
|
||||
std::vector<std::string> &ffzChannelEmoteCodes =
|
||||
emoteManager.ffzChannelEmoteCodes[this->channelName.toStdString()];
|
||||
app->emotes->ffzChannelEmoteCodes[this->channelName.toStdString()];
|
||||
for (const auto &m : ffzChannelEmoteCodes) {
|
||||
this->addString(m, TaggedString::Type::FFZChannelEmote);
|
||||
}
|
||||
|
||||
// Global: Emojis
|
||||
const auto &emojiShortCodes = emoteManager.emojiShortCodes;
|
||||
const auto &emojiShortCodes = app->emotes->emojiShortCodes;
|
||||
for (const auto &m : emojiShortCodes) {
|
||||
this->addString(":" + m + ":", TaggedString::Type::Emoji);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "util/networkrequest.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
|
||||
namespace chatterino {
|
||||
namespace util {
|
||||
|
||||
@@ -26,9 +28,9 @@ void NetworkRequest::setUseQuickLoadCache(bool value)
|
||||
void NetworkRequest::Data::writeToCache(const QByteArray &bytes)
|
||||
{
|
||||
if (this->useQuickLoadCache) {
|
||||
auto &pathManager = singletons::PathManager::getInstance();
|
||||
auto app = getApp();
|
||||
|
||||
QFile cachedFile(pathManager.cacheFolderPath + "/" + this->getHash());
|
||||
QFile cachedFile(app->paths->cacheFolderPath + "/" + this->getHash());
|
||||
|
||||
if (cachedFile.open(QIODevice::WriteOnly)) {
|
||||
cachedFile.write(bytes);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "application.hpp"
|
||||
#include "singletons/pathmanager.hpp"
|
||||
#include "util/networkmanager.hpp"
|
||||
#include "util/networkrequester.hpp"
|
||||
@@ -125,9 +126,9 @@ public:
|
||||
void get(FinishedCallback onFinished)
|
||||
{
|
||||
if (this->data.useQuickLoadCache) {
|
||||
auto &pathManager = singletons::PathManager::getInstance();
|
||||
auto app = getApp();
|
||||
|
||||
QFile cachedFile(pathManager.cacheFolderPath + "/" + this->data.getHash());
|
||||
QFile cachedFile(app->paths->cacheFolderPath + "/" + this->data.getHash());
|
||||
|
||||
if (cachedFile.exists()) {
|
||||
if (cachedFile.open(QIODevice::ReadOnly)) {
|
||||
|
||||
+10
-8
@@ -1,4 +1,6 @@
|
||||
#include "util/streamlink.hpp"
|
||||
|
||||
#include "application.hpp"
|
||||
#include "helpers.hpp"
|
||||
#include "singletons/settingsmanager.hpp"
|
||||
#include "widgets/qualitypopup.hpp"
|
||||
@@ -50,9 +52,9 @@ bool CheckStreamlinkPath(const QString &path)
|
||||
// TODO: Make streamlink binary finder smarter
|
||||
QString GetStreamlinkBinaryPath()
|
||||
{
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
auto app = getApp();
|
||||
|
||||
QString settingPath = settings.streamlinkPath;
|
||||
QString settingPath = app->settings->streamlinkPath;
|
||||
|
||||
QStringList paths;
|
||||
paths << settingPath;
|
||||
@@ -111,15 +113,15 @@ void GetStreamQualities(const QString &channelURL, std::function<void(QStringLis
|
||||
|
||||
void OpenStreamlink(const QString &channelURL, const QString &quality, QStringList extraArguments)
|
||||
{
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
auto app = getApp();
|
||||
|
||||
QString path = GetStreamlinkBinaryPath();
|
||||
|
||||
QStringList arguments;
|
||||
|
||||
QString additionalOptions = settings.streamlinkOpts.getValue();
|
||||
QString additionalOptions = app->settings->streamlinkOpts.getValue();
|
||||
if (!additionalOptions.isEmpty()) {
|
||||
arguments << settings.streamlinkOpts;
|
||||
arguments << app->settings->streamlinkOpts;
|
||||
}
|
||||
|
||||
arguments.append(extraArguments);
|
||||
@@ -135,11 +137,11 @@ void OpenStreamlink(const QString &channelURL, const QString &quality, QStringLi
|
||||
|
||||
void Start(const QString &channel)
|
||||
{
|
||||
auto app = getApp();
|
||||
|
||||
QString channelURL = "twitch.tv/" + channel;
|
||||
|
||||
singletons::SettingManager &settings = singletons::SettingManager::getInstance();
|
||||
|
||||
QString preferredQuality = settings.preferredQuality;
|
||||
QString preferredQuality = app->settings->preferredQuality;
|
||||
preferredQuality = preferredQuality.toLower();
|
||||
|
||||
if (preferredQuality == "choose") {
|
||||
|
||||
@@ -100,8 +100,7 @@ static void put(QUrl url, std::function<void(QJsonObject)> successCallback)
|
||||
{
|
||||
QNetworkRequest request(url);
|
||||
|
||||
auto &accountManager = singletons::AccountManager::getInstance();
|
||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
||||
auto currentTwitchUser = getApp()->accounts->Twitch.getCurrent();
|
||||
QByteArray oauthToken;
|
||||
if (currentTwitchUser) {
|
||||
oauthToken = currentTwitchUser->getOAuthToken().toUtf8();
|
||||
@@ -131,8 +130,7 @@ static void sendDelete(QUrl url, std::function<void()> successCallback)
|
||||
{
|
||||
QNetworkRequest request(url);
|
||||
|
||||
auto &accountManager = singletons::AccountManager::getInstance();
|
||||
auto currentTwitchUser = accountManager.Twitch.getCurrent();
|
||||
auto currentTwitchUser = getApp()->accounts->Twitch.getCurrent();
|
||||
QByteArray oauthToken;
|
||||
if (currentTwitchUser) {
|
||||
oauthToken = currentTwitchUser->getOAuthToken().toUtf8();
|
||||
|
||||
Reference in New Issue
Block a user