mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
renamed resources to ResourceManager
This commit is contained in:
parent
bfa2f1637e
commit
ad001431f2
|
@ -61,7 +61,6 @@ SOURCES += \
|
|||
src/messages/message.cpp \
|
||||
src/messages/word.cpp \
|
||||
src/messages/wordpart.cpp \
|
||||
src/resources.cpp \
|
||||
src/widgets/notebook.cpp \
|
||||
src/widgets/helper/notebookbutton.cpp \
|
||||
src/widgets/helper/notebooktab.cpp \
|
||||
|
@ -112,7 +111,8 @@ SOURCES += \
|
|||
src/widgets/tooltipwidget.cpp \
|
||||
src/singletons/thememanager.cpp \
|
||||
src/twitch/twitchaccountmanager.cpp \
|
||||
src/singletons/helper/completionmodel.cpp
|
||||
src/singletons/helper/completionmodel.cpp \
|
||||
src/singletons/resourcemanager.cpp
|
||||
|
||||
HEADERS += \
|
||||
src/precompiled_headers.hpp \
|
||||
|
@ -126,7 +126,6 @@ HEADERS += \
|
|||
src/messages/message.hpp \
|
||||
src/messages/word.hpp \
|
||||
src/messages/wordpart.hpp \
|
||||
src/resources.hpp \
|
||||
src/setting.hpp \
|
||||
src/twitch/emotevalue.hpp \
|
||||
src/widgets/notebook.hpp \
|
||||
|
@ -194,7 +193,8 @@ HEADERS += \
|
|||
src/singletons/thememanager.hpp \
|
||||
src/twitch/twitchaccountmanager.hpp \
|
||||
src/singletons/helper/completionmodel.hpp \
|
||||
src/singletons/helper/chatterinosetting.hpp
|
||||
src/singletons/helper/chatterinosetting.hpp \
|
||||
src/singletons/resourcemanager.hpp
|
||||
|
||||
|
||||
PRECOMPILED_HEADER =
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "singletons/ircmanager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "singletons/resourcemanager.hpp"
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
#include "singletons/fontmanager.hpp"
|
||||
#include "singletons/ircmanager.hpp"
|
||||
#include "messages/link.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "singletons/resourcemanager.hpp"
|
||||
#include "util/irchelpers.hpp"
|
||||
|
||||
#include <ctime>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "messagebuilder.hpp"
|
||||
#include "singletons/thememanager.hpp"
|
||||
#include "singletons/emotemanager.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "singletons/resourcemanager.hpp"
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
|
|
@ -3,10 +3,10 @@
|
|||
#include "channel.hpp"
|
||||
#include "debug/log.hpp"
|
||||
#include "messages/messageparseargs.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "singletons/accountmanager.hpp"
|
||||
#include "singletons/channelmanager.hpp"
|
||||
#include "singletons/emotemanager.hpp"
|
||||
#include "singletons/resourcemanager.hpp"
|
||||
#include "singletons/settingsmanager.hpp"
|
||||
#include "singletons/windowmanager.hpp"
|
||||
#include "twitch/twitchmessagebuilder.hpp"
|
||||
|
@ -27,7 +27,7 @@ using namespace chatterino::messages;
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
IrcManager::IrcManager(ChannelManager &_channelManager, Resources &_resources,
|
||||
IrcManager::IrcManager(ChannelManager &_channelManager, ResourceManager &_resources,
|
||||
AccountManager &_accountManager)
|
||||
: channelManager(_channelManager)
|
||||
, resources(_resources)
|
||||
|
@ -70,7 +70,7 @@ IrcManager::IrcManager(ChannelManager &_channelManager, Resources &_resources,
|
|||
|
||||
IrcManager &IrcManager::getInstance()
|
||||
{
|
||||
static IrcManager instance(ChannelManager::getInstance(), Resources::getInstance(),
|
||||
static IrcManager instance(ChannelManager::getInstance(), ResourceManager::getInstance(),
|
||||
AccountManager::getInstance());
|
||||
return instance;
|
||||
}
|
||||
|
|
|
@ -19,14 +19,14 @@
|
|||
namespace chatterino {
|
||||
|
||||
class ChannelManager;
|
||||
class Resources;
|
||||
class ResourceManager;
|
||||
class AccountManager;
|
||||
|
||||
class IrcManager : public QObject
|
||||
{
|
||||
// Q_OBJECT
|
||||
|
||||
IrcManager(ChannelManager &channelManager, Resources &resources,
|
||||
IrcManager(ChannelManager &channelManager, ResourceManager &resources,
|
||||
AccountManager &accountManager);
|
||||
|
||||
public:
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
private:
|
||||
ChannelManager &channelManager;
|
||||
Resources &resources;
|
||||
ResourceManager &resources;
|
||||
AccountManager &accountManager;
|
||||
|
||||
// variables
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "resources.hpp"
|
||||
#include "resourcemanager.hpp"
|
||||
//#include "singletons/emotemanager.hpp"
|
||||
//#include "singletons/windowmanager.hpp"
|
||||
#include "util/urlfetch.hpp"
|
||||
|
@ -16,7 +16,7 @@ inline messages::LazyLoadedImage *lli(const char *pixmapPath, qreal scale = 1)
|
|||
|
||||
} // namespace
|
||||
|
||||
Resources::Resources()
|
||||
ResourceManager::ResourceManager()
|
||||
: badgeStaff(lli(":/images/staff_bg.png"))
|
||||
, badgeAdmin(lli(":/images/admin_bg.png"))
|
||||
, badgeGlobalModerator(lli(":/images/globalmod_bg.png"))
|
||||
|
@ -41,13 +41,13 @@ Resources::Resources()
|
|||
this->loadChatterinoBadges();
|
||||
}
|
||||
|
||||
Resources &Resources::getInstance()
|
||||
ResourceManager &ResourceManager::getInstance()
|
||||
{
|
||||
static Resources instance;
|
||||
static ResourceManager instance;
|
||||
return instance;
|
||||
}
|
||||
|
||||
Resources::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
||||
ResourceManager::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
||||
: badgeImage1x(new messages::LazyLoadedImage(root.value("image_url_1x").toString()))
|
||||
, badgeImage2x(new messages::LazyLoadedImage(root.value("image_url_2x").toString()))
|
||||
, badgeImage4x(new messages::LazyLoadedImage(root.value("image_url_4x").toString()))
|
||||
|
@ -58,7 +58,7 @@ Resources::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
|||
{
|
||||
}
|
||||
|
||||
void Resources::loadChannelData(const QString &roomID, bool bypassCache)
|
||||
void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache)
|
||||
{
|
||||
qDebug() << "Load channel data for" << roomID;
|
||||
|
||||
|
@ -70,7 +70,7 @@ void Resources::loadChannelData(const QString &roomID, bool bypassCache)
|
|||
req.getJSON([this, roomID](QJsonObject &root) {
|
||||
QJsonObject sets = root.value("badge_sets").toObject();
|
||||
|
||||
Resources::Channel &ch = this->channels[roomID];
|
||||
ResourceManager::Channel &ch = this->channels[roomID];
|
||||
|
||||
for (QJsonObject::iterator it = sets.begin(); it != sets.end(); ++it) {
|
||||
QJsonObject versions = it.value().toObject().value("versions").toObject();
|
||||
|
@ -91,7 +91,7 @@ void Resources::loadChannelData(const QString &roomID, bool bypassCache)
|
|||
});
|
||||
}
|
||||
|
||||
void Resources::loadDynamicTwitchBadges()
|
||||
void ResourceManager::loadDynamicTwitchBadges()
|
||||
{
|
||||
static QString url("https://badges.twitch.tv/v1/badges/global/display?language=en");
|
||||
|
||||
|
@ -119,7 +119,7 @@ void Resources::loadDynamicTwitchBadges()
|
|||
});
|
||||
}
|
||||
|
||||
void Resources::loadChatterinoBadges()
|
||||
void ResourceManager::loadChatterinoBadges()
|
||||
{
|
||||
this->chatterinoBadges.clear();
|
||||
|
|
@ -8,12 +8,12 @@
|
|||
|
||||
namespace chatterino {
|
||||
|
||||
class Resources
|
||||
class ResourceManager
|
||||
{
|
||||
explicit Resources();
|
||||
ResourceManager();
|
||||
|
||||
public:
|
||||
static Resources &getInstance();
|
||||
static ResourceManager &getInstance();
|
||||
|
||||
messages::LazyLoadedImage *badgeStaff;
|
||||
messages::LazyLoadedImage *badgeAdmin;
|
|
@ -1,6 +1,6 @@
|
|||
#include "twitchmessagebuilder.hpp"
|
||||
#include "debug/log.hpp"
|
||||
#include "resources.hpp"
|
||||
#include "singletons/resourcemanager.hpp"
|
||||
#include "singletons/emotemanager.hpp"
|
||||
#include "singletons/ircmanager.hpp"
|
||||
#include "singletons/settingsmanager.hpp"
|
||||
|
@ -482,9 +482,9 @@ void TwitchMessageBuilder::appendModerationButtons()
|
|||
static QString buttonBanTooltip("Ban user");
|
||||
static QString buttonTimeoutTooltip("Timeout user");
|
||||
|
||||
this->appendWord(Word(Resources::getInstance().buttonBan, Word::ButtonBan, QString(),
|
||||
this->appendWord(Word(ResourceManager::getInstance().buttonBan, Word::ButtonBan, QString(),
|
||||
buttonBanTooltip, Link(Link::UserBan, ircMessage->account())));
|
||||
this->appendWord(Word(Resources::getInstance().buttonTimeout, Word::ButtonTimeout, QString(),
|
||||
this->appendWord(Word(ResourceManager::getInstance().buttonTimeout, Word::ButtonTimeout, QString(),
|
||||
buttonTimeoutTooltip, Link(Link::UserTimeout, ircMessage->account())));
|
||||
}
|
||||
|
||||
|
@ -567,7 +567,7 @@ bool TwitchMessageBuilder::appendEmote(EmoteData &emoteData)
|
|||
|
||||
void TwitchMessageBuilder::parseTwitchBadges()
|
||||
{
|
||||
const auto &channelResources = Resources::getInstance().channels[this->roomID];
|
||||
const auto &channelResources = ResourceManager::getInstance().channels[this->roomID];
|
||||
|
||||
auto iterator = this->tags.find("badges");
|
||||
|
||||
|
@ -584,7 +584,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
}
|
||||
|
||||
if (badge.startsWith("bits/")) {
|
||||
if (!Resources::getInstance().dynamicBadgesLoaded) {
|
||||
if (!ResourceManager::getInstance().dynamicBadgesLoaded) {
|
||||
// Do nothing
|
||||
continue;
|
||||
}
|
||||
|
@ -593,7 +593,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
std::string versionKey = cheerAmountQS.toStdString();
|
||||
|
||||
try {
|
||||
auto &badgeSet = Resources::getInstance().badgeSets.at("bits");
|
||||
auto &badgeSet = ResourceManager::getInstance().badgeSets.at("bits");
|
||||
|
||||
try {
|
||||
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
||||
|
@ -609,34 +609,34 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
debug::Log("No badge set with key bits. Exception: {}", e.what());
|
||||
}
|
||||
} else if (badge == "staff/1") {
|
||||
appendWord(Word(Resources::getInstance().badgeStaff, Word::BadgeGlobalAuthority,
|
||||
appendWord(Word(ResourceManager::getInstance().badgeStaff, Word::BadgeGlobalAuthority,
|
||||
QString(), QString("Twitch Staff")));
|
||||
} else if (badge == "admin/1") {
|
||||
appendWord(Word(Resources::getInstance().badgeAdmin, Word::BadgeGlobalAuthority,
|
||||
appendWord(Word(ResourceManager::getInstance().badgeAdmin, Word::BadgeGlobalAuthority,
|
||||
QString(), QString("Twitch Admin")));
|
||||
} else if (badge == "global_mod/1") {
|
||||
appendWord(Word(Resources::getInstance().badgeGlobalModerator,
|
||||
appendWord(Word(ResourceManager::getInstance().badgeGlobalModerator,
|
||||
Word::BadgeGlobalAuthority, QString(), QString("Global Moderator")));
|
||||
} else if (badge == "moderator/1") {
|
||||
// TODO: Implement custom FFZ moderator badge
|
||||
appendWord(Word(Resources::getInstance().badgeModerator, Word::BadgeChannelAuthority,
|
||||
appendWord(Word(ResourceManager::getInstance().badgeModerator, Word::BadgeChannelAuthority,
|
||||
QString(),
|
||||
QString("Channel Moderator"))); // custom badge
|
||||
} else if (badge == "turbo/1") {
|
||||
appendWord(Word(Resources::getInstance().badgeTurbo, Word::BadgeVanity, QString(),
|
||||
appendWord(Word(ResourceManager::getInstance().badgeTurbo, Word::BadgeVanity, QString(),
|
||||
QString("Turbo Subscriber")));
|
||||
} else if (badge == "broadcaster/1") {
|
||||
appendWord(Word(Resources::getInstance().badgeBroadcaster, Word::BadgeChannelAuthority,
|
||||
appendWord(Word(ResourceManager::getInstance().badgeBroadcaster, Word::BadgeChannelAuthority,
|
||||
QString(), QString("Channel Broadcaster")));
|
||||
} else if (badge == "premium/1") {
|
||||
appendWord(Word(Resources::getInstance().badgePremium, Word::BadgeVanity, QString(),
|
||||
appendWord(Word(ResourceManager::getInstance().badgePremium, Word::BadgeVanity, QString(),
|
||||
QString("Twitch Prime")));
|
||||
|
||||
} else if (badge.startsWith("partner/")) {
|
||||
int index = badge.midRef(8).toInt();
|
||||
switch (index) {
|
||||
case 1: {
|
||||
appendWord(Word(Resources::getInstance().badgeVerified, Word::BadgeVanity,
|
||||
appendWord(Word(ResourceManager::getInstance().badgeVerified, Word::BadgeVanity,
|
||||
QString(), "Twitch Verified"));
|
||||
} break;
|
||||
default: {
|
||||
|
@ -652,7 +652,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
auto badgeSetIt = channelResources.badgeSets.find("subscriber");
|
||||
if (badgeSetIt == channelResources.badgeSets.end()) {
|
||||
// Fall back to default badge
|
||||
appendWord(Word(Resources::getInstance().badgeSubscriber,
|
||||
appendWord(Word(ResourceManager::getInstance().badgeSubscriber,
|
||||
Word::Flags::BadgeSubscription, QString(),
|
||||
QString("Twitch Subscriber")));
|
||||
continue;
|
||||
|
@ -666,7 +666,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
|
||||
if (badgeVersionIt == badgeSet.versions.end()) {
|
||||
// Fall back to default badge
|
||||
appendWord(Word(Resources::getInstance().badgeSubscriber,
|
||||
appendWord(Word(ResourceManager::getInstance().badgeSubscriber,
|
||||
Word::Flags::BadgeSubscription, QString(),
|
||||
QString("Twitch Subscriber")));
|
||||
continue;
|
||||
|
@ -677,7 +677,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
appendWord(Word(badgeVersion.badgeImage1x, Word::Flags::BadgeSubscription, QString(),
|
||||
QString("Twitch " + QString::fromStdString(badgeVersion.title))));
|
||||
} else {
|
||||
if (!Resources::getInstance().dynamicBadgesLoaded) {
|
||||
if (!ResourceManager::getInstance().dynamicBadgesLoaded) {
|
||||
// Do nothing
|
||||
continue;
|
||||
}
|
||||
|
@ -695,7 +695,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
std::string versionKey = parts[1].toStdString();
|
||||
|
||||
try {
|
||||
auto &badgeSet = Resources::getInstance().badgeSets.at(badgeSetKey);
|
||||
auto &badgeSet = ResourceManager::getInstance().badgeSets.at(badgeSetKey);
|
||||
|
||||
try {
|
||||
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
||||
|
@ -717,7 +717,7 @@ void TwitchMessageBuilder::parseTwitchBadges()
|
|||
|
||||
void TwitchMessageBuilder::parseChatterinoBadges()
|
||||
{
|
||||
auto &badges = Resources::getInstance().chatterinoBadges;
|
||||
auto &badges = ResourceManager::getInstance().chatterinoBadges;
|
||||
auto it = badges.find(this->userName.toStdString());
|
||||
|
||||
if (it == badges.end()) {
|
||||
|
|
Loading…
Reference in a new issue