mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
Finish up singleton refactoring into one giant class
This commit is contained in:
parent
9426a9d633
commit
2f195891cd
|
@ -4,10 +4,12 @@
|
||||||
#include "singletons/accountmanager.hpp"
|
#include "singletons/accountmanager.hpp"
|
||||||
#include "singletons/commandmanager.hpp"
|
#include "singletons/commandmanager.hpp"
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
|
#include "singletons/fontmanager.hpp"
|
||||||
#include "singletons/loggingmanager.hpp"
|
#include "singletons/loggingmanager.hpp"
|
||||||
#include "singletons/nativemessagingmanager.hpp"
|
#include "singletons/nativemessagingmanager.hpp"
|
||||||
#include "singletons/pathmanager.hpp"
|
#include "singletons/pathmanager.hpp"
|
||||||
#include "singletons/pubsubmanager.hpp"
|
#include "singletons/pubsubmanager.hpp"
|
||||||
|
#include "singletons/resourcemanager.hpp"
|
||||||
#include "singletons/settingsmanager.hpp"
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
#include "singletons/windowmanager.hpp"
|
#include "singletons/windowmanager.hpp"
|
||||||
|
@ -57,7 +59,7 @@ void Application::construct()
|
||||||
isAppConstructed = true;
|
isAppConstructed = true;
|
||||||
|
|
||||||
// 1. Instantiate all classes
|
// 1. Instantiate all classes
|
||||||
this->paths = new singletons::PathManager(argc, argv);
|
this->paths = new singletons::PathManager(this->argc, this->argv);
|
||||||
this->themes = new singletons::ThemeManager;
|
this->themes = new singletons::ThemeManager;
|
||||||
this->windows = new singletons::WindowManager;
|
this->windows = new singletons::WindowManager;
|
||||||
this->logging = new singletons::LoggingManager;
|
this->logging = new singletons::LoggingManager;
|
||||||
|
@ -66,6 +68,10 @@ void Application::construct()
|
||||||
this->emotes = new singletons::EmoteManager;
|
this->emotes = new singletons::EmoteManager;
|
||||||
this->pubsub = new singletons::PubSubManager;
|
this->pubsub = new singletons::PubSubManager;
|
||||||
this->settings = new singletons::SettingManager;
|
this->settings = new singletons::SettingManager;
|
||||||
|
this->fonts = new singletons::FontManager;
|
||||||
|
this->resources = new singletons::ResourceManager;
|
||||||
|
|
||||||
|
this->twitch.server = new providers::twitch::TwitchServer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::instantiate(int argc, char **argv)
|
void Application::instantiate(int argc, char **argv)
|
||||||
|
@ -81,18 +87,20 @@ void Application::initialize()
|
||||||
isAppInitialized = true;
|
isAppInitialized = true;
|
||||||
|
|
||||||
// 2. Initialize/load classes
|
// 2. Initialize/load classes
|
||||||
|
this->settings->initialize();
|
||||||
this->windows->initialize();
|
this->windows->initialize();
|
||||||
|
|
||||||
this->nativeMessaging->registerHost();
|
this->nativeMessaging->registerHost();
|
||||||
|
|
||||||
this->settings->initialize();
|
this->settings->load();
|
||||||
this->commands->loadCommands();
|
this->commands->loadCommands();
|
||||||
|
|
||||||
// Initialize everything we need
|
|
||||||
this->emotes->loadGlobalEmotes();
|
this->emotes->loadGlobalEmotes();
|
||||||
|
|
||||||
this->accounts->load();
|
this->accounts->load();
|
||||||
|
|
||||||
|
this->twitch.server->initialize();
|
||||||
|
|
||||||
// XXX
|
// XXX
|
||||||
this->settings->updateWordTypeMask();
|
this->settings->updateWordTypeMask();
|
||||||
|
|
||||||
|
@ -121,8 +129,7 @@ void Application::initialize()
|
||||||
});
|
});
|
||||||
|
|
||||||
this->pubsub->sig.moderation.userBanned.connect([&](const auto &action) {
|
this->pubsub->sig.moderation.userBanned.connect([&](const auto &action) {
|
||||||
auto &server = providers::twitch::TwitchServer::getInstance();
|
auto chan = this->twitch.server->getChannelOrEmptyByID(action.roomID);
|
||||||
auto chan = server.getChannelOrEmptyByID(action.roomID);
|
|
||||||
|
|
||||||
if (chan->isEmpty()) {
|
if (chan->isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -134,8 +141,7 @@ void Application::initialize()
|
||||||
});
|
});
|
||||||
|
|
||||||
this->pubsub->sig.moderation.userUnbanned.connect([&](const auto &action) {
|
this->pubsub->sig.moderation.userUnbanned.connect([&](const auto &action) {
|
||||||
auto &server = providers::twitch::TwitchServer::getInstance();
|
auto chan = this->twitch.server->getChannelOrEmptyByID(action.roomID);
|
||||||
auto chan = server.getChannelOrEmptyByID(action.roomID);
|
|
||||||
|
|
||||||
if (chan->isEmpty()) {
|
if (chan->isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -164,7 +170,7 @@ void Application::initialize()
|
||||||
int Application::run(QApplication &qtApp)
|
int Application::run(QApplication &qtApp)
|
||||||
{
|
{
|
||||||
// Start connecting to the IRC Servers (Twitch only for now)
|
// Start connecting to the IRC Servers (Twitch only for now)
|
||||||
providers::twitch::TwitchServer::getInstance().connect();
|
this->twitch.server->connect();
|
||||||
|
|
||||||
// Show main window
|
// Show main window
|
||||||
this->windows->getMainWindow().show();
|
this->windows->getMainWindow().show();
|
||||||
|
|
|
@ -7,6 +7,14 @@
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
|
|
||||||
|
namespace providers {
|
||||||
|
namespace twitch {
|
||||||
|
|
||||||
|
class TwitchServer;
|
||||||
|
|
||||||
|
} // namespace twitch
|
||||||
|
} // namespace providers
|
||||||
|
|
||||||
namespace singletons {
|
namespace singletons {
|
||||||
|
|
||||||
class ThemeManager;
|
class ThemeManager;
|
||||||
|
@ -19,6 +27,8 @@ class EmoteManager;
|
||||||
class PubSubManager;
|
class PubSubManager;
|
||||||
class NativeMessagingManager;
|
class NativeMessagingManager;
|
||||||
class SettingManager;
|
class SettingManager;
|
||||||
|
class FontManager;
|
||||||
|
class ResourceManager;
|
||||||
|
|
||||||
} // namespace singletons
|
} // namespace singletons
|
||||||
|
|
||||||
|
@ -37,6 +47,8 @@ public:
|
||||||
|
|
||||||
int run(QApplication &qtApp);
|
int run(QApplication &qtApp);
|
||||||
|
|
||||||
|
friend void test();
|
||||||
|
|
||||||
singletons::PathManager *paths = nullptr;
|
singletons::PathManager *paths = nullptr;
|
||||||
singletons::ThemeManager *themes = nullptr;
|
singletons::ThemeManager *themes = nullptr;
|
||||||
singletons::WindowManager *windows = nullptr;
|
singletons::WindowManager *windows = nullptr;
|
||||||
|
@ -47,6 +59,13 @@ public:
|
||||||
singletons::PubSubManager *pubsub = nullptr;
|
singletons::PubSubManager *pubsub = nullptr;
|
||||||
singletons::NativeMessagingManager *nativeMessaging = nullptr;
|
singletons::NativeMessagingManager *nativeMessaging = nullptr;
|
||||||
singletons::SettingManager *settings = nullptr;
|
singletons::SettingManager *settings = nullptr;
|
||||||
|
singletons::FontManager *fonts = nullptr;
|
||||||
|
singletons::ResourceManager *resources = nullptr;
|
||||||
|
|
||||||
|
/// Provider-specific
|
||||||
|
struct {
|
||||||
|
providers::twitch::TwitchServer *server;
|
||||||
|
} twitch;
|
||||||
|
|
||||||
void save();
|
void save();
|
||||||
|
|
||||||
|
|
|
@ -62,10 +62,9 @@ bool MessageLayout::layout(int width, float scale, MessageElement::Flags flags)
|
||||||
this->emoteGeneration = app->emotes->getGeneration();
|
this->emoteGeneration = app->emotes->getGeneration();
|
||||||
|
|
||||||
// check if text changed
|
// check if text changed
|
||||||
bool textChanged =
|
bool textChanged = this->fontGeneration != app->fonts->getGeneration();
|
||||||
this->fontGeneration != singletons::FontManager::getInstance().getGeneration();
|
|
||||||
layoutRequired |= textChanged;
|
layoutRequired |= textChanged;
|
||||||
this->fontGeneration = singletons::FontManager::getInstance().getGeneration();
|
this->fontGeneration = app->fonts->getGeneration();
|
||||||
|
|
||||||
// check if work mask changed
|
// check if work mask changed
|
||||||
bool wordMaskChanged = this->currentWordFlags != flags; // app->settings->getWordTypeMask();
|
bool wordMaskChanged = this->currentWordFlags != flags; // app->settings->getWordTypeMask();
|
||||||
|
@ -160,8 +159,7 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
|
||||||
|
|
||||||
// draw disabled
|
// draw disabled
|
||||||
if (this->message->flags.HasFlag(Message::Disabled)) {
|
if (this->message->flags.HasFlag(Message::Disabled)) {
|
||||||
painter.fillRect(0, y, pixmap->width(), pixmap->height(),
|
painter.fillRect(0, y, pixmap->width(), pixmap->height(), app->themes->messages.disabled);
|
||||||
app->themes->messages.disabled);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw selection
|
// draw selection
|
||||||
|
@ -171,8 +169,7 @@ void MessageLayout::paint(QPainter &painter, int y, int messageIndex, Selection
|
||||||
|
|
||||||
// draw last read message line
|
// draw last read message line
|
||||||
if (isLastReadMessage) {
|
if (isLastReadMessage) {
|
||||||
QColor color = isWindowFocused
|
QColor color = isWindowFocused ? app->themes->tabs.selected.backgrounds.regular.color()
|
||||||
? app->themes->tabs.selected.backgrounds.regular.color()
|
|
||||||
: app->themes->tabs.selected.backgrounds.unfocused.color();
|
: app->themes->tabs.selected.backgrounds.unfocused.color();
|
||||||
|
|
||||||
QBrush brush(color, Qt::VerPattern);
|
QBrush brush(color, Qt::VerPattern);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
#include "messages/layouts/messagelayoutelement.hpp"
|
#include "messages/layouts/messagelayoutelement.hpp"
|
||||||
|
|
||||||
#include "application.hpp"
|
#include "application.hpp"
|
||||||
#include "messages/messageelement.hpp"
|
#include "messages/messageelement.hpp"
|
||||||
#include "util/debugcount.hpp"
|
#include "util/debugcount.hpp"
|
||||||
|
@ -165,9 +166,11 @@ int TextLayoutElement::getSelectionIndexCount()
|
||||||
|
|
||||||
void TextLayoutElement::paint(QPainter &painter)
|
void TextLayoutElement::paint(QPainter &painter)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
painter.setPen(this->color);
|
painter.setPen(this->color);
|
||||||
|
|
||||||
painter.setFont(singletons::FontManager::getInstance().getFont(this->style, this->scale));
|
painter.setFont(app->fonts->getFont(this->style, this->scale));
|
||||||
|
|
||||||
painter.drawText(QRectF(this->getRect().x(), this->getRect().y(), 10000, 10000), this->text,
|
painter.drawText(QRectF(this->getRect().x(), this->getRect().y(), 10000, 10000), this->text,
|
||||||
QTextOption(Qt::AlignLeft | Qt::AlignTop));
|
QTextOption(Qt::AlignLeft | Qt::AlignTop));
|
||||||
|
@ -183,8 +186,9 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFontMetrics &metrics =
|
auto app = getApp();
|
||||||
singletons::FontManager::getInstance().getFontMetrics(this->style, this->scale);
|
|
||||||
|
QFontMetrics &metrics = app->fonts->getFontMetrics(this->style, this->scale);
|
||||||
|
|
||||||
int x = this->getRect().left();
|
int x = this->getRect().left();
|
||||||
|
|
||||||
|
@ -203,8 +207,9 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs)
|
||||||
|
|
||||||
int TextLayoutElement::getXFromIndex(int index)
|
int TextLayoutElement::getXFromIndex(int index)
|
||||||
{
|
{
|
||||||
QFontMetrics &metrics =
|
auto app = getApp();
|
||||||
singletons::FontManager::getInstance().getFontMetrics(this->style, this->scale);
|
|
||||||
|
QFontMetrics &metrics = app->fonts->getFontMetrics(this->style, this->scale);
|
||||||
|
|
||||||
if (index <= 0) {
|
if (index <= 0) {
|
||||||
return this->getRect().left();
|
return this->getRect().left();
|
||||||
|
@ -242,7 +247,7 @@ void TextIconLayoutElement::paint(QPainter &painter)
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
QFont font = singletons::FontManager::getInstance().getFont(FontStyle::Tiny, this->scale);
|
QFont font = app->fonts->getFont(FontStyle::Tiny, this->scale);
|
||||||
|
|
||||||
painter.setPen(app->themes->messages.textColors.system);
|
painter.setPen(app->themes->messages.textColors.system);
|
||||||
painter.setFont(font);
|
painter.setFont(font);
|
||||||
|
|
|
@ -139,8 +139,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container, MessageEleme
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
|
|
||||||
if (_flags & this->getFlags()) {
|
if (_flags & this->getFlags()) {
|
||||||
QFontMetrics &metrics = singletons::FontManager::getInstance().getFontMetrics(
|
QFontMetrics &metrics = app->fonts->getFontMetrics(this->style, container.getScale());
|
||||||
this->style, container.getScale());
|
|
||||||
|
|
||||||
for (Word &word : this->words) {
|
for (Word &word : this->words) {
|
||||||
auto getTextLayoutElement = [&](QString text, int width, bool trailingSpace) {
|
auto getTextLayoutElement = [&](QString text, int width, bool trailingSpace) {
|
||||||
|
|
|
@ -35,12 +35,15 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
|
||||||
QStringList words = QString(message->toData()).split("#");
|
QStringList words = QString(message->toData()).split("#");
|
||||||
|
|
||||||
// ensure the format is valid
|
// ensure the format is valid
|
||||||
if (words.length() < 2)
|
if (words.length() < 2) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
QString channelName = words.at(1);
|
QString channelName = words.at(1);
|
||||||
|
|
||||||
auto channel = TwitchServer::getInstance().getChannelOrEmpty(channelName);
|
auto channel = app->twitch.server->getChannelOrEmpty(channelName);
|
||||||
|
|
||||||
if (channel->isEmpty()) {
|
if (channel->isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -51,7 +54,7 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message)
|
||||||
twitchChannel->setRoomID(roomID);
|
twitchChannel->setRoomID(roomID);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceManager::getInstance().loadChannelData(roomID);
|
app->resources->loadChannelData(roomID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +71,10 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
// get channel
|
// get channel
|
||||||
auto chan = TwitchServer::getInstance().getChannelOrEmpty(chanName);
|
auto chan = app->twitch.server->getChannelOrEmpty(chanName);
|
||||||
|
|
||||||
if (chan->isEmpty()) {
|
if (chan->isEmpty()) {
|
||||||
debug::Log("[IrcMessageHandler:handleClearChatMessage] Twitch channel {} not found",
|
debug::Log("[IrcMessageHandler:handleClearChatMessage] Twitch channel {} not found",
|
||||||
|
@ -125,8 +130,6 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto app = getApp();
|
|
||||||
|
|
||||||
// refresh all
|
// refresh all
|
||||||
app->windows->repaintVisibleChatWidgets(chan.get());
|
app->windows->repaintVisibleChatWidgets(chan.get());
|
||||||
}
|
}
|
||||||
|
@ -136,12 +139,14 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message)
|
||||||
QVariant _mod = message->tag("mod");
|
QVariant _mod = message->tag("mod");
|
||||||
|
|
||||||
if (_mod.isValid()) {
|
if (_mod.isValid()) {
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
QString channelName;
|
QString channelName;
|
||||||
if (!TrimChannelName(message->parameter(0), channelName)) {
|
if (!TrimChannelName(message->parameter(0), channelName)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto c = TwitchServer::getInstance().getChannelOrEmpty(channelName);
|
auto c = app->twitch.server->getChannelOrEmpty(channelName);
|
||||||
if (c->isEmpty()) {
|
if (c->isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -161,7 +166,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
|
||||||
|
|
||||||
args.isReceivedWhisper = true;
|
args.isReceivedWhisper = true;
|
||||||
|
|
||||||
auto c = TwitchServer::getInstance().whispersChannel.get();
|
auto c = app->twitch.server->whispersChannel.get();
|
||||||
|
|
||||||
twitch::TwitchMessageBuilder builder(c, message, message->parameter(1), args);
|
twitch::TwitchMessageBuilder builder(c, message, message->parameter(1), args);
|
||||||
|
|
||||||
|
@ -170,13 +175,13 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message)
|
||||||
_message->flags |= messages::Message::DoNotTriggerNotification;
|
_message->flags |= messages::Message::DoNotTriggerNotification;
|
||||||
|
|
||||||
if (_message->flags & messages::Message::Highlighted) {
|
if (_message->flags & messages::Message::Highlighted) {
|
||||||
TwitchServer::getInstance().mentionsChannel->addMessage(_message);
|
app->twitch.server->mentionsChannel->addMessage(_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
c->addMessage(_message);
|
c->addMessage(_message);
|
||||||
|
|
||||||
if (app->settings->inlineWhispers) {
|
if (app->settings->inlineWhispers) {
|
||||||
TwitchServer::getInstance().forEachChannel([_message](ChannelPtr channel) {
|
app->twitch.server->forEachChannel([_message](ChannelPtr channel) {
|
||||||
channel->addMessage(_message); //
|
channel->addMessage(_message); //
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -190,8 +195,9 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message)
|
||||||
|
|
||||||
void IrcMessageHandler::handleModeMessage(Communi::IrcMessage *message)
|
void IrcMessageHandler::handleModeMessage(Communi::IrcMessage *message)
|
||||||
{
|
{
|
||||||
auto channel =
|
auto app = getApp();
|
||||||
TwitchServer::getInstance().getChannelOrEmpty(message->parameter(0).remove(0, 1));
|
|
||||||
|
auto channel = app->twitch.server->getChannelOrEmpty(message->parameter(0).remove(0, 1));
|
||||||
|
|
||||||
if (channel->isEmpty()) {
|
if (channel->isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -206,19 +212,20 @@ void IrcMessageHandler::handleModeMessage(Communi::IrcMessage *message)
|
||||||
|
|
||||||
void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
MessagePtr msg = Message::createSystemMessage(message->content());
|
MessagePtr msg = Message::createSystemMessage(message->content());
|
||||||
|
|
||||||
QString channelName;
|
QString channelName;
|
||||||
if (!TrimChannelName(message->target(), channelName)) {
|
if (!TrimChannelName(message->target(), channelName)) {
|
||||||
// Notice wasn't targeted at a single channel, send to all twitch channels
|
// Notice wasn't targeted at a single channel, send to all twitch channels
|
||||||
TwitchServer::getInstance().forEachChannelAndSpecialChannels([msg](const auto &c) {
|
app->twitch.server->forEachChannelAndSpecialChannels([msg](const auto &c) {
|
||||||
c->addMessage(msg); //
|
c->addMessage(msg); //
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto channel = TwitchServer::getInstance().getChannelOrEmpty(channelName);
|
auto channel = app->twitch.server->getChannelOrEmpty(channelName);
|
||||||
|
|
||||||
if (channel->isEmpty()) {
|
if (channel->isEmpty()) {
|
||||||
debug::Log("[IrcManager:handleNoticeMessage] Channel {} not found in channel manager",
|
debug::Log("[IrcManager:handleNoticeMessage] Channel {} not found in channel manager",
|
||||||
|
|
|
@ -539,8 +539,9 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||||
// maybe put the individual badges into a map instead of this mess
|
// maybe put the individual badges into a map instead of this mess
|
||||||
void TwitchMessageBuilder::appendTwitchBadges()
|
void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
{
|
{
|
||||||
singletons::ResourceManager &resourceManager = singletons::ResourceManager::getInstance();
|
auto app = getApp();
|
||||||
const auto &channelResources = resourceManager.channels[this->roomID];
|
|
||||||
|
const auto &channelResources = app->resources->channels[this->roomID];
|
||||||
|
|
||||||
auto iterator = this->tags.find("badges");
|
auto iterator = this->tags.find("badges");
|
||||||
|
|
||||||
|
@ -557,7 +558,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (badge.startsWith("bits/")) {
|
if (badge.startsWith("bits/")) {
|
||||||
if (!singletons::ResourceManager::getInstance().dynamicBadgesLoaded) {
|
if (!app->resources->dynamicBadgesLoaded) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -576,45 +577,45 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
|
|
||||||
// Use default bit badge
|
// Use default bit badge
|
||||||
try {
|
try {
|
||||||
const auto &badge = resourceManager.badgeSets.at("bits").versions.at(versionKey);
|
const auto &badge = app->resources->badgeSets.at("bits").versions.at(versionKey);
|
||||||
this->emplace<ImageElement>(badge.badgeImage1x, MessageElement::BadgeVanity);
|
this->emplace<ImageElement>(badge.badgeImage1x, MessageElement::BadgeVanity);
|
||||||
} catch (const std::out_of_range &) {
|
} catch (const std::out_of_range &) {
|
||||||
debug::Log("No default bit badge for version {} found", versionKey);
|
debug::Log("No default bit badge for version {} found", versionKey);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else if (badge == "staff/1") {
|
} else if (badge == "staff/1") {
|
||||||
this->emplace<ImageElement>(resourceManager.badgeStaff,
|
this->emplace<ImageElement>(app->resources->badgeStaff,
|
||||||
MessageElement::BadgeGlobalAuthority)
|
MessageElement::BadgeGlobalAuthority)
|
||||||
->setTooltip("Twitch Staff");
|
->setTooltip("Twitch Staff");
|
||||||
} else if (badge == "admin/1") {
|
} else if (badge == "admin/1") {
|
||||||
this->emplace<ImageElement>(resourceManager.badgeAdmin,
|
this->emplace<ImageElement>(app->resources->badgeAdmin,
|
||||||
MessageElement::BadgeGlobalAuthority)
|
MessageElement::BadgeGlobalAuthority)
|
||||||
->setTooltip("Twitch Admin");
|
->setTooltip("Twitch Admin");
|
||||||
} else if (badge == "global_mod/1") {
|
} else if (badge == "global_mod/1") {
|
||||||
this->emplace<ImageElement>(resourceManager.badgeGlobalModerator,
|
this->emplace<ImageElement>(app->resources->badgeGlobalModerator,
|
||||||
MessageElement::BadgeGlobalAuthority)
|
MessageElement::BadgeGlobalAuthority)
|
||||||
->setTooltip("Twitch Global Moderator");
|
->setTooltip("Twitch Global Moderator");
|
||||||
} else if (badge == "moderator/1") {
|
} else if (badge == "moderator/1") {
|
||||||
// TODO: Implement custom FFZ moderator badge
|
// TODO: Implement custom FFZ moderator badge
|
||||||
this->emplace<ImageElement>(resourceManager.badgeModerator,
|
this->emplace<ImageElement>(app->resources->badgeModerator,
|
||||||
MessageElement::BadgeChannelAuthority)
|
MessageElement::BadgeChannelAuthority)
|
||||||
->setTooltip("Twitch Channel Moderator");
|
->setTooltip("Twitch Channel Moderator");
|
||||||
} else if (badge == "turbo/1") {
|
} else if (badge == "turbo/1") {
|
||||||
this->emplace<ImageElement>(resourceManager.badgeTurbo,
|
this->emplace<ImageElement>(app->resources->badgeTurbo,
|
||||||
MessageElement::BadgeGlobalAuthority)
|
MessageElement::BadgeGlobalAuthority)
|
||||||
->setTooltip("Twitch Turbo Subscriber");
|
->setTooltip("Twitch Turbo Subscriber");
|
||||||
} else if (badge == "broadcaster/1") {
|
} else if (badge == "broadcaster/1") {
|
||||||
this->emplace<ImageElement>(resourceManager.badgeBroadcaster,
|
this->emplace<ImageElement>(app->resources->badgeBroadcaster,
|
||||||
MessageElement::BadgeChannelAuthority)
|
MessageElement::BadgeChannelAuthority)
|
||||||
->setTooltip("Twitch Broadcaster");
|
->setTooltip("Twitch Broadcaster");
|
||||||
} else if (badge == "premium/1") {
|
} else if (badge == "premium/1") {
|
||||||
this->emplace<ImageElement>(resourceManager.badgePremium, MessageElement::BadgeVanity)
|
this->emplace<ImageElement>(app->resources->badgePremium, MessageElement::BadgeVanity)
|
||||||
->setTooltip("Twitch Prime Subscriber");
|
->setTooltip("Twitch Prime Subscriber");
|
||||||
} else if (badge.startsWith("partner/")) {
|
} else if (badge.startsWith("partner/")) {
|
||||||
int index = badge.midRef(8).toInt();
|
int index = badge.midRef(8).toInt();
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 1: {
|
case 1: {
|
||||||
this->emplace<ImageElement>(resourceManager.badgeVerified,
|
this->emplace<ImageElement>(app->resources->badgeVerified,
|
||||||
MessageElement::BadgeVanity)
|
MessageElement::BadgeVanity)
|
||||||
->setTooltip("Twitch Verified");
|
->setTooltip("Twitch Verified");
|
||||||
} break;
|
} break;
|
||||||
|
@ -631,7 +632,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
auto badgeSetIt = channelResources.badgeSets.find("subscriber");
|
auto badgeSetIt = channelResources.badgeSets.find("subscriber");
|
||||||
if (badgeSetIt == channelResources.badgeSets.end()) {
|
if (badgeSetIt == channelResources.badgeSets.end()) {
|
||||||
// Fall back to default badge
|
// Fall back to default badge
|
||||||
this->emplace<ImageElement>(resourceManager.badgeSubscriber,
|
this->emplace<ImageElement>(app->resources->badgeSubscriber,
|
||||||
MessageElement::BadgeSubscription)
|
MessageElement::BadgeSubscription)
|
||||||
->setTooltip("Twitch Subscriber");
|
->setTooltip("Twitch Subscriber");
|
||||||
continue;
|
continue;
|
||||||
|
@ -645,7 +646,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
|
|
||||||
if (badgeVersionIt == badgeSet.versions.end()) {
|
if (badgeVersionIt == badgeSet.versions.end()) {
|
||||||
// Fall back to default badge
|
// Fall back to default badge
|
||||||
this->emplace<ImageElement>(resourceManager.badgeSubscriber,
|
this->emplace<ImageElement>(app->resources->badgeSubscriber,
|
||||||
MessageElement::BadgeSubscription)
|
MessageElement::BadgeSubscription)
|
||||||
->setTooltip("Twitch Subscriber");
|
->setTooltip("Twitch Subscriber");
|
||||||
continue;
|
continue;
|
||||||
|
@ -657,7 +658,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
MessageElement::BadgeSubscription)
|
MessageElement::BadgeSubscription)
|
||||||
->setTooltip("Twitch " + QString::fromStdString(badgeVersion.title));
|
->setTooltip("Twitch " + QString::fromStdString(badgeVersion.title));
|
||||||
} else {
|
} else {
|
||||||
if (!resourceManager.dynamicBadgesLoaded) {
|
if (!app->resources->dynamicBadgesLoaded) {
|
||||||
// Do nothing
|
// Do nothing
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -675,7 +676,7 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
std::string versionKey = parts[1].toStdString();
|
std::string versionKey = parts[1].toStdString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeSet = resourceManager.badgeSets.at(badgeSetKey);
|
auto &badgeSet = app->resources->badgeSets.at(badgeSetKey);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
auto &badgeVersion = badgeSet.versions.at(versionKey);
|
||||||
|
@ -696,7 +697,9 @@ void TwitchMessageBuilder::appendTwitchBadges()
|
||||||
|
|
||||||
void TwitchMessageBuilder::appendChatterinoBadges()
|
void TwitchMessageBuilder::appendChatterinoBadges()
|
||||||
{
|
{
|
||||||
auto &badges = singletons::ResourceManager::getInstance().chatterinoBadges;
|
auto app = getApp();
|
||||||
|
|
||||||
|
auto &badges = app->resources->chatterinoBadges;
|
||||||
auto it = badges.find(this->userName.toStdString());
|
auto it = badges.find(this->userName.toStdString());
|
||||||
|
|
||||||
if (it == badges.end()) {
|
if (it == badges.end()) {
|
||||||
|
@ -711,9 +714,9 @@ void TwitchMessageBuilder::appendChatterinoBadges()
|
||||||
|
|
||||||
bool TwitchMessageBuilder::tryParseCheermote(const QString &string)
|
bool TwitchMessageBuilder::tryParseCheermote(const QString &string)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
// Try to parse custom cheermotes
|
// Try to parse custom cheermotes
|
||||||
const auto &channelResources =
|
const auto &channelResources = app->resources->channels[this->roomID];
|
||||||
singletons::ResourceManager::getInstance().channels[this->roomID];
|
|
||||||
if (channelResources.loaded) {
|
if (channelResources.loaded) {
|
||||||
for (const auto &cheermoteSet : channelResources.cheermoteSets) {
|
for (const auto &cheermoteSet : channelResources.cheermoteSets) {
|
||||||
auto match = cheermoteSet.regex.match(string);
|
auto match = cheermoteSet.regex.match(string);
|
||||||
|
|
|
@ -23,15 +23,12 @@ TwitchServer::TwitchServer()
|
||||||
, watchingChannel(Channel::getEmpty(), Channel::TwitchWatching)
|
, watchingChannel(Channel::getEmpty(), Channel::TwitchWatching)
|
||||||
{
|
{
|
||||||
qDebug() << "init TwitchServer";
|
qDebug() << "init TwitchServer";
|
||||||
|
|
||||||
getApp()->accounts->Twitch.userChanged.connect(
|
|
||||||
[this]() { util::postToThread([this] { this->connect(); }); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TwitchServer &TwitchServer::getInstance()
|
void TwitchServer::initialize()
|
||||||
{
|
{
|
||||||
static TwitchServer s;
|
getApp()->accounts->Twitch.userChanged.connect(
|
||||||
return s;
|
[this]() { util::postToThread([this] { this->connect(); }); });
|
||||||
}
|
}
|
||||||
|
|
||||||
void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead, bool isWrite)
|
void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead, bool isWrite)
|
||||||
|
@ -85,7 +82,7 @@ void TwitchServer::privateMessageReceived(IrcPrivateMessage *message)
|
||||||
}
|
}
|
||||||
|
|
||||||
this->onPrivateMessage.invoke(message);
|
this->onPrivateMessage.invoke(message);
|
||||||
auto chan = TwitchServer::getInstance().getChannelOrEmpty(channelName);
|
auto chan = this->getChannelOrEmpty(channelName);
|
||||||
|
|
||||||
if (chan->isEmpty()) {
|
if (chan->isEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
@ -98,7 +95,7 @@ void TwitchServer::privateMessageReceived(IrcPrivateMessage *message)
|
||||||
if (!builder.isIgnored()) {
|
if (!builder.isIgnored()) {
|
||||||
messages::MessagePtr _message = builder.build();
|
messages::MessagePtr _message = builder.build();
|
||||||
if (_message->flags & messages::Message::Highlighted) {
|
if (_message->flags & messages::Message::Highlighted) {
|
||||||
TwitchServer::getInstance().mentionsChannel->addMessage(_message);
|
this->mentionsChannel->addMessage(_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
chan->addMessage(_message);
|
chan->addMessage(_message);
|
||||||
|
|
|
@ -13,10 +13,11 @@ namespace twitch {
|
||||||
class TwitchServer final : public irc::AbstractIrcServer
|
class TwitchServer final : public irc::AbstractIrcServer
|
||||||
{
|
{
|
||||||
TwitchServer();
|
TwitchServer();
|
||||||
|
friend class Application;
|
||||||
|
|
||||||
|
void initialize();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static TwitchServer &getInstance();
|
|
||||||
|
|
||||||
// fourtf: ugh
|
// fourtf: ugh
|
||||||
void forEachChannelAndSpecialChannels(std::function<void(ChannelPtr)> func);
|
void forEachChannelAndSpecialChannels(std::function<void(ChannelPtr)> func);
|
||||||
|
|
||||||
|
|
|
@ -7,10 +7,9 @@ namespace singletons {
|
||||||
|
|
||||||
class AccountManager
|
class AccountManager
|
||||||
{
|
{
|
||||||
AccountManager() = default;
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
AccountManager() = default;
|
||||||
|
|
||||||
~AccountManager() = delete;
|
~AccountManager() = delete;
|
||||||
|
|
||||||
void load();
|
void load();
|
||||||
|
|
|
@ -151,10 +151,11 @@ QString CommandManager::execCommand(const QString &text, ChannelPtr channel, boo
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
messages::MessageBuilder b;
|
messages::MessageBuilder b;
|
||||||
|
|
||||||
b.emplace<messages::TextElement>(
|
b.emplace<messages::TextElement>(app->accounts->Twitch.getCurrent()->getUserName(),
|
||||||
getApp()->accounts->Twitch.getCurrent()->getUserName(),
|
|
||||||
messages::MessageElement::Text);
|
messages::MessageElement::Text);
|
||||||
b.emplace<messages::TextElement>("->", messages::MessageElement::Text);
|
b.emplace<messages::TextElement>("->", messages::MessageElement::Text);
|
||||||
b.emplace<messages::TextElement>(words[1], messages::MessageElement::Text);
|
b.emplace<messages::TextElement>(words[1], messages::MessageElement::Text);
|
||||||
|
@ -167,7 +168,7 @@ QString CommandManager::execCommand(const QString &text, ChannelPtr channel, boo
|
||||||
|
|
||||||
b.emplace<messages::TextElement>(rest, messages::MessageElement::Text);
|
b.emplace<messages::TextElement>(rest, messages::MessageElement::Text);
|
||||||
|
|
||||||
TwitchServer::getInstance().whispersChannel->addMessage(b.getMessage());
|
app->twitch.server->whispersChannel->addMessage(b.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,10 +17,9 @@ namespace singletons {
|
||||||
|
|
||||||
class CommandManager
|
class CommandManager
|
||||||
{
|
{
|
||||||
CommandManager() = default;
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
CommandManager() = default;
|
||||||
|
|
||||||
QString execCommand(const QString &text, std::shared_ptr<Channel> channel, bool dryRun);
|
QString execCommand(const QString &text, std::shared_ptr<Channel> channel, bool dryRun);
|
||||||
|
|
||||||
void loadCommands();
|
void loadCommands();
|
||||||
|
|
|
@ -22,10 +22,9 @@ namespace singletons {
|
||||||
|
|
||||||
class EmoteManager
|
class EmoteManager
|
||||||
{
|
{
|
||||||
EmoteManager();
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
EmoteManager();
|
||||||
|
|
||||||
~EmoteManager() = delete;
|
~EmoteManager() = delete;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
|
@ -32,6 +32,7 @@ FontManager::FontManager()
|
||||||
this->currentFontByScale.clear();
|
this->currentFontByScale.clear();
|
||||||
this->fontChanged.invoke();
|
this->fontChanged.invoke();
|
||||||
});
|
});
|
||||||
|
|
||||||
this->currentFontSize.connect([this](const int &newValue, auto) {
|
this->currentFontSize.connect([this](const int &newValue, auto) {
|
||||||
this->incGeneration();
|
this->incGeneration();
|
||||||
// this->currentFont.setSize(newValue);
|
// this->currentFont.setSize(newValue);
|
||||||
|
@ -40,12 +41,6 @@ FontManager::FontManager()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
FontManager &FontManager::getInstance()
|
|
||||||
{
|
|
||||||
static FontManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
QFont &FontManager::getFont(FontManager::Type type, float scale)
|
QFont &FontManager::getFont(FontManager::Type type, float scale)
|
||||||
{
|
{
|
||||||
// return this->currentFont.getFont(type);
|
// return this->currentFont.getFont(type);
|
||||||
|
|
|
@ -11,11 +11,13 @@ namespace singletons {
|
||||||
|
|
||||||
class FontManager
|
class FontManager
|
||||||
{
|
{
|
||||||
FontManager(const FontManager &) = delete;
|
public:
|
||||||
FontManager(FontManager &&) = delete;
|
|
||||||
FontManager();
|
FontManager();
|
||||||
|
|
||||||
public:
|
FontManager(const FontManager &) = delete;
|
||||||
|
FontManager(FontManager &&) = delete;
|
||||||
|
~FontManager() = delete;
|
||||||
|
|
||||||
enum Type : uint8_t {
|
enum Type : uint8_t {
|
||||||
Tiny,
|
Tiny,
|
||||||
Small,
|
Small,
|
||||||
|
@ -27,9 +29,6 @@ public:
|
||||||
VeryLarge,
|
VeryLarge,
|
||||||
};
|
};
|
||||||
|
|
||||||
// FontManager is initialized only once, on first use
|
|
||||||
static FontManager &getInstance();
|
|
||||||
|
|
||||||
QFont &getFont(Type type, float scale);
|
QFont &getFont(Type type, float scale);
|
||||||
QFontMetrics &getFontMetrics(Type type, float scale);
|
QFontMetrics &getFontMetrics(Type type, float scale);
|
||||||
|
|
||||||
|
|
|
@ -12,12 +12,11 @@ class PathManager;
|
||||||
|
|
||||||
class LoggingManager
|
class LoggingManager
|
||||||
{
|
{
|
||||||
LoggingManager() = default;
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
PathManager *pathManager = nullptr;
|
PathManager *pathManager = nullptr;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
LoggingManager() = default;
|
||||||
|
|
||||||
~LoggingManager() = delete;
|
~LoggingManager() = delete;
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
|
|
@ -130,6 +130,8 @@ void NativeMessagingManager::ReceiverThread::run()
|
||||||
|
|
||||||
void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &root)
|
void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &root)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
QString action = root.value("action").toString();
|
QString action = root.value("action").toString();
|
||||||
|
|
||||||
if (action.isNull()) {
|
if (action.isNull()) {
|
||||||
|
@ -151,16 +153,15 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_type == "twitch") {
|
if (_type == "twitch") {
|
||||||
util::postToThread([name, attach, winId, yOffset] {
|
util::postToThread([name, attach, winId, yOffset, app] {
|
||||||
auto &ts = providers::twitch::TwitchServer::getInstance();
|
app->twitch.server->watchingChannel.update(
|
||||||
|
app->twitch.server->getOrAddChannel(name));
|
||||||
ts.watchingChannel.update(ts.getOrAddChannel(name));
|
|
||||||
|
|
||||||
if (attach) {
|
if (attach) {
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
auto *window =
|
auto *window =
|
||||||
widgets::AttachedWindow::get(::GetForegroundWindow(), winId, yOffset);
|
widgets::AttachedWindow::get(::GetForegroundWindow(), winId, yOffset);
|
||||||
window->setChannel(ts.getOrAddChannel(name));
|
window->setChannel(app->twitch.server->getOrAddChannel(name));
|
||||||
window->show();
|
window->show();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,10 +7,9 @@ namespace singletons {
|
||||||
|
|
||||||
class NativeMessagingManager
|
class NativeMessagingManager
|
||||||
{
|
{
|
||||||
NativeMessagingManager();
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
NativeMessagingManager();
|
||||||
|
|
||||||
~NativeMessagingManager() = delete;
|
~NativeMessagingManager() = delete;
|
||||||
|
|
||||||
class ReceiverThread : public QThread
|
class ReceiverThread : public QThread
|
||||||
|
|
|
@ -7,10 +7,9 @@ namespace singletons {
|
||||||
|
|
||||||
class PathManager
|
class PathManager
|
||||||
{
|
{
|
||||||
PathManager(int argc, char **argv);
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
PathManager(int argc, char **argv);
|
||||||
|
|
||||||
// %APPDATA%/chatterino or ExecutablePath for portable mode
|
// %APPDATA%/chatterino or ExecutablePath for portable mode
|
||||||
QString settingsFolderPath;
|
QString settingsFolderPath;
|
||||||
|
|
||||||
|
|
|
@ -68,9 +68,6 @@ private:
|
||||||
|
|
||||||
class PubSubManager
|
class PubSubManager
|
||||||
{
|
{
|
||||||
PubSubManager();
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
using WebsocketMessagePtr = websocketpp::config::asio_tls_client::message_type::ptr;
|
using WebsocketMessagePtr = websocketpp::config::asio_tls_client::message_type::ptr;
|
||||||
using WebsocketContextPtr = websocketpp::lib::shared_ptr<boost::asio::ssl::context>;
|
using WebsocketContextPtr = websocketpp::lib::shared_ptr<boost::asio::ssl::context>;
|
||||||
|
|
||||||
|
@ -81,6 +78,8 @@ class PubSubManager
|
||||||
std::unique_ptr<std::thread> mainThread;
|
std::unique_ptr<std::thread> mainThread;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
PubSubManager();
|
||||||
|
|
||||||
~PubSubManager() = delete;
|
~PubSubManager() = delete;
|
||||||
|
|
||||||
enum class State {
|
enum class State {
|
||||||
|
|
|
@ -289,18 +289,15 @@ ResourceManager::ResourceManager()
|
||||||
, buttonTimeout(lli(":/images/button_timeout.png", 0.25))
|
, buttonTimeout(lli(":/images/button_timeout.png", 0.25))
|
||||||
{
|
{
|
||||||
qDebug() << "init ResourceManager";
|
qDebug() << "init ResourceManager";
|
||||||
|
}
|
||||||
|
|
||||||
|
void ResourceManager::initialize()
|
||||||
|
{
|
||||||
this->loadDynamicTwitchBadges();
|
this->loadDynamicTwitchBadges();
|
||||||
|
|
||||||
this->loadChatterinoBadges();
|
this->loadChatterinoBadges();
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceManager &ResourceManager::getInstance()
|
|
||||||
{
|
|
||||||
static ResourceManager instance;
|
|
||||||
return instance;
|
|
||||||
}
|
|
||||||
|
|
||||||
ResourceManager::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
ResourceManager::BadgeVersion::BadgeVersion(QJsonObject &&root)
|
||||||
: badgeImage1x(new messages::Image(root.value("image_url_1x").toString()))
|
: badgeImage1x(new messages::Image(root.value("image_url_1x").toString()))
|
||||||
, badgeImage2x(new messages::Image(root.value("image_url_2x").toString()))
|
, badgeImage2x(new messages::Image(root.value("image_url_2x").toString()))
|
||||||
|
|
|
@ -13,10 +13,12 @@ namespace singletons {
|
||||||
|
|
||||||
class ResourceManager
|
class ResourceManager
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
ResourceManager();
|
ResourceManager();
|
||||||
|
|
||||||
public:
|
~ResourceManager() = delete;
|
||||||
static ResourceManager &getInstance();
|
|
||||||
|
void initialize();
|
||||||
|
|
||||||
messages::Image *badgeStaff;
|
messages::Image *badgeStaff;
|
||||||
messages::Image *badgeAdmin;
|
messages::Image *badgeAdmin;
|
||||||
|
|
|
@ -32,7 +32,10 @@ SettingManager::SettingManager()
|
||||||
this->wordFlagsListener.cb = [this](auto) {
|
this->wordFlagsListener.cb = [this](auto) {
|
||||||
this->updateWordTypeMask(); //
|
this->updateWordTypeMask(); //
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
void SettingManager::initialize()
|
||||||
|
{
|
||||||
this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); });
|
this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); });
|
||||||
this->ignoredKeywords.connect([this](auto, auto) { this->updateIgnoredKeywords(); });
|
this->ignoredKeywords.connect([this](auto, auto) { this->updateIgnoredKeywords(); });
|
||||||
|
|
||||||
|
@ -52,7 +55,7 @@ bool SettingManager::isIgnoredEmote(const QString &)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SettingManager::initialize()
|
void SettingManager::load()
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
QString settingsPath = app->paths->settingsFolderPath + "/settings.json";
|
QString settingsPath = app->paths->settingsFolderPath + "/settings.json";
|
||||||
|
@ -155,7 +158,7 @@ const std::shared_ptr<std::vector<QString>> SettingManager::getIgnoredKeywords()
|
||||||
|
|
||||||
void SettingManager::updateModerationActions()
|
void SettingManager::updateModerationActions()
|
||||||
{
|
{
|
||||||
auto &resources = singletons::ResourceManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
this->_moderationActions.clear();
|
this->_moderationActions.clear();
|
||||||
|
|
||||||
|
@ -207,10 +210,10 @@ void SettingManager::updateModerationActions()
|
||||||
|
|
||||||
this->_moderationActions.emplace_back(line1, line2, str);
|
this->_moderationActions.emplace_back(line1, line2, str);
|
||||||
} else {
|
} else {
|
||||||
this->_moderationActions.emplace_back(resources.buttonTimeout, str);
|
this->_moderationActions.emplace_back(app->resources->buttonTimeout, str);
|
||||||
}
|
}
|
||||||
} else if (str.startsWith("/ban ")) {
|
} else if (str.startsWith("/ban ")) {
|
||||||
this->_moderationActions.emplace_back(resources.buttonBan, str);
|
this->_moderationActions.emplace_back(app->resources->buttonBan, str);
|
||||||
} else {
|
} else {
|
||||||
QString xD = str;
|
QString xD = str;
|
||||||
|
|
||||||
|
|
|
@ -21,16 +21,16 @@ class SettingManager
|
||||||
using StringSetting = ChatterinoSetting<std::string>;
|
using StringSetting = ChatterinoSetting<std::string>;
|
||||||
using QStringSetting = ChatterinoSetting<QString>;
|
using QStringSetting = ChatterinoSetting<QString>;
|
||||||
|
|
||||||
SettingManager();
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
SettingManager();
|
||||||
|
|
||||||
~SettingManager() = delete;
|
~SettingManager() = delete;
|
||||||
|
|
||||||
messages::MessageElement::Flags getWordFlags();
|
messages::MessageElement::Flags getWordFlags();
|
||||||
bool isIgnoredEmote(const QString &emote);
|
bool isIgnoredEmote(const QString &emote);
|
||||||
|
|
||||||
void initialize();
|
void initialize();
|
||||||
|
void load();
|
||||||
|
|
||||||
/// Appearance
|
/// Appearance
|
||||||
BoolSetting showTimestamps = {"/appearance/messages/showTimestamps", true};
|
BoolSetting showTimestamps = {"/appearance/messages/showTimestamps", true};
|
||||||
|
|
|
@ -13,10 +13,9 @@ class WindowManager;
|
||||||
|
|
||||||
class ThemeManager
|
class ThemeManager
|
||||||
{
|
{
|
||||||
ThemeManager();
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
ThemeManager();
|
||||||
|
|
||||||
~ThemeManager() = delete;
|
~ThemeManager() = delete;
|
||||||
|
|
||||||
inline bool isLightTheme() const
|
inline bool isLightTheme() const
|
||||||
|
|
|
@ -331,16 +331,17 @@ IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj)
|
||||||
{
|
{
|
||||||
util::assertInGuiThread();
|
util::assertInGuiThread();
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
QString type = obj.value("type").toString();
|
QString type = obj.value("type").toString();
|
||||||
if (type == "twitch") {
|
if (type == "twitch") {
|
||||||
return providers::twitch::TwitchServer::getInstance().getOrAddChannel(
|
return app->twitch.server->getOrAddChannel(obj.value("name").toString());
|
||||||
obj.value("name").toString());
|
|
||||||
} else if (type == "mentions") {
|
} else if (type == "mentions") {
|
||||||
return providers::twitch::TwitchServer::getInstance().mentionsChannel;
|
return app->twitch.server->mentionsChannel;
|
||||||
} else if (type == "watching") {
|
} else if (type == "watching") {
|
||||||
return providers::twitch::TwitchServer::getInstance().watchingChannel;
|
return app->twitch.server->watchingChannel;
|
||||||
} else if (type == "whispers") {
|
} else if (type == "whispers") {
|
||||||
return providers::twitch::TwitchServer::getInstance().whispersChannel;
|
return app->twitch.server->whispersChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Channel::getEmpty();
|
return Channel::getEmpty();
|
||||||
|
|
|
@ -7,10 +7,9 @@ namespace singletons {
|
||||||
|
|
||||||
class WindowManager
|
class WindowManager
|
||||||
{
|
{
|
||||||
WindowManager();
|
|
||||||
friend class Application;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
WindowManager();
|
||||||
|
|
||||||
~WindowManager() = delete;
|
~WindowManager() = delete;
|
||||||
|
|
||||||
void showSettingsDialog();
|
void showSettingsDialog();
|
||||||
|
|
|
@ -75,8 +75,7 @@ ChannelView::ChannelView(BaseWidget *parent)
|
||||||
this->goToBottom->getLabel().setText("More messages below");
|
this->goToBottom->getLabel().setText("More messages below");
|
||||||
this->goToBottom->setVisible(false);
|
this->goToBottom->setVisible(false);
|
||||||
|
|
||||||
this->managedConnections.emplace_back(
|
this->managedConnections.emplace_back(app->fonts->fontChanged.connect([this] {
|
||||||
singletons::FontManager::getInstance().fontChanged.connect([this] {
|
|
||||||
this->layoutMessages(); //
|
this->layoutMessages(); //
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -514,7 +513,7 @@ messages::MessageElement::Flags ChannelView::getFlags() const
|
||||||
if (split->getModerationMode()) {
|
if (split->getModerationMode()) {
|
||||||
flags = (MessageElement::Flags)(flags | MessageElement::ModeratorTools);
|
flags = (MessageElement::Flags)(flags | MessageElement::ModeratorTools);
|
||||||
}
|
}
|
||||||
if (this->channel == TwitchServer::getInstance().mentionsChannel) {
|
if (this->channel == app->twitch.server->mentionsChannel) {
|
||||||
flags = (MessageElement::Flags)(flags | MessageElement::ChannelName);
|
flags = (MessageElement::Flags)(flags | MessageElement::ChannelName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "label.hpp"
|
#include "label.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
|
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
|
@ -9,8 +11,11 @@ namespace widgets {
|
||||||
Label::Label(BaseWidget *parent)
|
Label::Label(BaseWidget *parent)
|
||||||
: BaseWidget(parent)
|
: BaseWidget(parent)
|
||||||
{
|
{
|
||||||
singletons::FontManager::getInstance().fontChanged.connect(
|
auto app = getApp();
|
||||||
[this]() { this->scaleChangedEvent(this->getScale()); });
|
|
||||||
|
app->fonts->fontChanged.connect([=]() {
|
||||||
|
this->scaleChangedEvent(this->getScale()); //
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString &Label::getText() const
|
const QString &Label::getText() const
|
||||||
|
@ -37,8 +42,9 @@ void Label::setFontStyle(FontStyle style)
|
||||||
|
|
||||||
void Label::scaleChangedEvent(float scale)
|
void Label::scaleChangedEvent(float scale)
|
||||||
{
|
{
|
||||||
QFontMetrics metrics =
|
auto app = getApp();
|
||||||
singletons::FontManager::getInstance().getFontMetrics(this->fontStyle, scale);
|
|
||||||
|
QFontMetrics metrics = app->fonts->getFontMetrics(this->fontStyle, scale);
|
||||||
|
|
||||||
this->preferedSize = QSize(metrics.width(this->text), metrics.height());
|
this->preferedSize = QSize(metrics.width(this->text), metrics.height());
|
||||||
|
|
||||||
|
@ -57,13 +63,13 @@ QSize Label::minimumSizeHint() const
|
||||||
|
|
||||||
void Label::paintEvent(QPaintEvent *)
|
void Label::paintEvent(QPaintEvent *)
|
||||||
{
|
{
|
||||||
QPainter painter(this);
|
auto app = getApp();
|
||||||
painter.setFont(singletons::FontManager::getInstance().getFont(
|
|
||||||
this->fontStyle, this->getScale() / painter.device()->devicePixelRatioF()));
|
|
||||||
|
|
||||||
int width = singletons::FontManager::getInstance()
|
QPainter painter(this);
|
||||||
.getFontMetrics(this->fontStyle, this->getScale())
|
painter.setFont(app->fonts->getFont(this->fontStyle,
|
||||||
.width(this->text);
|
this->getScale() / painter.device()->devicePixelRatioF()));
|
||||||
|
|
||||||
|
int width = app->fonts->getFontMetrics(this->fontStyle, this->getScale()).width(this->text);
|
||||||
|
|
||||||
int flags = Qt::TextSingleLine;
|
int flags = Qt::TextSingleLine;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "widgets/helper/splitheader.hpp"
|
#include "widgets/helper/splitheader.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "providers/twitch/twitchchannel.hpp"
|
#include "providers/twitch/twitchchannel.hpp"
|
||||||
#include "providers/twitch/twitchserver.hpp"
|
#include "providers/twitch/twitchserver.hpp"
|
||||||
#include "singletons/resourcemanager.hpp"
|
#include "singletons/resourcemanager.hpp"
|
||||||
|
@ -28,17 +30,16 @@ SplitHeader::SplitHeader(Split *_split)
|
||||||
: BaseWidget(_split)
|
: BaseWidget(_split)
|
||||||
, split(_split)
|
, split(_split)
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
this->setMouseTracking(true);
|
this->setMouseTracking(true);
|
||||||
|
|
||||||
singletons::ResourceManager &resourceManager = singletons::ResourceManager::getInstance();
|
|
||||||
|
|
||||||
util::LayoutCreator<SplitHeader> layoutCreator(this);
|
util::LayoutCreator<SplitHeader> layoutCreator(this);
|
||||||
auto layout = layoutCreator.emplace<QHBoxLayout>().withoutMargin();
|
auto layout = layoutCreator.emplace<QHBoxLayout>().withoutMargin();
|
||||||
{
|
{
|
||||||
// dropdown label
|
// dropdown label
|
||||||
auto dropdown = layout.emplace<RippleEffectButton>(this).assign(&this->dropdownButton);
|
auto dropdown = layout.emplace<RippleEffectButton>(this).assign(&this->dropdownButton);
|
||||||
dropdown->setMouseTracking(true);
|
dropdown->setMouseTracking(true);
|
||||||
dropdown->setPixmap(resourceManager.splitHeaderContext->getPixmap());
|
dropdown->setPixmap(app->resources->splitHeaderContext->getPixmap());
|
||||||
this->addDropdownItems(dropdown.getElement());
|
this->addDropdownItems(dropdown.getElement());
|
||||||
QObject::connect(dropdown.getElement(), &RippleEffectButton::clicked, this, [this] {
|
QObject::connect(dropdown.getElement(), &RippleEffectButton::clicked, this, [this] {
|
||||||
QTimer::singleShot(80, [&] {
|
QTimer::singleShot(80, [&] {
|
||||||
|
@ -197,10 +198,11 @@ void SplitHeader::updateChannelText()
|
||||||
|
|
||||||
void SplitHeader::updateModerationModeIcon()
|
void SplitHeader::updateModerationModeIcon()
|
||||||
{
|
{
|
||||||
singletons::ResourceManager &resourceManager = singletons::ResourceManager::getInstance();
|
auto app = getApp();
|
||||||
|
|
||||||
this->moderationButton->setPixmap(this->split->getModerationMode()
|
this->moderationButton->setPixmap(this->split->getModerationMode()
|
||||||
? resourceManager.moderationmode_enabled->getPixmap()
|
? app->resources->moderationmode_enabled->getPixmap()
|
||||||
: resourceManager.moderationmode_disabled->getPixmap());
|
: app->resources->moderationmode_disabled->getPixmap());
|
||||||
|
|
||||||
bool modButtonVisible = false;
|
bool modButtonVisible = false;
|
||||||
ChannelPtr channel = this->split->getChannel();
|
ChannelPtr channel = this->split->getChannel();
|
||||||
|
@ -285,8 +287,10 @@ void SplitHeader::menuReloadChannelEmotes()
|
||||||
|
|
||||||
void SplitHeader::menuManualReconnect()
|
void SplitHeader::menuManualReconnect()
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
// fourtf: connection
|
// fourtf: connection
|
||||||
providers::twitch::TwitchServer::getInstance().connect();
|
app->twitch.server->connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitHeader::menuShowChangelog()
|
void SplitHeader::menuShowChangelog()
|
||||||
|
|
|
@ -39,7 +39,6 @@ SplitInput::SplitInput(Split *_chatWidget)
|
||||||
void SplitInput::initLayout()
|
void SplitInput::initLayout()
|
||||||
{
|
{
|
||||||
auto app = getApp();
|
auto app = getApp();
|
||||||
auto &fontManager = singletons::FontManager::getInstance();
|
|
||||||
util::LayoutCreator<SplitInput> layoutCreator(this);
|
util::LayoutCreator<SplitInput> layoutCreator(this);
|
||||||
|
|
||||||
auto layout = layoutCreator.setLayoutType<QHBoxLayout>().withoutMargin().assign(&this->ui.hbox);
|
auto layout = layoutCreator.setLayoutType<QHBoxLayout>().withoutMargin().assign(&this->ui.hbox);
|
||||||
|
@ -66,11 +65,11 @@ void SplitInput::initLayout()
|
||||||
|
|
||||||
// set edit font
|
// set edit font
|
||||||
this->ui.textEdit->setFont(
|
this->ui.textEdit->setFont(
|
||||||
fontManager.getFont(singletons::FontManager::Type::Medium, this->getScale()));
|
app->fonts->getFont(singletons::FontManager::Type::Medium, this->getScale()));
|
||||||
|
|
||||||
this->managedConnections.emplace_back(fontManager.fontChanged.connect([this, &fontManager]() {
|
this->managedConnections.emplace_back(app->fonts->fontChanged.connect([=]() {
|
||||||
this->ui.textEdit->setFont(
|
this->ui.textEdit->setFont(
|
||||||
fontManager.getFont(singletons::FontManager::Type::Medium, this->getScale()));
|
app->fonts->getFont(singletons::FontManager::Type::Medium, this->getScale()));
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// open emote popup
|
// open emote popup
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
#include "selectchanneldialog.hpp"
|
#include "selectchanneldialog.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "providers/twitch/twitchserver.hpp"
|
#include "providers/twitch/twitchserver.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
|
|
||||||
|
@ -179,17 +180,18 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const
|
||||||
return this->selectedChannel;
|
return this->selectedChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
switch (this->ui.notebook->getSelectedIndex()) {
|
switch (this->ui.notebook->getSelectedIndex()) {
|
||||||
case TAB_TWITCH: {
|
case TAB_TWITCH: {
|
||||||
if (this->ui.twitch.channel->isChecked()) {
|
if (this->ui.twitch.channel->isChecked()) {
|
||||||
return providers::twitch::TwitchServer::getInstance().getOrAddChannel(
|
return app->twitch.server->getOrAddChannel(this->ui.twitch.channelName->text());
|
||||||
this->ui.twitch.channelName->text());
|
|
||||||
} else if (this->ui.twitch.watching->isChecked()) {
|
} else if (this->ui.twitch.watching->isChecked()) {
|
||||||
return providers::twitch::TwitchServer::getInstance().watchingChannel;
|
return app->twitch.server->watchingChannel;
|
||||||
} else if (this->ui.twitch.mentions->isChecked()) {
|
} else if (this->ui.twitch.mentions->isChecked()) {
|
||||||
return providers::twitch::TwitchServer::getInstance().mentionsChannel;
|
return app->twitch.server->mentionsChannel;
|
||||||
} else if (this->ui.twitch.whispers->isChecked()) {
|
} else if (this->ui.twitch.whispers->isChecked()) {
|
||||||
return providers::twitch::TwitchServer::getInstance().whispersChannel;
|
return app->twitch.server->whispersChannel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,35 +142,33 @@ QLayout *AppearancePage::createThemeColorChanger()
|
||||||
|
|
||||||
QLayout *AppearancePage::createFontChanger()
|
QLayout *AppearancePage::createFontChanger()
|
||||||
{
|
{
|
||||||
QHBoxLayout *layout = new QHBoxLayout;
|
auto app = getApp();
|
||||||
|
|
||||||
auto &fontManager = singletons::FontManager::getInstance();
|
QHBoxLayout *layout = new QHBoxLayout;
|
||||||
|
|
||||||
// LABEL
|
// LABEL
|
||||||
QLabel *label = new QLabel();
|
QLabel *label = new QLabel();
|
||||||
layout->addWidget(label);
|
layout->addWidget(label);
|
||||||
|
|
||||||
auto updateFontFamilyLabel = [label, &fontManager](auto) {
|
auto updateFontFamilyLabel = [=](auto) {
|
||||||
label->setText(QString::fromStdString(fontManager.currentFontFamily.getValue()) + ", " +
|
label->setText(QString::fromStdString(app->fonts->currentFontFamily.getValue()) + ", " +
|
||||||
QString::number(fontManager.currentFontSize) + "pt");
|
QString::number(app->fonts->currentFontSize) + "pt");
|
||||||
};
|
};
|
||||||
|
|
||||||
fontManager.currentFontFamily.connectSimple(updateFontFamilyLabel, this->managedConnections);
|
app->fonts->currentFontFamily.connectSimple(updateFontFamilyLabel, this->managedConnections);
|
||||||
fontManager.currentFontSize.connectSimple(updateFontFamilyLabel, this->managedConnections);
|
app->fonts->currentFontSize.connectSimple(updateFontFamilyLabel, this->managedConnections);
|
||||||
|
|
||||||
// BUTTON
|
// BUTTON
|
||||||
QPushButton *button = new QPushButton("Select");
|
QPushButton *button = new QPushButton("Select");
|
||||||
layout->addWidget(button);
|
layout->addWidget(button);
|
||||||
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed);
|
||||||
|
|
||||||
QObject::connect(button, &QPushButton::clicked, []() {
|
QObject::connect(button, &QPushButton::clicked, [=]() {
|
||||||
auto &fontManager = singletons::FontManager::getInstance();
|
QFontDialog dialog(app->fonts->getFont(singletons::FontManager::Medium, 1.));
|
||||||
QFontDialog dialog(fontManager.getFont(singletons::FontManager::Medium, 1.));
|
|
||||||
|
|
||||||
dialog.connect(&dialog, &QFontDialog::fontSelected, [](const QFont &font) {
|
dialog.connect(&dialog, &QFontDialog::fontSelected, [=](const QFont &font) {
|
||||||
auto &fontManager = singletons::FontManager::getInstance();
|
app->fonts->currentFontFamily = font.family().toStdString();
|
||||||
fontManager.currentFontFamily = font.family().toStdString();
|
app->fonts->currentFontSize = font.pointSize();
|
||||||
fontManager.currentFontSize = font.pointSize();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
#include "tooltipwidget.hpp"
|
#include "tooltipwidget.hpp"
|
||||||
|
|
||||||
|
#include "application.hpp"
|
||||||
#include "singletons/fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
|
|
||||||
|
@ -14,6 +16,8 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||||
: BaseWindow(parent)
|
: BaseWindow(parent)
|
||||||
, displayText(new QLabel())
|
, displayText(new QLabel())
|
||||||
{
|
{
|
||||||
|
auto app = getApp();
|
||||||
|
|
||||||
this->setStyleSheet("color: #fff; background: #000");
|
this->setStyleSheet("color: #fff; background: #000");
|
||||||
this->setWindowOpacity(0.8);
|
this->setWindowOpacity(0.8);
|
||||||
this->updateFont();
|
this->updateFont();
|
||||||
|
@ -31,8 +35,7 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||||
layout->addWidget(displayText);
|
layout->addWidget(displayText);
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
|
|
||||||
this->fontChangedConnection =
|
this->fontChangedConnection = app->fonts->fontChanged.connect([this] { this->updateFont(); });
|
||||||
singletons::FontManager::getInstance().fontChanged.connect([this] { this->updateFont(); });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TooltipWidget::~TooltipWidget()
|
TooltipWidget::~TooltipWidget()
|
||||||
|
@ -47,8 +50,10 @@ void TooltipWidget::scaleChangedEvent(float)
|
||||||
|
|
||||||
void TooltipWidget::updateFont()
|
void TooltipWidget::updateFont()
|
||||||
{
|
{
|
||||||
this->setFont(singletons::FontManager::getInstance().getFont(
|
auto app = getApp();
|
||||||
singletons::FontManager::Type::MediumSmall, this->getScale()));
|
|
||||||
|
this->setFont(
|
||||||
|
app->fonts->getFont(singletons::FontManager::Type::MediumSmall, this->getScale()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TooltipWidget::setText(QString text)
|
void TooltipWidget::setText(QString text)
|
||||||
|
|
Loading…
Reference in a new issue