From 5a26d5f17f60abf04f552bbc0294e9ca0ddf941a Mon Sep 17 00:00:00 2001 From: Date: Sun, 31 Dec 2017 22:58:35 +0100 Subject: [PATCH] put singletons into their namespace --- chatterino.pro | 5 +- src/application.cpp | 24 ++++--- src/channel.hpp | 2 +- src/emojis.hpp | 2 +- src/main.cpp | 1 + src/messages/lazyloadedimage.cpp | 6 +- src/messages/message.cpp | 8 +-- src/messages/messagebuilder.cpp | 4 +- src/messages/messagecolor.cpp | 2 +- src/messages/messagecolor.hpp | 2 +- src/messages/messageref.cpp | 12 ++-- src/messages/word.cpp | 16 +++-- src/messages/word.hpp | 4 +- src/singletons/accountmanager.cpp | 2 + src/singletons/accountmanager.hpp | 2 + src/singletons/channelmanager.cpp | 2 + src/singletons/channelmanager.hpp | 6 +- src/singletons/commandmanager.cpp | 2 + src/singletons/commandmanager.hpp | 2 + src/singletons/completionmanager.cpp | 2 + src/singletons/completionmanager.hpp | 2 + src/singletons/emotemanager.cpp | 46 ++++++------ src/singletons/emotemanager.hpp | 78 +++++++++----------- src/singletons/fontmanager.cpp | 2 + src/singletons/fontmanager.hpp | 2 + src/singletons/helper/chatterinosetting.hpp | 2 + src/singletons/helper/completionmodel.cpp | 6 +- src/singletons/helper/completionmodel.hpp | 2 + src/singletons/ircmanager.cpp | 7 +- src/singletons/ircmanager.hpp | 3 + src/singletons/resourcemanager.cpp | 2 + src/singletons/resourcemanager.hpp | 2 + src/singletons/settingsmanager.cpp | 20 +++--- src/singletons/settingsmanager.hpp | 10 +-- src/singletons/thememanager.cpp | 2 + src/singletons/thememanager.hpp | 2 + src/singletons/windowmanager.cpp | 3 + src/singletons/windowmanager.hpp | 2 + src/twitch/twitchaccountmanager.hpp | 4 +- src/twitch/twitchchannel.cpp | 14 ++-- src/twitch/twitchchannel.hpp | 6 +- src/twitch/twitchmessagebuilder.cpp | 80 ++++++++++----------- src/twitch/twitchmessagebuilder.hpp | 7 +- src/{ => util}/concurrentmap.hpp | 2 + src/util/emotemap.hpp | 24 +++++++ src/util/urlfetch.hpp | 2 +- src/widgets/accountpopup.cpp | 14 ++-- src/widgets/accountpopup.hpp | 4 +- src/widgets/accountswitchwidget.cpp | 18 ++--- src/widgets/basewidget.cpp | 8 +-- src/widgets/basewidget.hpp | 7 +- src/widgets/emotepopup.cpp | 16 ++--- src/widgets/emotepopup.hpp | 2 +- src/widgets/helper/channelview.cpp | 19 ++--- src/widgets/helper/notebooktab.cpp | 12 ++-- src/widgets/helper/notebooktab.hpp | 2 - src/widgets/helper/resizingtextedit.cpp | 2 +- src/widgets/helper/rippleeffectlabel.hpp | 3 - src/widgets/helper/scrollbarhighlight.hpp | 5 +- src/widgets/helper/splitheader.hpp | 2 - src/widgets/helper/splitinput.cpp | 14 ++-- src/widgets/logindialog.cpp | 2 +- src/widgets/notebook.cpp | 6 +- src/widgets/notebook.hpp | 3 - src/widgets/scrollbar.cpp | 2 +- src/widgets/scrollbar.hpp | 2 - src/widgets/settingsdialog.cpp | 30 ++++---- src/widgets/split.cpp | 12 ++-- src/widgets/splitcontainer.hpp | 3 - src/widgets/tooltipwidget.cpp | 6 +- src/widgets/window.cpp | 4 +- src/widgets/window.hpp | 9 ++- 72 files changed, 357 insertions(+), 288 deletions(-) rename src/{ => util}/concurrentmap.hpp (98%) create mode 100644 src/util/emotemap.hpp diff --git a/chatterino.pro b/chatterino.pro index 6f87ef98c..07eed3590 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -118,7 +118,7 @@ HEADERS += \ src/precompiled_headers.hpp \ src/asyncexec.hpp \ src/channel.hpp \ - src/concurrentmap.hpp \ + src/util/concurrentmap.hpp \ src/emojis.hpp \ src/singletons/ircmanager.hpp \ src/messages/lazyloadedimage.hpp \ @@ -194,7 +194,8 @@ HEADERS += \ src/twitch/twitchaccountmanager.hpp \ src/singletons/helper/completionmodel.hpp \ src/singletons/helper/chatterinosetting.hpp \ - src/singletons/resourcemanager.hpp + src/singletons/resourcemanager.hpp \ + src/util/emotemap.hpp PRECOMPILED_HEADER = diff --git a/src/application.cpp b/src/application.cpp index 2ee52b156..4a3dde62e 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -6,6 +6,8 @@ #include "singletons/thememanager.hpp" #include "singletons/windowmanager.hpp" +using namespace chatterino::singletons; + namespace chatterino { // this class is responsible for handling the workflow of Chatterino @@ -13,41 +15,43 @@ namespace chatterino { Application::Application() { - logging::init(); - SettingsManager::getInstance().load(); + singletons::WindowManager::getInstance(); - WindowManager::getInstance().initMainWindow(); + logging::init(); + singletons::SettingManager::getInstance().load(); + + singletons::WindowManager::getInstance().initMainWindow(); // Initialize everything we need - EmoteManager::getInstance().loadGlobalEmotes(); + singletons::EmoteManager::getInstance().loadGlobalEmotes(); - AccountManager::getInstance().load(); + singletons::AccountManager::getInstance().load(); // XXX - SettingsManager::getInstance().updateWordTypeMask(); + singletons::SettingManager::getInstance().updateWordTypeMask(); } Application::~Application() { this->save(); - chatterino::SettingsManager::getInstance().save(); + chatterino::singletons::SettingManager::getInstance().save(); } int Application::run(QApplication &qtApp) { // Start connecting to the IRC Servers (Twitch only for now) - IrcManager::getInstance().connect(); + singletons::IrcManager::getInstance().connect(); // Show main window - WindowManager::getInstance().getMainWindow().show(); + singletons::WindowManager::getInstance().getMainWindow().show(); return qtApp.exec(); } void Application::save() { - WindowManager::getInstance().save(); + singletons::WindowManager::getInstance().save(); } } // namespace chatterino diff --git a/src/channel.hpp b/src/channel.hpp index d01d67a2d..49625575e 100644 --- a/src/channel.hpp +++ b/src/channel.hpp @@ -1,9 +1,9 @@ #pragma once -#include "concurrentmap.hpp" #include "logging/loggingchannel.hpp" #include "messages/lazyloadedimage.hpp" #include "messages/limitedqueue.hpp" +#include "util/concurrentmap.hpp" #include #include diff --git a/src/emojis.hpp b/src/emojis.hpp index b50ffb2f4..b37eae68f 100644 --- a/src/emojis.hpp +++ b/src/emojis.hpp @@ -1,7 +1,7 @@ #pragma once -#include "concurrentmap.hpp" #include "messages/lazyloadedimage.hpp" +#include "util/concurrentmap.hpp" #include #include diff --git a/src/main.cpp b/src/main.cpp index 22ed54d54..c67aac5f4 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -90,5 +90,6 @@ int main(int argc, char *argv[]) // Deinitialize NetworkManager (stop thread and wait for finish, should be instant) chatterino::util::NetworkManager::deinit(); + exit(0); return ret; } diff --git a/src/messages/lazyloadedimage.cpp b/src/messages/lazyloadedimage.cpp index 9cb8e61bb..bca802a7f 100644 --- a/src/messages/lazyloadedimage.cpp +++ b/src/messages/lazyloadedimage.cpp @@ -79,12 +79,12 @@ void LazyLoadedImage::loadImage() lli->animated = true; } - EmoteManager::getInstance().incGeneration(); + singletons::EmoteManager::getInstance().incGeneration(); - WindowManager::getInstance().layoutVisibleChatWidgets(); + singletons::WindowManager::getInstance().layoutVisibleChatWidgets(); }); - EmoteManager::getInstance().getGifUpdateSignal().connect([=]() { + singletons::EmoteManager::getInstance().getGifUpdateSignal().connect([=]() { this->gifUpdateTimout(); }); // For some reason when Boost signal is in thread scope and thread deletes the signal // doesn't work, so this is the fix. diff --git a/src/messages/message.cpp b/src/messages/message.cpp index f81672cd8..9c9b60d05 100644 --- a/src/messages/message.cpp +++ b/src/messages/message.cpp @@ -83,14 +83,14 @@ void AddCurrentTimestamp(Message *message) strftime(timeStampBuffer, 69, "%H:%M", localtime(&t)); QString timestampNoSeconds(timeStampBuffer); message->getWords().push_back(Word(timestampNoSeconds, Word::TimestampNoSeconds, - MessageColor(MessageColor::System), FontManager::Medium, + MessageColor(MessageColor::System), singletons::FontManager::Medium, QString(), QString())); // Add word for timestamp with seconds strftime(timeStampBuffer, 69, "%H:%M:%S", localtime(&t)); QString timestampWithSeconds(timeStampBuffer); message->getWords().push_back(Word(timestampWithSeconds, Word::TimestampWithSeconds, - MessageColor(MessageColor::System), FontManager::Medium, + MessageColor(MessageColor::System), singletons::FontManager::Medium, QString(), QString())); } @@ -108,7 +108,7 @@ Message *Message::createSystemMessage(const QString &text) for (QString word : words) { message->getWords().push_back(Word(word, Word::Flags::Default, MessageColor(MessageColor::Type::System), - FontManager::Medium, word, QString())); + singletons::FontManager::Medium, word, QString())); } return message; @@ -149,7 +149,7 @@ Message *Message::createTimeoutMessage(const QString &username, const QString &d text.append("."); Word word(text, Word::Flags::Default, MessageColor(MessageColor::Type::System), - FontManager::Medium, text, QString()); + singletons::FontManager::Medium, text, QString()); message->getWords().push_back(word); diff --git a/src/messages/messagebuilder.cpp b/src/messages/messagebuilder.cpp index 88f6fa4d4..64739db0b 100644 --- a/src/messages/messagebuilder.cpp +++ b/src/messages/messagebuilder.cpp @@ -40,13 +40,13 @@ void MessageBuilder::appendTimestamp(QDateTime &time) // Add word for timestamp with no seconds QString timestampNoSeconds(time.toString("hh:mm")); this->appendWord(Word(timestampNoSeconds, Word::TimestampNoSeconds, - MessageColor(MessageColor::System), FontManager::Medium, QString(), + MessageColor(MessageColor::System), singletons::FontManager::Medium, QString(), QString())); // Add word for timestamp with seconds QString timestampWithSeconds(time.toString("hh:mm:ss")); this->appendWord(Word(timestampWithSeconds, Word::TimestampWithSeconds, - MessageColor(MessageColor::System), FontManager::Medium, QString(), + MessageColor(MessageColor::System), singletons::FontManager::Medium, QString(), QString())); } diff --git a/src/messages/messagecolor.cpp b/src/messages/messagecolor.cpp index 769f5528b..b3889c95b 100644 --- a/src/messages/messagecolor.cpp +++ b/src/messages/messagecolor.cpp @@ -19,7 +19,7 @@ MessageColor::Type MessageColor::getType() const return this->type; } -const QColor &MessageColor::getColor(ThemeManager &themeManager) const +const QColor &MessageColor::getColor(singletons::ThemeManager &themeManager) const { switch (this->type) { case Type::Custom: diff --git a/src/messages/messagecolor.hpp b/src/messages/messagecolor.hpp index a021bd102..c1b25168b 100644 --- a/src/messages/messagecolor.hpp +++ b/src/messages/messagecolor.hpp @@ -16,7 +16,7 @@ public: explicit MessageColor(Type type = Text); Type getType() const; - const QColor &getColor(ThemeManager &themeManager) const; + const QColor &getColor(singletons::ThemeManager &themeManager) const; private: Type type; diff --git a/src/messages/messageref.cpp b/src/messages/messageref.cpp index f4e552b2c..932bed151 100644 --- a/src/messages/messageref.cpp +++ b/src/messages/messageref.cpp @@ -35,7 +35,7 @@ int MessageRef::getHeight() const // return true if redraw is required bool MessageRef::layout(int width, float scale) { - auto &emoteManager = EmoteManager::getInstance(); + auto &emoteManager = singletons::EmoteManager::getInstance(); bool rebuildRequired = false, layoutRequired = false; @@ -50,15 +50,15 @@ bool MessageRef::layout(int width, float scale) this->emoteGeneration = emoteManager.getGeneration(); // check if text changed - bool textChanged = this->fontGeneration != FontManager::getInstance().getGeneration(); + bool textChanged = this->fontGeneration != singletons::FontManager::getInstance().getGeneration(); layoutRequired |= textChanged; - this->fontGeneration = FontManager::getInstance().getGeneration(); + this->fontGeneration = singletons::FontManager::getInstance().getGeneration(); // check if work mask changed bool wordMaskChanged = - this->currentWordTypes != SettingsManager::getInstance().getWordTypeMask(); + this->currentWordTypes != singletons::SettingManager::getInstance().getWordTypeMask(); layoutRequired |= wordMaskChanged; - this->currentWordTypes = SettingsManager::getInstance().getWordTypeMask(); + this->currentWordTypes = singletons::SettingManager::getInstance().getWordTypeMask(); // check if dpi changed bool scaleChanged = this->scale != scale; @@ -92,7 +92,7 @@ bool MessageRef::layout(int width, float scale) void MessageRef::actuallyLayout(int width) { - auto &settings = SettingsManager::getInstance(); + auto &settings = singletons::SettingManager::getInstance(); const int spaceWidth = 4; const int right = width - MARGIN_RIGHT; diff --git a/src/messages/word.cpp b/src/messages/word.cpp index 2db6d74ad..bc38adc8c 100644 --- a/src/messages/word.cpp +++ b/src/messages/word.cpp @@ -18,8 +18,9 @@ Word::Word(LazyLoadedImage *image, Flags type, const QString ©text, const QS } // Text word -Word::Word(const QString &text, Flags type, const MessageColor &color, FontManager::Type font, - const QString ©text, const QString &tooltip, const Link &link) +Word::Word(const QString &text, Flags type, const MessageColor &color, + singletons::FontManager::Type font, const QString ©text, const QString &tooltip, + const Link &link) : image(nullptr) , text(text) , color(color) @@ -64,10 +65,11 @@ QSize Word::getSize(float scale) const data.size.setHeight((int)(metrics.height())); } else { const int mediumTextLineHeight = - FontManager::getInstance().getFontMetrics(this->font, scale).height(); - const qreal emoteScale = SettingsManager::getInstance().emoteScale.get() * scale; + singletons::FontManager::getInstance().getFontMetrics(this->font, scale).height(); + const qreal emoteScale = + singletons::SettingManager::getInstance().emoteScale.get() * scale; const bool scaleEmotesByLineHeight = - SettingsManager::getInstance().scaleEmotesByLineHeight; + singletons::SettingManager::getInstance().scaleEmotesByLineHeight; auto &image = this->getImage(); @@ -114,12 +116,12 @@ bool Word::hasTrailingSpace() const QFont &Word::getFont(float scale) const { - return FontManager::getInstance().getFont(this->font, scale); + return singletons::FontManager::getInstance().getFont(this->font, scale); } QFontMetrics &Word::getFontMetrics(float scale) const { - return FontManager::getInstance().getFontMetrics(this->font, scale); + return singletons::FontManager::getInstance().getFontMetrics(this->font, scale); } Word::Flags Word::getFlags() const diff --git a/src/messages/word.hpp b/src/messages/word.hpp index cc99017e7..0aa796a6f 100644 --- a/src/messages/word.hpp +++ b/src/messages/word.hpp @@ -96,7 +96,7 @@ public: explicit Word(LazyLoadedImage *_image, Flags getFlags, const QString ©text, const QString &tooltip, const Link &getLink = Link()); explicit Word(const QString &_text, Flags getFlags, const MessageColor &textColor, - FontManager::Type font, const QString ©text, const QString &tooltip, + singletons::FontManager::Type font, const QString ©text, const QString &tooltip, const Link &getLink = Link()); bool isImage() const; @@ -138,7 +138,7 @@ private: int yOffset = 0; bool _hasTrailingSpace = true; - FontManager::Type font = FontManager::Medium; + singletons::FontManager::Type font = singletons::FontManager::Medium; Link link; struct ScaleDependantData { diff --git a/src/singletons/accountmanager.cpp b/src/singletons/accountmanager.cpp index 30e72e161..d88efbbc4 100644 --- a/src/singletons/accountmanager.cpp +++ b/src/singletons/accountmanager.cpp @@ -1,6 +1,7 @@ #include "singletons/accountmanager.hpp" namespace chatterino { +namespace singletons { namespace { @@ -43,3 +44,4 @@ void AccountManager::load() } } // namespace chatterino +} diff --git a/src/singletons/accountmanager.hpp b/src/singletons/accountmanager.hpp index 7634375ed..b80d79a8a 100644 --- a/src/singletons/accountmanager.hpp +++ b/src/singletons/accountmanager.hpp @@ -3,6 +3,7 @@ #include "twitch/twitchaccountmanager.hpp" namespace chatterino { +namespace singletons { class AccountManager { @@ -17,3 +18,4 @@ public: }; } // namespace chatterino +} diff --git a/src/singletons/channelmanager.cpp b/src/singletons/channelmanager.cpp index 45134c937..c2e007d46 100644 --- a/src/singletons/channelmanager.cpp +++ b/src/singletons/channelmanager.cpp @@ -4,6 +4,7 @@ using namespace chatterino::twitch; namespace chatterino { +namespace singletons { ChannelManager &ChannelManager::getInstance() { @@ -138,3 +139,4 @@ void ChannelManager::doOnAll(std::function)> func) } } // namespace chatterino +} diff --git a/src/singletons/channelmanager.hpp b/src/singletons/channelmanager.hpp index b74a6cdf0..e2009926b 100644 --- a/src/singletons/channelmanager.hpp +++ b/src/singletons/channelmanager.hpp @@ -7,8 +7,7 @@ #include namespace chatterino { - -class WindowManager; +namespace singletons { class IrcManager; class ChannelManager @@ -43,7 +42,8 @@ private: pajlada::Signals::Signal ircJoin; pajlada::Signals::Signal ircPart; - friend class IrcManager; + friend class singletons::IrcManager; }; } // namespace chatterino +} diff --git a/src/singletons/commandmanager.cpp b/src/singletons/commandmanager.cpp index 335d8289b..e35ab502e 100644 --- a/src/singletons/commandmanager.cpp +++ b/src/singletons/commandmanager.cpp @@ -3,6 +3,7 @@ #include namespace chatterino { +namespace singletons { CommandManager &CommandManager::getInstance() { static CommandManager instance; @@ -81,3 +82,4 @@ CommandManager &CommandManager::getInstance() // this->text = _text.mid(index + 1); //} } +} diff --git a/src/singletons/commandmanager.hpp b/src/singletons/commandmanager.hpp index c5c2dfac7..75a093720 100644 --- a/src/singletons/commandmanager.hpp +++ b/src/singletons/commandmanager.hpp @@ -4,6 +4,7 @@ #include namespace chatterino { +namespace singletons { class CommandManager { @@ -36,3 +37,4 @@ public: // std::vector commands; }; } +} diff --git a/src/singletons/completionmanager.cpp b/src/singletons/completionmanager.cpp index a3b52d6a0..b316bc501 100644 --- a/src/singletons/completionmanager.cpp +++ b/src/singletons/completionmanager.cpp @@ -5,6 +5,7 @@ #include "singletons/emotemanager.hpp" namespace chatterino { +namespace singletons { CompletionManager &CompletionManager::getInstance() { @@ -26,3 +27,4 @@ CompletionModel *CompletionManager::createModel(const std::string &channelName) } } // namespace chatterino +} diff --git a/src/singletons/completionmanager.hpp b/src/singletons/completionmanager.hpp index d8a9ee30a..174d08354 100644 --- a/src/singletons/completionmanager.hpp +++ b/src/singletons/completionmanager.hpp @@ -8,6 +8,7 @@ #include "helper/completionmodel.hpp" namespace chatterino { +namespace singletons { class CompletionManager { CompletionManager() = default; @@ -22,3 +23,4 @@ private: }; } // namespace chatterino +} diff --git a/src/singletons/emotemanager.cpp b/src/singletons/emotemanager.cpp index 24e42aa81..820f68f7a 100644 --- a/src/singletons/emotemanager.cpp +++ b/src/singletons/emotemanager.cpp @@ -21,8 +21,9 @@ using namespace chatterino::messages; namespace chatterino { +namespace singletons { -EmoteManager::EmoteManager(SettingsManager &_settingsManager, WindowManager &_windowManager) +EmoteManager::EmoteManager(SettingManager &_settingsManager, WindowManager &_windowManager) : settingsManager(_settingsManager) , windowManager(_windowManager) , findShortCodesRegex(":([-+\\w]+):") @@ -38,7 +39,7 @@ EmoteManager::EmoteManager(SettingsManager &_settingsManager, WindowManager &_wi EmoteManager &EmoteManager::getInstance() { - static EmoteManager instance(SettingsManager::getInstance(), WindowManager::getInstance()); + static EmoteManager instance(SettingManager::getInstance(), WindowManager::getInstance()); return instance; } @@ -49,7 +50,8 @@ void EmoteManager::loadGlobalEmotes() this->loadFFZEmotes(); } -void EmoteManager::reloadBTTVChannelEmotes(const QString &channelName, std::weak_ptr _map) +void EmoteManager::reloadBTTVChannelEmotes(const QString &channelName, + std::weak_ptr _map) { printf("[EmoteManager] Reload BTTV Channel Emotes for channel %s\n", qPrintable(channelName)); @@ -88,7 +90,7 @@ void EmoteManager::reloadBTTVChannelEmotes(const QString &channelName, std::weak link = link.replace("{{id}}", id).replace("{{image}}", "1x"); auto emote = this->getBTTVChannelEmoteFromCaches().getOrAdd(id, [this, &code, &link] { - return EmoteData( + return util::EmoteData( new LazyLoadedImage(link, 1, code, code + "
Channel BTTV Emote")); }); @@ -101,7 +103,8 @@ void EmoteManager::reloadBTTVChannelEmotes(const QString &channelName, std::weak }); } -void EmoteManager::reloadFFZChannelEmotes(const QString &channelName, std::weak_ptr _map) +void EmoteManager::reloadFFZChannelEmotes(const QString &channelName, + std::weak_ptr _map) { printf("[EmoteManager] Reload FFZ Channel Emotes for channel %s\n", qPrintable(channelName)); @@ -137,7 +140,7 @@ void EmoteManager::reloadFFZChannelEmotes(const QString &channelName, std::weak_ auto emote = this->getFFZChannelEmoteFromCaches().getOrAdd(id, [this, &code, &url1] { - return EmoteData( + return util::EmoteData( new LazyLoadedImage(url1, 1, code, code + "
Channel FFZ Emote")); }); @@ -151,37 +154,37 @@ void EmoteManager::reloadFFZChannelEmotes(const QString &channelName, std::weak_ }); } -ConcurrentMap &EmoteManager::getTwitchEmotes() +util::ConcurrentMap &EmoteManager::getTwitchEmotes() { return _twitchEmotes; } -EmoteMap &EmoteManager::getFFZEmotes() +util::EmoteMap &EmoteManager::getFFZEmotes() { return ffzGlobalEmotes; } -EmoteMap &EmoteManager::getChatterinoEmotes() +util::EmoteMap &EmoteManager::getChatterinoEmotes() { return _chatterinoEmotes; } -EmoteMap &EmoteManager::getBTTVChannelEmoteFromCaches() +util::EmoteMap &EmoteManager::getBTTVChannelEmoteFromCaches() { return _bttvChannelEmoteFromCaches; } -EmoteMap &EmoteManager::getEmojis() +util::EmoteMap &EmoteManager::getEmojis() { return this->emojis; } -ConcurrentMap &EmoteManager::getFFZChannelEmoteFromCaches() +util::ConcurrentMap &EmoteManager::getFFZChannelEmoteFromCaches() { return _ffzChannelEmoteFromCaches; } -ConcurrentMap &EmoteManager::getTwitchEmoteFromCache() +util::ConcurrentMap &EmoteManager::getTwitchEmoteFromCache() { return _twitchEmoteFromCache; } @@ -237,7 +240,8 @@ void EmoteManager::loadEmojis() "emojione/2.2.6/assets/png/" + code + ".png"; - this->emojis.insert(code, EmoteData(new LazyLoadedImage(url, 0.35, ":" + shortCode + ":", + this->emojis.insert(code, + util::EmoteData(new LazyLoadedImage(url, 0.35, ":" + shortCode + ":", ":" + shortCode + ":
Emoji"))); // TODO(pajlada): The vectors in emojiFirstByte need to be sorted by @@ -245,7 +249,7 @@ void EmoteManager::loadEmojis() } } -void EmoteManager::parseEmojis(std::vector> &parsedWords, +void EmoteManager::parseEmojis(std::vector> &parsedWords, const QString &text) { int lastParsedEmojiEndIndex = 0; @@ -316,11 +320,12 @@ void EmoteManager::parseEmojis(std::vector> &pars // Create or fetch cached emoji image auto emojiImage = this->emojis.getOrAdd(matchedEmoji.code, [this, &url] { - return EmoteData(new LazyLoadedImage(url, 0.35, "?????????", "???????????????")); // + return util::EmoteData( + new LazyLoadedImage(url, 0.35, "?????????", "???????????????")); // }); // Push the emoji as a word to parsedWords - parsedWords.push_back(std::tuple(emojiImage, QString())); + parsedWords.push_back(std::tuple(emojiImage, QString())); lastParsedEmojiEndIndex = currentParsedEmojiEndIndex; @@ -482,7 +487,7 @@ void EmoteManager::loadFFZEmotes() // id is used for lookup // emoteName is used for giving a name to the emote in case it doesn't exist -EmoteData EmoteManager::getTwitchEmoteById(long id, const QString &emoteName) +util::EmoteData EmoteManager::getTwitchEmoteById(long id, const QString &emoteName) { return _twitchEmoteFromCache.getOrAdd(id, [this, &emoteName, &id] { qreal scale; @@ -502,10 +507,10 @@ QString EmoteManager::getTwitchEmoteLink(long id, qreal &scale) return value.replace("{id}", QString::number(id)).replace("{scale}", "2"); } -EmoteData EmoteManager::getCheerImage(long long amount, bool animated) +util::EmoteData EmoteManager::getCheerImage(long long amount, bool animated) { // TODO: fix this xD - return EmoteData(); + return util::EmoteData(); } boost::signals2::signal &EmoteManager::getGifUpdateSignal() @@ -535,3 +540,4 @@ boost::signals2::signal &EmoteManager::getGifUpdateSignal() } } // namespace chatterino +} diff --git a/src/singletons/emotemanager.hpp b/src/singletons/emotemanager.hpp index 6f827a9b4..db276d11c 100644 --- a/src/singletons/emotemanager.hpp +++ b/src/singletons/emotemanager.hpp @@ -2,12 +2,13 @@ #define GIF_FRAME_LENGTH 33 -#include "concurrentmap.hpp" #include "emojis.hpp" #include "messages/lazyloadedimage.hpp" #include "signalvector.hpp" #include "twitch/emotevalue.hpp" #include "twitch/twitchuser.hpp" +#include "util/concurrentmap.hpp" +#include "util/emotemap.hpp" #include #include @@ -17,28 +18,15 @@ #include namespace chatterino { +namespace singletons { -class SettingsManager; +class SettingManager; class WindowManager; -struct EmoteData { - EmoteData() - { - } - - EmoteData(messages::LazyLoadedImage *_image) - : image(_image) - { - } - - messages::LazyLoadedImage *image = nullptr; -}; - -typedef ConcurrentMap EmoteMap; - class EmoteManager { - explicit EmoteManager(SettingsManager &manager, WindowManager &windowManager); + explicit EmoteManager(singletons::SettingManager &manager, + singletons::WindowManager &windowManager); public: static EmoteManager &getInstance(); @@ -46,21 +34,21 @@ public: void loadGlobalEmotes(); void reloadBTTVChannelEmotes(const QString &channelName, - std::weak_ptr channelEmoteMap); + std::weak_ptr channelEmoteMap); void reloadFFZChannelEmotes(const QString &channelName, - std::weak_ptr channelEmoteMap); + std::weak_ptr channelEmoteMap); - ConcurrentMap &getTwitchEmotes(); - EmoteMap &getFFZEmotes(); - EmoteMap &getChatterinoEmotes(); - EmoteMap &getBTTVChannelEmoteFromCaches(); - EmoteMap &getEmojis(); - ConcurrentMap &getFFZChannelEmoteFromCaches(); - ConcurrentMap &getTwitchEmoteFromCache(); + util::ConcurrentMap &getTwitchEmotes(); + util::EmoteMap &getFFZEmotes(); + util::EmoteMap &getChatterinoEmotes(); + util::EmoteMap &getBTTVChannelEmoteFromCaches(); + util::EmoteMap &getEmojis(); + util::ConcurrentMap &getFFZChannelEmoteFromCaches(); + util::ConcurrentMap &getTwitchEmoteFromCache(); - EmoteData getCheerImage(long long int amount, bool animated); + util::EmoteData getCheerImage(long long int amount, bool animated); - EmoteData getTwitchEmoteById(long int id, const QString &emoteName); + util::EmoteData getTwitchEmoteById(long int id, const QString &emoteName); int getGeneration() { @@ -75,10 +63,10 @@ public: boost::signals2::signal &getGifUpdateSignal(); // Bit badge/emotes? - ConcurrentMap miscImageCache; + util::ConcurrentMap miscImageCache; private: - SettingsManager &settingsManager; + SettingManager &settingsManager; WindowManager &windowManager; /// Emojis @@ -91,12 +79,13 @@ private: QMap> emojiFirstByte; // url Emoji-one image - EmoteMap emojis; + util::EmoteMap emojis; void loadEmojis(); public: - void parseEmojis(std::vector> &parsedWords, const QString &text); + void parseEmojis(std::vector> &parsedWords, + const QString &text); QString replaceShortCodes(const QString &text); @@ -123,41 +112,41 @@ public: private: // emote code - ConcurrentMap _twitchEmotes; + util::ConcurrentMap _twitchEmotes; // emote id - ConcurrentMap _twitchEmoteFromCache; + util::ConcurrentMap _twitchEmoteFromCache; /// BTTV emotes - EmoteMap bttvChannelEmotes; + util::EmoteMap bttvChannelEmotes; public: - ConcurrentMap bttvChannels; - EmoteMap bttvGlobalEmotes; + util::ConcurrentMap bttvChannels; + util::EmoteMap bttvGlobalEmotes; SignalVector bttvGlobalEmoteCodes; // roomID std::map> bttvChannelEmoteCodes; - EmoteMap _bttvChannelEmoteFromCaches; + util::EmoteMap _bttvChannelEmoteFromCaches; private: void loadBTTVEmotes(); /// FFZ emotes - EmoteMap ffzChannelEmotes; + util::EmoteMap ffzChannelEmotes; public: - ConcurrentMap ffzChannels; - EmoteMap ffzGlobalEmotes; + util::ConcurrentMap ffzChannels; + util::EmoteMap ffzGlobalEmotes; SignalVector ffzGlobalEmoteCodes; std::map> ffzChannelEmoteCodes; private: - ConcurrentMap _ffzChannelEmoteFromCaches; + util::ConcurrentMap _ffzChannelEmoteFromCaches; void loadFFZEmotes(); /// Chatterino emotes - EmoteMap _chatterinoEmotes; + util::EmoteMap _chatterinoEmotes; boost::signals2::signal gifUpdateTimerSignal; QTimer gifUpdateTimer; @@ -170,3 +159,4 @@ private: }; } // namespace chatterino +} diff --git a/src/singletons/fontmanager.cpp b/src/singletons/fontmanager.cpp index 21fabe8e6..3242acd6e 100644 --- a/src/singletons/fontmanager.cpp +++ b/src/singletons/fontmanager.cpp @@ -3,6 +3,7 @@ #include namespace chatterino { +namespace singletons { FontManager::FontManager() : currentFontFamily("/appearance/currentFontFamily", "Arial") @@ -89,3 +90,4 @@ FontManager::Font &FontManager::getCurrentFont(float dpi) return this->currentFontByDpi.back().second; } } // namespace chatterino +} diff --git a/src/singletons/fontmanager.hpp b/src/singletons/fontmanager.hpp index ee2ff6f9d..bc94836c9 100644 --- a/src/singletons/fontmanager.hpp +++ b/src/singletons/fontmanager.hpp @@ -6,6 +6,7 @@ #include namespace chatterino { +namespace singletons { class FontManager { @@ -133,3 +134,4 @@ private: }; } // namespace chatterino +} diff --git a/src/singletons/helper/chatterinosetting.hpp b/src/singletons/helper/chatterinosetting.hpp index 59591d73c..05d28d53b 100644 --- a/src/singletons/helper/chatterinosetting.hpp +++ b/src/singletons/helper/chatterinosetting.hpp @@ -1,6 +1,7 @@ #pragma once namespace chatterino { +namespace singletons { static void _registerSetting(std::weak_ptr setting); template @@ -65,3 +66,4 @@ public: } }; } +} diff --git a/src/singletons/helper/completionmodel.cpp b/src/singletons/helper/completionmodel.cpp index 9c8b630ac..94ecdb9b8 100644 --- a/src/singletons/helper/completionmodel.cpp +++ b/src/singletons/helper/completionmodel.cpp @@ -7,6 +7,7 @@ #include "singletons/emotemanager.hpp" namespace chatterino { +namespace singletons { CompletionModel::CompletionModel(const QString &_channelName) : channelName(_channelName) { @@ -16,7 +17,7 @@ void CompletionModel::refresh() { // debug::Log("[CompletionModel:{}] Refreshing...]", this->channelName); - auto &emoteManager = EmoteManager::getInstance(); + auto &emoteManager = singletons::EmoteManager::getInstance(); this->emotes.clear(); // User-specific: Twitch Emotes @@ -60,7 +61,7 @@ void CompletionModel::refresh() } // Channel-specific: Usernames - auto c = ChannelManager::getInstance().getTwitchChannel(this->channelName); + auto c = singletons::ChannelManager::getInstance().getTwitchChannel(this->channelName); auto usernames = c->getUsernamesForCompletions(); for (const auto &name : usernames) { assert(!name.displayName.isEmpty()); @@ -86,3 +87,4 @@ void CompletionModel::addString(const QString &str) this->emotes.push_back(str + " "); } } +} diff --git a/src/singletons/helper/completionmodel.hpp b/src/singletons/helper/completionmodel.hpp index b9f866d0a..7e62ff3bf 100644 --- a/src/singletons/helper/completionmodel.hpp +++ b/src/singletons/helper/completionmodel.hpp @@ -7,6 +7,7 @@ #include namespace chatterino { +namespace singletons { class CompletionModel : public QAbstractListModel { public: @@ -39,3 +40,4 @@ private: QString channelName; }; } +} diff --git a/src/singletons/ircmanager.cpp b/src/singletons/ircmanager.cpp index 310fcecf5..4443980ea 100644 --- a/src/singletons/ircmanager.cpp +++ b/src/singletons/ircmanager.cpp @@ -26,6 +26,7 @@ using namespace chatterino::messages; namespace chatterino { +namespace singletons { IrcManager::IrcManager(ChannelManager &_channelManager, ResourceManager &_resources, AccountManager &_accountManager) @@ -70,7 +71,8 @@ IrcManager::IrcManager(ChannelManager &_channelManager, ResourceManager &_resour IrcManager &IrcManager::getInstance() { - static IrcManager instance(ChannelManager::getInstance(), ResourceManager::getInstance(), + static IrcManager instance(ChannelManager::getInstance(), + singletons::ResourceManager::getInstance(), AccountManager::getInstance()); return instance; } @@ -196,7 +198,7 @@ void IrcManager::sendMessage(const QString &channelName, QString message) static int i = 0; if (this->writeConnection) { - if (SettingsManager::getInstance().allowDuplicateMessages && (++i % 2) == 0) { + if (singletons::SettingManager::getInstance().allowDuplicateMessages && (++i % 2) == 0) { message.append(this->messageSuffix); } this->writeConnection->sendRaw("PRIVMSG #" + channelName + " :" + message); @@ -528,3 +530,4 @@ Communi::IrcConnection *IrcManager::getReadConnection() } } // namespace chatterino +} diff --git a/src/singletons/ircmanager.hpp b/src/singletons/ircmanager.hpp index 71da1350c..49248245d 100644 --- a/src/singletons/ircmanager.hpp +++ b/src/singletons/ircmanager.hpp @@ -17,10 +17,12 @@ #include namespace chatterino { +namespace singletons { class ChannelManager; class ResourceManager; class AccountManager; +class WindowManager; class IrcManager : public QObject { @@ -100,3 +102,4 @@ private: }; } // namespace chatterino +} diff --git a/src/singletons/resourcemanager.cpp b/src/singletons/resourcemanager.cpp index 3b039b8db..1056b4093 100644 --- a/src/singletons/resourcemanager.cpp +++ b/src/singletons/resourcemanager.cpp @@ -6,6 +6,7 @@ #include namespace chatterino { +namespace singletons { namespace { @@ -153,3 +154,4 @@ void ResourceManager::loadChatterinoBadges() } } // namespace chatterino +} diff --git a/src/singletons/resourcemanager.hpp b/src/singletons/resourcemanager.hpp index 01c6dac17..0f0239eb5 100644 --- a/src/singletons/resourcemanager.hpp +++ b/src/singletons/resourcemanager.hpp @@ -7,6 +7,7 @@ #include namespace chatterino { +namespace singletons { class ResourceManager { @@ -90,3 +91,4 @@ public: }; } // namespace chatterino +} diff --git a/src/singletons/settingsmanager.cpp b/src/singletons/settingsmanager.cpp index bd450ef04..86d591f6c 100644 --- a/src/singletons/settingsmanager.cpp +++ b/src/singletons/settingsmanager.cpp @@ -8,6 +8,7 @@ using namespace chatterino::messages; namespace chatterino { +namespace singletons { std::vector> _settings; @@ -16,7 +17,7 @@ void _registerSetting(std::weak_ptr setting) _settings.push_back(setting); } -SettingsManager::SettingsManager() +SettingManager::SettingManager() : streamlinkPath("/behaviour/streamlink/path", "") , preferredQuality("/behaviour/streamlink/quality", "Choose") , emoteScale(this->settingsItems, "emoteScale", 1.0) @@ -39,7 +40,7 @@ SettingsManager::SettingsManager() }; } -void SettingsManager::save() +void SettingManager::save() { for (auto &item : this->settingsItems) { if (item.get().getName() != "highlightProperties") { @@ -62,7 +63,7 @@ void SettingsManager::save() } } -void SettingsManager::load() +void SettingManager::load() { for (auto &item : this->settingsItems) { if (item.get().getName() != "highlightProperties") { @@ -82,22 +83,22 @@ void SettingsManager::load() } } -Word::Flags SettingsManager::getWordTypeMask() +Word::Flags SettingManager::getWordTypeMask() { return this->wordTypeMask; } -bool SettingsManager::isIgnoredEmote(const QString &) +bool SettingManager::isIgnoredEmote(const QString &) { return false; } -QSettings &SettingsManager::getQSettings() +QSettings &SettingManager::getQSettings() { return this->settings; } -void SettingsManager::updateWordTypeMask() +void SettingManager::updateWordTypeMask() { uint32_t newMaskUint = Word::Text; @@ -136,7 +137,7 @@ void SettingsManager::updateWordTypeMask() } } -void SettingsManager::saveSnapshot() +void SettingManager::saveSnapshot() { rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType); rapidjson::Document::AllocatorType &a = d->GetAllocator(); @@ -157,7 +158,7 @@ void SettingsManager::saveSnapshot() debug::Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d)); } -void SettingsManager::recallSnapshot() +void SettingManager::recallSnapshot() { if (!this->snapshot) { return; @@ -184,3 +185,4 @@ void SettingsManager::recallSnapshot() } } // namespace chatterino +} diff --git a/src/singletons/settingsmanager.hpp b/src/singletons/settingsmanager.hpp index 0f54682bb..57e19a341 100644 --- a/src/singletons/settingsmanager.hpp +++ b/src/singletons/settingsmanager.hpp @@ -9,10 +9,11 @@ #include namespace chatterino { +namespace singletons { static void _registerSetting(std::weak_ptr setting); -class SettingsManager : public QObject +class SettingManager : public QObject { Q_OBJECT @@ -81,9 +82,9 @@ public: BoolSetting inlineWhispers = {"/whispers/enableInlineWhispers", true}; - static SettingsManager &getInstance() + static SettingManager &getInstance() { - static SettingsManager instance; + static SettingManager instance; return instance; } void updateWordTypeMask(); @@ -97,7 +98,7 @@ signals: private: std::unique_ptr snapshot; - SettingsManager(); + SettingManager(); QSettings settings; std::vector> settingsItems; @@ -107,3 +108,4 @@ private: }; } // namespace chatterino +} diff --git a/src/singletons/thememanager.cpp b/src/singletons/thememanager.cpp index f71fffbe9..a296b4c5f 100644 --- a/src/singletons/thememanager.cpp +++ b/src/singletons/thememanager.cpp @@ -7,6 +7,7 @@ #include namespace chatterino { +namespace singletons { namespace detail { @@ -160,3 +161,4 @@ void ThemeManager::normalizeColor(QColor &color) } } // namespace chatterino +} diff --git a/src/singletons/thememanager.hpp b/src/singletons/thememanager.hpp index 1d969e5c1..85e84aaca 100644 --- a/src/singletons/thememanager.hpp +++ b/src/singletons/thememanager.hpp @@ -6,6 +6,7 @@ #include namespace chatterino { +namespace singletons { class WindowManager; @@ -107,3 +108,4 @@ private: }; } // namespace chatterino +} diff --git a/src/singletons/windowmanager.cpp b/src/singletons/windowmanager.cpp index e8cca5014..5faf956dd 100644 --- a/src/singletons/windowmanager.cpp +++ b/src/singletons/windowmanager.cpp @@ -1,5 +1,6 @@ #include "windowmanager.hpp" #include "appdatapath.hpp" +#include "singletons/fontmanager.hpp" #include "singletons/thememanager.hpp" #include @@ -7,6 +8,7 @@ #include namespace chatterino { +namespace singletons { WindowManager &WindowManager::getInstance() { static WindowManager instance(ThemeManager::getInstance()); @@ -102,3 +104,4 @@ void WindowManager::save() } } // namespace chatterino +} diff --git a/src/singletons/windowmanager.hpp b/src/singletons/windowmanager.hpp index b1d221a89..936f57db1 100644 --- a/src/singletons/windowmanager.hpp +++ b/src/singletons/windowmanager.hpp @@ -3,6 +3,7 @@ #include "widgets/window.hpp" namespace chatterino { +namespace singletons { class ThemeManager; @@ -41,3 +42,4 @@ private: }; } // namespace chatterino +} diff --git a/src/twitch/twitchaccountmanager.hpp b/src/twitch/twitchaccountmanager.hpp index 3ef786599..191a86b40 100644 --- a/src/twitch/twitchaccountmanager.hpp +++ b/src/twitch/twitchaccountmanager.hpp @@ -13,7 +13,9 @@ // namespace chatterino { +namespace singletons { class AccountManager; +} namespace twitch { @@ -59,7 +61,7 @@ private: std::vector> users; mutable std::mutex mutex; - friend class chatterino::AccountManager; + friend class chatterino::singletons::AccountManager; }; } } diff --git a/src/twitch/twitchchannel.cpp b/src/twitch/twitchchannel.cpp index ca4b299fc..b7403bfa4 100644 --- a/src/twitch/twitchchannel.cpp +++ b/src/twitch/twitchchannel.cpp @@ -11,8 +11,8 @@ namespace twitch { TwitchChannel::TwitchChannel(const QString &channelName) : Channel(channelName) - , bttvChannelEmotes(new EmoteMap) - , ffzChannelEmotes(new EmoteMap) + , bttvChannelEmotes(new util::EmoteMap) + , ffzChannelEmotes(new util::EmoteMap) , subscriptionURL("https://www.twitch.tv/subs/" + name) , channelURL("https://twitch.tv/" + name) , popoutPlayerURL("https://player.twitch.tv/?channel=" + name) @@ -64,7 +64,7 @@ void TwitchChannel::setRoomID(const QString &_roomID) void TwitchChannel::reloadChannelEmotes() { - auto &emoteManager = EmoteManager::getInstance(); + auto &emoteManager = singletons::EmoteManager::getInstance(); debug::Log("[TwitchChannel:{}] Reloading channel emotes", this->name); @@ -74,14 +74,14 @@ void TwitchChannel::reloadChannelEmotes() void TwitchChannel::sendMessage(const QString &message) { - auto &emoteManager = EmoteManager::getInstance(); + auto &emoteManager = singletons::EmoteManager::getInstance(); debug::Log("[TwitchChannel:{}] Send message: {}", this->name, message); // Do last message processing QString parsedMessage = emoteManager.replaceShortCodes(message); - IrcManager::getInstance().sendMessage(this->name, parsedMessage); + singletons::IrcManager::getInstance().sendMessage(this->name, parsedMessage); } void TwitchChannel::setLive(bool newLiveStatus) @@ -155,7 +155,7 @@ void TwitchChannel::fetchRecentMessages() { static QString genericURL = "https://tmi.twitch.tv/api/rooms/%1/recent_messages?client_id=" + getDefaultClientID(); - static auto readConnection = IrcManager::getInstance().getReadConnection(); + static auto readConnection = singletons::IrcManager::getInstance().getReadConnection(); util::twitch::get(genericURL.arg(roomID), QThread::currentThread(), [=](QJsonObject obj) { this->dontAddMessages = false; @@ -165,7 +165,7 @@ void TwitchChannel::fetchRecentMessages() QByteArray content = msgArray[i].toString().toUtf8(); auto msg = Communi::IrcMessage::fromData(content, readConnection); auto privMsg = static_cast(msg); - IrcManager::getInstance().privateMessageReceived(privMsg); + singletons::IrcManager::getInstance().privateMessageReceived(privMsg); } }); } diff --git a/src/twitch/twitchchannel.hpp b/src/twitch/twitchchannel.hpp index f317fdb0e..f7f1a0733 100644 --- a/src/twitch/twitchchannel.hpp +++ b/src/twitch/twitchchannel.hpp @@ -1,9 +1,9 @@ #pragma once #include "channel.hpp" -#include "concurrentmap.hpp" #include "singletons/emotemanager.hpp" #include "singletons/ircmanager.hpp" +#include "util/concurrentmap.hpp" namespace chatterino { namespace twitch { @@ -22,8 +22,8 @@ public: bool canSendMessage() const override; void sendMessage(const QString &message) override; - const std::shared_ptr bttvChannelEmotes; - const std::shared_ptr ffzChannelEmotes; + const std::shared_ptr bttvChannelEmotes; + const std::shared_ptr ffzChannelEmotes; const QString subscriptionURL; const QString channelURL; diff --git a/src/twitch/twitchmessagebuilder.cpp b/src/twitch/twitchmessagebuilder.cpp index 63ed8b3a4..a660aa69c 100644 --- a/src/twitch/twitchmessagebuilder.cpp +++ b/src/twitch/twitchmessagebuilder.cpp @@ -25,14 +25,14 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, , ircMessage(_ircMessage) , args(_args) , tags(this->ircMessage->tags()) - , usernameColor(ThemeManager::getInstance().SystemMessageColor) + , usernameColor(singletons::ThemeManager::getInstance().SystemMessageColor) { } SharedMessage TwitchMessageBuilder::parse() { - SettingsManager &settings = SettingsManager::getInstance(); - EmoteManager &emoteManager = EmoteManager::getInstance(); + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); + singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance(); this->originalMessage = this->ircMessage->content(); @@ -86,7 +86,7 @@ SharedMessage TwitchMessageBuilder::parse() } // twitch emotes - std::vector> twitchEmotes; + std::vector> twitchEmotes; iterator = this->tags.find("emotes"); if (iterator != this->tags.end()) { @@ -97,8 +97,8 @@ SharedMessage TwitchMessageBuilder::parse() } struct { - bool operator()(const std::pair &lhs, - const std::pair &rhs) + bool operator()(const std::pair &lhs, + const std::pair &rhs) { return lhs.first < rhs.first; } @@ -127,7 +127,7 @@ SharedMessage TwitchMessageBuilder::parse() currentTwitchEmote->second.image->getName() + QString("\nTwitch Emote"))); this->appendWord( Word(currentTwitchEmote->second.image->getName(), Word::TwitchEmoteText, textColor, - FontManager::Medium, currentTwitchEmote->second.image->getName(), + singletons::FontManager::Medium, currentTwitchEmote->second.image->getName(), currentTwitchEmote->second.image->getName() + QString("\nTwitch Emote"))); i += split.length() + 1; @@ -137,13 +137,13 @@ SharedMessage TwitchMessageBuilder::parse() } // split words - std::vector> parsed; + std::vector> parsed; // Parse emojis and take all non-emojis and put them in parsed as full text-words emoteManager.parseEmojis(parsed, split); for (const auto &tuple : parsed) { - const EmoteData &emoteData = std::get<0>(tuple); + const util::EmoteData &emoteData = std::get<0>(tuple); if (emoteData.image == nullptr) { // is text QString string = std::get<1>(tuple); @@ -200,7 +200,7 @@ SharedMessage TwitchMessageBuilder::parse() this->appendWord(Word( QString("x" + string.mid(5)), Word::BitsAmount, MessageColor(bitsColor), - FontManager::Medium, QString(string.mid(5)), QString("Twitch Cheer"), + singletons::FontManager::Medium, QString(string.mid(5)), QString("Twitch Cheer"), Link(Link::Url, QString("https://blog.twitch.tv/" "introducing-cheering-celebrate-together-da62af41fac6")))); @@ -230,12 +230,12 @@ SharedMessage TwitchMessageBuilder::parse() textColor = MessageColor(MessageColor::Link); } - this->appendWord(Word(string, Word::Text, textColor, FontManager::Medium, string, + this->appendWord(Word(string, Word::Text, textColor, singletons::FontManager::Medium, string, QString(), link)); } else { // is emoji this->appendWord(Word(emoteData.image, Word::EmojiImage, emoteData.image->getName(), emoteData.image->getTooltip())); - Word(emoteData.image->getName(), Word::EmojiText, textColor, FontManager::Medium, + Word(emoteData.image->getName(), Word::EmojiText, textColor, singletons::FontManager::Medium, emoteData.image->getName(), emoteData.image->getTooltip()); } } @@ -284,7 +284,7 @@ void TwitchMessageBuilder::parseChannelName() { QString channelName("#" + this->channel->name); this->appendWord(Word(channelName, Word::Misc, MessageColor(MessageColor::System), - FontManager::Medium, QString(channelName), QString(), + singletons::FontManager::Medium, QString(channelName), QString(), Link(Link::Url, this->channel->name + "\n" + this->messageID))); } @@ -372,7 +372,7 @@ void TwitchMessageBuilder::appendUsername() } this->appendWord(Word(usernameString, Word::Username, MessageColor(this->usernameColor), - FontManager::MediumBold, usernameString, QString(), + singletons::FontManager::MediumBold, usernameString, QString(), Link(Link::UserInfo, this->userName))); } @@ -380,7 +380,7 @@ void TwitchMessageBuilder::parseHighlights() { static auto player = new QMediaPlayer; static QUrl currentPlayerUrl; - SettingsManager &settings = SettingsManager::getInstance(); + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); static pajlada::Settings::Setting currentUser("/accounts/current"); QString currentUsername = QString::fromStdString(currentUser.getValue()); @@ -471,7 +471,7 @@ void TwitchMessageBuilder::parseHighlights() } if (doAlert) { - QApplication::alert(WindowManager::getInstance().getMainWindow().window(), 2500); + QApplication::alert(singletons::WindowManager::getInstance().getMainWindow().window(), 2500); } } } @@ -482,17 +482,17 @@ void TwitchMessageBuilder::appendModerationButtons() static QString buttonBanTooltip("Ban user"); static QString buttonTimeoutTooltip("Timeout user"); - this->appendWord(Word(ResourceManager::getInstance().buttonBan, Word::ButtonBan, QString(), + this->appendWord(Word(singletons::ResourceManager::getInstance().buttonBan, Word::ButtonBan, QString(), buttonBanTooltip, Link(Link::UserBan, ircMessage->account()))); - this->appendWord(Word(ResourceManager::getInstance().buttonTimeout, Word::ButtonTimeout, QString(), + this->appendWord(Word(singletons::ResourceManager::getInstance().buttonTimeout, Word::ButtonTimeout, QString(), buttonTimeoutTooltip, Link(Link::UserTimeout, ircMessage->account()))); } void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcPrivateMessage *ircMessage, const QString &emote, - std::vector> &vec) + std::vector> &vec) { - EmoteManager &emoteManager = EmoteManager::getInstance(); + singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance(); if (!emote.contains(':')) { return; } @@ -524,14 +524,14 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcPrivateMessage *i QString name = ircMessage->content().mid(start, end - start + 1); vec.push_back( - std::pair(start, emoteManager.getTwitchEmoteById(id, name))); + std::pair(start, emoteManager.getTwitchEmoteById(id, name))); } } bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString) { - EmoteManager &emoteManager = EmoteManager::getInstance(); - EmoteData emoteData; + singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance(); + util::EmoteData emoteData; if (emoteManager.bttvGlobalEmotes.tryGet(emoteString, emoteData)) { // BTTV Global Emote @@ -555,7 +555,7 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString) return false; } -bool TwitchMessageBuilder::appendEmote(EmoteData &emoteData) +bool TwitchMessageBuilder::appendEmote(util::EmoteData &emoteData) { this->appendWord(Word(emoteData.image, Word::BttvEmoteImage, emoteData.image->getName(), emoteData.image->getTooltip(), @@ -567,7 +567,7 @@ bool TwitchMessageBuilder::appendEmote(EmoteData &emoteData) void TwitchMessageBuilder::parseTwitchBadges() { - const auto &channelResources = ResourceManager::getInstance().channels[this->roomID]; + const auto &channelResources = singletons::ResourceManager::getInstance().channels[this->roomID]; auto iterator = this->tags.find("badges"); @@ -584,7 +584,7 @@ void TwitchMessageBuilder::parseTwitchBadges() } if (badge.startsWith("bits/")) { - if (!ResourceManager::getInstance().dynamicBadgesLoaded) { + if (!singletons::ResourceManager::getInstance().dynamicBadgesLoaded) { // Do nothing continue; } @@ -593,7 +593,7 @@ void TwitchMessageBuilder::parseTwitchBadges() std::string versionKey = cheerAmountQS.toStdString(); try { - auto &badgeSet = ResourceManager::getInstance().badgeSets.at("bits"); + auto &badgeSet = singletons::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(ResourceManager::getInstance().badgeStaff, Word::BadgeGlobalAuthority, + appendWord(Word(singletons::ResourceManager::getInstance().badgeStaff, Word::BadgeGlobalAuthority, QString(), QString("Twitch Staff"))); } else if (badge == "admin/1") { - appendWord(Word(ResourceManager::getInstance().badgeAdmin, Word::BadgeGlobalAuthority, + appendWord(Word(singletons::ResourceManager::getInstance().badgeAdmin, Word::BadgeGlobalAuthority, QString(), QString("Twitch Admin"))); } else if (badge == "global_mod/1") { - appendWord(Word(ResourceManager::getInstance().badgeGlobalModerator, + appendWord(Word(singletons::ResourceManager::getInstance().badgeGlobalModerator, Word::BadgeGlobalAuthority, QString(), QString("Global Moderator"))); } else if (badge == "moderator/1") { // TODO: Implement custom FFZ moderator badge - appendWord(Word(ResourceManager::getInstance().badgeModerator, Word::BadgeChannelAuthority, + appendWord(Word(singletons::ResourceManager::getInstance().badgeModerator, Word::BadgeChannelAuthority, QString(), QString("Channel Moderator"))); // custom badge } else if (badge == "turbo/1") { - appendWord(Word(ResourceManager::getInstance().badgeTurbo, Word::BadgeVanity, QString(), + appendWord(Word(singletons::ResourceManager::getInstance().badgeTurbo, Word::BadgeVanity, QString(), QString("Turbo Subscriber"))); } else if (badge == "broadcaster/1") { - appendWord(Word(ResourceManager::getInstance().badgeBroadcaster, Word::BadgeChannelAuthority, + appendWord(Word(singletons::ResourceManager::getInstance().badgeBroadcaster, Word::BadgeChannelAuthority, QString(), QString("Channel Broadcaster"))); } else if (badge == "premium/1") { - appendWord(Word(ResourceManager::getInstance().badgePremium, Word::BadgeVanity, QString(), + appendWord(Word(singletons::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(ResourceManager::getInstance().badgeVerified, Word::BadgeVanity, + appendWord(Word(singletons::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(ResourceManager::getInstance().badgeSubscriber, + appendWord(Word(singletons::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(ResourceManager::getInstance().badgeSubscriber, + appendWord(Word(singletons::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 (!ResourceManager::getInstance().dynamicBadgesLoaded) { + if (!singletons::ResourceManager::getInstance().dynamicBadgesLoaded) { // Do nothing continue; } @@ -695,7 +695,7 @@ void TwitchMessageBuilder::parseTwitchBadges() std::string versionKey = parts[1].toStdString(); try { - auto &badgeSet = ResourceManager::getInstance().badgeSets.at(badgeSetKey); + auto &badgeSet = singletons::ResourceManager::getInstance().badgeSets.at(badgeSetKey); try { auto &badgeVersion = badgeSet.versions.at(versionKey); @@ -717,7 +717,7 @@ void TwitchMessageBuilder::parseTwitchBadges() void TwitchMessageBuilder::parseChatterinoBadges() { - auto &badges = ResourceManager::getInstance().chatterinoBadges; + auto &badges = singletons::ResourceManager::getInstance().chatterinoBadges; auto it = badges.find(this->userName.toStdString()); if (it == badges.end()) { diff --git a/src/twitch/twitchmessagebuilder.hpp b/src/twitch/twitchmessagebuilder.hpp index 69711803a..9a281217e 100644 --- a/src/twitch/twitchmessagebuilder.hpp +++ b/src/twitch/twitchmessagebuilder.hpp @@ -10,10 +10,7 @@ #include namespace chatterino { - -class WindowManager; class Channel; -class ThemeManager; namespace twitch { class TwitchChannel; @@ -61,9 +58,9 @@ private: void appendModerationButtons(); void appendTwitchEmote(const Communi::IrcPrivateMessage *ircMessage, const QString &emote, - std::vector> &vec); + std::vector> &vec); bool tryAppendEmote(QString &emoteString); - bool appendEmote(EmoteData &emoteData); + bool appendEmote(util::EmoteData &emoteData); void parseTwitchBadges(); void parseChatterinoBadges(); diff --git a/src/concurrentmap.hpp b/src/util/concurrentmap.hpp similarity index 98% rename from src/concurrentmap.hpp rename to src/util/concurrentmap.hpp index 0b4ba6112..183d726d2 100644 --- a/src/concurrentmap.hpp +++ b/src/util/concurrentmap.hpp @@ -9,6 +9,7 @@ #include namespace chatterino { +namespace util { template class ConcurrentMap @@ -84,3 +85,4 @@ private: QMap data; }; } // namespace chatterino +} diff --git a/src/util/emotemap.hpp b/src/util/emotemap.hpp new file mode 100644 index 000000000..f285169e5 --- /dev/null +++ b/src/util/emotemap.hpp @@ -0,0 +1,24 @@ +#pragma once + +#include "messages/lazyloadedimage.hpp" +#include "util/concurrentmap.hpp" + +namespace chatterino { +namespace util { + +struct EmoteData { + EmoteData() + { + } + + EmoteData(messages::LazyLoadedImage *_image) + : image(_image) + { + } + + messages::LazyLoadedImage *image = nullptr; +}; + +typedef ConcurrentMap EmoteMap; +} +} diff --git a/src/util/urlfetch.hpp b/src/util/urlfetch.hpp index 972f175e9..f2bb884bd 100644 --- a/src/util/urlfetch.hpp +++ b/src/util/urlfetch.hpp @@ -133,7 +133,7 @@ static void put(QUrl url, std::function successCallback) { QNetworkRequest request(url); - auto &accountManager = AccountManager::getInstance(); + auto &accountManager = singletons::AccountManager::getInstance(); auto currentTwitchUser = accountManager.Twitch.getCurrent(); QByteArray oauthToken; if (currentTwitchUser) { diff --git a/src/widgets/accountpopup.cpp b/src/widgets/accountpopup.cpp index 5e7060011..171c8b6b8 100644 --- a/src/widgets/accountpopup.cpp +++ b/src/widgets/accountpopup.cpp @@ -1,7 +1,7 @@ #include "widgets/accountpopup.hpp" -#include "singletons/accountmanager.hpp" #include "channel.hpp" #include "credentials.hpp" +#include "singletons/accountmanager.hpp" #include "singletons/settingsmanager.hpp" #include "ui_accountpopupform.h" #include "util/urlfetch.hpp" @@ -32,7 +32,7 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr _channel) this->resize(0, 0); - SettingsManager &settings = SettingsManager::getInstance(); + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); this->permission = permissions::User; for (auto button : this->ui->profileLayout->findChildren()) { @@ -59,7 +59,7 @@ AccountPopupWidget::AccountPopupWidget(std::shared_ptr _channel) this->sendCommand(this->ui->mod, "/mod "); this->sendCommand(this->ui->unMod, "/unmod "); - auto &accountManager = AccountManager::getInstance(); + auto &accountManager = singletons::AccountManager::getInstance(); QString userId; QString userNickname; auto currentTwitchUser = accountManager.Twitch.getCurrent(); @@ -185,7 +185,8 @@ void AccountPopupWidget::loadAvatar(const QUrl &avatarUrl) void AccountPopupWidget::updatePermissions() { - AccountManager &accountManager = AccountManager::getInstance(); + singletons::AccountManager &accountManager = singletons::AccountManager::getInstance(); + auto currentTwitchUser = accountManager.Twitch.getCurrent(); if (!currentTwitchUser) { // No twitch user set (should never happen) @@ -242,7 +243,7 @@ void AccountPopupWidget::focusOutEvent(QFocusEvent *) void AccountPopupWidget::showEvent(QShowEvent *) { - AccountManager &accountManager = AccountManager::getInstance(); + singletons::AccountManager &accountManager = singletons::AccountManager::getInstance(); auto currentTwitchUser = accountManager.Twitch.getCurrent(); if (!currentTwitchUser) { // No twitch user set (should never happen) @@ -266,7 +267,8 @@ void AccountPopupWidget::showEvent(QShowEvent *) this->updateButtons(this->ui->ownerLayout, false); } - QString blacklisted = SettingsManager::getInstance().highlightUserBlacklist.getnonConst(); + QString blacklisted = + singletons::SettingManager::getInstance().highlightUserBlacklist.getnonConst(); QStringList list = blacklisted.split("\n", QString::SkipEmptyParts); if (list.contains(this->ui->lblUsername->text(), Qt::CaseInsensitive)) { this->ui->disableHighlights->hide(); diff --git a/src/widgets/accountpopup.hpp b/src/widgets/accountpopup.hpp index 79167f00a..7e65979df 100644 --- a/src/widgets/accountpopup.hpp +++ b/src/widgets/accountpopup.hpp @@ -1,7 +1,7 @@ #pragma once #include "basewidget.hpp" -#include "concurrentmap.hpp" +#include "util/concurrentmap.hpp" #include "twitch/twitchchannel.hpp" #include @@ -52,7 +52,7 @@ private: QString userID; QPixmap avatar; - ConcurrentMap avatarMap; + util::ConcurrentMap avatarMap; protected: virtual void focusOutEvent(QFocusEvent *event) override; diff --git a/src/widgets/accountswitchwidget.cpp b/src/widgets/accountswitchwidget.cpp index 54984c94f..ba4805185 100644 --- a/src/widgets/accountswitchwidget.cpp +++ b/src/widgets/accountswitchwidget.cpp @@ -1,6 +1,6 @@ #include "accountswitchwidget.hpp" -#include "singletons/accountmanager.hpp" #include "const.hpp" +#include "singletons/accountmanager.hpp" namespace chatterino { namespace widgets { @@ -8,20 +8,22 @@ namespace widgets { AccountSwitchWidget::AccountSwitchWidget(QWidget *parent) : QListWidget(parent) { + singletons::AccountManager &accountManager = singletons::AccountManager::getInstance(); + this->addItem(ANONYMOUS_USERNAME_LABEL); - for (const auto &userName : AccountManager::getInstance().Twitch.getUsernames()) { + for (const auto &userName : accountManager.Twitch.getUsernames()) { this->addItem(userName); } - AccountManager::getInstance().Twitch.userListUpdated.connect([this]() { + accountManager.Twitch.userListUpdated.connect([this, &accountManager]() { this->blockSignals(true); this->clear(); this->addItem(ANONYMOUS_USERNAME_LABEL); - for (const auto &userName : AccountManager::getInstance().Twitch.getUsernames()) { + for (const auto &userName : accountManager.Twitch.getUsernames()) { this->addItem(userName); } @@ -32,13 +34,13 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent) this->refreshSelection(); - QObject::connect(this, &QListWidget::clicked, [this] { + QObject::connect(this, &QListWidget::clicked, [this, &accountManager] { if (!this->selectedItems().isEmpty()) { QString newUsername = this->currentItem()->text(); if (newUsername.compare(ANONYMOUS_USERNAME_LABEL, Qt::CaseInsensitive) == 0) { - AccountManager::getInstance().Twitch.currentUsername = ""; + accountManager.Twitch.currentUsername = ""; } else { - AccountManager::getInstance().Twitch.currentUsername = newUsername.toStdString(); + accountManager.Twitch.currentUsername = newUsername.toStdString(); } } }); @@ -55,7 +57,7 @@ void AccountSwitchWidget::refreshSelection() // Select the currently logged in user if (this->count() > 0) { - auto currentUser = AccountManager::getInstance().Twitch.getCurrent(); + auto currentUser = singletons::AccountManager::getInstance().Twitch.getCurrent(); if (currentUser->isAnon()) { this->setCurrentRow(0); diff --git a/src/widgets/basewidget.cpp b/src/widgets/basewidget.cpp index 0c314747f..40f824363 100644 --- a/src/widgets/basewidget.cpp +++ b/src/widgets/basewidget.cpp @@ -12,7 +12,7 @@ namespace chatterino { namespace widgets { -BaseWidget::BaseWidget(ThemeManager &_themeManager, QWidget *parent) +BaseWidget::BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent) : QWidget(parent) , themeManager(_themeManager) { @@ -21,14 +21,14 @@ BaseWidget::BaseWidget(ThemeManager &_themeManager, QWidget *parent) BaseWidget::BaseWidget(BaseWidget *parent) : QWidget(parent) - , themeManager(ThemeManager::getInstance()) + , themeManager(singletons::ThemeManager::getInstance()) { this->init(); } BaseWidget::BaseWidget(QWidget *parent) : QWidget(parent) - , themeManager(ThemeManager::getInstance()) + , themeManager(singletons::ThemeManager::getInstance()) { } @@ -72,7 +72,7 @@ void BaseWidget::initAsWindow() } #endif - if (SettingsManager::getInstance().windowTopMost.getValue()) { + if (singletons::SettingManager::getInstance().windowTopMost.getValue()) { this->setWindowFlags(this->windowFlags() | Qt::WindowStaysOnTopHint); } } diff --git a/src/widgets/basewidget.hpp b/src/widgets/basewidget.hpp index 74c811892..04ef5eb48 100644 --- a/src/widgets/basewidget.hpp +++ b/src/widgets/basewidget.hpp @@ -3,8 +3,9 @@ #include namespace chatterino { - +namespace singletons { class ThemeManager; +} namespace widgets { @@ -13,13 +14,13 @@ class BaseWidget : public QWidget Q_OBJECT public: - explicit BaseWidget(ThemeManager &_themeManager, QWidget *parent); + explicit BaseWidget(singletons::ThemeManager &_themeManager, QWidget *parent); explicit BaseWidget(BaseWidget *parent); explicit BaseWidget(QWidget *parent = nullptr); - ThemeManager &themeManager; + singletons::ThemeManager &themeManager; float getDpiMultiplier(); diff --git a/src/widgets/emotepopup.cpp b/src/widgets/emotepopup.cpp index c01be6388..667cbdc3c 100644 --- a/src/widgets/emotepopup.cpp +++ b/src/widgets/emotepopup.cpp @@ -12,7 +12,7 @@ using namespace chatterino::messages; namespace chatterino { namespace widgets { -EmotePopup::EmotePopup(ThemeManager &themeManager) +EmotePopup::EmotePopup(singletons::ThemeManager &themeManager) : BaseWidget(themeManager, 0) { this->initAsWindow(); @@ -44,12 +44,12 @@ void EmotePopup::loadChannel(std::shared_ptr _channel) std::shared_ptr emoteChannel(new Channel("")); - auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) { + auto addEmotes = [&](util::EmoteMap &map, const QString &title, const QString &emoteDesc) { // TITLE messages::MessageBuilder builder1; builder1.appendWord(Word(title, Word::Flags::Text, MessageColor(MessageColor::Text), - FontManager::Medium, QString(), QString())); + singletons::FontManager::Medium, QString(), QString())); builder1.getMessage()->centered = true; emoteChannel->addMessage(builder1.getMessage()); @@ -58,7 +58,7 @@ void EmotePopup::loadChannel(std::shared_ptr _channel) messages::MessageBuilder builder2; builder2.getMessage()->centered = true; - map.each([&](const QString &key, const EmoteData &value) { + map.each([&](const QString &key, const util::EmoteData &value) { builder2.appendWord(Word(value.image, Word::Flags::AlwaysShow, key, emoteDesc, Link(Link::Type::InsertText, key))); }); @@ -66,7 +66,7 @@ void EmotePopup::loadChannel(std::shared_ptr _channel) emoteChannel->addMessage(builder2.getMessage()); }; - EmoteManager &emoteManager = EmoteManager::getInstance(); + singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance(); addEmotes(emoteManager.bttvGlobalEmotes, "BetterTTV Global Emotes", "BetterTTV Global Emote"); addEmotes(*channel->bttvChannelEmotes.get(), "BetterTTV Channel Emotes", @@ -81,7 +81,7 @@ void EmotePopup::loadChannel(std::shared_ptr _channel) void EmotePopup::loadEmojis() { - EmoteMap &emojis = EmoteManager::getInstance().getEmojis(); + util::EmoteMap &emojis = singletons::EmoteManager::getInstance().getEmojis(); std::shared_ptr emojiChannel(new Channel("")); @@ -89,7 +89,7 @@ void EmotePopup::loadEmojis() messages::MessageBuilder builder1; builder1.appendWord(Word("emojis", Word::Flags::Text, MessageColor(MessageColor::Text), - FontManager::Medium, QString(), QString())); + singletons::FontManager::Medium, QString(), QString())); builder1.getMessage()->centered = true; emojiChannel->addMessage(builder1.getMessage()); @@ -97,7 +97,7 @@ void EmotePopup::loadEmojis() // emojis messages::MessageBuilder builder; builder.getMessage()->centered = true; - emojis.each([this, &builder](const QString &key, const EmoteData &value) { + emojis.each([this, &builder](const QString &key, const util::EmoteData &value) { builder.appendWord(Word(value.image, Word::Flags::AlwaysShow, key, "emoji", Link(Link::Type::InsertText, key))); }); diff --git a/src/widgets/emotepopup.hpp b/src/widgets/emotepopup.hpp index 028ff03a7..313e3ced7 100644 --- a/src/widgets/emotepopup.hpp +++ b/src/widgets/emotepopup.hpp @@ -10,7 +10,7 @@ namespace widgets { class EmotePopup : public BaseWidget { public: - explicit EmotePopup(ThemeManager &); + explicit EmotePopup(singletons::ThemeManager &); void loadChannel(std::shared_ptr channel); void loadEmojis(); diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index c9d1c9893..0392c2ffa 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -39,7 +39,8 @@ ChannelView::ChannelView(BaseWidget *parent) #endif this->setMouseTracking(true); - QObject::connect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged, this, + QObject::connect(&singletons::SettingManager::getInstance(), + &singletons::SettingManager::wordTypeMaskChanged, this, &ChannelView::wordTypeMaskChanged); this->scrollBar.getCurrentValueChanged().connect([this] { @@ -51,7 +52,7 @@ ChannelView::ChannelView(BaseWidget *parent) this->queueUpdate(); }); - WindowManager &windowManager = WindowManager::getInstance(); + singletons::WindowManager &windowManager = singletons::WindowManager::getInstance(); this->repaintGifsConnection = windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); }); @@ -62,9 +63,10 @@ ChannelView::ChannelView(BaseWidget *parent) this->goToBottom->getLabel().setText("Jump to bottom"); this->goToBottom->setVisible(false); - this->managedConnections.emplace_back(FontManager::getInstance().fontChanged.connect([this] { - this->layoutMessages(); // - })); + this->managedConnections.emplace_back( + singletons::FontManager::getInstance().fontChanged.connect([this] { + this->layoutMessages(); // + })); connect(goToBottom, &RippleEffectLabel::clicked, this, [this] { QTimer::singleShot(180, [this] { this->scrollBar.scrollToBottom(); }); }); @@ -82,8 +84,9 @@ ChannelView::ChannelView(BaseWidget *parent) ChannelView::~ChannelView() { - QObject::disconnect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged, - this, &ChannelView::wordTypeMaskChanged); + QObject::disconnect(&singletons::SettingManager::getInstance(), + &singletons::SettingManager::wordTypeMaskChanged, this, + &ChannelView::wordTypeMaskChanged); this->messageAppendedConnection.disconnect(); this->messageRemovedConnection.disconnect(); this->repaintGifsConnection.disconnect(); @@ -776,7 +779,7 @@ void ChannelView::drawMessageSelection(QPainter &painter, messages::MessageRef * void ChannelView::wheelEvent(QWheelEvent *event) { if (this->scrollBar.isVisible()) { - float mouseMultiplier = SettingsManager::getInstance().mouseScrollMultiplier; + float mouseMultiplier = singletons::SettingManager::getInstance().mouseScrollMultiplier; this->scrollBar.setDesiredValue( this->scrollBar.getDesiredValue() - event->delta() / 10.0 * mouseMultiplier, true); diff --git a/src/widgets/helper/notebooktab.cpp b/src/widgets/helper/notebooktab.cpp index 02d370f9e..f3bd631ab 100644 --- a/src/widgets/helper/notebooktab.cpp +++ b/src/widgets/helper/notebooktab.cpp @@ -29,7 +29,7 @@ NotebookTab::NotebookTab(Notebook *_notebook, const std::string &_uuid) this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic)); - SettingsManager::getInstance().hideTabX.connect( + singletons::SettingManager::getInstance().hideTabX.connect( boost::bind(&NotebookTab::hideTabXChanged, this, _1), this->managedConnections); this->setMouseTracking(true); @@ -74,7 +74,7 @@ void NotebookTab::calcSize() float scale = getDpiMultiplier(); QString qTitle(qS(this->title)); - if (SettingsManager::getInstance().hideTabX) { + if (singletons::SettingManager::getInstance().hideTabX) { this->resize(static_cast((fontMetrics().width(qTitle) + 16) * scale), static_cast(24 * scale)); } else { @@ -190,12 +190,12 @@ void NotebookTab::paintEvent(QPaintEvent *) painter.setPen(fg); float scale = this->getDpiMultiplier(); - int rectW = (SettingsManager::getInstance().hideTabX ? 0 : static_cast(16) * scale); + int rectW = (singletons::SettingManager::getInstance().hideTabX ? 0 : static_cast(16) * scale); QRect rect(0, 0, this->width() - rectW, this->height()); painter.drawText(rect, this->getTitle(), QTextOption(Qt::AlignCenter)); - if (!SettingsManager::getInstance().hideTabX && (mouseOver || selected)) { + if (!singletons::SettingManager::getInstance().hideTabX && (mouseOver || selected)) { QRect xRect = this->getXRect(); if (mouseOverX) { painter.fillRect(xRect, QColor(0, 0, 0, 64)); @@ -237,7 +237,7 @@ void NotebookTab::mouseReleaseEvent(QMouseEvent *event) this->notebook->removePage(this->page); } } else { - if (!SettingsManager::getInstance().hideTabX && this->mouseDownX && + if (!singletons::SettingManager::getInstance().hideTabX && this->mouseDownX && this->getXRect().contains(event->pos())) { this->mouseDownX = false; @@ -270,7 +270,7 @@ void NotebookTab::dragEnterEvent(QDragEnterEvent *) void NotebookTab::mouseMoveEvent(QMouseEvent *event) { - if (!SettingsManager::getInstance().hideTabX) { + if (!singletons::SettingManager::getInstance().hideTabX) { bool overX = this->getXRect().contains(event->pos()); if (overX != this->mouseOverX) { diff --git a/src/widgets/helper/notebooktab.hpp b/src/widgets/helper/notebooktab.hpp index b890ad036..f51cc9977 100644 --- a/src/widgets/helper/notebooktab.hpp +++ b/src/widgets/helper/notebooktab.hpp @@ -10,8 +10,6 @@ namespace chatterino { -class ThemeManager; - namespace widgets { class Notebook; diff --git a/src/widgets/helper/resizingtextedit.cpp b/src/widgets/helper/resizingtextedit.cpp index cc072ef44..0b97e9651 100644 --- a/src/widgets/helper/resizingtextedit.cpp +++ b/src/widgets/helper/resizingtextedit.cpp @@ -88,7 +88,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event) } auto *completionModel = - static_cast(this->completer->model()); + static_cast(this->completer->model()); if (!this->nextCompletion) { completionModel->refresh(); diff --git a/src/widgets/helper/rippleeffectlabel.hpp b/src/widgets/helper/rippleeffectlabel.hpp index 08a05e837..430793f58 100644 --- a/src/widgets/helper/rippleeffectlabel.hpp +++ b/src/widgets/helper/rippleeffectlabel.hpp @@ -10,9 +10,6 @@ #include namespace chatterino { - -class ThemeManager; - namespace widgets { class RippleEffectLabel : public RippleEffectButton diff --git a/src/widgets/helper/scrollbarhighlight.hpp b/src/widgets/helper/scrollbarhighlight.hpp index 9be6f1681..1eb972dee 100644 --- a/src/widgets/helper/scrollbarhighlight.hpp +++ b/src/widgets/helper/scrollbarhighlight.hpp @@ -3,8 +3,9 @@ #include "QString" namespace chatterino { - +namespace singletons { class ThemeManager; +} namespace widgets { @@ -18,7 +19,7 @@ public: ScrollBarHighlight(double _position, int _colorIndex, ScrollBar *parent, Style _style = Default, QString _tag = ""); - ThemeManager &themeManager; + singletons::ThemeManager &themeManager; double getPosition() { diff --git a/src/widgets/helper/splitheader.hpp b/src/widgets/helper/splitheader.hpp index bfe47e1d4..278b80edf 100644 --- a/src/widgets/helper/splitheader.hpp +++ b/src/widgets/helper/splitheader.hpp @@ -16,8 +16,6 @@ namespace chatterino { -class ThemeManager; - namespace widgets { class Split; diff --git a/src/widgets/helper/splitinput.cpp b/src/widgets/helper/splitinput.cpp index 08d05cdf5..5aa16baf2 100644 --- a/src/widgets/helper/splitinput.cpp +++ b/src/widgets/helper/splitinput.cpp @@ -27,13 +27,13 @@ SplitInput::SplitInput(Split *_chatWidget) this->hbox.addLayout(&this->editContainer); this->hbox.addLayout(&this->vbox); - auto &fontManager = FontManager::getInstance(); + auto &fontManager = singletons::FontManager::getInstance(); this->textInput.setFont( - fontManager.getFont(FontManager::Type::Medium, this->getDpiMultiplier())); + fontManager.getFont(singletons::FontManager::Type::Medium, this->getDpiMultiplier())); this->managedConnections.emplace_back(fontManager.fontChanged.connect([this, &fontManager]() { this->textInput.setFont( - fontManager.getFont(FontManager::Type::Medium, this->getDpiMultiplier())); + fontManager.getFont(singletons::FontManager::Type::Medium, this->getDpiMultiplier())); })); this->editContainer.addWidget(&this->textInput); @@ -67,10 +67,10 @@ SplitInput::SplitInput(Split *_chatWidget) connect(&textInput, &ResizingTextEdit::textChanged, this, &SplitInput::editTextChanged); this->refreshTheme(); - textLengthLabel.setHidden(!SettingsManager::getInstance().showMessageLength); + textLengthLabel.setHidden(!singletons::SettingManager::getInstance().showMessageLength); - auto completer = - new QCompleter(CompletionManager::getInstance().createModel(this->chatWidget->channelName)); + auto completer = new QCompleter( + singletons::CompletionManager::getInstance().createModel(this->chatWidget->channelName)); this->textInput.setCompleter(completer); @@ -180,7 +180,7 @@ SplitInput::SplitInput(Split *_chatWidget) } }); - SettingsManager::getInstance().showMessageLength.connect( + singletons::SettingManager::getInstance().showMessageLength.connect( [this](const bool &value, auto) { this->textLengthLabel.setHidden(!value); }, this->managedConnections); diff --git a/src/widgets/logindialog.cpp b/src/widgets/logindialog.cpp index afd53bf84..ac27aa41f 100644 --- a/src/widgets/logindialog.cpp +++ b/src/widgets/logindialog.cpp @@ -50,7 +50,7 @@ void LogInWithCredentials(const std::string &userID, const std::string &username pajlada::Settings::Setting::set("/accounts/uid" + userID + "/oauthToken", oauthToken); - AccountManager::getInstance().Twitch.reloadUsers(); + singletons::AccountManager::getInstance().Twitch.reloadUsers(); messageBox.exec(); } diff --git a/src/widgets/notebook.cpp b/src/widgets/notebook.cpp index f8e24340f..30c774f51 100644 --- a/src/widgets/notebook.cpp +++ b/src/widgets/notebook.cpp @@ -40,7 +40,7 @@ Notebook::Notebook(Window *parent, bool _showButtons, const std::string &setting this->userButton.move(24, 0); this->userButton.icon = NotebookButton::IconUser; - auto &settingsManager = SettingsManager::getInstance(); + auto &settingsManager = singletons::SettingManager::getInstance(); settingsManager.hidePreferencesButton.connectSimple([this](auto) { this->performLayout(); }); settingsManager.hideUserButton.connectSimple([this](auto) { this->performLayout(); }); @@ -177,13 +177,13 @@ void Notebook::performLayout(bool animated) int x = 0, y = 0; float scale = this->getDpiMultiplier(); - if (!showButtons || SettingsManager::getInstance().hidePreferencesButton) { + if (!showButtons || singletons::SettingManager::getInstance().hidePreferencesButton) { this->settingsButton.hide(); } else { this->settingsButton.show(); x += settingsButton.width(); } - if (!showButtons || SettingsManager::getInstance().hideUserButton) { + if (!showButtons || singletons::SettingManager::getInstance().hideUserButton) { this->userButton.hide(); } else { this->userButton.move(x, 0); diff --git a/src/widgets/notebook.hpp b/src/widgets/notebook.hpp index ab90b06d8..b35762e9f 100644 --- a/src/widgets/notebook.hpp +++ b/src/widgets/notebook.hpp @@ -9,9 +9,6 @@ #include namespace chatterino { - -class ChannelManager; - namespace widgets { class Window; diff --git a/src/widgets/scrollbar.cpp b/src/widgets/scrollbar.cpp index fdd47b2e2..d1608d41b 100644 --- a/src/widgets/scrollbar.cpp +++ b/src/widgets/scrollbar.cpp @@ -17,7 +17,7 @@ ScrollBar::ScrollBar(ChannelView *parent) : BaseWidget(parent) , currentValueAnimation(this, "currentValue") , highlights(nullptr) - , smoothScrollingSetting(SettingsManager::getInstance().enableSmoothScrolling) + , smoothScrollingSetting(singletons::SettingManager::getInstance().enableSmoothScrolling) { resize((int)(16 * this->getDpiMultiplier()), 100); this->currentValueAnimation.setDuration(250); diff --git a/src/widgets/scrollbar.hpp b/src/widgets/scrollbar.hpp index 58c2117ef..37b1ae361 100644 --- a/src/widgets/scrollbar.hpp +++ b/src/widgets/scrollbar.hpp @@ -11,8 +11,6 @@ namespace chatterino { -class ThemeManager; - namespace widgets { class ChannelView; diff --git a/src/widgets/settingsdialog.cpp b/src/widgets/settingsdialog.cpp index b15d86234..81b47fa23 100644 --- a/src/widgets/settingsdialog.cpp +++ b/src/widgets/settingsdialog.cpp @@ -106,7 +106,7 @@ void SettingsDialog::addTabs() QVBoxLayout *SettingsDialog::createAccountsTab() { auto layout = new QVBoxLayout(); - SettingsManager &settings = SettingsManager::getInstance(); + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); // add remove buttons auto buttonBox = new QDialogButtonBox(this); @@ -136,7 +136,7 @@ QVBoxLayout *SettingsDialog::createAccountsTab() return; } - AccountManager::getInstance().Twitch.removeUser(selectedUser); + singletons::AccountManager::getInstance().Twitch.removeUser(selectedUser); }); layout->addWidget(this->ui.accountSwitchWidget); @@ -146,7 +146,7 @@ QVBoxLayout *SettingsDialog::createAccountsTab() QVBoxLayout *SettingsDialog::createAppearanceTab() { - auto &settings = SettingsManager::getInstance(); + auto &settings = singletons::SettingManager::getInstance(); auto layout = this->createTabLayout(); { @@ -163,7 +163,7 @@ QVBoxLayout *SettingsDialog::createAppearanceTab() fontLayout->addWidget(fontFamilyLabel); { - auto &fontManager = FontManager::getInstance(); + auto &fontManager = singletons::FontManager::getInstance(); auto UpdateFontFamilyLabel = [fontFamilyLabel, &fontManager](auto) { fontFamilyLabel->setText( @@ -178,11 +178,11 @@ QVBoxLayout *SettingsDialog::createAppearanceTab() } fontButton->connect(fontButton, &QPushButton::clicked, []() { - auto &fontManager = FontManager::getInstance(); - QFontDialog dialog(fontManager.getFont(FontManager::Medium, 1.)); + auto &fontManager = singletons::FontManager::getInstance(); + QFontDialog dialog(fontManager.getFont(singletons::FontManager::Medium, 1.)); dialog.connect(&dialog, &QFontDialog::fontSelected, [](const QFont &font) { - auto &fontManager = FontManager::getInstance(); + auto &fontManager = singletons::FontManager::getInstance(); fontManager.currentFontFamily = font.family().toStdString(); fontManager.currentFontSize = font.pointSize(); }); @@ -263,7 +263,7 @@ QVBoxLayout *SettingsDialog::createAppearanceTab() QObject::connect(combo, &QComboBox::currentTextChanged, this, [](const QString &value) { // dirty hack - EmoteManager::getInstance().incGeneration(); + singletons::EmoteManager::getInstance().incGeneration(); pajlada::Settings::Setting::set("/appearance/theme/name", value.toStdString()); }); @@ -312,7 +312,7 @@ QVBoxLayout *SettingsDialog::createAppearanceTab() QVBoxLayout *SettingsDialog::createBehaviourTab() { - SettingsManager &settings = SettingsManager::getInstance(); + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); auto layout = this->createTabLayout(); auto form = new QFormLayout(); @@ -329,14 +329,14 @@ QVBoxLayout *SettingsDialog::createBehaviourTab() auto scroll = new QSlider(Qt::Horizontal); form->addRow("Mouse scroll speed:", scroll); - float currentValue = SettingsManager::getInstance().mouseScrollMultiplier; + float currentValue = singletons::SettingManager::getInstance().mouseScrollMultiplier; int scrollValue = ((currentValue - 0.1f) / 2.f) * 99.f; scroll->setValue(scrollValue); connect(scroll, &QSlider::valueChanged, [](int newValue) { float mul = static_cast(newValue) / 99.f; float newScrollValue = (mul * 2.1f) + 0.1f; - SettingsManager::getInstance().mouseScrollMultiplier = newScrollValue; + singletons::SettingManager::getInstance().mouseScrollMultiplier = newScrollValue; }); form->addRow("Streamlink path:", createLineEdit(settings.streamlinkPath)); @@ -361,7 +361,7 @@ QVBoxLayout *SettingsDialog::createCommandsTab() QVBoxLayout *SettingsDialog::createEmotesTab() { - SettingsManager &settings = SettingsManager::getInstance(); + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); auto layout = this->createTabLayout(); layout->addWidget(createCheckbox("Enable Twitch Emotes", settings.enableTwitchEmotes)); @@ -405,7 +405,7 @@ QVBoxLayout *SettingsDialog::createLogsTab() QVBoxLayout *SettingsDialog::createHighlightingTab() { - SettingsManager &settings = SettingsManager::getInstance(); + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); auto layout = this->createTabLayout(); auto highlights = new QListWidget(); @@ -615,7 +615,7 @@ void SettingsDialog::refresh() { this->ui.accountSwitchWidget->refresh(); - SettingsManager::getInstance().saveSnapshot(); + singletons::SettingManager::getInstance().saveSnapshot(); } void SettingsDialog::dpiMultiplierChanged(float oldDpi, float newDpi) @@ -754,7 +754,7 @@ void SettingsDialog::okButtonClicked() void SettingsDialog::cancelButtonClicked() { - auto &settings = SettingsManager::getInstance(); + auto &settings = singletons::SettingManager::getInstance(); settings.recallSnapshot(); diff --git a/src/widgets/split.cpp b/src/widgets/split.cpp index 4cd505e09..a5b8e78d5 100644 --- a/src/widgets/split.cpp +++ b/src/widgets/split.cpp @@ -51,7 +51,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid) , settingRoot(fS("/splits/{}", this->uuid)) , channelName(fS("{}/channelName", this->settingRoot)) , parentPage(*parent) - , channel(ChannelManager::getInstance().emptyChannel) + , channel(singletons::ChannelManager::getInstance().emptyChannel) , vbox(this) , header(this) , view(this) @@ -97,7 +97,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid) }); this->input.textChanged.connect([this](const QString &newText) { - if (!SettingsManager::getInstance().hideEmptyInput) { + if (!singletons::SettingManager::getInstance().hideEmptyInput) { return; } @@ -108,7 +108,7 @@ Split::Split(SplitContainer *parent, const std::string &_uuid) } }); - SettingsManager::getInstance().hideEmptyInput.connect([this](const bool &hideEmptyInput, auto) { + singletons::SettingManager::getInstance().hideEmptyInput.connect([this](const bool &hideEmptyInput, auto) { if (hideEmptyInput && this->input.getInputText().length() == 0) { this->input.hide(); } else { @@ -170,7 +170,7 @@ double Split::getFlexSizeY() void Split::channelNameUpdated(const std::string &newChannelName) { - auto &cman = ChannelManager::getInstance(); + auto &cman = singletons::ChannelManager::getInstance(); // remove current channel if (!this->channel->isEmpty()) { @@ -264,7 +264,7 @@ void Split::doChangeChannel() void Split::doPopup() { - Window &window = WindowManager::getInstance().createWindow(); + Window &window = singletons::WindowManager::getInstance().createWindow(); Split *split = new Split(static_cast(window.getNotebook().getSelectedPage()), this->uuid); @@ -293,7 +293,7 @@ void Split::doOpenPopupPlayer() void Split::doOpenStreamlink() { - SettingsManager &settings = SettingsManager::getInstance(); + singletons::SettingManager &settings = singletons::SettingManager::getInstance(); QString preferredQuality = QString::fromStdString(settings.preferredQuality.getValue()).toLower(); // TODO(Confuseh): Default streamlink paths diff --git a/src/widgets/splitcontainer.hpp b/src/widgets/splitcontainer.hpp index ca9a05109..5d0c2deb5 100644 --- a/src/widgets/splitcontainer.hpp +++ b/src/widgets/splitcontainer.hpp @@ -13,9 +13,6 @@ #include namespace chatterino { - -class ChannelManager; - namespace widgets { class SplitContainer : public BaseWidget diff --git a/src/widgets/tooltipwidget.cpp b/src/widgets/tooltipwidget.cpp index cd502a3ca..cdb41ec31 100644 --- a/src/widgets/tooltipwidget.cpp +++ b/src/widgets/tooltipwidget.cpp @@ -20,7 +20,7 @@ TooltipWidget::TooltipWidget(BaseWidget *parent) palette.setColor(QPalette::Background, black); this->setPalette(palette); this->setWindowOpacity(0.8); - this->setFont(FontManager::getInstance().getFont(FontManager::Type::MediumSmall, + this->setFont(singletons::FontManager::getInstance().getFont(singletons::FontManager::Type::MediumSmall, this->getDpiMultiplier())); this->setAttribute(Qt::WA_ShowWithoutActivating); @@ -32,8 +32,8 @@ TooltipWidget::TooltipWidget(BaseWidget *parent) layout->addWidget(displayText); this->setLayout(layout); - FontManager::getInstance().fontChanged.connect([this] { - this->setFont(FontManager::getInstance().getFont(FontManager::Type::MediumSmall, + singletons::FontManager::getInstance().fontChanged.connect([this] { + this->setFont(singletons::FontManager::getInstance().getFont(singletons::FontManager::Type::MediumSmall, this->getDpiMultiplier())); }); } diff --git a/src/widgets/window.cpp b/src/widgets/window.cpp index 7d52d43d7..d9bd6e42e 100644 --- a/src/widgets/window.cpp +++ b/src/widgets/window.cpp @@ -14,7 +14,7 @@ namespace chatterino { namespace widgets { -Window::Window(const QString &windowName, ThemeManager &_themeManager, bool _isMainWindow) +Window::Window(const QString &windowName, singletons::ThemeManager &_themeManager, bool _isMainWindow) : BaseWidget(_themeManager, nullptr) , settingRoot(fS("/windows/{}", windowName)) , windowGeometry(this->settingRoot) @@ -24,7 +24,7 @@ Window::Window(const QString &windowName, ThemeManager &_themeManager, bool _isM { this->initAsWindow(); - AccountManager::getInstance().Twitch.currentUsername.connect( + singletons::AccountManager::getInstance().Twitch.currentUsername.connect( [this](const std::string &newUsername, auto) { if (newUsername.empty()) { this->refreshWindowTitle("Not logged in"); diff --git a/src/widgets/window.hpp b/src/widgets/window.hpp index 11a31cf5f..6c16075c4 100644 --- a/src/widgets/window.hpp +++ b/src/widgets/window.hpp @@ -14,10 +14,9 @@ #include namespace chatterino { - -class ChannelManager; +namespace singletons { class ThemeManager; -class CompletionManager; +} namespace widgets { @@ -45,7 +44,7 @@ class Window : public BaseWidget WindowGeometry windowGeometry; public: - explicit Window(const QString &windowName, ThemeManager &_themeManager, bool isMainWindow); + explicit Window(const QString &windowName, singletons::ThemeManager &_themeManager, bool isMainWindow); void repaintVisibleChatWidgets(Channel *channel = nullptr); @@ -59,7 +58,7 @@ protected: virtual void closeEvent(QCloseEvent *event) override; private: - ThemeManager &themeManager; + singletons::ThemeManager &themeManager; float dpi;