From 54eb07e11693c2f5a24eda1f02e715b098a2e736 Mon Sep 17 00:00:00 2001 From: fourtf Date: Tue, 26 Jun 2018 17:06:17 +0200 Subject: [PATCH] removed namespaces --- src/Application.cpp | 65 +++++++------- src/Application.hpp | 32 +++---- src/common/Channel.cpp | 14 +-- src/common/Channel.hpp | 22 ++--- src/common/CompletionModel.cpp | 6 +- src/common/Emotemap.cpp | 6 +- src/common/Emotemap.hpp | 10 +-- src/common/NetworkRequest.hpp | 12 +-- src/common/SignalVector2.hpp | 10 +-- src/common/SignalVectorModel.hpp | 2 +- src/common/UrlFetch.hpp | 22 ++--- .../accounts/AccountController.hpp | 4 +- src/controllers/accounts/AccountModel.cpp | 6 +- src/controllers/accounts/AccountModel.hpp | 2 +- .../commands/CommandController.cpp | 39 ++++----- .../commands/CommandController.hpp | 2 +- src/controllers/commands/CommandModel.cpp | 2 +- src/controllers/commands/CommandModel.hpp | 2 +- .../highlights/HighlightController.cpp | 4 +- .../highlights/HighlightController.hpp | 8 +- src/controllers/highlights/HighlightModel.cpp | 16 ++-- src/controllers/highlights/HighlightModel.hpp | 2 +- .../highlights/HighlightPhrase.hpp | 12 +-- src/controllers/ignores/IgnoreController.hpp | 4 +- src/controllers/ignores/IgnoreModel.cpp | 6 +- src/controllers/ignores/IgnoreModel.hpp | 2 +- src/controllers/ignores/IgnorePhrase.hpp | 12 +-- .../taggedusers/TaggedUsersController.hpp | 2 +- .../taggedusers/TaggedUsersModel.cpp | 10 +-- .../taggedusers/TaggedUsersModel.hpp | 2 +- src/main.cpp | 18 ++-- src/messages/Image.cpp | 36 ++++---- src/messages/LimitedQueue.hpp | 2 +- src/messages/Message.cpp | 16 ++-- src/messages/Message.hpp | 12 +-- src/messages/MessageColor.cpp | 2 +- src/messages/MessageColor.hpp | 2 +- src/messages/MessageElement.cpp | 8 +- src/messages/MessageElement.hpp | 8 +- src/messages/layouts/MessageLayout.cpp | 8 +- src/messages/layouts/MessageLayout.hpp | 2 +- src/messages/layouts/MessageLayoutElement.cpp | 4 +- src/providers/bttv/BttvEmotes.cpp | 24 +++--- src/providers/bttv/BttvEmotes.hpp | 8 +- src/providers/emoji/Emojis.cpp | 16 ++-- src/providers/emoji/Emojis.hpp | 6 +- src/providers/ffz/FfzEmotes.cpp | 18 ++-- src/providers/ffz/FfzEmotes.hpp | 8 +- src/providers/irc/AbstractIrcServer.cpp | 2 +- src/providers/twitch/IrcMessageHandler.cpp | 36 ++++---- src/providers/twitch/Pubsub.cpp | 86 +++++++++---------- src/providers/twitch/Pubsub.hpp | 6 +- src/providers/twitch/PubsubHelpers.cpp | 2 +- src/providers/twitch/PubsubHelpers.hpp | 6 +- src/providers/twitch/TwitchAccount.cpp | 22 ++--- src/providers/twitch/TwitchAccount.hpp | 2 +- src/providers/twitch/TwitchAccountManager.cpp | 12 +-- src/providers/twitch/TwitchAccountManager.hpp | 9 +- src/providers/twitch/TwitchChannel.cpp | 48 +++++------ src/providers/twitch/TwitchChannel.hpp | 6 +- src/providers/twitch/TwitchEmotes.cpp | 56 ++++++------ src/providers/twitch/TwitchEmotes.hpp | 10 +-- src/providers/twitch/TwitchHelpers.cpp | 2 +- src/providers/twitch/TwitchMessageBuilder.cpp | 53 ++++++------ src/providers/twitch/TwitchMessageBuilder.hpp | 12 +-- src/providers/twitch/TwitchServer.cpp | 8 +- src/providers/twitch/TwitchServer.hpp | 7 +- src/singletons/EmoteManager.hpp | 8 +- src/singletons/FontManager.cpp | 6 +- src/singletons/FontManager.hpp | 2 +- src/singletons/LoggingManager.cpp | 2 +- src/singletons/LoggingManager.hpp | 2 +- src/singletons/NativeMessagingManager.cpp | 12 +-- src/singletons/PathManager.cpp | 4 +- src/singletons/ResourceManager.cpp | 80 ++++++++--------- src/singletons/ResourceManager.hpp | 60 ++++++------- src/singletons/SettingsManager.cpp | 6 +- src/singletons/SettingsManager.hpp | 4 +- src/singletons/UpdateManager.cpp | 16 ++-- src/singletons/WindowManager.cpp | 72 ++++++++-------- src/singletons/WindowManager.hpp | 16 ++-- src/singletons/helper/LoggingChannel.cpp | 6 +- src/singletons/helper/LoggingChannel.hpp | 2 +- src/singletons/helper/ModerationAction.cpp | 4 +- src/singletons/helper/ModerationAction.hpp | 6 +- src/util/StreamLink.cpp | 2 +- src/widgets/AttachedWindow.cpp | 6 +- src/widgets/BaseWidget.hpp | 2 +- src/widgets/BaseWindow.cpp | 19 ++-- src/widgets/Scrollbar.cpp | 2 +- src/widgets/Scrollbar.hpp | 6 +- src/widgets/StreamView.cpp | 2 +- src/widgets/TooltipWidget.cpp | 2 +- src/widgets/Window.cpp | 4 +- src/widgets/dialogs/EmotePopup.cpp | 18 ++-- src/widgets/dialogs/EmotePopup.hpp | 2 +- src/widgets/dialogs/LastRunCrashDialog.cpp | 26 +++--- src/widgets/dialogs/LoginDialog.cpp | 2 +- src/widgets/dialogs/NotificationPopup.cpp | 2 +- src/widgets/dialogs/NotificationPopup.hpp | 2 +- src/widgets/dialogs/QualityPopup.cpp | 6 +- src/widgets/dialogs/SelectChannelDialog.cpp | 6 +- src/widgets/dialogs/SettingsDialog.cpp | 32 +++---- src/widgets/dialogs/SettingsDialog.hpp | 2 +- src/widgets/dialogs/UserInfoPopup.cpp | 20 ++--- src/widgets/helper/ChannelView.cpp | 60 ++++++------- src/widgets/helper/ChannelView.hpp | 38 ++++---- src/widgets/helper/DebugPopup.cpp | 2 +- src/widgets/helper/NotebookTab.cpp | 8 +- src/widgets/helper/SearchPopup.cpp | 2 +- src/widgets/helper/SearchPopup.hpp | 2 +- src/widgets/helper/SettingsDialogTab.cpp | 4 +- src/widgets/helper/SettingsDialogTab.hpp | 6 +- src/widgets/settingspages/AboutPage.cpp | 4 +- src/widgets/settingspages/AccountsPage.cpp | 6 +- src/widgets/settingspages/AppearancePage.cpp | 14 +-- src/widgets/settingspages/BehaviourPage.cpp | 2 +- .../settingspages/BrowserextensionPage.cpp | 2 +- src/widgets/settingspages/CommandPage.cpp | 8 +- src/widgets/settingspages/EmotesPage.cpp | 4 +- .../settingspages/ExternaltoolsPage.cpp | 2 +- .../settingspages/HighlightingPage.cpp | 8 +- src/widgets/settingspages/IgnoreusersPage.cpp | 8 +- .../settingspages/KeyboardsettingsPage.cpp | 2 +- src/widgets/settingspages/LogsPage.cpp | 2 +- src/widgets/settingspages/ModerationPage.cpp | 6 +- .../settingspages/SpecialChannelsPage.cpp | 2 +- src/widgets/splits/Split.cpp | 8 +- src/widgets/splits/SplitColumn.hpp | 4 +- src/widgets/splits/SplitContainer.cpp | 18 ++-- src/widgets/splits/SplitHeader.cpp | 4 +- src/widgets/splits/SplitInput.cpp | 10 +-- 132 files changed, 805 insertions(+), 823 deletions(-) diff --git a/src/Application.cpp b/src/Application.cpp index 7d2df20f9..1e32fc01b 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -54,22 +54,22 @@ void Application::construct() isAppConstructed = true; // 1. Instantiate all classes - this->settings = new singletons::SettingManager; - this->paths = singletons::PathManager::getInstance(); - this->themes = new singletons::ThemeManager; - this->windows = new singletons::WindowManager; - this->logging = new singletons::LoggingManager; - this->commands = new controllers::commands::CommandController; - this->highlights = new controllers::highlights::HighlightController; - this->ignores = new controllers::ignores::IgnoreController; - this->taggedUsers = new controllers::taggedusers::TaggedUsersController; - this->accounts = new controllers::accounts::AccountController; - this->emotes = new singletons::EmoteManager; - this->fonts = new singletons::FontManager; - this->resources = new singletons::ResourceManager; + this->settings = new chatterino::SettingManager; + this->paths = chatterino::PathManager::getInstance(); + this->themes = new chatterino::ThemeManager; + this->windows = new chatterino::WindowManager; + this->logging = new chatterino::LoggingManager; + this->commands = new CommandController; + this->highlights = new HighlightController; + this->ignores = new IgnoreController; + this->taggedUsers = new TaggedUsersController; + this->accounts = new AccountController; + this->emotes = new chatterino::EmoteManager; + this->fonts = new chatterino::FontManager; + this->resources = new chatterino::ResourceManager; - this->twitch.server = new providers::twitch::TwitchServer; - this->twitch.pubsub = new providers::twitch::PubSub; + this->twitch.server = new TwitchServer; + this->twitch.pubsub = new PubSub; } void Application::instantiate(int argc, char **argv) @@ -119,11 +119,11 @@ void Application::initialize() #endif this->twitch.pubsub->sig.whisper.sent.connect([](const auto &msg) { - debug::Log("WHISPER SENT LOL"); // + Log("WHISPER SENT LOL"); // }); this->twitch.pubsub->sig.whisper.received.connect([](const auto &msg) { - debug::Log("WHISPER RECEIVED LOL"); // + Log("WHISPER RECEIVED LOL"); // }); this->twitch.pubsub->sig.moderation.chatCleared.connect([this](const auto &action) { @@ -134,8 +134,8 @@ void Application::initialize() QString text = QString("%1 cleared the chat").arg(action.source.name); - auto msg = messages::Message::createSystemMessage(text); - util::postToThread([chan, msg] { chan->addMessage(msg); }); + auto msg = chatterino::Message::createSystemMessage(text); + postToThread([chan, msg] { chan->addMessage(msg); }); }); this->twitch.pubsub->sig.moderation.modeChanged.connect([this](const auto &action) { @@ -144,18 +144,17 @@ void Application::initialize() return; } - QString text = - QString("%1 turned %2 %3 mode") // - .arg(action.source.name) - .arg(action.state == providers::twitch::ModeChangedAction::State::On ? "on" : "off") - .arg(action.getModeName()); + QString text = QString("%1 turned %2 %3 mode") // + .arg(action.source.name) + .arg(action.state == ModeChangedAction::State::On ? "on" : "off") + .arg(action.getModeName()); if (action.duration > 0) { text.append(" (" + QString::number(action.duration) + " seconds)"); } - auto msg = messages::Message::createSystemMessage(text); - util::postToThread([chan, msg] { chan->addMessage(msg); }); + auto msg = chatterino::Message::createSystemMessage(text); + postToThread([chan, msg] { chan->addMessage(msg); }); }); this->twitch.pubsub->sig.moderation.moderationStateChanged.connect([this](const auto &action) { @@ -172,8 +171,8 @@ void Application::initialize() text = QString("%1 unmodded %2").arg(action.source.name, action.target.name); } - auto msg = messages::Message::createSystemMessage(text); - util::postToThread([chan, msg] { chan->addMessage(msg); }); + auto msg = chatterino::Message::createSystemMessage(text); + postToThread([chan, msg] { chan->addMessage(msg); }); }); this->twitch.pubsub->sig.moderation.userBanned.connect([&](const auto &action) { @@ -183,10 +182,10 @@ void Application::initialize() return; } - auto msg = messages::Message::createTimeoutMessage(action); - msg->flags |= messages::Message::PubSub; + auto msg = chatterino::Message::createTimeoutMessage(action); + msg->flags |= chatterino::Message::PubSub; - util::postToThread([chan, msg] { chan->addOrReplaceTimeout(msg); }); + postToThread([chan, msg] { chan->addOrReplaceTimeout(msg); }); }); this->twitch.pubsub->sig.moderation.userUnbanned.connect([&](const auto &action) { @@ -196,9 +195,9 @@ void Application::initialize() return; } - auto msg = messages::Message::createUntimeoutMessage(action); + auto msg = chatterino::Message::createUntimeoutMessage(action); - util::postToThread([chan, msg] { chan->addMessage(msg); }); + postToThread([chan, msg] { chan->addMessage(msg); }); }); this->twitch.pubsub->start(); diff --git a/src/Application.hpp b/src/Application.hpp index d320d99e3..36662c20a 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -44,25 +44,25 @@ public: friend void test(); - singletons::PathManager *paths = nullptr; - singletons::ThemeManager *themes = nullptr; - singletons::WindowManager *windows = nullptr; - singletons::LoggingManager *logging = nullptr; - controllers::commands::CommandController *commands = nullptr; - controllers::highlights::HighlightController *highlights = nullptr; - controllers::ignores::IgnoreController *ignores = nullptr; - controllers::taggedusers::TaggedUsersController *taggedUsers = nullptr; - controllers::accounts::AccountController *accounts = nullptr; - singletons::EmoteManager *emotes = nullptr; - singletons::NativeMessagingManager *nativeMessaging = nullptr; - singletons::SettingManager *settings = nullptr; - singletons::FontManager *fonts = nullptr; - singletons::ResourceManager *resources = nullptr; + chatterino::PathManager *paths = nullptr; + chatterino::ThemeManager *themes = nullptr; + chatterino::WindowManager *windows = nullptr; + chatterino::LoggingManager *logging = nullptr; + CommandController *commands = nullptr; + HighlightController *highlights = nullptr; + IgnoreController *ignores = nullptr; + TaggedUsersController *taggedUsers = nullptr; + AccountController *accounts = nullptr; + chatterino::EmoteManager *emotes = nullptr; + chatterino::NativeMessagingManager *nativeMessaging = nullptr; + chatterino::SettingManager *settings = nullptr; + chatterino::FontManager *fonts = nullptr; + chatterino::ResourceManager *resources = nullptr; /// Provider-specific struct { - providers::twitch::TwitchServer *server = nullptr; - providers::twitch::PubSub *pubsub = nullptr; + TwitchServer *server = nullptr; + PubSub *pubsub = nullptr; } twitch; void save(); diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index 5d6e4e7a4..96cecc1a7 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -53,7 +53,7 @@ bool Channel::isEmpty() const return this->name.isEmpty(); } -messages::LimitedQueueSnapshot Channel::getMessageSnapshot() +chatterino::LimitedQueueSnapshot Channel::getMessageSnapshot() { return this->messages.getSnapshot(); } @@ -81,7 +81,7 @@ void Channel::addMessage(MessagePtr message) this->messageAppended.invoke(message); } -void Channel::addOrReplaceTimeout(messages::MessagePtr message) +void Channel::addOrReplaceTimeout(chatterino::MessagePtr message) { LimitedQueueSnapshot snapshot = this->getMessageSnapshot(); int snapshotLength = snapshot.getLength(); @@ -118,7 +118,7 @@ void Channel::addOrReplaceTimeout(messages::MessagePtr message) int count = s->count + 1; - messages::MessagePtr replacement(Message::createSystemMessage( + chatterino::MessagePtr replacement(Message::createSystemMessage( message->searchText + QString(" (") + QString::number(count) + " times)")); replacement->timeoutUser = message->timeoutUser; @@ -162,16 +162,16 @@ void Channel::disableAllMessages() } } -void Channel::addMessagesAtStart(std::vector &_messages) +void Channel::addMessagesAtStart(std::vector &_messages) { - std::vector addedMessages = this->messages.pushFront(_messages); + std::vector addedMessages = this->messages.pushFront(_messages); if (addedMessages.size() != 0) { this->messagesAddedAtStart.invoke(addedMessages); } } -void Channel::replaceMessage(messages::MessagePtr message, messages::MessagePtr replacement) +void Channel::replaceMessage(chatterino::MessagePtr message, chatterino::MessagePtr replacement) { int index = this->messages.replaceItem(message, replacement); @@ -180,7 +180,7 @@ void Channel::replaceMessage(messages::MessagePtr message, messages::MessagePtr } } -void Channel::addRecentChatter(const std::shared_ptr &message) +void Channel::addRecentChatter(const std::shared_ptr &message) { // Do nothing by default } diff --git a/src/common/Channel.hpp b/src/common/Channel.hpp index db9d3bf01..f07a2b188 100644 --- a/src/common/Channel.hpp +++ b/src/common/Channel.hpp @@ -35,23 +35,23 @@ public: pajlada::Signals::Signal sendMessageSignal; - pajlada::Signals::Signal messageRemovedFromStart; - pajlada::Signals::Signal messageAppended; - pajlada::Signals::Signal &> messagesAddedAtStart; - pajlada::Signals::Signal messageReplaced; + pajlada::Signals::Signal messageRemovedFromStart; + pajlada::Signals::Signal messageAppended; + pajlada::Signals::Signal &> messagesAddedAtStart; + pajlada::Signals::Signal messageReplaced; pajlada::Signals::NoArgSignal destroyed; Type getType() const; bool isTwitchChannel() const; virtual bool isEmpty() const; - messages::LimitedQueueSnapshot getMessageSnapshot(); + chatterino::LimitedQueueSnapshot getMessageSnapshot(); - void addMessage(messages::MessagePtr message); - void addMessagesAtStart(std::vector &messages); - void addOrReplaceTimeout(messages::MessagePtr message); + void addMessage(chatterino::MessagePtr message); + void addMessagesAtStart(std::vector &messages); + void addOrReplaceTimeout(chatterino::MessagePtr message); void disableAllMessages(); - void replaceMessage(messages::MessagePtr message, messages::MessagePtr replacement); - virtual void addRecentChatter(const std::shared_ptr &message); + void replaceMessage(chatterino::MessagePtr message, chatterino::MessagePtr replacement); + virtual void addRecentChatter(const std::shared_ptr &message); QString name; QStringList modList; @@ -69,7 +69,7 @@ protected: virtual void onConnected(); private: - messages::LimitedQueue messages; + chatterino::LimitedQueue messages; Type type; }; diff --git a/src/common/CompletionModel.cpp b/src/common/CompletionModel.cpp index af6f5961c..62472b9eb 100644 --- a/src/common/CompletionModel.cpp +++ b/src/common/CompletionModel.cpp @@ -19,7 +19,7 @@ CompletionModel::CompletionModel(const QString &_channelName) void CompletionModel::refresh() { - debug::Log("[CompletionModel:{}] Refreshing...]", this->channelName); + Log("[CompletionModel:{}] Refreshing...]", this->channelName); auto app = getApp(); @@ -75,7 +75,7 @@ void CompletionModel::refresh() // Channel-specific: Usernames // fourtf: only works with twitch chat - // auto c = singletons::ChannelManager::getInstance().getTwitchChannel(this->channelName); + // auto c = chatterino::ChannelManager::getInstance().getTwitchChannel(this->channelName); // auto usernames = c->getUsernamesForCompletions(); // for (const auto &name : usernames) { // assert(!name.displayName.isEmpty()); @@ -131,7 +131,7 @@ void CompletionModel::ClearExpiredStrings() const auto &taggedString = *it; if (taggedString.HasExpired(now)) { - // debug::Log("String {} expired", taggedString.str); + // Log("String {} expired", taggedString.str); it = this->emotes.erase(it); } else { ++it; diff --git a/src/common/Emotemap.cpp b/src/common/Emotemap.cpp index b55b1bf20..a04c037eb 100644 --- a/src/common/Emotemap.cpp +++ b/src/common/Emotemap.cpp @@ -5,7 +5,7 @@ namespace chatterino { -EmoteData::EmoteData(messages::Image *_image) +EmoteData::EmoteData(chatterino::Image *_image) : image1x(_image) { } @@ -16,7 +16,7 @@ bool EmoteData::isValid() const return this->image1x != nullptr; } -messages::Image *EmoteData::getImage(float scale) const +chatterino::Image *EmoteData::getImage(float scale) const { int quality = getApp()->settings->preferredEmoteQuality; @@ -31,7 +31,7 @@ messages::Image *EmoteData::getImage(float scale) const }(); } - messages::Image *_image; + chatterino::Image *_image; if (quality == 3 && this->image3x != nullptr) { _image = this->image3x; } else if (quality >= 2 && this->image2x != nullptr) { diff --git a/src/common/Emotemap.hpp b/src/common/Emotemap.hpp index 87217b28b..2f25d0071 100644 --- a/src/common/Emotemap.hpp +++ b/src/common/Emotemap.hpp @@ -8,15 +8,15 @@ namespace chatterino { struct EmoteData { EmoteData() = default; - EmoteData(messages::Image *_image); + EmoteData(chatterino::Image *_image); // Emotes must have a 1x image to be valid bool isValid() const; - messages::Image *getImage(float scale) const; + chatterino::Image *getImage(float scale) const; - messages::Image *image1x = nullptr; - messages::Image *image2x = nullptr; - messages::Image *image3x = nullptr; + chatterino::Image *image1x = nullptr; + chatterino::Image *image2x = nullptr; + chatterino::Image *image3x = nullptr; // Link to the emote page i.e. https://www.frankerfacez.com/emoticon/144722-pajaCringe QString pageLink; diff --git a/src/common/NetworkRequest.hpp b/src/common/NetworkRequest.hpp index 62b79ad58..bb8766ab2 100644 --- a/src/common/NetworkRequest.hpp +++ b/src/common/NetworkRequest.hpp @@ -31,7 +31,7 @@ static rapidjson::Document parseJSONFromData2(const QByteArray &data) rapidjson::ParseResult result = ret.Parse(data.data(), data.length()); if (result.Code() != rapidjson::kParseErrorNone) { - debug::Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()), + Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()), result.Offset()); return ret; } @@ -51,7 +51,7 @@ static rapidjson::Document parseJSONFromReply2(QNetworkReply *reply) rapidjson::ParseResult result = ret.Parse(data.data(), data.length()); if (result.Code() != rapidjson::kParseErrorNone) { - debug::Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()), + Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()), result.Offset()); return ret; } @@ -242,7 +242,7 @@ public: if (timer != nullptr) { QObject::connect(timer, &QTimer::timeout, worker, [reply, timer]() { - debug::Log("Aborted!"); + Log("Aborted!"); reply->abort(); timer->deleteLater(); }); @@ -314,7 +314,7 @@ public: } break; default: { - debug::Log("[Execute] Unhandled request type {}", (int)this->data.requestType); + Log("[Execute] Unhandled request type {}", (int)this->data.requestType); } break; } } @@ -407,14 +407,14 @@ private: } if (reply == nullptr) { - debug::Log("Unhandled request type {}", (int)data.requestType); + Log("Unhandled request type {}", (int)data.requestType); return; } if (timer != nullptr) { QObject::connect(timer, &QTimer::timeout, worker, [reply, timer, data]() { - debug::Log("Aborted!"); + Log("Aborted!"); reply->abort(); timer->deleteLater(); data.onError(-2); diff --git a/src/common/SignalVector2.hpp b/src/common/SignalVector2.hpp index 21c6dbeba..f479cd85b 100644 --- a/src/common/SignalVector2.hpp +++ b/src/common/SignalVector2.hpp @@ -36,14 +36,14 @@ public: const std::vector &getVector() const { - util::assertInGuiThread(); + assertInGuiThread(); return this->vector; } void invokeDelayedItemsChanged() { - util::assertInGuiThread(); + assertInGuiThread(); if (!this->itemsChangedTimer.isActive()) { itemsChangedTimer.start(); @@ -64,7 +64,7 @@ public: void removeItem(int index, void *caller = 0) { - util::assertInGuiThread(); + assertInGuiThread(); assert(index >= 0 && index < this->vector.size()); TVectorItem item = this->vector[index]; @@ -87,7 +87,7 @@ class UnsortedSignalVector : public BaseSignalVector public: virtual int insertItem(const TVectorItem &item, int index = -1, void *caller = 0) override { - util::assertInGuiThread(); + assertInGuiThread(); if (index == -1) { index = this->vector.size(); } else { @@ -109,7 +109,7 @@ class SortedSignalVector : public BaseSignalVector public: virtual int insertItem(const TVectorItem &item, int = -1, void *caller = nullptr) override { - util::assertInGuiThread(); + assertInGuiThread(); auto it = std::lower_bound(this->vector.begin(), this->vector.end(), item, Compare{}); int index = it - this->vector.begin(); diff --git a/src/common/SignalVectorModel.hpp b/src/common/SignalVectorModel.hpp index 14732e255..6b664548a 100644 --- a/src/common/SignalVectorModel.hpp +++ b/src/common/SignalVectorModel.hpp @@ -23,7 +23,7 @@ public: } } - void init(util::BaseSignalVector *vec) + void init(BaseSignalVector *vec) { this->vector = vec; diff --git a/src/common/UrlFetch.hpp b/src/common/UrlFetch.hpp index b713bb3a6..a1b3e204e 100644 --- a/src/common/UrlFetch.hpp +++ b/src/common/UrlFetch.hpp @@ -1,10 +1,10 @@ #pragma once -#include "controllers/accounts/AccountController.hpp" -#include "providers/twitch/Credentials.hpp" -#include "debug/Log.hpp" #include "common/NetworkManager.hpp" #include "common/NetworkRequest.hpp" +#include "controllers/accounts/AccountController.hpp" +#include "debug/Log.hpp" +#include "providers/twitch/Credentials.hpp" #include #include @@ -26,7 +26,7 @@ namespace chatterino { static void get(QString url, const QObject *caller, std::function successCallback) { - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(caller); req.setRawHeader("Client-ID", getDefaultClientID()); req.setRawHeader("Accept", "application/vnd.twitchtv.v5+json"); @@ -39,7 +39,7 @@ static void get(QString url, const QObject *caller, static void get2(QString url, const QObject *caller, bool useQuickLoadCache, std::function successCallback) { - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(caller); req.setRawHeader("Client-ID", getDefaultClientID()); req.setRawHeader("Accept", "application/vnd.twitchtv.v5+json"); @@ -54,7 +54,7 @@ static void getAuthorized(QString url, const QString &clientID, const QString &o const QObject *caller, std::function successCallback) { - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(caller); req.setRawHeader("Client-ID", clientID.toUtf8()); req.setRawHeader("Authorization", "OAuth " + oauthToken.toUtf8()); @@ -71,24 +71,24 @@ static void getUserID(QString username, const QObject *caller, get("https://api.twitch.tv/kraken/users?login=" + username, caller, [=](const QJsonObject &root) { if (!root.value("users").isArray()) { - debug::Log("API Error while getting user id, users is not an array"); + Log("API Error while getting user id, users is not an array"); return; } auto users = root.value("users").toArray(); if (users.size() != 1) { - debug::Log("API Error while getting user id, users array size is not 1"); + Log("API Error while getting user id, users array size is not 1"); return; } if (!users[0].isObject()) { - debug::Log("API Error while getting user id, first user is not an object"); + Log("API Error while getting user id, first user is not an object"); return; } auto firstUser = users[0].toObject(); auto id = firstUser.value("_id"); if (!id.isString()) { - debug::Log("API Error: while getting user id, first user object `_id` key is not a " - "string"); + Log("API Error: while getting user id, first user object `_id` key is not a " + "string"); return; } successCallback(id.toString()); diff --git a/src/controllers/accounts/AccountController.hpp b/src/controllers/accounts/AccountController.hpp index 4ceb67e9d..937bda3d7 100644 --- a/src/controllers/accounts/AccountController.hpp +++ b/src/controllers/accounts/AccountController.hpp @@ -20,10 +20,10 @@ public: void load(); - providers::twitch::TwitchAccountManager twitch; + TwitchAccountManager twitch; private: - util::SortedSignalVector, util::SharedPtrElementLess> + SortedSignalVector, SharedPtrElementLess> accounts; }; diff --git a/src/controllers/accounts/AccountModel.cpp b/src/controllers/accounts/AccountModel.cpp index b8589e2f6..3302f59b4 100644 --- a/src/controllers/accounts/AccountModel.cpp +++ b/src/controllers/accounts/AccountModel.cpp @@ -5,7 +5,7 @@ namespace chatterino { AccountModel::AccountModel(QObject *parent) - : util::SignalVectorModel>(1, parent) + : SignalVectorModel>(1, parent) { } @@ -20,7 +20,7 @@ std::shared_ptr AccountModel::getItemFromRow(std::vector &item, std::vector &row) { - util::setStringItem(row[0], item->toString(), false); + setStringItem(row[0], item->toString(), false); row[0]->setData(QFont("Segoe UI", 10), Qt::FontRole); } @@ -30,7 +30,7 @@ int AccountModel::beforeInsert(const std::shared_ptr &item, if (this->categoryCount[item->getCategory()]++ == 0) { auto row = this->createRow(); - util::setStringItem(row[0], item->getCategory(), false, false); + setStringItem(row[0], item->getCategory(), false, false); row[0]->setData(QFont("Segoe UI Light", 16), Qt::FontRole); this->insertCustomRow(std::move(row), proposedIndex); diff --git a/src/controllers/accounts/AccountModel.hpp b/src/controllers/accounts/AccountModel.hpp index e631ec2a7..38f7b2f4a 100644 --- a/src/controllers/accounts/AccountModel.hpp +++ b/src/controllers/accounts/AccountModel.hpp @@ -10,7 +10,7 @@ namespace chatterino { class AccountController; -class AccountModel : public util::SignalVectorModel> +class AccountModel : public SignalVectorModel> { public: AccountModel(QObject *parent); diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index a92b80300..ad53c094e 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -23,8 +23,6 @@ "/followersoff" \ } -using namespace chatterino::providers::twitch; - namespace chatterino { CommandController::CommandController() @@ -72,8 +70,7 @@ void CommandController::save() { QFile textFile(this->filePath); if (!textFile.open(QIODevice::WriteOnly)) { - debug::Log("[CommandController::saveCommands] Unable to open {} for writing", - this->filePath); + Log("[CommandController::saveCommands] Unable to open {} for writing", this->filePath); return; } @@ -115,17 +112,15 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, auto app = getApp(); - messages::MessageBuilder b; + MessageBuilder b; - b.emplace(); - b.emplace(app->accounts->twitch.getCurrent()->getUserName(), - messages::MessageElement::Text, - messages::MessageColor::Text, - FontStyle::ChatMediumBold); - b.emplace("->", messages::MessageElement::Text); - b.emplace(words[1] + ":", messages::MessageElement::Text, - messages::MessageColor::Text, - FontStyle::ChatMediumBold); + b.emplace(); + b.emplace(app->accounts->twitch.getCurrent()->getUserName(), + MessageElement::Text, MessageColor::Text, + FontStyle::ChatMediumBold); + b.emplace("->", MessageElement::Text); + b.emplace(words[1] + ":", MessageElement::Text, MessageColor::Text, + FontStyle::ChatMediumBold); QString rest = ""; @@ -133,8 +128,8 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, rest += words[i] + " "; } - b.emplace(rest, messages::MessageElement::Text); - b.getMessage()->flags |= messages::Message::DoNotTriggerNotification; + b.emplace(rest, MessageElement::Text); + b.getMessage()->flags |= Message::DoNotTriggerNotification; app->twitch.server->whispersChannel->addMessage(b.getMessage()); @@ -157,7 +152,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, if (commandName == "/debug-args") { QString msg = QApplication::instance()->arguments().join(' '); - channel->addMessage(messages::Message::createSystemMessage(msg)); + channel->addMessage(chatterino::Message::createSystemMessage(msg)); return ""; } else if (commandName == "/uptime") { @@ -166,7 +161,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, QString messageText = streamStatus.live ? streamStatus.uptime : "Channel is not live."; - channel->addMessage(messages::Message::createSystemMessage(messageText)); + channel->addMessage(chatterino::Message::createSystemMessage(messageText)); return ""; } else if (commandName == "/ignore" && words.size() >= 2) { @@ -176,13 +171,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, auto target = words.at(1); if (user->isAnon()) { - channel->addMessage(messages::Message::createSystemMessage( + channel->addMessage(chatterino::Message::createSystemMessage( "You must be logged in to ignore someone")); return ""; } user->ignore(target, [channel](auto resultCode, const QString &message) { - channel->addMessage(messages::Message::createSystemMessage(message)); + channel->addMessage(chatterino::Message::createSystemMessage(message)); }); return ""; @@ -193,13 +188,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, auto target = words.at(1); if (user->isAnon()) { - channel->addMessage(messages::Message::createSystemMessage( + channel->addMessage(chatterino::Message::createSystemMessage( "You must be logged in to ignore someone")); return ""; } user->unignore(target, [channel](auto resultCode, const QString &message) { - channel->addMessage(messages::Message::createSystemMessage(message)); + channel->addMessage(chatterino::Message::createSystemMessage(message)); }); return ""; diff --git a/src/controllers/commands/CommandController.hpp b/src/controllers/commands/CommandController.hpp index d07532b21..c4055f426 100644 --- a/src/controllers/commands/CommandController.hpp +++ b/src/controllers/commands/CommandController.hpp @@ -26,7 +26,7 @@ public: CommandModel *createModel(QObject *parent); - util::UnsortedSignalVector items; + UnsortedSignalVector items; private: QMap commandsMap; diff --git a/src/controllers/commands/CommandModel.cpp b/src/controllers/commands/CommandModel.cpp index c02be86dc..66e088533 100644 --- a/src/controllers/commands/CommandModel.cpp +++ b/src/controllers/commands/CommandModel.cpp @@ -4,7 +4,7 @@ namespace chatterino { // commandmodel CommandModel::CommandModel(QObject *parent) - : util::SignalVectorModel(2, parent) + : SignalVectorModel(2, parent) { } diff --git a/src/controllers/commands/CommandModel.hpp b/src/controllers/commands/CommandModel.hpp index 7a66c4e91..a1fbeb7a5 100644 --- a/src/controllers/commands/CommandModel.hpp +++ b/src/controllers/commands/CommandModel.hpp @@ -9,7 +9,7 @@ namespace chatterino { class CommandController; -class CommandModel : public util::SignalVectorModel +class CommandModel : public SignalVectorModel { explicit CommandModel(QObject *parent); diff --git a/src/controllers/highlights/HighlightController.cpp b/src/controllers/highlights/HighlightController.cpp index 10ebeded8..b037669d4 100644 --- a/src/controllers/highlights/HighlightController.cpp +++ b/src/controllers/highlights/HighlightController.cpp @@ -32,9 +32,9 @@ HighlightModel *HighlightController::createModel(QObject *parent) return model; } -void HighlightController::addHighlight(const messages::MessagePtr &msg) +void HighlightController::addHighlight(const chatterino::MessagePtr &msg) { - // static widgets::NotificationPopup popup; + // static NotificationPopup popup; // popup.updatePosition(); // popup.addMessage(msg); diff --git a/src/controllers/highlights/HighlightController.hpp b/src/controllers/highlights/HighlightController.hpp index d2cb2b825..20239ae45 100644 --- a/src/controllers/highlights/HighlightController.hpp +++ b/src/controllers/highlights/HighlightController.hpp @@ -1,9 +1,9 @@ #pragma once +#include "common/SignalVector2.hpp" #include "controllers/highlights/HighlightPhrase.hpp" #include "messages/Message.hpp" #include "singletons/SettingsManager.hpp" -#include "common/SignalVector2.hpp" namespace chatterino { @@ -16,16 +16,16 @@ public: void initialize(); - util::UnsortedSignalVector phrases; + UnsortedSignalVector phrases; HighlightModel *createModel(QObject *parent); - void addHighlight(const messages::MessagePtr &msg); + void addHighlight(const chatterino::MessagePtr &msg); private: bool initialized = false; - singletons::ChatterinoSetting> highlightsSetting = { + chatterino::ChatterinoSetting> highlightsSetting = { "/highlighting/highlights"}; }; diff --git a/src/controllers/highlights/HighlightModel.cpp b/src/controllers/highlights/HighlightModel.cpp index 4ddb1defb..b068561df 100644 --- a/src/controllers/highlights/HighlightModel.cpp +++ b/src/controllers/highlights/HighlightModel.cpp @@ -8,7 +8,7 @@ namespace chatterino { // commandmodel HighlightModel::HighlightModel(QObject *parent) - : util::SignalVectorModel(4, parent) + : SignalVectorModel(4, parent) { } @@ -26,19 +26,19 @@ HighlightPhrase HighlightModel::getItemFromRow(std::vector &row // turns a row in the model into a vector item void HighlightModel::getRowFromItem(const HighlightPhrase &item, std::vector &row) { - util::setStringItem(row[0], item.getPattern()); - util::setBoolItem(row[1], item.getAlert()); - util::setBoolItem(row[2], item.getSound()); - util::setBoolItem(row[3], item.isRegex()); + setStringItem(row[0], item.getPattern()); + setBoolItem(row[1], item.getAlert()); + setBoolItem(row[2], item.getSound()); + setBoolItem(row[3], item.isRegex()); } void HighlightModel::afterInit() { std::vector row = this->createRow(); - util::setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true, false); + setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true, false); row[0]->setData("Your username (automatic)", Qt::DisplayRole); - util::setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true, false); - util::setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(), true, false); + setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true, false); + setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(), true, false); row[3]->setFlags(0); this->insertCustomRow(row, 0); } diff --git a/src/controllers/highlights/HighlightModel.hpp b/src/controllers/highlights/HighlightModel.hpp index d9311c325..1d49203a9 100644 --- a/src/controllers/highlights/HighlightModel.hpp +++ b/src/controllers/highlights/HighlightModel.hpp @@ -9,7 +9,7 @@ namespace chatterino { class HighlightController; -class HighlightModel : public util::SignalVectorModel +class HighlightModel : public SignalVectorModel { explicit HighlightModel(QObject *parent); diff --git a/src/controllers/highlights/HighlightPhrase.hpp b/src/controllers/highlights/HighlightPhrase.hpp index 814bee698..d568eb6bd 100644 --- a/src/controllers/highlights/HighlightPhrase.hpp +++ b/src/controllers/highlights/HighlightPhrase.hpp @@ -74,8 +74,8 @@ namespace pajlada { namespace Settings { template <> -struct Serialize { - static rapidjson::Value get(const chatterino::controllers::highlights::HighlightPhrase &value, +struct Serialize { + static rapidjson::Value get(const chatterino::HighlightPhrase &value, rapidjson::Document::AllocatorType &a) { rapidjson::Value ret(rapidjson::kObjectType); @@ -90,11 +90,11 @@ struct Serialize { }; template <> -struct Deserialize { - static chatterino::controllers::highlights::HighlightPhrase get(const rapidjson::Value &value) +struct Deserialize { + static chatterino::HighlightPhrase get(const rapidjson::Value &value) { if (!value.IsObject()) { - return chatterino::controllers::highlights::HighlightPhrase(QString(), true, false, + return chatterino::HighlightPhrase(QString(), true, false, false); } @@ -108,7 +108,7 @@ struct Deserialize { chatterino::rj::getSafe(value, "sound", _sound); chatterino::rj::getSafe(value, "regex", _isRegex); - return chatterino::controllers::highlights::HighlightPhrase(_pattern, _alert, _sound, + return chatterino::HighlightPhrase(_pattern, _alert, _sound, _isRegex); } }; diff --git a/src/controllers/ignores/IgnoreController.hpp b/src/controllers/ignores/IgnoreController.hpp index 4d15878ef..c9d47591f 100644 --- a/src/controllers/ignores/IgnoreController.hpp +++ b/src/controllers/ignores/IgnoreController.hpp @@ -13,14 +13,14 @@ class IgnoreController public: void initialize(); - util::UnsortedSignalVector phrases; + UnsortedSignalVector phrases; IgnoreModel *createModel(QObject *parent); private: bool initialized = false; - singletons::ChatterinoSetting> ignoresSetting = { + chatterino::ChatterinoSetting> ignoresSetting = { "/ignore/phrases"}; }; diff --git a/src/controllers/ignores/IgnoreModel.cpp b/src/controllers/ignores/IgnoreModel.cpp index 6a983c54b..e241a8650 100644 --- a/src/controllers/ignores/IgnoreModel.cpp +++ b/src/controllers/ignores/IgnoreModel.cpp @@ -8,7 +8,7 @@ namespace chatterino { // commandmodel IgnoreModel::IgnoreModel(QObject *parent) - : util::SignalVectorModel(2, parent) + : SignalVectorModel(2, parent) { } @@ -25,8 +25,8 @@ IgnorePhrase IgnoreModel::getItemFromRow(std::vector &row, // turns a row in the model into a vector item void IgnoreModel::getRowFromItem(const IgnorePhrase &item, std::vector &row) { - util::setStringItem(row[0], item.getPattern()); - util::setBoolItem(row[1], item.isRegex()); + setStringItem(row[0], item.getPattern()); + setBoolItem(row[1], item.isRegex()); } } // namespace chatterino diff --git a/src/controllers/ignores/IgnoreModel.hpp b/src/controllers/ignores/IgnoreModel.hpp index f582b9521..74037da4e 100644 --- a/src/controllers/ignores/IgnoreModel.hpp +++ b/src/controllers/ignores/IgnoreModel.hpp @@ -9,7 +9,7 @@ namespace chatterino { class IgnoreController; -class IgnoreModel : public util::SignalVectorModel +class IgnoreModel : public SignalVectorModel { explicit IgnoreModel(QObject *parent); diff --git a/src/controllers/ignores/IgnorePhrase.hpp b/src/controllers/ignores/IgnorePhrase.hpp index aec1a94d5..024358120 100644 --- a/src/controllers/ignores/IgnorePhrase.hpp +++ b/src/controllers/ignores/IgnorePhrase.hpp @@ -57,8 +57,8 @@ namespace pajlada { namespace Settings { template <> -struct Serialize { - static rapidjson::Value get(const chatterino::controllers::ignores::IgnorePhrase &value, +struct Serialize { + static rapidjson::Value get(const chatterino::IgnorePhrase &value, rapidjson::Document::AllocatorType &a) { rapidjson::Value ret(rapidjson::kObjectType); @@ -71,11 +71,11 @@ struct Serialize { }; template <> -struct Deserialize { - static chatterino::controllers::ignores::IgnorePhrase get(const rapidjson::Value &value) +struct Deserialize { + static chatterino::IgnorePhrase get(const rapidjson::Value &value) { if (!value.IsObject()) { - return chatterino::controllers::ignores::IgnorePhrase(QString(), false); + return chatterino::IgnorePhrase(QString(), false); } QString _pattern; @@ -84,7 +84,7 @@ struct Deserialize { chatterino::rj::getSafe(value, "pattern", _pattern); chatterino::rj::getSafe(value, "regex", _isRegex); - return chatterino::controllers::ignores::IgnorePhrase(_pattern, _isRegex); + return chatterino::IgnorePhrase(_pattern, _isRegex); } }; diff --git a/src/controllers/taggedusers/TaggedUsersController.hpp b/src/controllers/taggedusers/TaggedUsersController.hpp index c66d45b86..fd309870c 100644 --- a/src/controllers/taggedusers/TaggedUsersController.hpp +++ b/src/controllers/taggedusers/TaggedUsersController.hpp @@ -12,7 +12,7 @@ class TaggedUsersController public: TaggedUsersController(); - util::SortedSignalVector> users; + SortedSignalVector> users; TaggedUsersModel *createModel(QObject *parent = nullptr); }; diff --git a/src/controllers/taggedusers/TaggedUsersModel.cpp b/src/controllers/taggedusers/TaggedUsersModel.cpp index cfd24e4eb..f0ae0b60f 100644 --- a/src/controllers/taggedusers/TaggedUsersModel.cpp +++ b/src/controllers/taggedusers/TaggedUsersModel.cpp @@ -7,7 +7,7 @@ namespace chatterino { // commandmodel TaggedUsersModel::TaggedUsersModel(QObject *parent) - : util::SignalVectorModel(1, parent) + : SignalVectorModel(1, parent) { } @@ -21,16 +21,16 @@ TaggedUser TaggedUsersModel::getItemFromRow(std::vector &row, // turns a row in the model into a vector item void TaggedUsersModel::getRowFromItem(const TaggedUser &item, std::vector &row) { - util::setStringItem(row[0], item.name); + setStringItem(row[0], item.name); } void TaggedUsersModel::afterInit() { // std::vector row = this->createRow(); - // util::setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true, + // setBoolItem(row[0], getApp()->settings->enableHighlightsSelf.getValue(), true, // false); row[0]->setData("Your username (automatic)", Qt::DisplayRole); - // util::setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true, - // false); util::setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(), + // setBoolItem(row[1], getApp()->settings->enableHighlightTaskbar.getValue(), true, + // false); setBoolItem(row[2], getApp()->settings->enableHighlightSound.getValue(), // true, false); row[3]->setFlags(0); this->insertCustomRow(row, 0); } diff --git a/src/controllers/taggedusers/TaggedUsersModel.hpp b/src/controllers/taggedusers/TaggedUsersModel.hpp index 1b7571176..7465e0fa9 100644 --- a/src/controllers/taggedusers/TaggedUsersModel.hpp +++ b/src/controllers/taggedusers/TaggedUsersModel.hpp @@ -7,7 +7,7 @@ namespace chatterino { class TaggedUsersController; -class TaggedUsersModel : public util::SignalVectorModel +class TaggedUsersModel : public SignalVectorModel { explicit TaggedUsersModel(QObject *parent); diff --git a/src/main.cpp b/src/main.cpp index 9c8727efb..9748fdebc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,9 +1,9 @@ #include "Application.hpp" +#include "common/NetworkManager.hpp" #include "singletons/NativeMessagingManager.hpp" #include "singletons/PathManager.hpp" #include "singletons/UpdateManager.hpp" #include "util/DebugCount.hpp" -#include "common/NetworkManager.hpp" #include "widgets/dialogs/LastRunCrashDialog.hpp" #include @@ -40,7 +40,7 @@ int main(int argc, char *argv[]) // QApplication::setAttribute(Qt::AA_UseSoftwareOpenGL, true); QApplication a(argc, argv); - chatterino::singletons::PathManager::initInstance(); + chatterino::PathManager::initInstance(); // read args QStringList args; @@ -49,10 +49,6 @@ int main(int argc, char *argv[]) args << argv[i]; } - for (auto &arg : args) { - chatterino::util::DebugCount::increase(arg); - } - // TODO: can be any argument if (args.size() > 0 && (args[0].startsWith("chrome-extension://") || args[0].endsWith(".json"))) { @@ -71,10 +67,10 @@ int runGui(QApplication &a, int argc, char *argv[]) installCustomPalette(); // Initialize NetworkManager - chatterino::util::NetworkManager::init(); + chatterino::NetworkManager::init(); // Check for upates - chatterino::singletons::UpdateManager::getInstance().checkForUpdates(); + chatterino::UpdateManager::getInstance().checkForUpdates(); // Initialize application chatterino::Application::instantiate(argc, argv); @@ -88,7 +84,7 @@ int runGui(QApplication &a, int argc, char *argv[]) if (QFile::exists(runningPath)) { #ifndef DISABLE_CRASH_DIALOG - chatterino::widgets::LastRunCrashDialog dialog; + chatterino::LastRunCrashDialog dialog; switch (dialog.exec()) { case QDialog::Accepted: { @@ -122,14 +118,14 @@ int runGui(QApplication &a, int argc, char *argv[]) pajlada::Settings::SettingManager::save(); // Deinitialize NetworkManager (stop thread and wait for finish, should be instant) - chatterino::util::NetworkManager::deinit(); + chatterino::NetworkManager::deinit(); _exit(0); } void runNativeMessagingHost() { - auto *nm = new chatterino::singletons::NativeMessagingManager; + auto *nm = new chatterino::NativeMessagingManager; #ifdef Q_OS_WIN _setmode(_fileno(stdin), _O_BINARY); diff --git a/src/messages/Image.cpp b/src/messages/Image.cpp index 4cc89061a..718d25ef7 100644 --- a/src/messages/Image.cpp +++ b/src/messages/Image.cpp @@ -1,13 +1,13 @@ #include "messages/Image.hpp" #include "Application.hpp" +#include "common/NetworkManager.hpp" +#include "common/UrlFetch.hpp" #include "debug/Log.hpp" #include "singletons/EmoteManager.hpp" #include "singletons/IrcManager.hpp" #include "singletons/WindowManager.hpp" -#include "common/NetworkManager.hpp" #include "util/PostToThread.hpp" -#include "common/UrlFetch.hpp" #include #include @@ -32,7 +32,7 @@ Image::Image(const QString &url, qreal scale, const QString &name, const QString , ishat(isHat) , scale(scale) { - util::DebugCount::increase("images"); + DebugCount::increase("images"); } Image::Image(QPixmap *image, qreal scale, const QString &name, const QString &tooltip, @@ -46,25 +46,25 @@ Image::Image(QPixmap *image, qreal scale, const QString &name, const QString &to , isLoading(true) , isLoaded(true) { - util::DebugCount::increase("images"); + DebugCount::increase("images"); } Image::~Image() { - util::DebugCount::decrease("images"); + DebugCount::decrease("images"); if (this->isAnimated()) { - util::DebugCount::decrease("animated images"); + DebugCount::decrease("animated images"); } if (this->isLoaded) { - util::DebugCount::decrease("loaded images"); + DebugCount::decrease("loaded images"); } } void Image::loadImage() { - util::NetworkRequest req(this->getUrl()); + NetworkRequest req(this->getUrl()); req.setCaller(this); req.setUseQuickLoadCache(true); req.get([this](QByteArray bytes) -> bool { @@ -80,21 +80,21 @@ void Image::loadImage() // clear stuff before loading the image again this->allFrames.clear(); if (this->isAnimated()) { - util::DebugCount::decrease("animated images"); + DebugCount::decrease("animated images"); } if (this->isLoaded) { - util::DebugCount::decrease("loaded images"); + DebugCount::decrease("loaded images"); } if (reader.imageCount() == -1) { // An error occured in the reader - debug::Log("An error occured reading the image: '{}'", reader.errorString()); - debug::Log("Image url: {}", this->url); + Log("An error occured reading the image: '{}'", reader.errorString()); + Log("Image url: {}", this->url); return false; } if (reader.imageCount() == 0) { - debug::Log("Error: No images read in the buffer"); + Log("Error: No images read in the buffer"); // No images read in the buffer. maybe a cache error? return false; } @@ -108,7 +108,7 @@ void Image::loadImage() this->loadedPixmap = pixmap; } - chatterino::messages::Image::FrameData data; + chatterino::Image::FrameData data; data.duration = std::max(20, reader.nextImageDelay()); data.image = pixmap; @@ -117,14 +117,14 @@ void Image::loadImage() } if (this->allFrames.size() != reader.imageCount()) { - // debug::Log("Error: Wrong amount of images read"); + // Log("Error: Wrong amount of images read"); // One or more images failed to load from the buffer // return false; } if (this->allFrames.size() > 1) { if (!this->animated) { - util::postToThread([this] { + postToThread([this] { getApp()->emotes->gifTimer.signal.connect([=]() { this->gifUpdateTimout(); }); // For some reason when Boost signal is in @@ -135,13 +135,13 @@ void Image::loadImage() this->animated = true; - util::DebugCount::increase("animated images"); + DebugCount::increase("animated images"); } this->currentPixmap = this->loadedPixmap; this->isLoaded = true; - util::DebugCount::increase("loaded images"); + DebugCount::increase("loaded images"); if (!loadedEventQueued) { loadedEventQueued = true; diff --git a/src/messages/LimitedQueue.hpp b/src/messages/LimitedQueue.hpp index 7ca1c406f..84474e8fc 100644 --- a/src/messages/LimitedQueue.hpp +++ b/src/messages/LimitedQueue.hpp @@ -200,7 +200,7 @@ public: // void insertAfter(const std::vector &items, const T &index) - messages::LimitedQueueSnapshot getSnapshot() + chatterino::LimitedQueueSnapshot getSnapshot() { std::lock_guard lock(this->mutex); diff --git a/src/messages/Message.cpp b/src/messages/Message.cpp index aeb99dc1a..a7b8a5b8b 100644 --- a/src/messages/Message.cpp +++ b/src/messages/Message.cpp @@ -3,7 +3,7 @@ #include "providers/twitch/PubsubActions.hpp" #include "util/IrcHelpers.hpp" -using SBHighlight = chatterino::widgets::ScrollbarHighlight; +using SBHighlight = chatterino::ScrollbarHighlight; namespace chatterino { @@ -116,7 +116,7 @@ MessagePtr Message::createTimeoutMessage(const QString &username, const QString if (reason.length() > 0) { text.append(": \""); - text.append(util::parseTagString(reason)); + text.append(parseTagString(reason)); text.append("\""); } text.append("."); @@ -132,7 +132,7 @@ MessagePtr Message::createTimeoutMessage(const QString &username, const QString return message; } -MessagePtr Message::createTimeoutMessage(const providers::twitch::BanAction &action, uint32_t count) +MessagePtr Message::createTimeoutMessage(const BanAction &action, uint32_t count) { MessagePtr msg(new Message); @@ -175,14 +175,14 @@ MessagePtr Message::createTimeoutMessage(const providers::twitch::BanAction &act } } - msg->addElement(new messages::TextElement(text, messages::MessageElement::Text, - messages::MessageColor::System)); + msg->addElement(new chatterino::TextElement(text, chatterino::MessageElement::Text, + chatterino::MessageColor::System)); msg->searchText = text; return msg; } -MessagePtr Message::createUntimeoutMessage(const providers::twitch::UnbanAction &action) +MessagePtr Message::createUntimeoutMessage(const UnbanAction &action) { MessagePtr msg(new Message); @@ -204,8 +204,8 @@ MessagePtr Message::createUntimeoutMessage(const providers::twitch::UnbanAction .arg(action.target.name); } - msg->addElement(new messages::TextElement(text, messages::MessageElement::Text, - messages::MessageColor::System)); + msg->addElement(new chatterino::TextElement(text, chatterino::MessageElement::Text, + chatterino::MessageColor::System)); msg->searchText = text; return msg; diff --git a/src/messages/Message.hpp b/src/messages/Message.hpp index 784d2f855..12ad597a4 100644 --- a/src/messages/Message.hpp +++ b/src/messages/Message.hpp @@ -19,12 +19,12 @@ struct Message { Message() : parseTime(QTime::currentTime()) { - util::DebugCount::increase("messages"); + DebugCount::increase("messages"); } ~Message() { - util::DebugCount::decrease("messages"); + DebugCount::decrease("messages"); } enum MessageFlags : uint16_t { @@ -43,7 +43,7 @@ struct Message { Subscription = (1 << 11), }; - util::FlagsEnum flags; + FlagsEnum flags; QTime parseTime; QString id; QString searchText; @@ -59,7 +59,7 @@ struct Message { const std::vector> &getElements() const; // Scrollbar - widgets::ScrollbarHighlight getScrollBarHighlight() const; + ScrollbarHighlight getScrollBarHighlight() const; private: std::vector> elements; @@ -72,10 +72,10 @@ public: const QString &durationInSeconds, const QString &reason, bool multipleTimes); - static std::shared_ptr createTimeoutMessage(const providers::twitch::BanAction &action, + static std::shared_ptr createTimeoutMessage(const BanAction &action, uint32_t count = 1); static std::shared_ptr createUntimeoutMessage( - const providers::twitch::UnbanAction &action); + const UnbanAction &action); }; using MessagePtr = std::shared_ptr; diff --git a/src/messages/MessageColor.cpp b/src/messages/MessageColor.cpp index d8f7816f3..161e562fa 100644 --- a/src/messages/MessageColor.cpp +++ b/src/messages/MessageColor.cpp @@ -13,7 +13,7 @@ MessageColor::MessageColor(Type _type) { } -const QColor &MessageColor::getColor(singletons::ThemeManager &themeManager) const +const QColor &MessageColor::getColor(chatterino::ThemeManager &themeManager) const { switch (this->type) { case Type::Custom: diff --git a/src/messages/MessageColor.hpp b/src/messages/MessageColor.hpp index 363007142..e2100bf96 100644 --- a/src/messages/MessageColor.hpp +++ b/src/messages/MessageColor.hpp @@ -12,7 +12,7 @@ struct MessageColor { MessageColor(const QColor &color); MessageColor(Type type = Text); - const QColor &getColor(singletons::ThemeManager &themeManager) const; + const QColor &getColor(chatterino::ThemeManager &themeManager) const; private: Type type; diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index dcf77984f..8c887ae9a 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -12,12 +12,12 @@ namespace chatterino { MessageElement::MessageElement(Flags _flags) : flags(_flags) { - util::DebugCount::increase("message elements"); + DebugCount::increase("message elements"); } MessageElement::~MessageElement() { - util::DebugCount::decrease("message elements"); + DebugCount::decrease("message elements"); } MessageElement *MessageElement::setLink(const Link &_link) @@ -78,7 +78,7 @@ void ImageElement::addToContainer(MessageLayoutContainer &container, MessageElem } // EMOTE -EmoteElement::EmoteElement(const util::EmoteData &_data, MessageElement::Flags flags) +EmoteElement::EmoteElement(const EmoteData &_data, MessageElement::Flags flags) : MessageElement(flags) , data(_data) { @@ -248,7 +248,7 @@ void TwitchModerationElement::addToContainer(MessageLayoutContainer &container, if (_flags & MessageElement::ModeratorTools) { QSize size((int)(container.getScale() * 16), (int)(container.getScale() * 16)); - for (const singletons::ModerationAction &m : getApp()->settings->getModerationActions()) { + for (const chatterino::ModerationAction &m : getApp()->settings->getModerationActions()) { if (m.isImage()) { container.addElement((new ImageLayoutElement(*this, m.getImage(), size)) ->setLink(Link(Link::UserAction, m.getAction()))); diff --git a/src/messages/MessageElement.hpp b/src/messages/MessageElement.hpp index 65e44d8c2..f6880d25e 100644 --- a/src/messages/MessageElement.hpp +++ b/src/messages/MessageElement.hpp @@ -1,10 +1,10 @@ #pragma once +#include "common/Emotemap.hpp" #include "messages/Image.hpp" #include "messages/Link.hpp" #include "messages/MessageColor.hpp" #include "singletons/FontManager.hpp" -#include "common/Emotemap.hpp" #include #include @@ -19,8 +19,6 @@ class Channel; struct EmoteData; struct MessageLayoutContainer; -using namespace chatterino::messages::layouts; - class MessageElement : boost::noncopyable { public: @@ -167,12 +165,12 @@ class EmoteElement : public MessageElement std::unique_ptr textElement; public: - EmoteElement(const util::EmoteData &data, MessageElement::Flags flags); + EmoteElement(const EmoteData &data, MessageElement::Flags flags); ~EmoteElement() override = default; void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override; - const util::EmoteData data; + const EmoteData data; }; // contains a text, formated depending on the preferences diff --git a/src/messages/layouts/MessageLayout.cpp b/src/messages/layouts/MessageLayout.cpp index a2e53a0da..be245a1c3 100644 --- a/src/messages/layouts/MessageLayout.cpp +++ b/src/messages/layouts/MessageLayout.cpp @@ -24,12 +24,12 @@ MessageLayout::MessageLayout(MessagePtr message) : message_(message) , buffer_(nullptr) { - util::DebugCount::increase("message layout"); + DebugCount::increase("message layout"); } MessageLayout::~MessageLayout() { - util::DebugCount::decrease("message layout"); + DebugCount::decrease("message layout"); } Message *MessageLayout::getMessage() @@ -140,7 +140,7 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex, this->buffer_ = std::shared_ptr(pixmap); this->bufferValid_ = false; - util::DebugCount::increase("message drawing buffers"); + DebugCount::increase("message drawing buffers"); } if (!this->bufferValid_ || !selection.isEmpty()) { @@ -230,7 +230,7 @@ void MessageLayout::invalidateBuffer() void MessageLayout::deleteBuffer() { if (this->buffer_ != nullptr) { - util::DebugCount::decrease("message drawing buffers"); + DebugCount::decrease("message drawing buffers"); this->buffer_ = nullptr; } diff --git a/src/messages/layouts/MessageLayout.hpp b/src/messages/layouts/MessageLayout.hpp index c343c0657..3084931cb 100644 --- a/src/messages/layouts/MessageLayout.hpp +++ b/src/messages/layouts/MessageLayout.hpp @@ -34,7 +34,7 @@ public: int getHeight() const; // Flags - util::FlagsEnum flags; + FlagsEnum flags; // Layout bool layout(int width, float scale_, MessageElement::Flags flags); diff --git a/src/messages/layouts/MessageLayoutElement.cpp b/src/messages/layouts/MessageLayoutElement.cpp index 904722a17..72803b0be 100644 --- a/src/messages/layouts/MessageLayoutElement.cpp +++ b/src/messages/layouts/MessageLayoutElement.cpp @@ -18,12 +18,12 @@ MessageLayoutElement::MessageLayoutElement(MessageElement &_creator, const QSize : creator(_creator) { this->rect.setSize(size); - util::DebugCount::increase("message layout elements"); + DebugCount::increase("message layout elements"); } MessageLayoutElement::~MessageLayoutElement() { - util::DebugCount::decrease("message layout elements"); + DebugCount::decrease("message layout elements"); } MessageElement &MessageLayoutElement::getCreator() const diff --git a/src/providers/bttv/BttvEmotes.cpp b/src/providers/bttv/BttvEmotes.cpp index b89baef95..87da6ce8d 100644 --- a/src/providers/bttv/BttvEmotes.cpp +++ b/src/providers/bttv/BttvEmotes.cpp @@ -21,7 +21,7 @@ void BTTVEmotes::loadGlobalEmotes() { QString url("https://api.betterttv.net/2/emotes"); - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(QThread::currentThread()); req.setTimeout(30000); req.setUseQuickLoadCache(true); @@ -35,12 +35,12 @@ void BTTVEmotes::loadGlobalEmotes() QString id = emote.toObject().value("id").toString(); QString code = emote.toObject().value("code").toString(); - util::EmoteData emoteData; - emoteData.image1x = new messages::Image(getEmoteLink(urlTemplate, id, "1x"), 1, code, + EmoteData emoteData; + emoteData.image1x = new chatterino::Image(getEmoteLink(urlTemplate, id, "1x"), 1, code, code + "
Global BTTV Emote"); - emoteData.image2x = new messages::Image(getEmoteLink(urlTemplate, id, "2x"), 0.5, code, + emoteData.image2x = new chatterino::Image(getEmoteLink(urlTemplate, id, "2x"), 0.5, code, code + "
Global BTTV Emote"); - emoteData.image3x = new messages::Image(getEmoteLink(urlTemplate, id, "3x"), 0.25, code, + emoteData.image3x = new chatterino::Image(getEmoteLink(urlTemplate, id, "3x"), 0.25, code, code + "
Global BTTV Emote"); emoteData.pageLink = "https://manage.betterttv.net/emotes/" + id; @@ -52,15 +52,15 @@ void BTTVEmotes::loadGlobalEmotes() }); } -void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr _map) +void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr _map) { printf("[BTTVEmotes] Reload BTTV Channel Emotes for channel %s\n", qPrintable(channelName)); QString url("https://api.betterttv.net/2/channels/" + channelName); - debug::Log("Request bttv channel emotes for {}", channelName); + Log("Request bttv channel emotes for {}", channelName); - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(QThread::currentThread()); req.setTimeout(3000); req.setUseQuickLoadCache(true); @@ -86,21 +86,21 @@ void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptrchannelEmoteCache.getOrAdd(id, [&] { - util::EmoteData emoteData; + EmoteData emoteData; QString link = linkTemplate; link.detach(); emoteData.image1x = - new messages::Image(link.replace("{{id}}", id).replace("{{image}}", "1x"), 1, + new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "1x"), 1, code, code + "
Channel BTTV Emote"); link = linkTemplate; link.detach(); emoteData.image2x = - new messages::Image(link.replace("{{id}}", id).replace("{{image}}", "2x"), 0.5, + new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "2x"), 0.5, code, code + "
Channel BTTV Emote"); link = linkTemplate; link.detach(); emoteData.image3x = - new messages::Image(link.replace("{{id}}", id).replace("{{image}}", "3x"), 0.25, + new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "3x"), 0.25, code, code + "
Channel BTTV Emote"); emoteData.pageLink = "https://manage.betterttv.net/emotes/" + id; diff --git a/src/providers/bttv/BttvEmotes.hpp b/src/providers/bttv/BttvEmotes.hpp index 900c0360d..69e2df819 100644 --- a/src/providers/bttv/BttvEmotes.hpp +++ b/src/providers/bttv/BttvEmotes.hpp @@ -11,18 +11,18 @@ namespace chatterino { class BTTVEmotes { public: - util::EmoteMap globalEmotes; + EmoteMap globalEmotes; SignalVector globalEmoteCodes; - util::EmoteMap channelEmotes; + EmoteMap channelEmotes; std::map> channelEmoteCodes; void loadGlobalEmotes(); void loadChannelEmotes(const QString &channelName, - std::weak_ptr channelEmoteMap); + std::weak_ptr channelEmoteMap); private: - util::EmoteMap channelEmoteCache; + EmoteMap channelEmoteCache; }; } // namespace chatterino diff --git a/src/providers/emoji/Emojis.cpp b/src/providers/emoji/Emojis.cpp index b2aa11a8a..2a3d9e1c9 100644 --- a/src/providers/emoji/Emojis.cpp +++ b/src/providers/emoji/Emojis.cpp @@ -111,7 +111,7 @@ void Emojis::loadEmojis() rapidjson::ParseResult result = root.Parse(data.toUtf8(), data.length()); if (result.Code() != rapidjson::kParseErrorNone) { - debug::Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()), + Log("JSON parse error: {} ({})", rapidjson::GetParseError_En(result.Code()), result.Offset()); return; } @@ -138,7 +138,7 @@ void Emojis::loadEmojis() auto toneNameIt = toneNames.find(tone); if (toneNameIt == toneNames.end()) { - debug::Log("Tone with key {} does not exist in tone names map", tone); + Log("Tone with key {} does not exist in tone names map", tone); continue; } @@ -206,7 +206,7 @@ void Emojis::loadEmojiSet() auto app = getApp(); app->settings->emojiSet.connect([=](const auto &emojiSet, auto) { - debug::Log("Using emoji set {}", emojiSet); + Log("Using emoji set {}", emojiSet); this->emojis.each([=](const auto &name, std::shared_ptr &emoji) { QString emojiSetToUse = emojiSet; // clang-format off @@ -260,13 +260,13 @@ void Emojis::loadEmojiSet() urlPrefix = it->second; } QString url = urlPrefix + code + ".png"; - emoji->emoteData.image1x = new messages::Image( + emoji->emoteData.image1x = new chatterino::Image( url, 0.35, emoji->value, ":" + emoji->shortCodes[0] + ":
Emoji"); }); }); } -void Emojis::parse(std::vector> &parsedWords, +void Emojis::parse(std::vector> &parsedWords, const QString &text) { int lastParsedEmojiEndIndex = 0; @@ -328,13 +328,13 @@ void Emojis::parse(std::vector> &parsedWord if (charactersFromLastParsedEmoji > 0) { // Add characters inbetween emojis - parsedWords.emplace_back(util::EmoteData(), text.mid(lastParsedEmojiEndIndex, + parsedWords.emplace_back(EmoteData(), text.mid(lastParsedEmojiEndIndex, charactersFromLastParsedEmoji)); } // Push the emoji as a word to parsedWords parsedWords.push_back( - std::tuple(matchedEmoji->emoteData, QString())); + std::tuple(matchedEmoji->emoteData, QString())); lastParsedEmojiEndIndex = currentParsedEmojiEndIndex; @@ -343,7 +343,7 @@ void Emojis::parse(std::vector> &parsedWord if (lastParsedEmojiEndIndex < text.length()) { // Add remaining characters - parsedWords.emplace_back(util::EmoteData(), text.mid(lastParsedEmojiEndIndex)); + parsedWords.emplace_back(EmoteData(), text.mid(lastParsedEmojiEndIndex)); } } diff --git a/src/providers/emoji/Emojis.hpp b/src/providers/emoji/Emojis.hpp index 59895a370..4d80c7428 100644 --- a/src/providers/emoji/Emojis.hpp +++ b/src/providers/emoji/Emojis.hpp @@ -26,10 +26,10 @@ struct EmojiData { std::vector variations; - util::EmoteData emoteData; + EmoteData emoteData; }; -using EmojiMap = util::ConcurrentMap>; +using EmojiMap = ConcurrentMap>; class Emojis { @@ -51,7 +51,7 @@ private: public: QString replaceShortCodes(const QString &text); - void parse(std::vector> &parsedWords, const QString &text); + void parse(std::vector> &parsedWords, const QString &text); private: /// Emojis diff --git a/src/providers/ffz/FfzEmotes.cpp b/src/providers/ffz/FfzEmotes.cpp index 0bff7571e..136ededf6 100644 --- a/src/providers/ffz/FfzEmotes.cpp +++ b/src/providers/ffz/FfzEmotes.cpp @@ -21,7 +21,7 @@ QString getEmoteLink(const QJsonObject &urls, const QString &emoteScale) } void fillInEmoteData(const QJsonObject &urls, const QString &code, const QString &tooltip, - util::EmoteData &emoteData) + EmoteData &emoteData) { QString url1x = getEmoteLink(urls, "1"); QString url2x = getEmoteLink(urls, "2"); @@ -29,14 +29,14 @@ void fillInEmoteData(const QJsonObject &urls, const QString &code, const QString assert(!url1x.isEmpty()); - emoteData.image1x = new messages::Image(url1x, 1, code, tooltip); + emoteData.image1x = new chatterino::Image(url1x, 1, code, tooltip); if (!url2x.isEmpty()) { - emoteData.image2x = new messages::Image(url2x, 0.5, code, tooltip); + emoteData.image2x = new chatterino::Image(url2x, 0.5, code, tooltip); } if (!url3x.isEmpty()) { - emoteData.image3x = new messages::Image(url3x, 0.25, code, tooltip); + emoteData.image3x = new chatterino::Image(url3x, 0.25, code, tooltip); } } @@ -46,7 +46,7 @@ void FFZEmotes::loadGlobalEmotes() { QString url("https://api.frankerfacez.com/v1/set/global"); - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(QThread::currentThread()); req.setTimeout(30000); req.setUseQuickLoadCache(true); @@ -64,7 +64,7 @@ void FFZEmotes::loadGlobalEmotes() int id = object.value("id").toInt(); QJsonObject urls = object.value("urls").toObject(); - util::EmoteData emoteData; + EmoteData emoteData; fillInEmoteData(urls, code, code + "
Global FFZ Emote", emoteData); emoteData.pageLink = QString("https://www.frankerfacez.com/emoticon/%1-%2").arg(id).arg(code); @@ -78,13 +78,13 @@ void FFZEmotes::loadGlobalEmotes() }); } -void FFZEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr _map) +void FFZEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptr _map) { printf("[FFZEmotes] Reload FFZ Channel Emotes for channel %s\n", qPrintable(channelName)); QString url("https://api.frankerfacez.com/v1/room/" + channelName); - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(QThread::currentThread()); req.setTimeout(3000); req.setUseQuickLoadCache(true); @@ -113,7 +113,7 @@ void FFZEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptrchannelEmoteCache.getOrAdd(id, [id, &code, &urls] { - util::EmoteData emoteData; + EmoteData emoteData; fillInEmoteData(urls, code, code + "
Channel FFZ Emote", emoteData); emoteData.pageLink = QString("https://www.frankerfacez.com/emoticon/%1-%2").arg(id).arg(code); diff --git a/src/providers/ffz/FfzEmotes.hpp b/src/providers/ffz/FfzEmotes.hpp index feee468a7..44c4b5b7d 100644 --- a/src/providers/ffz/FfzEmotes.hpp +++ b/src/providers/ffz/FfzEmotes.hpp @@ -11,18 +11,18 @@ namespace chatterino { class FFZEmotes { public: - util::EmoteMap globalEmotes; + EmoteMap globalEmotes; SignalVector globalEmoteCodes; - util::EmoteMap channelEmotes; + EmoteMap channelEmotes; std::map> channelEmoteCodes; void loadGlobalEmotes(); void loadChannelEmotes(const QString &channelName, - std::weak_ptr channelEmoteMap); + std::weak_ptr channelEmoteMap); private: - util::ConcurrentMap channelEmoteCache; + ConcurrentMap channelEmoteCache; }; } // namespace chatterino diff --git a/src/providers/irc/AbstractIrcServer.cpp b/src/providers/irc/AbstractIrcServer.cpp index 39f3d8ecf..592ce4ff1 100644 --- a/src/providers/irc/AbstractIrcServer.cpp +++ b/src/providers/irc/AbstractIrcServer.cpp @@ -126,7 +126,7 @@ std::shared_ptr AbstractIrcServer::getOrAddChannel(const QString &dirty chan->destroyed.connect([this, clojuresInCppAreShit] { // fourtf: issues when the server itself is destroyed - debug::Log("[AbstractIrcServer::addChannel] {} was destroyed", clojuresInCppAreShit); + Log("[AbstractIrcServer::addChannel] {} was destroyed", clojuresInCppAreShit); this->channels.remove(clojuresInCppAreShit); if (this->readConnection_) { diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index f0fb0c51a..eb15a65e3 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -46,7 +46,7 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *_message, const QString return; } - messages::MessageParseArgs args; + chatterino::MessageParseArgs args; if (isSub) { args.trimSubscriberUsername = true; } @@ -58,13 +58,13 @@ void IrcMessageHandler::addMessage(Communi::IrcMessage *_message, const QString TwitchMessageBuilder builder(chan.get(), _message, args, content, isAction); if (isSub || !builder.isIgnored()) { - messages::MessagePtr msg = builder.build(); + chatterino::MessagePtr msg = builder.build(); if (isSub) { - msg->flags |= messages::Message::Subscription; - msg->flags &= ~messages::Message::Highlighted; + msg->flags |= chatterino::Message::Subscription; + msg->flags &= ~chatterino::Message::Highlighted; } else { - if (msg->flags & messages::Message::Highlighted) { + if (msg->flags & chatterino::Message::Highlighted) { server.mentionsChannel->addMessage(msg); getApp()->highlights->addHighlight(msg); } @@ -85,7 +85,7 @@ void IrcMessageHandler::handleRoomStateMessage(Communi::IrcMessage *message) return; } auto chan = app->twitch.server->getChannelOrEmpty(chanName); - TwitchChannel *twitchChannel = dynamic_cast(chan.get()); + TwitchChannel *twitchChannel = dynamic_cast(chan.get()); if (twitchChannel) { // room-id @@ -140,7 +140,7 @@ void IrcMessageHandler::handleClearChatMessage(Communi::IrcMessage *message) auto chan = app->twitch.server->getChannelOrEmpty(chanName); if (chan->isEmpty()) { - debug::Log("[IrcMessageHandler:handleClearChatMessage] Twitch channel {} not found", + Log("[IrcMessageHandler:handleClearChatMessage] Twitch channel {} not found", chanName); return; } @@ -190,7 +190,7 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message) return; } - twitch::TwitchChannel *tc = dynamic_cast(c.get()); + TwitchChannel *tc = dynamic_cast(c.get()); if (tc != nullptr) { tc->setMod(_mod == "1"); } @@ -200,20 +200,20 @@ void IrcMessageHandler::handleUserStateMessage(Communi::IrcMessage *message) void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message) { auto app = getApp(); - debug::Log("Received whisper!"); - messages::MessageParseArgs args; + Log("Received whisper!"); + chatterino::MessageParseArgs args; args.isReceivedWhisper = true; auto c = app->twitch.server->whispersChannel.get(); - twitch::TwitchMessageBuilder builder(c, message, args, message->parameter(1), false); + TwitchMessageBuilder builder(c, message, args, message->parameter(1), false); if (!builder.isIgnored()) { - messages::MessagePtr _message = builder.build(); - _message->flags |= messages::Message::DoNotTriggerNotification; + chatterino::MessagePtr _message = builder.build(); + _message->flags |= chatterino::Message::DoNotTriggerNotification; - if (_message->flags & messages::Message::Highlighted) { + if (_message->flags & chatterino::Message::Highlighted) { app->twitch.server->mentionsChannel->addMessage(_message); } @@ -254,9 +254,9 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message, Tw if (it != tags.end()) { auto newMessage = - messages::Message::createSystemMessage(util::parseTagString(it.value().toString())); + chatterino::Message::createSystemMessage(parseTagString(it.value().toString())); - newMessage->flags |= messages::Message::Subscription; + newMessage->flags |= chatterino::Message::Subscription; QString channelName; @@ -311,7 +311,7 @@ void IrcMessageHandler::handleNoticeMessage(Communi::IrcNoticeMessage *message) auto channel = app->twitch.server->getChannelOrEmpty(channelName); if (channel->isEmpty()) { - debug::Log("[IrcManager:handleNoticeMessage] Channel {} not found in channel manager ", + Log("[IrcManager:handleNoticeMessage] Channel {} not found in channel manager ", channelName); return; } @@ -338,7 +338,7 @@ void IrcMessageHandler::handleWriteConnectionNoticeMessage(Communi::IrcNoticeMes return; } - debug::Log("Showing notice message from write connection with message id '{}'", msgID); + Log("Showing notice message from write connection with message id '{}'", msgID); } this->handleNoticeMessage(message); diff --git a/src/providers/twitch/Pubsub.cpp b/src/providers/twitch/Pubsub.cpp index 557efc8f0..d9f749e0c 100644 --- a/src/providers/twitch/Pubsub.cpp +++ b/src/providers/twitch/Pubsub.cpp @@ -107,7 +107,7 @@ void PubSubClient::handlePong() { assert(this->awaitingPong); - debug::Log("Got pong!"); + Log("Got pong!"); this->awaitingPong = false; } @@ -141,7 +141,7 @@ void PubSubClient::ping() } if (self->awaitingPong) { - debug::Log("No pong respnose, disconnect!"); + Log("No pong respnose, disconnect!"); // TODO(pajlada): Label this connection as "disconnect me" } }); @@ -161,7 +161,7 @@ bool PubSubClient::send(const char *payload) this->websocketClient.send(this->handle, payload, websocketpp::frame::opcode::text, ec); if (ec) { - debug::Log("Error sending message {}: {}", payload, ec.message()); + Log("Error sending message {}: {}", payload, ec.message()); // TODO(pajlada): Check which error code happened and maybe gracefully handle it return false; @@ -198,26 +198,26 @@ PubSub::PubSub() action.state = ModeChangedAction::State::On; if (!data.HasMember("args")) { - debug::Log("Missing required args member"); + Log("Missing required args member"); return; } const auto &args = data["args"]; if (!args.IsArray()) { - debug::Log("args member must be an array"); + Log("args member must be an array"); return; } if (args.Size() == 0) { - debug::Log("Missing duration argument in slowmode on"); + Log("Missing duration argument in slowmode on"); return; } const auto &durationArg = args[0]; if (!durationArg.IsString()) { - debug::Log("Duration arg must be a string"); + Log("Duration arg must be a string"); return; } @@ -299,7 +299,7 @@ PubSub::PubSub() return; } } catch (const std::runtime_error &ex) { - debug::Log("Error parsing moderation action: {}", ex.what()); + Log("Error parsing moderation action: {}", ex.what()); } action.modded = false; @@ -323,7 +323,7 @@ PubSub::PubSub() return; } } catch (const std::runtime_error &ex) { - debug::Log("Error parsing moderation action: {}", ex.what()); + Log("Error parsing moderation action: {}", ex.what()); } action.modded = true; @@ -363,7 +363,7 @@ PubSub::PubSub() this->sig.moderation.userBanned.invoke(action); } catch (const std::runtime_error &ex) { - debug::Log("Error parsing moderation action: {}", ex.what()); + Log("Error parsing moderation action: {}", ex.what()); } }; @@ -392,7 +392,7 @@ PubSub::PubSub() this->sig.moderation.userBanned.invoke(action); } catch (const std::runtime_error &ex) { - debug::Log("Error parsing moderation action: {}", ex.what()); + Log("Error parsing moderation action: {}", ex.what()); } }; @@ -417,7 +417,7 @@ PubSub::PubSub() this->sig.moderation.userUnbanned.invoke(action); } catch (const std::runtime_error &ex) { - debug::Log("Error parsing moderation action: {}", ex.what()); + Log("Error parsing moderation action: {}", ex.what()); } }; @@ -442,7 +442,7 @@ PubSub::PubSub() this->sig.moderation.userUnbanned.invoke(action); } catch (const std::runtime_error &ex) { - debug::Log("Error parsing moderation action: {}", ex.what()); + Log("Error parsing moderation action: {}", ex.what()); } }; @@ -468,7 +468,7 @@ void PubSub::addClient() auto con = this->websocketClient.get_connection(TWITCH_PUBSUB_URL, ec); if (ec) { - debug::Log("Unable to establish connection: {}", ec.message()); + Log("Unable to establish connection: {}", ec.message()); return; } @@ -480,13 +480,13 @@ void PubSub::start() this->mainThread.reset(new std::thread(std::bind(&PubSub::runThread, this))); } -void PubSub::listenToWhispers(std::shared_ptr account) +void PubSub::listenToWhispers(std::shared_ptr account) { assert(account != nullptr); std::string userID = account->getUserId().toStdString(); - debug::Log("Connection open!"); + Log("Connection open!"); websocketpp::lib::error_code ec; std::vector topics({"whispers." + userID}); @@ -494,7 +494,7 @@ void PubSub::listenToWhispers(std::shared_ptr this->listen(std::move(createListenMessage(topics, account))); if (ec) { - debug::Log("Unable to send message to websocket server: {}", ec.message()); + Log("Unable to send message to websocket server: {}", ec.message()); return; } } @@ -508,7 +508,7 @@ void PubSub::unlistenAllModerationActions() } void PubSub::listenToChannelModerationActions( - const QString &channelID, std::shared_ptr account) + const QString &channelID, std::shared_ptr account) { assert(!channelID.isEmpty()); assert(account != nullptr); @@ -518,17 +518,17 @@ void PubSub::listenToChannelModerationActions( std::string topic(fS("chat_moderator_actions.{}.{}", userID, channelID)); if (this->isListeningToTopic(topic)) { - debug::Log("We are already listening to topic {}", topic); + Log("We are already listening to topic {}", topic); return; } - debug::Log("Listen to topic {}", topic); + Log("Listen to topic {}", topic); this->listenToTopic(topic, account); } void PubSub::listenToTopic(const std::string &topic, - std::shared_ptr account) + std::shared_ptr account) { auto message = createListenMessage({topic}, account); @@ -538,17 +538,17 @@ void PubSub::listenToTopic(const std::string &topic, void PubSub::listen(rapidjson::Document &&msg) { if (this->tryListen(msg)) { - debug::Log("Successfully listened!"); + Log("Successfully listened!"); return; } - debug::Log("Added to the back of the queue"); + Log("Added to the back of the queue"); this->requests.emplace_back(std::make_unique(std::move(msg))); } bool PubSub::tryListen(rapidjson::Document &msg) { - debug::Log("tryListen with {} clients", this->clients.size()); + Log("tryListen with {} clients", this->clients.size()); for (const auto &p : this->clients) { const auto &client = p.second; if (client->listen(msg)) { @@ -580,20 +580,20 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl, WebsocketMessagePtr webs rapidjson::ParseResult res = msg.Parse(payload.c_str()); if (!res) { - debug::Log("Error parsing message '{}' from PubSub: {}", payload, + Log("Error parsing message '{}' from PubSub: {}", payload, rapidjson::GetParseError_En(res.Code())); return; } if (!msg.IsObject()) { - debug::Log("Error parsing message '{}' from PubSub. Root object is not an object", payload); + Log("Error parsing message '{}' from PubSub. Root object is not an object", payload); return; } std::string type; if (!rj::getSafe(msg, "type", type)) { - debug::Log("Missing required string member `type` in message root"); + Log("Missing required string member `type` in message root"); return; } @@ -601,14 +601,14 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl, WebsocketMessagePtr webs this->handleListenResponse(msg); } else if (type == "MESSAGE") { if (!msg.HasMember("data")) { - debug::Log("Missing required object member `data` in message root"); + Log("Missing required object member `data` in message root"); return; } const auto &data = msg["data"]; if (!data.IsObject()) { - debug::Log("Member `data` must be an object"); + Log("Member `data` must be an object"); return; } @@ -624,7 +624,7 @@ void PubSub::onMessage(websocketpp::connection_hdl hdl, WebsocketMessagePtr webs client.second->handlePong(); } else { - debug::Log("Unknown message type: {}", type); + Log("Unknown message type: {}", type); } } @@ -666,7 +666,7 @@ PubSub::WebsocketContextPtr PubSub::onTLSInit(websocketpp::connection_hdl hdl) boost::asio::ssl::context::no_sslv2 | boost::asio::ssl::context::single_dh_use); } catch (const std::exception &e) { - debug::Log("Exception caught in OnTLSInit: {}", e.what()); + Log("Exception caught in OnTLSInit: {}", e.what()); } return ctx; @@ -681,12 +681,12 @@ void PubSub::handleListenResponse(const rapidjson::Document &msg) rj::getSafe(msg, "nonce", nonce); if (error.empty()) { - debug::Log("Successfully listened to nonce {}", nonce); + Log("Successfully listened to nonce {}", nonce); // Nothing went wrong return; } - debug::Log("PubSub error: {} on nonce {}", error, nonce); + Log("PubSub error: {} on nonce {}", error, nonce); return; } } @@ -696,14 +696,14 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData) QString topic; if (!rj::getSafe(outerData, "topic", topic)) { - debug::Log("Missing required string member `topic` in outerData"); + Log("Missing required string member `topic` in outerData"); return; } std::string payload; if (!rj::getSafe(outerData, "message", payload)) { - debug::Log("Expected string message in outerData"); + Log("Expected string message in outerData"); return; } @@ -712,7 +712,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData) rapidjson::ParseResult res = msg.Parse(payload.c_str()); if (!res) { - debug::Log("Error parsing message '{}' from PubSub: {}", payload, + Log("Error parsing message '{}' from PubSub: {}", payload, rapidjson::GetParseError_En(res.Code())); return; } @@ -721,7 +721,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData) std::string whisperType; if (!rj::getSafe(msg, "type", whisperType)) { - debug::Log("Bad whisper data"); + Log("Bad whisper data"); return; } @@ -732,7 +732,7 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData) } else if (whisperType == "thread") { // Handle thread? } else { - debug::Log("Invalid whisper type: {}", whisperType); + Log("Invalid whisper type: {}", whisperType); assert(false); return; } @@ -744,30 +744,30 @@ void PubSub::handleMessageResponse(const rapidjson::Value &outerData) std::string moderationAction; if (!rj::getSafe(data, "moderation_action", moderationAction)) { - debug::Log("Missing moderation action in data: {}", rj::stringify(data)); + Log("Missing moderation action in data: {}", rj::stringify(data)); return; } auto handlerIt = this->moderationActionHandlers.find(moderationAction); if (handlerIt == this->moderationActionHandlers.end()) { - debug::Log("No handler found for moderation action {}", moderationAction); + Log("No handler found for moderation action {}", moderationAction); return; } // Invoke handler function handlerIt->second(data, topicParts[2]); } else { - debug::Log("Unknown topic: {}", topic); + Log("Unknown topic: {}", topic); return; } } void PubSub::runThread() { - debug::Log("Start pubsub manager thread"); + Log("Start pubsub manager thread"); this->websocketClient.run(); - debug::Log("Done with pubsub manager thread"); + Log("Done with pubsub manager thread"); } } // namespace chatterino diff --git a/src/providers/twitch/Pubsub.hpp b/src/providers/twitch/Pubsub.hpp index 90da3f9ea..04443de68 100644 --- a/src/providers/twitch/Pubsub.hpp +++ b/src/providers/twitch/Pubsub.hpp @@ -117,18 +117,18 @@ public: } whisper; } sig; - void listenToWhispers(std::shared_ptr account); + void listenToWhispers(std::shared_ptr account); void unlistenAllModerationActions(); void listenToChannelModerationActions( - const QString &channelID, std::shared_ptr account); + const QString &channelID, std::shared_ptr account); std::vector> requests; private: void listenToTopic(const std::string &topic, - std::shared_ptr account); + std::shared_ptr account); void listen(rapidjson::Document &&msg); bool tryListen(rapidjson::Document &msg); diff --git a/src/providers/twitch/PubsubHelpers.cpp b/src/providers/twitch/PubsubHelpers.cpp index 5f13e1a38..e93340fe4 100644 --- a/src/providers/twitch/PubsubHelpers.cpp +++ b/src/providers/twitch/PubsubHelpers.cpp @@ -32,7 +32,7 @@ bool getTargetUser(const rapidjson::Value &data, ActionUser &user) } rapidjson::Document createListenMessage(const std::vector &topicsVec, - std::shared_ptr account) + std::shared_ptr account) { rapidjson::Document msg(rapidjson::kObjectType); auto &a = msg.GetAllocator(); diff --git a/src/providers/twitch/PubsubHelpers.hpp b/src/providers/twitch/PubsubHelpers.hpp index 3be2dbab8..07bda24b1 100644 --- a/src/providers/twitch/PubsubHelpers.hpp +++ b/src/providers/twitch/PubsubHelpers.hpp @@ -20,7 +20,7 @@ bool getCreatedByUser(const rapidjson::Value &data, ActionUser &user); bool getTargetUser(const rapidjson::Value &data, ActionUser &user); rapidjson::Document createListenMessage(const std::vector &topicsVec, - std::shared_ptr account); + std::shared_ptr account); rapidjson::Document createUnlistenMessage(const std::vector &topicsVec); // Create timer using given ioService @@ -32,7 +32,7 @@ void runAfter(boost::asio::io_service &ioService, Duration duration, Callback cb timer->async_wait([timer, cb](const boost::system::error_code &ec) { if (ec) { - debug::Log("Error in runAfter: {}", ec.message()); + Log("Error in runAfter: {}", ec.message()); return; } @@ -48,7 +48,7 @@ void runAfter(std::shared_ptr timer, Duration duratio timer->async_wait([timer, cb](const boost::system::error_code &ec) { if (ec) { - debug::Log("Error in runAfter: {}", ec.message()); + Log("Error in runAfter: {}", ec.message()); return; } diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp index 3cd408510..24cd8cd7d 100644 --- a/src/providers/twitch/TwitchAccount.cpp +++ b/src/providers/twitch/TwitchAccount.cpp @@ -10,7 +10,7 @@ namespace chatterino { TwitchAccount::TwitchAccount(const QString &_username, const QString &_oauthToken, const QString &_oauthClient, const QString &_userID) - : controllers::accounts::Account(ProviderId::Twitch) + : Account(ProviderId::Twitch) , oauthClient(_oauthClient) , oauthToken(_oauthToken) , userName(_username) @@ -75,8 +75,8 @@ void TwitchAccount::loadIgnores() { QString url("https://api.twitch.tv/kraken/users/" + this->getUserId() + "/blocks"); - util::NetworkRequest req(url); - req.setRequestType(util::NetworkRequest::GetRequest); + NetworkRequest req(url); + req.setRequestType(NetworkRequest::GetRequest); req.setCaller(QThread::currentThread()); req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken()); req.onSuccess([=](const rapidjson::Document &document) { @@ -119,7 +119,7 @@ void TwitchAccount::loadIgnores() void TwitchAccount::ignore(const QString &targetName, std::function onFinished) { - util::twitch::getUserID(targetName, QThread::currentThread(), [=](QString targetUserID) { + getUserID(targetName, QThread::currentThread(), [=](QString targetUserID) { this->ignoreByID(targetUserID, targetName, onFinished); // }); } @@ -130,8 +130,8 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe QString url("https://api.twitch.tv/kraken/users/" + this->getUserId() + "/blocks/" + targetUserID); - util::NetworkRequest req(url); - req.setRequestType(util::NetworkRequest::PutRequest); + NetworkRequest req(url); + req.setRequestType(NetworkRequest::PutRequest); req.setCaller(QThread::currentThread()); req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken()); @@ -179,7 +179,7 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe void TwitchAccount::unignore(const QString &targetName, std::function onFinished) { - util::twitch::getUserID(targetName, QThread::currentThread(), [=](QString targetUserID) { + getUserID(targetName, QThread::currentThread(), [=](QString targetUserID) { this->unignoreByID(targetUserID, targetName, onFinished); // }); } @@ -191,8 +191,8 @@ void TwitchAccount::unignoreByID( QString url("https://api.twitch.tv/kraken/users/" + this->getUserId() + "/blocks/" + targetUserID); - util::NetworkRequest req(url); - req.setRequestType(util::NetworkRequest::DeleteRequest); + NetworkRequest req(url); + req.setRequestType(NetworkRequest::DeleteRequest); req.setCaller(QThread::currentThread()); req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken()); @@ -226,8 +226,8 @@ void TwitchAccount::checkFollow(const QString targetUserID, QString url("https://api.twitch.tv/kraken/users/" + this->getUserId() + "/follows/channels/" + targetUserID); - util::NetworkRequest req(url); - req.setRequestType(util::NetworkRequest::GetRequest); + NetworkRequest req(url); + req.setRequestType(NetworkRequest::GetRequest); req.setCaller(QThread::currentThread()); req.makeAuthorizedV5(this->getOAuthClient(), this->getOAuthToken()); diff --git a/src/providers/twitch/TwitchAccount.hpp b/src/providers/twitch/TwitchAccount.hpp index cf3ae7df0..56e5b9db7 100644 --- a/src/providers/twitch/TwitchAccount.hpp +++ b/src/providers/twitch/TwitchAccount.hpp @@ -27,7 +27,7 @@ enum FollowResult { FollowResult_Failed, }; -class TwitchAccount : public controllers::accounts::Account +class TwitchAccount : public Account { public: TwitchAccount(const QString &username, const QString &oauthToken, const QString &oauthClient, diff --git a/src/providers/twitch/TwitchAccountManager.cpp b/src/providers/twitch/TwitchAccountManager.cpp index bdb690832..4bfa2b8b4 100644 --- a/src/providers/twitch/TwitchAccountManager.cpp +++ b/src/providers/twitch/TwitchAccountManager.cpp @@ -92,18 +92,18 @@ void TwitchAccountManager::reloadUsers() switch (this->addUser(userData)) { case AddUserResponse::UserAlreadyExists: { - debug::Log("User {} already exists", userData.username); + Log("User {} already exists", userData.username); // Do nothing } break; case AddUserResponse::UserValuesUpdated: { - debug::Log("User {} already exists, and values updated!", userData.username); + Log("User {} already exists, and values updated!", userData.username); if (userData.username == this->getCurrent()->getUserName()) { - debug::Log("It was the current user, so we need to reconnect stuff!"); + Log("It was the current user, so we need to reconnect stuff!"); this->currentUserChanged.invoke(); } } break; case AddUserResponse::UserAdded: { - debug::Log("Added user {}", userData.username); + Log("Added user {}", userData.username); listUpdated = true; } break; } @@ -122,11 +122,11 @@ void TwitchAccountManager::load() QString newUsername(QString::fromStdString(newValue)); auto user = this->findUserByUsername(newUsername); if (user) { - debug::Log("[AccountManager:currentUsernameChanged] User successfully updated to {}", + Log("[AccountManager:currentUsernameChanged] User successfully updated to {}", newUsername); this->currentUser = user; } else { - debug::Log( + Log( "[AccountManager:currentUsernameChanged] User successfully updated to anonymous"); this->currentUser = this->anonymousUser; } diff --git a/src/providers/twitch/TwitchAccountManager.hpp b/src/providers/twitch/TwitchAccountManager.hpp index 80043b822..1cfd00ec8 100644 --- a/src/providers/twitch/TwitchAccountManager.hpp +++ b/src/providers/twitch/TwitchAccountManager.hpp @@ -1,8 +1,8 @@ #pragma once +#include "common/SignalVector2.hpp" #include "providers/twitch/TwitchAccount.hpp" #include "util/SharedPtrElementLess.hpp" -#include "common/SignalVector2.hpp" #include @@ -15,8 +15,8 @@ // namespace chatterino { + class AccountController; -} class TwitchAccountManager { @@ -47,8 +47,7 @@ public: pajlada::Signals::NoArgSignal currentUserChanged; pajlada::Signals::NoArgSignal userListUpdated; - util::SortedSignalVector, - util::SharedPtrElementLess> + SortedSignalVector, SharedPtrElementLess> accounts; private: @@ -65,7 +64,7 @@ private: std::shared_ptr anonymousUser; mutable std::mutex mutex; - friend class chatterino::controllers::accounts::AccountController; + friend class chatterino::AccountController; }; } // namespace chatterino diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 673efb074..6fe7a270a 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -19,15 +19,15 @@ namespace chatterino { TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *_readConnection) : Channel(channelName, Channel::Twitch) - , bttvChannelEmotes(new util::EmoteMap) - , ffzChannelEmotes(new util::EmoteMap) + , bttvChannelEmotes(new EmoteMap) + , ffzChannelEmotes(new EmoteMap) , subscriptionURL("https://www.twitch.tv/subs/" + name) , channelURL("https://twitch.tv/" + name) , popoutPlayerURL("https://player.twitch.tv/?channel=" + name) , mod(false) , readConnection(_readConnection) { - debug::Log("[TwitchChannel:{}] Opened", this->name); + Log("[TwitchChannel:{}] Opened", this->name); this->startRefreshLiveStatusTimer(60 * 1000); @@ -83,7 +83,7 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection } } - util::twitch::get("https://tmi.twitch.tv/group/user/" + this->name + "/chatters", + get("https://tmi.twitch.tv/group/user/" + this->name + "/chatters", QThread::currentThread(), refreshChatters); }; @@ -95,7 +95,7 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection #if 0 for (int i = 0; i < 1000; i++) { - this->addMessage(messages::Message::createSystemMessage("asdf")); + this->addMessage(chatterino::Message::createSystemMessage("asdf")); } #endif } @@ -130,7 +130,7 @@ void TwitchChannel::reloadChannelEmotes() { auto app = getApp(); - debug::Log("[TwitchChannel:{}] Reloading channel emotes", this->name); + Log("[TwitchChannel:{}] Reloading channel emotes", this->name); app->emotes->bttv.loadChannelEmotes(this->name, this->bttvChannelEmotes); app->emotes->ffz.loadChannelEmotes(this->name, this->ffzChannelEmotes); @@ -144,12 +144,12 @@ void TwitchChannel::sendMessage(const QString &message) // XXX: It would be nice if we could add a link here somehow that opened the "account // manager" dialog this->addMessage( - messages::Message::createSystemMessage("You need to log in to send messages. You can " + chatterino::Message::createSystemMessage("You need to log in to send messages. You can " "link your Twitch account in the settings.")); return; } - debug::Log("[TwitchChannel:{}] Send message: {}", this->name, message); + Log("[TwitchChannel:{}] Send message: {}", this->name, message); // Do last message processing QString parsedMessage = app->emotes->emojis.replaceShortCodes(message); @@ -204,7 +204,7 @@ bool TwitchChannel::hasModRights() return this->isMod() || this->isBroadcaster(); } -void TwitchChannel::addRecentChatter(const std::shared_ptr &message) +void TwitchChannel::addRecentChatter(const std::shared_ptr &message) { assert(!message->loginName.isEmpty()); @@ -233,9 +233,9 @@ void TwitchChannel::addJoinedUser(const QString &user) QTimer::singleShot(500, &this->object, [this] { std::lock_guard guard(this->joinedUserMutex); - auto message = messages::Message::createSystemMessage("Users joined: " + + auto message = chatterino::Message::createSystemMessage("Users joined: " + this->joinedUsers.join(", ")); - message->flags |= messages::Message::Collapsed; + message->flags |= chatterino::Message::Collapsed; this->addMessage(message); this->joinedUsers.clear(); this->joinedUsersMergeQueued = false; @@ -262,9 +262,9 @@ void TwitchChannel::addPartedUser(const QString &user) QTimer::singleShot(500, &this->object, [this] { std::lock_guard guard(this->partedUserMutex); - auto message = messages::Message::createSystemMessage("Users parted: " + + auto message = chatterino::Message::createSystemMessage("Users parted: " + this->partedUsers.join(", ")); - message->flags |= messages::Message::Collapsed; + message->flags |= chatterino::Message::Collapsed; this->addMessage(message); this->partedUsers.clear(); @@ -321,18 +321,18 @@ void TwitchChannel::setLive(bool newLiveStatus) void TwitchChannel::refreshLiveStatus() { if (this->roomID.isEmpty()) { - debug::Log("[TwitchChannel:{}] Refreshing live status (Missing ID)", this->name); + Log("[TwitchChannel:{}] Refreshing live status (Missing ID)", this->name); this->setLive(false); return; } - debug::Log("[TwitchChannel:{}] Refreshing live status", this->name); + Log("[TwitchChannel:{}] Refreshing live status", this->name); QString url("https://api.twitch.tv/kraken/streams/" + this->roomID); std::weak_ptr weak = this->shared_from_this(); - util::twitch::get2(url, QThread::currentThread(), false, [weak](const rapidjson::Document &d) { + get2(url, QThread::currentThread(), false, [weak](const rapidjson::Document &d) { ChannelPtr shared = weak.lock(); if (!shared) { @@ -342,12 +342,12 @@ void TwitchChannel::refreshLiveStatus() TwitchChannel *channel = dynamic_cast(shared.get()); if (!d.IsObject()) { - debug::Log("[TwitchChannel:refreshLiveStatus] root is not an object"); + Log("[TwitchChannel:refreshLiveStatus] root is not an object"); return; } if (!d.HasMember("stream")) { - debug::Log("[TwitchChannel:refreshLiveStatus] Missing stream in root"); + Log("[TwitchChannel:refreshLiveStatus] Missing stream in root"); return; } @@ -361,7 +361,7 @@ void TwitchChannel::refreshLiveStatus() if (!stream.HasMember("viewers") || !stream.HasMember("game") || !stream.HasMember("channel") || !stream.HasMember("created_at")) { - debug::Log("[TwitchChannel:refreshLiveStatus] Missing members in stream"); + Log("[TwitchChannel:refreshLiveStatus] Missing members in stream"); channel->setLive(false); return; } @@ -369,7 +369,7 @@ void TwitchChannel::refreshLiveStatus() const rapidjson::Value &streamChannel = stream["channel"]; if (!streamChannel.IsObject() || !streamChannel.HasMember("status")) { - debug::Log("[TwitchChannel:refreshLiveStatus] Missing member \"status\" in channel"); + Log("[TwitchChannel:refreshLiveStatus] Missing member \"status\" in channel"); return; } @@ -432,7 +432,7 @@ void TwitchChannel::fetchRecentMessages() std::weak_ptr weak = this->shared_from_this(); - util::twitch::get(genericURL.arg(roomID), QThread::currentThread(), [weak](QJsonObject obj) { + get(genericURL.arg(roomID), QThread::currentThread(), [weak](QJsonObject obj) { ChannelPtr shared = weak.lock(); if (!shared) { @@ -449,15 +449,15 @@ void TwitchChannel::fetchRecentMessages() return; } - std::vector messages; + std::vector messages; for (const QJsonValueRef _msg : msgArray) { QByteArray content = _msg.toString().toUtf8(); auto msg = Communi::IrcMessage::fromData(content, readConnection); auto privMsg = static_cast(msg); - messages::MessageParseArgs args; - twitch::TwitchMessageBuilder builder(channel, privMsg, args); + chatterino::MessageParseArgs args; + TwitchMessageBuilder builder(channel, privMsg, args); if (!builder.isIgnored()) { messages.push_back(builder.build()); } diff --git a/src/providers/twitch/TwitchChannel.hpp b/src/providers/twitch/TwitchChannel.hpp index 2d24e115a..9a77243d8 100644 --- a/src/providers/twitch/TwitchChannel.hpp +++ b/src/providers/twitch/TwitchChannel.hpp @@ -60,12 +60,12 @@ public: bool isBroadcaster() const override; bool hasModRights(); - void addRecentChatter(const std::shared_ptr &message) final; + void addRecentChatter(const std::shared_ptr &message) final; void addJoinedUser(const QString &user); void addPartedUser(const QString &user); - 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/providers/twitch/TwitchEmotes.cpp b/src/providers/twitch/TwitchEmotes.cpp index 15fc8a8aa..9aa7d95dc 100644 --- a/src/providers/twitch/TwitchEmotes.cpp +++ b/src/providers/twitch/TwitchEmotes.cpp @@ -1,10 +1,10 @@ #include "providers/twitch/TwitchEmotes.hpp" +#include "common/UrlFetch.hpp" +#include "debug/Benchmark.hpp" #include "debug/Log.hpp" #include "messages/Image.hpp" -#include "debug/Benchmark.hpp" #include "util/RapidjsonHelpers.hpp" -#include "common/UrlFetch.hpp" #define TWITCH_EMOTE_TEMPLATE "https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}" @@ -47,19 +47,19 @@ QString cleanUpCode(const QString &dirtyEmoteCode) void loadSetData(std::shared_ptr emoteSet) { - debug::Log("Load twitch emote set data for {}", emoteSet->key); - util::NetworkRequest req("https://braize.pajlada.com/chatterino/twitchemotes/set/" + - emoteSet->key + "/"); + Log("Load twitch emote set data for {}", emoteSet->key); + NetworkRequest req("https://braize.pajlada.com/chatterino/twitchemotes/set/" + emoteSet->key + + "/"); - req.setRequestType(util::NetworkRequest::GetRequest); + req.setRequestType(NetworkRequest::GetRequest); req.onError([](int errorCode) -> bool { - debug::Log("Emote sets on ERROR {}", errorCode); + Log("Emote sets on ERROR {}", errorCode); return true; }); req.onSuccess([emoteSet](const rapidjson::Document &root) -> bool { - debug::Log("Emote sets on success"); + Log("Emote sets on success"); if (!root.IsObject()) { return false; } @@ -99,7 +99,7 @@ TwitchEmotes::TwitchEmotes() // id is used for lookup // emoteName is used for giving a name to the emote in case it doesn't exist -util::EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emoteName) +EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emoteName) { QString _emoteName = emoteName; _emoteName.replace("<", "<"); @@ -121,18 +121,18 @@ util::EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emo } return _twitchEmoteFromCache.getOrAdd(id, [&emoteName, &_emoteName, &id] { - util::EmoteData newEmoteData; + EmoteData newEmoteData; auto cleanCode = cleanUpCode(emoteName); - newEmoteData.image1x = new messages::Image(getEmoteLink(id, "1.0"), 1, emoteName, - _emoteName + "
Twitch Emote 1x"); + newEmoteData.image1x = new chatterino::Image(getEmoteLink(id, "1.0"), 1, emoteName, + _emoteName + "
Twitch Emote 1x"); newEmoteData.image1x->setCopyString(cleanCode); - newEmoteData.image2x = new messages::Image(getEmoteLink(id, "2.0"), .5, emoteName, - _emoteName + "
Twitch Emote 2x"); + newEmoteData.image2x = new chatterino::Image(getEmoteLink(id, "2.0"), .5, emoteName, + _emoteName + "
Twitch Emote 2x"); newEmoteData.image2x->setCopyString(cleanCode); - newEmoteData.image3x = new messages::Image(getEmoteLink(id, "3.0"), .25, emoteName, - _emoteName + "
Twitch Emote 3x"); + newEmoteData.image3x = new chatterino::Image(getEmoteLink(id, "3.0"), .25, emoteName, + _emoteName + "
Twitch Emote 3x"); newEmoteData.image3x->setCopyString(cleanCode); @@ -142,21 +142,21 @@ util::EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emo void TwitchEmotes::refresh(const std::shared_ptr &user) { - debug::Log("Loading Twitch emotes for user {}", user->getUserName()); + Log("Loading Twitch emotes for user {}", user->getUserName()); const auto &roomID = user->getUserId(); const auto &clientID = user->getOAuthClient(); const auto &oauthToken = user->getOAuthToken(); if (clientID.isEmpty() || oauthToken.isEmpty()) { - debug::Log("Missing Client ID or OAuth token"); + Log("Missing Client ID or OAuth token"); return; } TwitchAccountEmoteData &emoteData = this->emotes[roomID]; if (emoteData.filled) { - debug::Log("Emotes are already loaded for room id {}", roomID); + Log("Emotes are already loaded for room id {}", roomID); return; } @@ -183,7 +183,7 @@ void TwitchEmotes::refresh(const std::shared_ptr &user) emoteSet->emotes.emplace_back(id, cleanCode); emoteData.emoteCodes.push_back(cleanCode); - util::EmoteData emote = this->getEmoteById(id, code); + EmoteData emote = this->getEmoteById(id, code); emoteData.emotes.insert(code, emote); } @@ -193,13 +193,13 @@ void TwitchEmotes::refresh(const std::shared_ptr &user) emoteData.filled = true; }; - util::twitch::getAuthorized(url, clientID, oauthToken, QThread::currentThread(), loadEmotes); + getAuthorized(url, clientID, oauthToken, QThread::currentThread(), loadEmotes); } void TwitchEmotes::loadSetData(std::shared_ptr emoteSet) { if (!emoteSet) { - debug::Log("null emote set sent"); + Log("null emote set sent"); return; } @@ -211,14 +211,14 @@ void TwitchEmotes::loadSetData(std::shared_ptr emoteSet) return; } - debug::Log("Load twitch emote set data for {}..", emoteSet->key); - util::NetworkRequest req("https://braize.pajlada.com/chatterino/twitchemotes/set/" + - emoteSet->key + "/"); + Log("Load twitch emote set data for {}..", emoteSet->key); + NetworkRequest req("https://braize.pajlada.com/chatterino/twitchemotes/set/" + emoteSet->key + + "/"); - req.setRequestType(util::NetworkRequest::GetRequest); + req.setRequestType(NetworkRequest::GetRequest); req.onError([](int errorCode) -> bool { - debug::Log("Emote sets on ERROR {}", errorCode); + Log("Emote sets on ERROR {}", errorCode); return true; }); @@ -238,7 +238,7 @@ void TwitchEmotes::loadSetData(std::shared_ptr emoteSet) return false; } - debug::Log("Loaded twitch emote set data for {}!", emoteSet->key); + Log("Loaded twitch emote set data for {}!", emoteSet->key); if (type == "sub") { emoteSet->text = QString("Twitch Subscriber Emote (%1)").arg(channelName); diff --git a/src/providers/twitch/TwitchEmotes.hpp b/src/providers/twitch/TwitchEmotes.hpp index a68d52b68..17729ad24 100644 --- a/src/providers/twitch/TwitchEmotes.hpp +++ b/src/providers/twitch/TwitchEmotes.hpp @@ -17,10 +17,10 @@ class TwitchEmotes public: TwitchEmotes(); - util::EmoteData getEmoteById(const QString &id, const QString &emoteName); + EmoteData getEmoteById(const QString &id, const QString &emoteName); /// Twitch emotes - void refresh(const std::shared_ptr &user); + void refresh(const std::shared_ptr &user); struct TwitchEmote { TwitchEmote(const QString &_id, const QString &_code) @@ -50,7 +50,7 @@ public: std::vector emoteCodes; - util::EmoteMap emotes; + EmoteMap emotes; bool filled = false; }; @@ -62,10 +62,10 @@ private: void loadSetData(std::shared_ptr emoteSet); // emote code - util::ConcurrentMap _twitchEmotes; + ConcurrentMap _twitchEmotes; // emote id - util::ConcurrentMap _twitchEmoteFromCache; + ConcurrentMap _twitchEmoteFromCache; }; } // namespace chatterino diff --git a/src/providers/twitch/TwitchHelpers.cpp b/src/providers/twitch/TwitchHelpers.cpp index 2ef9c6042..f236b10cb 100644 --- a/src/providers/twitch/TwitchHelpers.cpp +++ b/src/providers/twitch/TwitchHelpers.cpp @@ -6,7 +6,7 @@ namespace chatterino { bool trimChannelName(const QString &channelName, QString &outChannelName) { if (channelName.length() < 3) { - debug::Log("channel name length below 3"); + Log("channel name length below 3"); return false; } diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index f8e9cd1e9..dc93aea97 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -18,13 +18,11 @@ #include #include -using namespace chatterino::messages; - namespace chatterino { TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage, - const messages::MessageParseArgs &_args) + const chatterino::MessageParseArgs &_args) : channel(_channel) , twitchChannel(dynamic_cast(_channel)) , ircMessage(_ircMessage) @@ -39,8 +37,8 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, const Communi::IrcMessage *_ircMessage, - const messages::MessageParseArgs &_args, QString content, - bool isAction) + const chatterino::MessageParseArgs &_args, + QString content, bool isAction) : channel(_channel) , twitchChannel(dynamic_cast(_channel)) , ircMessage(_ircMessage) @@ -60,8 +58,7 @@ bool TwitchMessageBuilder::isIgnored() const // TODO(pajlada): Do we need to check if the phrase is valid first? for (const auto &phrase : app->ignores->phrases.getVector()) { if (phrase.isMatch(this->originalMessage)) { - debug::Log("Blocking message because it contains ignored phrase {}", - phrase.getPattern()); + Log("Blocking message because it contains ignored phrase {}", phrase.getPattern()); return true; } } @@ -71,7 +68,7 @@ bool TwitchMessageBuilder::isIgnored() const for (const auto &user : app->accounts->twitch.getCurrent()->getIgnores()) { if (sourceUserID == user.id) { - debug::Log("Blocking message because it's from blocked user {}", user.name); + Log("Blocking message because it's from blocked user {}", user.name); return true; } } @@ -82,7 +79,7 @@ bool TwitchMessageBuilder::isIgnored() const for (const auto &user : app->accounts->twitch.getCurrent()->getIgnores()) { if (sourceUserID == user.id) { - debug::Log("Blocking message because it's from blocked user {}", user.name); + Log("Blocking message because it's from blocked user {}", user.name); return true; } } @@ -167,7 +164,7 @@ MessagePtr TwitchMessageBuilder::build() } // twitch emotes - std::vector> twitchEmotes; + std::vector> twitchEmotes; iterator = this->tags.find("emotes"); if (iterator != this->tags.end()) { @@ -205,13 +202,13 @@ MessagePtr TwitchMessageBuilder::build() } // split words - std::vector> parsed; + std::vector> parsed; // Parse emojis and take all non-emojis and put them in parsed as full text-words app->emotes->emojis.parse(parsed, split); for (const auto &tuple : parsed) { - const util::EmoteData &emoteData = std::get<0>(tuple); + const EmoteData &emoteData = std::get<0>(tuple); if (!emoteData.isValid()) { // is text QString string = std::get<1>(tuple); @@ -334,7 +331,7 @@ void TwitchMessageBuilder::appendUsername() auto iterator = this->tags.find("display-name"); if (iterator != this->tags.end()) { - QString displayName = util::parseTagString(iterator.value().toString()).trimmed(); + QString displayName = parseTagString(iterator.value().toString()).trimmed(); if (QString::compare(displayName, this->userName, Qt::CaseInsensitive) == 0) { username = displayName; @@ -449,13 +446,11 @@ void TwitchMessageBuilder::parseHighlights() // TODO: This vector should only be rebuilt upon highlights being changed // fourtf: should be implemented in the HighlightsController - std::vector activeHighlights = - app->highlights->phrases.getVector(); + std::vector activeHighlights = app->highlights->phrases.getVector(); if (app->settings->enableHighlightsSelf && currentUsername.size() > 0) { - controllers::highlights::HighlightPhrase selfHighlight( - currentUsername, app->settings->enableHighlightTaskbar, - app->settings->enableHighlightSound, false); + HighlightPhrase selfHighlight(currentUsername, app->settings->enableHighlightTaskbar, + app->settings->enableHighlightSound, false); activeHighlights.emplace_back(std::move(selfHighlight)); } @@ -466,10 +461,10 @@ void TwitchMessageBuilder::parseHighlights() bool hasFocus = (QApplication::focusWidget() != nullptr); if (!blackList.contains(this->ircMessage->nick(), Qt::CaseInsensitive)) { - for (const controllers::highlights::HighlightPhrase &highlight : activeHighlights) { + for (const HighlightPhrase &highlight : activeHighlights) { if (highlight.isMatch(this->originalMessage)) { - debug::Log("Highlight because {} matches {}", this->originalMessage, - highlight.getPattern()); + Log("Highlight because {} matches {}", this->originalMessage, + highlight.getPattern()); doHighlight = true; if (highlight.getAlert()) { @@ -506,7 +501,7 @@ void TwitchMessageBuilder::parseHighlights() void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessage, const QString &emote, - std::vector> &vec) + std::vector> &vec) { auto app = getApp(); if (!emote.contains(':')) { @@ -539,15 +534,15 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessa QString name = this->originalMessage.mid(start, end - start + 1); - vec.push_back(std::pair( - start, app->emotes->twitch.getEmoteById(id, name))); + vec.push_back( + std::pair(start, app->emotes->twitch.getEmoteById(id, name))); } } bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString) { auto app = getApp(); - util::EmoteData emoteData; + EmoteData emoteData; auto appendEmote = [&](MessageElement::Flags flags) { this->emplace(emoteData, flags); @@ -621,7 +616,7 @@ void TwitchMessageBuilder::appendTwitchBadges() this->emplace(badge.badgeImage1x, MessageElement::BadgeVanity) ->setTooltip(tooltip); } catch (const std::out_of_range &) { - debug::Log("No default bit badge for version {} found", versionKey); + Log("No default bit badge for version {} found", versionKey); continue; } } else if (badge == "staff/1") { @@ -768,7 +763,7 @@ bool TwitchMessageBuilder::tryParseCheermote(const QString &string) bool ok = false; int numBits = amount.toInt(&ok); if (!ok) { - debug::Log("Error parsing bit amount in tryParseCheermote"); + Log("Error parsing bit amount in tryParseCheermote"); return false; } @@ -785,8 +780,8 @@ bool TwitchMessageBuilder::tryParseCheermote(const QString &string) } if (savedIt == cheermoteSet.cheermotes.end()) { - debug::Log("Error getting a cheermote from a cheermote set for the bit amount {}", - numBits); + Log("Error getting a cheermote from a cheermote set for the bit amount {}", + numBits); return false; } diff --git a/src/providers/twitch/TwitchMessageBuilder.hpp b/src/providers/twitch/TwitchMessageBuilder.hpp index 6155a9d58..58669400f 100644 --- a/src/providers/twitch/TwitchMessageBuilder.hpp +++ b/src/providers/twitch/TwitchMessageBuilder.hpp @@ -14,7 +14,7 @@ namespace chatterino { class Channel; class TwitchChannel; -class TwitchMessageBuilder : public messages::MessageBuilder +class TwitchMessageBuilder : public chatterino::MessageBuilder { public: enum UsernameDisplayMode : int { @@ -26,22 +26,22 @@ public: TwitchMessageBuilder() = delete; explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage, - const messages::MessageParseArgs &_args); + const chatterino::MessageParseArgs &_args); explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcMessage *_ircMessage, - const messages::MessageParseArgs &_args, QString content, + const chatterino::MessageParseArgs &_args, QString content, bool isAction); Channel *channel; TwitchChannel *twitchChannel; const Communi::IrcMessage *ircMessage; - messages::MessageParseArgs args; + chatterino::MessageParseArgs args; const QVariantMap tags; QString messageID; QString userName; bool isIgnored() const; - messages::MessagePtr build(); + chatterino::MessagePtr build(); private: QString roomID; @@ -60,7 +60,7 @@ private: void parseHighlights(); void appendTwitchEmote(const Communi::IrcMessage *ircMessage, const QString &emote, - std::vector> &vec); + std::vector> &vec); bool tryAppendEmote(QString &emoteString); void appendTwitchBadges(); diff --git a/src/providers/twitch/TwitchServer.cpp b/src/providers/twitch/TwitchServer.cpp index b65381a7d..d95962761 100644 --- a/src/providers/twitch/TwitchServer.cpp +++ b/src/providers/twitch/TwitchServer.cpp @@ -29,10 +29,10 @@ TwitchServer::TwitchServer() void TwitchServer::initialize() { getApp()->accounts->twitch.currentUserChanged.connect( - [this]() { util::postToThread([this] { this->connect(); }); }); + [this]() { postToThread([this] { this->connect(); }); }); } -void TwitchServer::initializeConnection(providers::irc::IrcConnection *connection, bool isRead, +void TwitchServer::initializeConnection(IrcConnection *connection, bool isRead, bool isWrite) { std::shared_ptr account = getApp()->accounts->twitch.getCurrent(); @@ -196,7 +196,7 @@ void TwitchServer::onMessageSendRequested(TwitchChannel *channel, const QString if (!lastMessage.empty() && lastMessage.back() + minMessageOffset > now) { if (this->lastErrorTimeSpeed_ + 30s < now) { auto errorMessage = - messages::Message::createSystemMessage("sending messages too fast"); + chatterino::Message::createSystemMessage("sending messages too fast"); channel->addMessage(errorMessage); @@ -214,7 +214,7 @@ void TwitchServer::onMessageSendRequested(TwitchChannel *channel, const QString if (lastMessage.size() >= maxMessageCount) { if (this->lastErrorTimeAmount_ + 30s < now) { auto errorMessage = - messages::Message::createSystemMessage("sending too many messages"); + chatterino::Message::createSystemMessage("sending too many messages"); channel->addMessage(errorMessage); diff --git a/src/providers/twitch/TwitchServer.hpp b/src/providers/twitch/TwitchServer.hpp index 9634a6b05..56d12c6a4 100644 --- a/src/providers/twitch/TwitchServer.hpp +++ b/src/providers/twitch/TwitchServer.hpp @@ -11,7 +11,7 @@ namespace chatterino { -class TwitchServer final : public irc::AbstractIrcServer +class TwitchServer final : public AbstractIrcServer { public: TwitchServer(); @@ -23,15 +23,14 @@ public: std::shared_ptr getChannelOrEmptyByID(const QString &channelID); - util::MutexValue lastUserThatWhisperedMe; + MutexValue lastUserThatWhisperedMe; const ChannelPtr whispersChannel; const ChannelPtr mentionsChannel; IndirectChannel watchingChannel; protected: - void initializeConnection(providers::irc::IrcConnection *connection, bool isRead, - bool isWrite) override; + void initializeConnection(IrcConnection *connection, bool isRead, bool isWrite) override; std::shared_ptr createChannel(const QString &channelName) override; void privateMessageReceived(Communi::IrcPrivateMessage *message) override; diff --git a/src/singletons/EmoteManager.hpp b/src/singletons/EmoteManager.hpp index e8320f59b..1372d7619 100644 --- a/src/singletons/EmoteManager.hpp +++ b/src/singletons/EmoteManager.hpp @@ -17,10 +17,10 @@ public: void initialize(); - providers::twitch::TwitchEmotes twitch; - providers::bttv::BTTVEmotes bttv; - providers::ffz::FFZEmotes ffz; - providers::emoji::Emojis emojis; + TwitchEmotes twitch; + BTTVEmotes bttv; + FFZEmotes ffz; + Emojis emojis; GIFTimer gifTimer; }; diff --git a/src/singletons/FontManager.cpp b/src/singletons/FontManager.cpp index c08976598..fcd95c888 100644 --- a/src/singletons/FontManager.cpp +++ b/src/singletons/FontManager.cpp @@ -29,7 +29,7 @@ FontManager::FontManager() qDebug() << "init FontManager"; this->chatFontFamily.connect([this](const std::string &, auto) { - util::assertInGuiThread(); + assertInGuiThread(); if (getApp()->windows) { getApp()->windows->incGeneration(); @@ -42,7 +42,7 @@ FontManager::FontManager() }); this->chatFontSize.connect([this](const int &, auto) { - util::assertInGuiThread(); + assertInGuiThread(); if (getApp()->windows) { getApp()->windows->incGeneration(); @@ -69,7 +69,7 @@ QFontMetrics FontManager::getFontMetrics(FontManager::Type type, float scale) FontManager::FontData &FontManager::getOrCreateFontData(Type type, float scale) { - util::assertInGuiThread(); + assertInGuiThread(); assert(type >= 0 && type < EndType); diff --git a/src/singletons/FontManager.hpp b/src/singletons/FontManager.hpp index 5796adfe8..6e46283c2 100644 --- a/src/singletons/FontManager.hpp +++ b/src/singletons/FontManager.hpp @@ -77,6 +77,6 @@ private: std::vector> fontsByType; }; -using FontStyle = singletons::FontManager::Type; +using FontStyle = chatterino::FontManager::Type; } // namespace chatterino diff --git a/src/singletons/LoggingManager.cpp b/src/singletons/LoggingManager.cpp index b91975d11..272659acb 100644 --- a/src/singletons/LoggingManager.cpp +++ b/src/singletons/LoggingManager.cpp @@ -17,7 +17,7 @@ void LoggingManager::initialize() this->pathManager = getApp()->paths; } -void LoggingManager::addMessage(const QString &channelName, messages::MessagePtr message) +void LoggingManager::addMessage(const QString &channelName, chatterino::MessagePtr message) { auto app = getApp(); diff --git a/src/singletons/LoggingManager.hpp b/src/singletons/LoggingManager.hpp index 539a9fd46..f52d4dc85 100644 --- a/src/singletons/LoggingManager.hpp +++ b/src/singletons/LoggingManager.hpp @@ -20,7 +20,7 @@ public: void initialize(); - void addMessage(const QString &channelName, messages::MessagePtr message); + void addMessage(const QString &channelName, chatterino::MessagePtr message); private: std::map> loggingChannels; diff --git a/src/singletons/NativeMessagingManager.cpp b/src/singletons/NativeMessagingManager.cpp index 3bcfd295f..2a0c7c3b8 100644 --- a/src/singletons/NativeMessagingManager.cpp +++ b/src/singletons/NativeMessagingManager.cpp @@ -176,7 +176,7 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro qDebug() << attach; #ifdef USEWINSDK - widgets::AttachedWindow::GetArgs args; + AttachedWindow::GetArgs args; args.winId = root.value("winId").toString(); args.yOffset = root.value("yOffset").toInt(-1); args.width = root.value("size").toObject().value("width").toInt(-1); @@ -190,7 +190,7 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro #endif if (_type == "twitch") { - util::postToThread([=] { + postToThread([=] { if (!name.isEmpty()) { app->twitch.server->watchingChannel.update( app->twitch.server->getOrAddChannel(name)); @@ -199,7 +199,7 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro if (attach) { #ifdef USEWINSDK // if (args.height != -1) { - auto *window = widgets::AttachedWindow::get(::GetForegroundWindow(), args); + auto *window = AttachedWindow::get(::GetForegroundWindow(), args); if (!name.isEmpty()) { window->setChannel(app->twitch.server->getOrAddChannel(name)); } @@ -221,9 +221,9 @@ void NativeMessagingManager::ReceiverThread::handleMessage(const QJsonObject &ro } #ifdef USEWINSDK - util::postToThread([winId] { + postToThread([winId] { qDebug() << "NW detach"; - widgets::AttachedWindow::detach(winId); + AttachedWindow::detach(winId); }); #endif } else { @@ -235,7 +235,7 @@ std::string &NativeMessagingManager::getGuiMessageQueueName() { static std::string name = "chatterino_gui" + - singletons::PathManager::getInstance()->applicationFilePathHash.toStdString(); + chatterino::PathManager::getInstance()->applicationFilePathHash.toStdString(); return name; } diff --git a/src/singletons/PathManager.cpp b/src/singletons/PathManager.cpp index 52e926449..50427cbd2 100644 --- a/src/singletons/PathManager.cpp +++ b/src/singletons/PathManager.cpp @@ -59,7 +59,7 @@ void PathManager::initAppFilePathHash() void PathManager::initCheckPortable() { this->portable = - QFileInfo::exists(util::combinePath(QCoreApplication::applicationDirPath(), "portable")); + QFileInfo::exists(combinePath(QCoreApplication::applicationDirPath(), "portable")); } void PathManager::initAppDataDirectory() @@ -99,7 +99,7 @@ void PathManager::initSubDirectories() // create settings subdirectories and validate that they are created properly auto makePath = [&](const std::string &name) -> QString { - auto path = util::combinePath(this->rootAppDataDirectory, QString::fromStdString(name)); + auto path = combinePath(this->rootAppDataDirectory, QString::fromStdString(name)); if (!QDir().mkpath(path)) { throw std::runtime_error("Error creating appdata path %appdata%/chatterino/" + name); diff --git a/src/singletons/ResourceManager.cpp b/src/singletons/ResourceManager.cpp index 9ae25dced..92d6673c6 100644 --- a/src/singletons/ResourceManager.cpp +++ b/src/singletons/ResourceManager.cpp @@ -8,9 +8,9 @@ namespace chatterino { namespace { -inline messages::Image *lli(const char *pixmapPath, qreal scale = 1) +inline chatterino::Image *lli(const char *pixmapPath, qreal scale = 1) { - return new messages::Image(new QPixmap(pixmapPath), scale); + return new chatterino::Image(new QPixmap(pixmapPath), scale); } template @@ -221,7 +221,7 @@ inline bool ParseSingleCheermoteSet(ResourceManager::JSONCheermoteSet &set, qreal chatterinoScale = 1 / scaleNumber; - auto image = new messages::Image(url, chatterinoScale); + auto image = new chatterino::Image(url, chatterinoScale); // TODO(pajlada): Fill in name and tooltip tier.images[background][state][scale] = image; @@ -310,9 +310,9 @@ void ResourceManager::initialize() } ResourceManager::BadgeVersion::BadgeVersion(QJsonObject &&root) - : badgeImage1x(new messages::Image(root.value("image_url_1x").toString())) - , badgeImage2x(new messages::Image(root.value("image_url_2x").toString())) - , badgeImage4x(new messages::Image(root.value("image_url_4x").toString())) + : badgeImage1x(new chatterino::Image(root.value("image_url_1x").toString())) + , badgeImage2x(new chatterino::Image(root.value("image_url_2x").toString())) + , badgeImage4x(new chatterino::Image(root.value("image_url_4x").toString())) , description(root.value("description").toString().toStdString()) , title(root.value("title").toString().toStdString()) , clickAction(root.value("clickAction").toString().toStdString()) @@ -324,7 +324,7 @@ void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache) { QString url = "https://badges.twitch.tv/v1/badges/channels/" + roomID + "/display?language=en"; - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(QThread::currentThread()); req.getJSON([this, roomID](QJsonObject &root) { @@ -352,52 +352,52 @@ void ResourceManager::loadChannelData(const QString &roomID, bool bypassCache) QString cheermoteURL = "https://api.twitch.tv/kraken/bits/actions?channel_id=" + roomID; - util::twitch::get2( - cheermoteURL, QThread::currentThread(), true, [this, roomID](const rapidjson::Document &d) { - ResourceManager::Channel &ch = this->channels[roomID]; + get2(cheermoteURL, QThread::currentThread(), true, + [this, roomID](const rapidjson::Document &d) { + ResourceManager::Channel &ch = this->channels[roomID]; - ParseCheermoteSets(ch.jsonCheermoteSets, d); + ParseCheermoteSets(ch.jsonCheermoteSets, d); - for (auto &set : ch.jsonCheermoteSets) { - CheermoteSet cheermoteSet; - cheermoteSet.regex = - QRegularExpression("^" + set.prefix.toLower() + "([1-9][0-9]*)$"); + for (auto &set : ch.jsonCheermoteSets) { + CheermoteSet cheermoteSet; + cheermoteSet.regex = + QRegularExpression("^" + set.prefix.toLower() + "([1-9][0-9]*)$"); - for (auto &tier : set.tiers) { - Cheermote cheermote; + for (auto &tier : set.tiers) { + Cheermote cheermote; - cheermote.color = QColor(tier.color); - cheermote.minBits = tier.minBits; + cheermote.color = QColor(tier.color); + cheermote.minBits = tier.minBits; - // TODO(pajlada): We currently hardcode dark here :| - // We will continue to do so for now since we haven't had to - // solve that anywhere else - cheermote.emoteDataAnimated.image1x = tier.images["dark"]["animated"]["1"]; - cheermote.emoteDataAnimated.image2x = tier.images["dark"]["animated"]["2"]; - cheermote.emoteDataAnimated.image3x = tier.images["dark"]["animated"]["4"]; + // TODO(pajlada): We currently hardcode dark here :| + // We will continue to do so for now since we haven't had to + // solve that anywhere else + cheermote.emoteDataAnimated.image1x = tier.images["dark"]["animated"]["1"]; + cheermote.emoteDataAnimated.image2x = tier.images["dark"]["animated"]["2"]; + cheermote.emoteDataAnimated.image3x = tier.images["dark"]["animated"]["4"]; - cheermote.emoteDataStatic.image1x = tier.images["dark"]["static"]["1"]; - cheermote.emoteDataStatic.image2x = tier.images["dark"]["static"]["2"]; - cheermote.emoteDataStatic.image3x = tier.images["dark"]["static"]["4"]; + cheermote.emoteDataStatic.image1x = tier.images["dark"]["static"]["1"]; + cheermote.emoteDataStatic.image2x = tier.images["dark"]["static"]["2"]; + cheermote.emoteDataStatic.image3x = tier.images["dark"]["static"]["4"]; - cheermoteSet.cheermotes.emplace_back(cheermote); - } + cheermoteSet.cheermotes.emplace_back(cheermote); + } - std::sort(cheermoteSet.cheermotes.begin(), cheermoteSet.cheermotes.end(), - [](const auto &lhs, const auto &rhs) { - return lhs.minBits < rhs.minBits; // - }); + std::sort(cheermoteSet.cheermotes.begin(), cheermoteSet.cheermotes.end(), + [](const auto &lhs, const auto &rhs) { + return lhs.minBits < rhs.minBits; // + }); - ch.cheermoteSets.emplace_back(cheermoteSet); - } - }); + ch.cheermoteSets.emplace_back(cheermoteSet); + } + }); } void ResourceManager::loadDynamicTwitchBadges() { static QString url("https://badges.twitch.tv/v1/badges/global/display?language=en"); - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(QThread::currentThread()); req.getJSON([this](QJsonObject &root) { QJsonObject sets = root.value("badge_sets").toObject(); @@ -426,7 +426,7 @@ void ResourceManager::loadChatterinoBadges() static QString url("https://fourtf.com/chatterino/badges.json"); - util::NetworkRequest req(url); + NetworkRequest req(url); req.setCaller(QThread::currentThread()); req.getJSON([this](QJsonObject &root) { @@ -438,7 +438,7 @@ void ResourceManager::loadChatterinoBadges() const QString &badgeVariantImageURL = badgeVariant.value("image").toString(); auto badgeVariantPtr = std::make_shared( - badgeVariantTooltip, new messages::Image(badgeVariantImageURL)); + badgeVariantTooltip, new chatterino::Image(badgeVariantImageURL)); QJsonArray badgeVariantUsers = badgeVariant.value("users").toArray(); diff --git a/src/singletons/ResourceManager.hpp b/src/singletons/ResourceManager.hpp index fe1b3554b..54300c954 100644 --- a/src/singletons/ResourceManager.hpp +++ b/src/singletons/ResourceManager.hpp @@ -35,39 +35,39 @@ public: QPixmap unmod; } buttons; - messages::Image *badgeStaff; - messages::Image *badgeAdmin; - messages::Image *badgeGlobalModerator; - messages::Image *badgeModerator; - messages::Image *badgeTurbo; - messages::Image *badgeBroadcaster; - messages::Image *badgePremium; - messages::Image *badgeVerified; - messages::Image *badgeSubscriber; - messages::Image *badgeCollapsed; + chatterino::Image *badgeStaff; + chatterino::Image *badgeAdmin; + chatterino::Image *badgeGlobalModerator; + chatterino::Image *badgeModerator; + chatterino::Image *badgeTurbo; + chatterino::Image *badgeBroadcaster; + chatterino::Image *badgePremium; + chatterino::Image *badgeVerified; + chatterino::Image *badgeSubscriber; + chatterino::Image *badgeCollapsed; - messages::Image *cheerBadge100000; - messages::Image *cheerBadge10000; - messages::Image *cheerBadge5000; - messages::Image *cheerBadge1000; - messages::Image *cheerBadge100; - messages::Image *cheerBadge1; + chatterino::Image *cheerBadge100000; + chatterino::Image *cheerBadge10000; + chatterino::Image *cheerBadge5000; + chatterino::Image *cheerBadge1000; + chatterino::Image *cheerBadge100; + chatterino::Image *cheerBadge1; - messages::Image *moderationmode_enabled; - messages::Image *moderationmode_disabled; + chatterino::Image *moderationmode_enabled; + chatterino::Image *moderationmode_disabled; - messages::Image *splitHeaderContext; + chatterino::Image *splitHeaderContext; - std::map cheerBadges; + std::map cheerBadges; struct BadgeVersion { BadgeVersion() = delete; explicit BadgeVersion(QJsonObject &&root); - messages::Image *badgeImage1x; - messages::Image *badgeImage2x; - messages::Image *badgeImage4x; + chatterino::Image *badgeImage1x; + chatterino::Image *badgeImage2x; + chatterino::Image *badgeImage4x; std::string description; std::string title; std::string clickAction; @@ -82,8 +82,8 @@ public: bool dynamicBadgesLoaded = false; - messages::Image *buttonBan; - messages::Image *buttonTimeout; + chatterino::Image *buttonBan; + chatterino::Image *buttonTimeout; struct JSONCheermoteSet { QString prefix; @@ -102,7 +102,7 @@ public: QString color; // Background State Scale - std::map>> images; + std::map>> images; }; std::vector tiers; @@ -113,8 +113,8 @@ public: QColor color; int minBits; - util::EmoteData emoteDataAnimated; - util::EmoteData emoteDataStatic; + EmoteData emoteDataAnimated; + EmoteData emoteDataStatic; }; struct CheermoteSet { @@ -135,14 +135,14 @@ public: // Chatterino badges struct ChatterinoBadge { - ChatterinoBadge(const std::string &_tooltip, messages::Image *_image) + ChatterinoBadge(const std::string &_tooltip, chatterino::Image *_image) : tooltip(_tooltip) , image(_image) { } std::string tooltip; - messages::Image *image; + chatterino::Image *image; }; // username diff --git a/src/singletons/SettingsManager.cpp b/src/singletons/SettingsManager.cpp index 72276c11e..946f19f00 100644 --- a/src/singletons/SettingsManager.cpp +++ b/src/singletons/SettingsManager.cpp @@ -122,7 +122,7 @@ void SettingManager::saveSnapshot() this->snapshot.reset(d); - debug::Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d)); + Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d)); } void SettingManager::recallSnapshot() @@ -136,14 +136,14 @@ void SettingManager::recallSnapshot() for (const auto &weakSetting : _settings) { auto setting = weakSetting.lock(); if (!setting) { - debug::Log("Error stage 1 of loading"); + Log("Error stage 1 of loading"); continue; } const char *path = setting->getPath().c_str(); if (!snapshotObject.HasMember(path)) { - debug::Log("Error stage 2 of loading"); + Log("Error stage 2 of loading"); continue; } diff --git a/src/singletons/SettingsManager.hpp b/src/singletons/SettingsManager.hpp index 809f49c08..ba00128ea 100644 --- a/src/singletons/SettingsManager.hpp +++ b/src/singletons/SettingsManager.hpp @@ -25,7 +25,7 @@ public: ~SettingManager() = delete; - messages::MessageElement::Flags getWordFlags(); + chatterino::MessageElement::Flags getWordFlags(); bool isIgnoredEmote(const QString &emote); void initialize(); @@ -142,7 +142,7 @@ private: void updateModerationActions(); - messages::MessageElement::Flags wordFlags = messages::MessageElement::Default; + chatterino::MessageElement::Flags wordFlags = chatterino::MessageElement::Default; pajlada::Settings::SettingListener wordFlagsListener; }; diff --git a/src/singletons/UpdateManager.cpp b/src/singletons/UpdateManager.cpp index 7c0215136..d8ead5a50 100644 --- a/src/singletons/UpdateManager.cpp +++ b/src/singletons/UpdateManager.cpp @@ -49,12 +49,12 @@ void UpdateManager::installUpdates() box->setAttribute(Qt::WA_DeleteOnClose); box->show(); - util::NetworkRequest req(this->updateUrl_); + NetworkRequest req(this->updateUrl_); req.setTimeout(600000); req.onError([this](int) -> bool { this->setStatus_(DownloadFailed); - util::postToThread([] { + postToThread([] { QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update", "Failed while trying to download the update."); box->setAttribute(Qt::WA_DeleteOnClose); @@ -65,7 +65,7 @@ void UpdateManager::installUpdates() return true; }); req.get([this](QByteArray &object) { - auto filename = util::combinePath(getApp()->paths->miscDirectory, "update.zip"); + auto filename = combinePath(getApp()->paths->miscDirectory, "update.zip"); QFile file(filename); file.open(QIODevice::Truncate | QIODevice::WriteOnly); @@ -75,7 +75,7 @@ void UpdateManager::installUpdates() return false; } - QProcess::startDetached(util::combinePath(QCoreApplication::applicationDirPath(), + QProcess::startDetached(combinePath(QCoreApplication::applicationDirPath(), "updater.1/ChatterinoUpdater.exe"), {filename, "restart"}); @@ -92,7 +92,7 @@ void UpdateManager::checkForUpdates() #ifdef Q_OS_WIN QString url = "https://notitia.chatterino.com/version/chatterino/" CHATTERINO_OS "/stable"; - util::NetworkRequest req(url); + NetworkRequest req(url); req.setTimeout(30000); req.getJSON([this](QJsonObject &object) { QJsonValue version_val = object.value("version"); @@ -102,7 +102,7 @@ void UpdateManager::checkForUpdates() this->setStatus_(SearchFailed); qDebug() << "error updating"; - util::postToThread([] { + postToThread([] { QMessageBox *box = new QMessageBox( QMessageBox::Information, "Chatterino Update", "Error while searching for updates.\n\nEither the service is down " @@ -119,7 +119,7 @@ void UpdateManager::checkForUpdates() if (this->currentVersion_ != this->onlineVersion_) { this->setStatus_(UpdateAvailable); - util::postToThread([this] { + postToThread([this] { QMessageBox *box = new QMessageBox(QMessageBox::Information, "Chatterino Update", "An update for chatterino is available.\n\nDo you " @@ -150,7 +150,7 @@ void UpdateManager::setStatus_(UpdateStatus status) { if (this->status_ != status) { this->status_ = status; - util::postToThread([this, status] { this->statusUpdated.invoke(status); }); + postToThread([this, status] { this->statusUpdated.invoke(status); }); } } diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 56f9369ec..102a58e10 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -21,21 +21,21 @@ namespace chatterino { -using SplitNode = widgets::SplitContainer::Node; -using SplitDirection = widgets::SplitContainer::Direction; +using SplitNode = SplitContainer::Node; +using SplitDirection = SplitContainer::Direction; const int WindowManager::uiScaleMin = -5; const int WindowManager::uiScaleMax = 10; void WindowManager::showSettingsDialog() { - QTimer::singleShot(80, [] { widgets::SettingsDialog::showDialog(); }); + QTimer::singleShot(80, [] { SettingsDialog::showDialog(); }); } void WindowManager::showAccountSelectPopup(QPoint point) { // static QWidget *lastFocusedWidget = nullptr; - static widgets::AccountSwitchPopupWidget *w = new widgets::AccountSwitchPopupWidget(); + static AccountSwitchPopupWidget *w = new AccountSwitchPopupWidget(); if (w->hasFocus()) { w->hide(); @@ -91,29 +91,29 @@ void WindowManager::repaintGifEmotes() // } //} -widgets::Window &WindowManager::getMainWindow() +Window &WindowManager::getMainWindow() { - util::assertInGuiThread(); + assertInGuiThread(); return *this->mainWindow; } -widgets::Window &WindowManager::getSelectedWindow() +Window &WindowManager::getSelectedWindow() { - util::assertInGuiThread(); + assertInGuiThread(); return *this->selectedWindow; } -widgets::Window &WindowManager::createWindow(widgets::Window::WindowType type) +Window &WindowManager::createWindow(Window::WindowType type) { - util::assertInGuiThread(); + assertInGuiThread(); - auto *window = new widgets::Window(type); + auto *window = new Window(type); this->windows.push_back(window); window->show(); - if (type != widgets::Window::Main) { + if (type != Window::Main) { window->setAttribute(Qt::WA_DeleteOnClose); QObject::connect(window, &QWidget::destroyed, [this, window] { @@ -134,21 +134,21 @@ int WindowManager::windowCount() return this->windows.size(); } -widgets::Window *WindowManager::windowAt(int index) +Window *WindowManager::windowAt(int index) { - util::assertInGuiThread(); + assertInGuiThread(); if (index < 0 || (size_t)index >= this->windows.size()) { return nullptr; } - debug::Log("getting window at bad index {}", index); + Log("getting window at bad index {}", index); return this->windows.at(index); } void WindowManager::initialize() { - util::assertInGuiThread(); + assertInGuiThread(); auto app = getApp(); app->themes->repaintVisibleChatWidgets.connect([this] { this->repaintVisibleChatWidgets(); }); @@ -169,16 +169,16 @@ void WindowManager::initialize() // get type QString type_val = window_obj.value("type").toString(); - widgets::Window::WindowType type = - type_val == "main" ? widgets::Window::Main : widgets::Window::Popup; + Window::WindowType type = + type_val == "main" ? Window::Main : Window::Popup; - if (type == widgets::Window::Main && mainWindow != nullptr) { - type = widgets::Window::Popup; + if (type == Window::Main && mainWindow != nullptr) { + type = Window::Popup; } - widgets::Window &window = createWindow(type); + Window &window = createWindow(type); - if (type == widgets::Window::Main) { + if (type == Window::Main) { mainWindow = &window; } @@ -197,7 +197,7 @@ void WindowManager::initialize() // load tabs QJsonArray tabs = window_obj.value("tabs").toArray(); for (QJsonValue tab_val : tabs) { - widgets::SplitContainer *page = window.getNotebook().addPage(false); + SplitContainer *page = window.getNotebook().addPage(false); QJsonObject tab_obj = tab_val.toObject(); @@ -225,7 +225,7 @@ void WindowManager::initialize() int colNr = 0; for (QJsonValue column_val : tab_obj.value("splits").toArray()) { for (QJsonValue split_val : column_val.toArray()) { - widgets::Split *split = new widgets::Split(page); + Split *split = new Split(page); QJsonObject split_obj = split_val.toObject(); split->setChannel(decodeChannel(split_obj)); @@ -238,7 +238,7 @@ void WindowManager::initialize() } if (mainWindow == nullptr) { - mainWindow = &createWindow(widgets::Window::Main); + mainWindow = &createWindow(Window::Main); mainWindow->getNotebook().addPage(true); } @@ -247,22 +247,22 @@ void WindowManager::initialize() void WindowManager::save() { - util::assertInGuiThread(); + assertInGuiThread(); auto app = getApp(); QJsonDocument document; // "serialize" QJsonArray window_arr; - for (widgets::Window *window : this->windows) { + for (Window *window : this->windows) { QJsonObject window_obj; // window type switch (window->getType()) { - case widgets::Window::Main: + case Window::Main: window_obj.insert("type", "main"); break; - case widgets::Window::Popup: + case Window::Popup: window_obj.insert("type", "popup"); break; } @@ -278,8 +278,8 @@ void WindowManager::save() for (int tab_i = 0; tab_i < window->getNotebook().getPageCount(); tab_i++) { QJsonObject tab_obj; - widgets::SplitContainer *tab = - dynamic_cast(window->getNotebook().getPageAt(tab_i)); + SplitContainer *tab = + dynamic_cast(window->getNotebook().getPageAt(tab_i)); assert(tab != nullptr); // custom tab title @@ -355,7 +355,7 @@ void WindowManager::encodeNodeRecusively(SplitNode *node, QJsonObject &obj) void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj) { - util::assertInGuiThread(); + assertInGuiThread(); switch (channel.getType()) { case Channel::Twitch: { @@ -376,7 +376,7 @@ void WindowManager::encodeChannel(IndirectChannel channel, QJsonObject &obj) IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj) { - util::assertInGuiThread(); + assertInGuiThread(); auto app = getApp(); @@ -396,9 +396,9 @@ IndirectChannel WindowManager::decodeChannel(const QJsonObject &obj) void WindowManager::closeAll() { - util::assertInGuiThread(); + assertInGuiThread(); - for (widgets::Window *window : windows) { + for (Window *window : windows) { window->close(); } } @@ -415,7 +415,7 @@ void WindowManager::incGeneration() int WindowManager::clampUiScale(int scale) { - return util::clamp(scale, uiScaleMin, uiScaleMax); + return clamp(scale, uiScaleMin, uiScaleMax); } float WindowManager::getUiScaleValue() diff --git a/src/singletons/WindowManager.hpp b/src/singletons/WindowManager.hpp index fa978f3c1..3b19dc682 100644 --- a/src/singletons/WindowManager.hpp +++ b/src/singletons/WindowManager.hpp @@ -21,12 +21,12 @@ public: void repaintGifEmotes(); // void updateAll(); - widgets::Window &getMainWindow(); - widgets::Window &getSelectedWindow(); - widgets::Window &createWindow(widgets::Window::WindowType type); + Window &getMainWindow(); + Window &getSelectedWindow(); + Window &createWindow(Window::WindowType type); int windowCount(); - widgets::Window *windowAt(int index); + Window *windowAt(int index); void save(); void initialize(); @@ -49,12 +49,12 @@ private: std::atomic generation{0}; - std::vector windows; + std::vector windows; - widgets::Window *mainWindow = nullptr; - widgets::Window *selectedWindow = nullptr; + Window *mainWindow = nullptr; + Window *selectedWindow = nullptr; - void encodeNodeRecusively(widgets::SplitContainer::Node *node, QJsonObject &obj); + void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj); public: static void encodeChannel(IndirectChannel channel, QJsonObject &obj); diff --git a/src/singletons/helper/LoggingChannel.cpp b/src/singletons/helper/LoggingChannel.cpp index 15d0b66a0..d477e63f1 100644 --- a/src/singletons/helper/LoggingChannel.cpp +++ b/src/singletons/helper/LoggingChannel.cpp @@ -63,13 +63,13 @@ void LoggingChannel::openLogFile() QString directory = this->baseDirectory + QDir::separator() + this->subDirectory; if (!QDir().mkpath(directory)) { - debug::Log("Unable to create logging path"); + Log("Unable to create logging path"); return; } // Open file handle to log file of current date QString fileName = directory + QDir::separator() + baseFileName; - debug::Log("Logging to {}", fileName); + Log("Logging to {}", fileName); this->fileHandle.setFileName(fileName); this->fileHandle.open(QIODevice::Append); @@ -77,7 +77,7 @@ void LoggingChannel::openLogFile() this->appendLine(this->generateOpeningString(now)); } -void LoggingChannel::addMessage(std::shared_ptr message) +void LoggingChannel::addMessage(std::shared_ptr message) { QDateTime now = QDateTime::currentDateTime(); diff --git a/src/singletons/helper/LoggingChannel.hpp b/src/singletons/helper/LoggingChannel.hpp index 83ff6f809..98d9f0203 100644 --- a/src/singletons/helper/LoggingChannel.hpp +++ b/src/singletons/helper/LoggingChannel.hpp @@ -17,7 +17,7 @@ class LoggingChannel : boost::noncopyable public: ~LoggingChannel(); - void addMessage(std::shared_ptr message); + void addMessage(std::shared_ptr message); private: void openLogFile(); diff --git a/src/singletons/helper/ModerationAction.cpp b/src/singletons/helper/ModerationAction.cpp index 7a5f061a4..c61cc653a 100644 --- a/src/singletons/helper/ModerationAction.cpp +++ b/src/singletons/helper/ModerationAction.cpp @@ -4,7 +4,7 @@ namespace chatterino { -ModerationAction::ModerationAction(messages::Image *_image, const QString &_action) +ModerationAction::ModerationAction(chatterino::Image *_image, const QString &_action) : _isImage(true) , image(_image) , action(_action) @@ -26,7 +26,7 @@ bool ModerationAction::isImage() const return this->_isImage; } -messages::Image *ModerationAction::getImage() const +chatterino::Image *ModerationAction::getImage() const { return this->image; } diff --git a/src/singletons/helper/ModerationAction.hpp b/src/singletons/helper/ModerationAction.hpp index 7d37ccaca..52b5449d1 100644 --- a/src/singletons/helper/ModerationAction.hpp +++ b/src/singletons/helper/ModerationAction.hpp @@ -9,18 +9,18 @@ class Image; class ModerationAction { public: - ModerationAction(messages::Image *image, const QString &action); + ModerationAction(chatterino::Image *image, const QString &action); ModerationAction(const QString &line1, const QString &line2, const QString &action); bool isImage() const; - messages::Image *getImage() const; + chatterino::Image *getImage() const; const QString &getLine1() const; const QString &getLine2() const; const QString &getAction() const; private: bool _isImage; - messages::Image *image; + chatterino::Image *image; QString line1; QString line2; QString action; diff --git a/src/util/StreamLink.cpp b/src/util/StreamLink.cpp index e34c90b35..a009a2944 100644 --- a/src/util/StreamLink.cpp +++ b/src/util/StreamLink.cpp @@ -167,7 +167,7 @@ void Start(const QString &channel) if (preferredQuality == "choose") { GetStreamQualities(channelURL, [=](QStringList qualityOptions) { - widgets::QualityPopup::showDialog(channel, qualityOptions); + QualityPopup::showDialog(channel, qualityOptions); }); return; diff --git a/src/widgets/AttachedWindow.cpp b/src/widgets/AttachedWindow.cpp index 5a68d3686..65e0a681c 100644 --- a/src/widgets/AttachedWindow.cpp +++ b/src/widgets/AttachedWindow.cpp @@ -32,7 +32,7 @@ AttachedWindow::AttachedWindow(void *_target, int _yOffset) split->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::MinimumExpanding); layout->addWidget(split); - util::DebugCount::increase("attached window"); + DebugCount::increase("attached window"); } AttachedWindow::~AttachedWindow() @@ -44,7 +44,7 @@ AttachedWindow::~AttachedWindow() } } - util::DebugCount::decrease("attached window"); + DebugCount::decrease("attached window"); } AttachedWindow *AttachedWindow::get(void *target, const GetArgs &args) @@ -179,7 +179,7 @@ void AttachedWindow::updateWindowRect_(void *_attachedPtr) SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); float scale = 1.f; - if (auto dpi = util::getWindowDpi(attached)) { + if (auto dpi = getWindowDpi(attached)) { scale = dpi.get() / 96.f; // for (auto w : this->ui_.split->findChildren()) { diff --git a/src/widgets/BaseWidget.hpp b/src/widgets/BaseWidget.hpp index 7bead3ea0..4767e676b 100644 --- a/src/widgets/BaseWidget.hpp +++ b/src/widgets/BaseWidget.hpp @@ -41,7 +41,7 @@ protected: void setScale(float value); - singletons::ThemeManager *themeManager; + chatterino::ThemeManager *themeManager; private: void init(); diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index e29fdf234..1d4f7a4da 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -8,10 +8,10 @@ #include "util/NativeEventHelper.hpp" #include "util/PostToThread.hpp" #include "util/WindowsHelper.hpp" -#include "widgets/helper/RippleEffectLabel.hpp" -#include "widgets/helper/Shortcut.hpp" #include "widgets/Label.hpp" #include "widgets/TooltipWidget.hpp" +#include "widgets/helper/RippleEffectLabel.hpp" +#include "widgets/helper/Shortcut.hpp" #include #include @@ -60,7 +60,7 @@ BaseWindow::BaseWindow(QWidget *parent, Flags _flags) this->connections_.managedConnect( getApp()->settings->uiScale.getValueChangedSignal(), - [this](auto, auto) { util::postToThread([this] { this->updateScale(); }); }); + [this](auto, auto) { postToThread([this] { this->updateScale(); }); }); this->updateScale(); @@ -147,7 +147,7 @@ void BaseWindow::init() } // DPI -// auto dpi = util::getWindowDpi(this->winId()); +// auto dpi = getWindowDpi(this->winId()); // if (dpi) { // this->scale = dpi.value() / 96.f; @@ -171,6 +171,7 @@ void BaseWindow::init() // this->setWindowFlag(Qt::WindowStaysOnTopHint); // } #endif +} void BaseWindow::setStayInScreenRect(bool value) { @@ -249,10 +250,10 @@ void BaseWindow::wheelEvent(QWheelEvent *event) if (event->modifiers() & Qt::ControlModifier) { if (event->delta() > 0) { - getApp()->settings->uiScale.setValue(singletons::WindowManager::clampUiScale( + getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale( getApp()->settings->uiScale.getValue() + 1)); } else { - getApp()->settings->uiScale.setValue(singletons::WindowManager::clampUiScale( + getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale( getApp()->settings->uiScale.getValue() - 1)); } } @@ -278,7 +279,7 @@ void BaseWindow::mousePressEvent(QMouseEvent *event) }; if (!recursiveCheckMouseTracking(widget)) { - debug::Log("Start moving"); + Log("Start moving"); this->moving = true; } } @@ -293,7 +294,7 @@ void BaseWindow::mouseReleaseEvent(QMouseEvent *event) #ifndef Q_OS_WIN if (this->flags_ & FramelessDraggable) { if (this->moving) { - debug::Log("Stop moving"); + Log("Stop moving"); this->moving = false; } } @@ -438,7 +439,7 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r return true; } case WM_SHOWWINDOW: { - if (auto dpi = util::getWindowDpi(msg->hwnd)) { + if (auto dpi = getWindowDpi(msg->hwnd)) { this->nativeScale_ = dpi.get() / 96.f; this->updateScale(); } diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index d3a9e1dee..f47705e04 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -52,7 +52,7 @@ void Scrollbar::unpauseHighlights() this->highlightsPaused_ = false; } -messages::LimitedQueueSnapshot Scrollbar::getHighlightSnapshot() +chatterino::LimitedQueueSnapshot Scrollbar::getHighlightSnapshot() { if (!this->highlightsPaused_) { this->highlightSnapshot_ = this->highlights_.getSnapshot(); diff --git a/src/widgets/Scrollbar.hpp b/src/widgets/Scrollbar.hpp index 17db6a2ca..e4e742f8a 100644 --- a/src/widgets/Scrollbar.hpp +++ b/src/widgets/Scrollbar.hpp @@ -68,10 +68,10 @@ private: QPropertyAnimation currentValueAnimation_; - messages::LimitedQueue highlights_; + chatterino::LimitedQueue highlights_; bool highlightsPaused_{false}; - messages::LimitedQueueSnapshot highlightSnapshot_; - messages::LimitedQueueSnapshot getHighlightSnapshot(); + chatterino::LimitedQueueSnapshot highlightSnapshot_; + chatterino::LimitedQueueSnapshot getHighlightSnapshot(); bool atBottom_{false}; diff --git a/src/widgets/StreamView.cpp b/src/widgets/StreamView.cpp index f59fadd13..05bd0e68e 100644 --- a/src/widgets/StreamView.cpp +++ b/src/widgets/StreamView.cpp @@ -13,7 +13,7 @@ namespace chatterino { StreamView::StreamView(ChannelPtr channel, const QUrl &url) { - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); #ifdef USEWEBENGINE auto web = layoutCreator.emplace(this).assign(&this->stream); diff --git a/src/widgets/TooltipWidget.cpp b/src/widgets/TooltipWidget.cpp index fca89cd5f..6eec31923 100644 --- a/src/widgets/TooltipWidget.cpp +++ b/src/widgets/TooltipWidget.cpp @@ -77,7 +77,7 @@ void TooltipWidget::updateFont() auto app = getApp(); this->setFont( - app->fonts->getFont(singletons::FontManager::Type::ChatMediumSmall, this->getScale())); + app->fonts->getFont(chatterino::FontManager::Type::ChatMediumSmall, this->getScale())); } void TooltipWidget::setText(QString text) diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 7c34bfa58..75bc3b10f 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -100,7 +100,7 @@ Window::Window(WindowType _type) auto s = new QShortcut(QKeySequence::ZoomIn, this); s->setContext(Qt::WindowShortcut); QObject::connect(s, &QShortcut::activated, this, [] { - getApp()->settings->uiScale.setValue(singletons::WindowManager::clampUiScale( + getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale( getApp()->settings->uiScale.getValue() + 1)); }); } @@ -108,7 +108,7 @@ Window::Window(WindowType _type) auto s = new QShortcut(QKeySequence::ZoomOut, this); s->setContext(Qt::WindowShortcut); QObject::connect(s, &QShortcut::activated, this, [] { - getApp()->settings->uiScale.setValue(singletons::WindowManager::clampUiScale( + getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale( getApp()->settings->uiScale.getValue() - 1)); }); } diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index d3b0181f7..a32efd449 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -56,9 +56,9 @@ void EmotePopup::loadChannel(ChannelPtr _channel) ChannelPtr emoteChannel(new Channel("", Channel::None)); - auto addEmotes = [&](util::EmoteMap &map, const QString &title, const QString &emoteDesc) { + auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) { // TITLE - messages::MessageBuilder builder1; + chatterino::MessageBuilder builder1; builder1.append(new TextElement(title, MessageElement::Text)); @@ -66,11 +66,11 @@ void EmotePopup::loadChannel(ChannelPtr _channel) emoteChannel->addMessage(builder1.getMessage()); // EMOTES - messages::MessageBuilder builder2; + chatterino::MessageBuilder builder2; builder2.getMessage()->flags |= Message::Centered; builder2.getMessage()->flags |= Message::DisableCompactEmotes; - map.each([&](const QString &key, const util::EmoteData &value) { + map.each([&](const QString &key, const EmoteData &value) { builder2.append((new EmoteElement(value, MessageElement::Flags::AlwaysShow)) ->setLink(Link(Link::InsertText, key))); }); @@ -86,7 +86,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel) // fix this pile of garbage for (const auto &set : app->emotes->twitch.emotes[userID].emoteSets) { // TITLE - messages::MessageBuilder builder1; + chatterino::MessageBuilder builder1; QString setText; if (set->text.isEmpty()) { @@ -105,12 +105,12 @@ void EmotePopup::loadChannel(ChannelPtr _channel) emoteChannel->addMessage(builder1.getMessage()); // EMOTES - messages::MessageBuilder builder2; + chatterino::MessageBuilder builder2; builder2.getMessage()->flags |= Message::Centered; builder2.getMessage()->flags |= Message::DisableCompactEmotes; for (const auto &emote : set->emotes) { - [&](const QString &key, const util::EmoteData &value) { + [&](const QString &key, const EmoteData &value) { builder2.append((new EmoteElement(value, MessageElement::Flags::AlwaysShow)) ->setLink(Link(Link::InsertText, key))); }(emote.code, app->emotes->twitch.getEmoteById(emote.id, emote.code)); @@ -137,14 +137,14 @@ void EmotePopup::loadEmojis() ChannelPtr emojiChannel(new Channel("", Channel::None)); // title - messages::MessageBuilder builder1; + chatterino::MessageBuilder builder1; builder1.append(new TextElement("emojis", MessageElement::Text)); builder1.getMessage()->flags |= Message::Centered; emojiChannel->addMessage(builder1.getMessage()); // emojis - messages::MessageBuilder builder; + chatterino::MessageBuilder builder; builder.getMessage()->flags |= Message::Centered; builder.getMessage()->flags |= Message::DisableCompactEmotes; diff --git a/src/widgets/dialogs/EmotePopup.hpp b/src/widgets/dialogs/EmotePopup.hpp index 37436ede3..6e584db96 100644 --- a/src/widgets/dialogs/EmotePopup.hpp +++ b/src/widgets/dialogs/EmotePopup.hpp @@ -16,7 +16,7 @@ public: void loadChannel(ChannelPtr channel); void loadEmojis(); - pajlada::Signals::Signal linkClicked; + pajlada::Signals::Signal linkClicked; private: ChannelView *viewEmotes; diff --git a/src/widgets/dialogs/LastRunCrashDialog.cpp b/src/widgets/dialogs/LastRunCrashDialog.cpp index d5c3248b0..bcfce0185 100644 --- a/src/widgets/dialogs/LastRunCrashDialog.cpp +++ b/src/widgets/dialogs/LastRunCrashDialog.cpp @@ -16,9 +16,9 @@ LastRunCrashDialog::LastRunCrashDialog() this->setWindowFlag(Qt::WindowContextHelpButtonHint, false); this->setWindowTitle("Chatterino"); - auto &updateManager = singletons::UpdateManager::getInstance(); + auto &updateManager = chatterino::UpdateManager::getInstance(); - auto layout = util::LayoutCreator(this).setLayoutType(); + auto layout = LayoutCreator(this).setLayoutType(); layout.emplace( "The application wasn't terminated properly the last time it was executed."); @@ -31,7 +31,7 @@ LastRunCrashDialog::LastRunCrashDialog() // auto *installUpdateButton = buttons->addButton("Install Update", // QDialogButtonBox::NoRole); installUpdateButton->setEnabled(false); // QObject::connect(installUpdateButton, &QPushButton::clicked, [this, update]() mutable { - // auto &updateManager = singletons::UpdateManager::getInstance(); + // auto &updateManager = chatterino::UpdateManager::getInstance(); // updateManager.installUpdates(); // this->setEnabled(false); @@ -43,36 +43,36 @@ LastRunCrashDialog::LastRunCrashDialog() // Updates // auto updateUpdateLabel = [update]() mutable { - // auto &updateManager = singletons::UpdateManager::getInstance(); + // auto &updateManager = chatterino::UpdateManager::getInstance(); // switch (updateManager.getStatus()) { - // case singletons::UpdateManager::None: { + // case chatterino::UpdateManager::None: { // update->setText("Not checking for updates."); // } break; - // case singletons::UpdateManager::Searching: { + // case chatterino::UpdateManager::Searching: { // update->setText("Checking for updates..."); // } break; - // case singletons::UpdateManager::UpdateAvailable: { + // case chatterino::UpdateManager::UpdateAvailable: { // update->setText("Update available."); // } break; - // case singletons::UpdateManager::NoUpdateAvailable: { + // case chatterino::UpdateManager::NoUpdateAvailable: { // update->setText("No update abailable."); // } break; - // case singletons::UpdateManager::SearchFailed: { + // case chatterino::UpdateManager::SearchFailed: { // update->setText("Error while searching for update.\nEither the update service // is " // "temporarily down or there is an issue with your // installation."); // } break; - // case singletons::UpdateManager::Downloading: { + // case chatterino::UpdateManager::Downloading: { // update->setText( // "Downloading the update. Chatterino will close once the download is // done."); // } break; - // case singletons::UpdateManager::DownloadFailed: { + // case chatterino::UpdateManager::DownloadFailed: { // update->setText("Download failed."); // } break; - // case singletons::UpdateManager::WriteFileFailed: { + // case chatterino::UpdateManager::WriteFileFailed: { // update->setText("Writing the update file to the hard drive failed."); // } break; // } @@ -80,7 +80,7 @@ LastRunCrashDialog::LastRunCrashDialog() // updateUpdateLabel(); // this->managedConnect(updateManager.statusUpdated, [updateUpdateLabel](auto) mutable { - // util::postToThread([updateUpdateLabel]() mutable { updateUpdateLabel(); }); + // postToThread([updateUpdateLabel]() mutable { updateUpdateLabel(); }); // }); } diff --git a/src/widgets/dialogs/LoginDialog.cpp b/src/widgets/dialogs/LoginDialog.cpp index ac9848076..0d3476678 100644 --- a/src/widgets/dialogs/LoginDialog.cpp +++ b/src/widgets/dialogs/LoginDialog.cpp @@ -172,7 +172,7 @@ AdvancedLoginWidget::AdvancedLoginWidget() this->ui.buttonLowerRow.layout.addWidget(&this->ui.buttonLowerRow.fillInUserIDButton); connect(&this->ui.buttonLowerRow.fillInUserIDButton, &QPushButton::clicked, [=]() { - util::twitch::getUserID(this->ui.usernameInput.text(), this, [=](const QString &userID) { + getUserID(this->ui.usernameInput.text(), this, [=](const QString &userID) { this->ui.userIDInput.setText(userID); // }); }); diff --git a/src/widgets/dialogs/NotificationPopup.cpp b/src/widgets/dialogs/NotificationPopup.cpp index 21965e10a..5404a09d8 100644 --- a/src/widgets/dialogs/NotificationPopup.cpp +++ b/src/widgets/dialogs/NotificationPopup.cpp @@ -38,7 +38,7 @@ void NotificationPopup::updatePosition() } } -void NotificationPopup::addMessage(messages::MessagePtr msg) +void NotificationPopup::addMessage(chatterino::MessagePtr msg) { this->channel->addMessage(msg); diff --git a/src/widgets/dialogs/NotificationPopup.hpp b/src/widgets/dialogs/NotificationPopup.hpp index cb2e15ff2..bec14ccd1 100644 --- a/src/widgets/dialogs/NotificationPopup.hpp +++ b/src/widgets/dialogs/NotificationPopup.hpp @@ -14,7 +14,7 @@ public: enum Location { TopLeft, TopRight, BottomLeft, BottomRight }; NotificationPopup(); - void addMessage(messages::MessagePtr msg); + void addMessage(chatterino::MessagePtr msg); void updatePosition(); private: diff --git a/src/widgets/dialogs/QualityPopup.cpp b/src/widgets/dialogs/QualityPopup.cpp index eb2a2d00b..c19413eef 100644 --- a/src/widgets/dialogs/QualityPopup.cpp +++ b/src/widgets/dialogs/QualityPopup.cpp @@ -43,9 +43,9 @@ void QualityPopup::okButtonClicked() QString channelURL = "twitch.tv/" + this->channelName; try { - streamlink::OpenStreamlink(channelURL, this->ui_.selector.currentText()); - } catch (const streamlink::Exception &ex) { - debug::Log("Exception caught trying to open streamlink: {}", ex.what()); + OpenStreamlink(channelURL, this->ui_.selector.currentText()); + } catch (const Exception &ex) { + Log("Exception caught trying to open streamlink: {}", ex.what()); } this->close(); diff --git a/src/widgets/dialogs/SelectChannelDialog.cpp b/src/widgets/dialogs/SelectChannelDialog.cpp index a7b4adacb..9da44f1cb 100644 --- a/src/widgets/dialogs/SelectChannelDialog.cpp +++ b/src/widgets/dialogs/SelectChannelDialog.cpp @@ -23,13 +23,13 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent) this->tabFilter.dialog = this; - util::LayoutCreator layoutWidget(this->getLayoutContainer()); + LayoutCreator layoutWidget(this->getLayoutContainer()); auto layout = layoutWidget.setLayoutType().withoutMargin(); auto notebook = layout.emplace(this).assign(&this->ui_.notebook); // twitch { - util::LayoutCreator obj(new QWidget()); + LayoutCreator obj(new QWidget()); auto vbox = obj.setLayoutType(); // channel_btn @@ -106,7 +106,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent) // irc /*{ - util::LayoutCreator obj(new QWidget()); + LayoutCreator obj(new QWidget()); auto vbox = obj.setLayoutType(); auto edit = vbox.emplace("not implemented"); diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index c48a321cd..0b8a4ac3b 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -36,7 +36,7 @@ SettingsDialog::SettingsDialog() void SettingsDialog::initUi() { - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); // tab pages layoutCreator.emplace() @@ -76,34 +76,34 @@ void SettingsDialog::addTabs() { this->ui_.tabContainer->setSpacing(0); - this->addTab(new settingspages::AccountsPage); + this->addTab(new AccountsPage); this->ui_.tabContainer->addSpacing(16); - this->addTab(new settingspages::AppearancePage); - this->addTab(new settingspages::BehaviourPage); + this->addTab(new AppearancePage); + this->addTab(new BehaviourPage); this->ui_.tabContainer->addSpacing(16); - this->addTab(new settingspages::CommandPage); - // this->addTab(new settingspages::EmotesPage); - this->addTab(new settingspages::HighlightingPage); - this->addTab(new settingspages::IgnoreUsersPage); + this->addTab(new CommandPage); + // this->addTab(new EmotesPage); + this->addTab(new HighlightingPage); + this->addTab(new IgnoreUsersPage); this->ui_.tabContainer->addSpacing(16); - this->addTab(new settingspages::KeyboardSettingsPage); - // this->addTab(new settingspages::LogsPage); - this->addTab(new settingspages::ModerationPage); - // this->addTab(new settingspages::SpecialChannelsPage); - this->addTab(new settingspages::BrowserExtensionPage); - this->addTab(new settingspages::ExternalToolsPage); + this->addTab(new KeyboardSettingsPage); + // this->addTab(new LogsPage); + this->addTab(new ModerationPage); + // this->addTab(new SpecialChannelsPage); + this->addTab(new BrowserExtensionPage); + this->addTab(new ExternalToolsPage); this->ui_.tabContainer->addStretch(1); - this->addTab(new settingspages::AboutPage, Qt::AlignBottom); + this->addTab(new AboutPage, Qt::AlignBottom); } -void SettingsDialog::addTab(settingspages::SettingsPage *page, Qt::Alignment alignment) +void SettingsDialog::addTab(SettingsPage *page, Qt::Alignment alignment) { auto tab = new SettingsDialogTab(this, page, page->getIconResource()); diff --git a/src/widgets/dialogs/SettingsDialog.hpp b/src/widgets/dialogs/SettingsDialog.hpp index 0fc4581ad..066ab4983 100644 --- a/src/widgets/dialogs/SettingsDialog.hpp +++ b/src/widgets/dialogs/SettingsDialog.hpp @@ -47,7 +47,7 @@ private: void initUi(); void addTabs(); - void addTab(settingspages::SettingsPage *page, Qt::Alignment alignment = Qt::AlignTop); + void addTab(SettingsPage *page, Qt::Alignment alignment = Qt::AlignTop); void select(SettingsDialogTab *tab); diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index 3c3f3b3b9..4ca58bcca 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -33,7 +33,7 @@ UserInfoPopup::UserInfoPopup() auto app = getApp(); - auto layout = util::LayoutCreator(this).setLayoutType(); + auto layout = LayoutCreator(this).setLayoutType(); // first line auto head = layout.emplace().withoutMargin(); @@ -86,8 +86,8 @@ UserInfoPopup::UserInfoPopup() // userstate this->userStateChanged.connect([this, mod, unmod]() mutable { - providers::twitch::TwitchChannel *twitchChannel = - dynamic_cast(this->channel_.get()); + TwitchChannel *twitchChannel = + dynamic_cast(this->channel_.get()); if (twitchChannel) { qDebug() << this->userName_; @@ -111,8 +111,8 @@ UserInfoPopup::UserInfoPopup() auto timeout = moderation.emplace(); this->userStateChanged.connect([this, lineMod, timeout]() mutable { - providers::twitch::TwitchChannel *twitchChannel = - dynamic_cast(this->channel_.get()); + TwitchChannel *twitchChannel = + dynamic_cast(this->channel_.get()); if (twitchChannel) { lineMod->setVisible(twitchChannel->hasModRights()); @@ -171,10 +171,10 @@ void UserInfoPopup::installEvents() this->ui_.follow->setEnabled(false); if (this->ui_.follow->isChecked()) { - util::twitch::put(requestUrl, + put(requestUrl, [this](QJsonObject) { this->ui_.follow->setEnabled(true); }); } else { - util::twitch::sendDelete(requestUrl, [this] { this->ui_.follow->setEnabled(true); }); + sendDelete(requestUrl, [this] { this->ui_.follow->setEnabled(true); }); } }); @@ -234,13 +234,13 @@ void UserInfoPopup::updateUserData() std::weak_ptr hack = this->hack_; // get user info - util::twitch::getUserID(this->userName_, this, [this, hack](QString id) { + getUserID(this->userName_, this, [this, hack](QString id) { auto currentUser = getApp()->accounts->twitch.getCurrent(); this->userId_ = id; // get channel info - util::twitch::get( + get( "https://api.twitch.tv/kraken/channels/" + id, this, [this](const QJsonObject &obj) { this->ui_.followerCountLabel->setText( TEXT_FOLLOWERS + QString::number(obj.value("followers").toInt())); @@ -307,7 +307,7 @@ UserInfoPopup::TimeoutWidget::TimeoutWidget() : BaseWidget(nullptr) { auto layout = - util::LayoutCreator(this).setLayoutType().withoutMargin(); + LayoutCreator(this).setLayoutType().withoutMargin(); QColor color1(255, 255, 255, 80); QColor color2(255, 255, 255, 0); diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 43babc8af..e3e222f4f 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -271,7 +271,7 @@ QString ChannelView::getSelectedText() { QString result = ""; - messages::LimitedQueueSnapshot messagesSnapshot = this->getMessagesSnapshot(); + chatterino::LimitedQueueSnapshot messagesSnapshot = this->getMessagesSnapshot(); Selection _selection = this->selection_; @@ -317,17 +317,17 @@ bool ChannelView::getEnableScrollingToBottom() const return this->enableScrollingToBottom_; } -void ChannelView::setOverrideFlags(boost::optional value) +void ChannelView::setOverrideFlags(boost::optional value) { this->overrideFlags_ = value; } -const boost::optional &ChannelView::getOverrideFlags() const +const boost::optional &ChannelView::getOverrideFlags() const { return this->overrideFlags_; } -messages::LimitedQueueSnapshot ChannelView::getMessagesSnapshot() +chatterino::LimitedQueueSnapshot ChannelView::getMessagesSnapshot() { if (!this->isPaused() /*|| this->scrollBar_.isVisible()*/) { this->snapshot_ = this->messages.getSnapshot(); @@ -435,7 +435,7 @@ void ChannelView::setChannel(ChannelPtr newChannel) MessageLayoutPtr newItem(new MessageLayout(replacement)); auto snapshot = this->messages.getSnapshot(); if (index >= snapshot.getLength()) { - debug::Log("Tried to replace out of bounds message. Index: {}. Length: {}", index, + Log("Tried to replace out of bounds message. Index: {}. Length: {}", index, snapshot.getLength()); return; } @@ -530,7 +530,7 @@ void ChannelView::setSelection(const SelectionItem &start, const SelectionItem & this->selectionChanged.invoke(); } -messages::MessageElement::Flags ChannelView::getFlags() const +chatterino::MessageElement::Flags ChannelView::getFlags() const { auto app = getApp(); @@ -598,11 +598,11 @@ void ChannelView::drawMessages(QPainter &painter) int y = int(-(messagesSnapshot[start].get()->getHeight() * (fmod(this->scrollBar_.getCurrentValue(), 1)))); - messages::MessageLayout *end = nullptr; + chatterino::MessageLayout *end = nullptr; bool windowFocused = this->window() == QApplication::activeWindow(); for (size_t i = start; i < messagesSnapshot.getLength(); ++i) { - messages::MessageLayout *layout = messagesSnapshot[i].get(); + chatterino::MessageLayout *layout = messagesSnapshot[i].get(); bool isLastMessage = false; if (app->settings->showLastMessageIndicator) { @@ -633,7 +633,7 @@ void ChannelView::drawMessages(QPainter &painter) } // delete the message buffers that aren't on screen - for (const std::shared_ptr &item : this->messagesOnScreen_) { + for (const std::shared_ptr &item : this->messagesOnScreen_) { item->deleteBuffer(); } @@ -641,7 +641,7 @@ void ChannelView::drawMessages(QPainter &painter) // add all messages on screen to the map for (size_t i = start; i < messagesSnapshot.getLength(); ++i) { - std::shared_ptr layout = messagesSnapshot[i]; + std::shared_ptr layout = messagesSnapshot[i]; this->messagesOnScreen_.insert(layout); @@ -758,7 +758,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event) } auto tooltipWidget = TooltipWidget::getInstance(); - std::shared_ptr layout; + std::shared_ptr layout; QPoint relativePos; int messageIndex; @@ -787,7 +787,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event) } // check if word underneath cursor - const messages::MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); + const chatterino::MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); if (hoverLayoutElement == nullptr) { this->setCursor(Qt::ArrowCursor); @@ -820,7 +820,7 @@ void ChannelView::mousePressEvent(QMouseEvent *event) this->mouseDown.invoke(event); - std::shared_ptr layout; + std::shared_ptr layout; QPoint relativePos; int messageIndex; @@ -882,7 +882,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) if (this->isMouseDown_) { this->isMouseDown_ = false; - if (fabsf(util::distanceBetweenPoints(this->lastPressPosition_, event->screenPos())) > + if (fabsf(distanceBetweenPoints(this->lastPressPosition_, event->screenPos())) > 15.f) { return; } @@ -893,7 +893,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) if (this->isRightMouseDown_) { this->isRightMouseDown_ = false; - if (fabsf(util::distanceBetweenPoints(this->lastRightPressPosition_, + if (fabsf(distanceBetweenPoints(this->lastRightPressPosition_, event->screenPos())) > 15.f) { return; } @@ -908,7 +908,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) // find message this->layoutMessages(); - std::shared_ptr layout; + std::shared_ptr layout; QPoint relativePos; int messageIndex; @@ -927,7 +927,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) return; } - const messages::MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); + const chatterino::MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); if (hoverLayoutElement == nullptr) { return; @@ -938,8 +938,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) } void ChannelView::handleMouseClick(QMouseEvent *event, - const messages::MessageLayoutElement *hoveredElement, - messages::MessageLayout *layout) + const chatterino::MessageLayoutElement *hoveredElement, + chatterino::MessageLayout *layout) { switch (event->button()) { case Qt::LeftButton: { @@ -971,8 +971,8 @@ void ChannelView::handleMouseClick(QMouseEvent *event, } } -void ChannelView::addContextMenuItems(const messages::MessageLayoutElement *hoveredElement, - messages::MessageLayout *layout) +void ChannelView::addContextMenuItems(const chatterino::MessageLayoutElement *hoveredElement, + chatterino::MessageLayout *layout) { const auto &creator = hoveredElement->getCreator(); auto creatorFlags = creator.getFlags(); @@ -982,7 +982,7 @@ void ChannelView::addContextMenuItems(const messages::MessageLayoutElement *hove // Emote actions if (creatorFlags & (MessageElement::Flags::EmoteImages | MessageElement::Flags::EmojiImage)) { - const auto &emoteElement = static_cast(creator); + const auto &emoteElement = static_cast(creator); // TODO: We might want to add direct "Open image" variants alongside the Copy // actions @@ -1099,7 +1099,7 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event) auto app = getApp(); if (app->settings->linksDoubleClickOnly) { - std::shared_ptr layout; + std::shared_ptr layout; QPoint relativePos; int messageIndex; @@ -1112,7 +1112,7 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event) return; } - const messages::MessageLayoutElement *hoverLayoutElement = + const chatterino::MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); if (hoverLayoutElement == nullptr) { @@ -1133,15 +1133,15 @@ void ChannelView::hideEvent(QHideEvent *) this->messagesOnScreen_.clear(); } -void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link, - messages::MessageLayout *layout) +void ChannelView::handleLinkClick(QMouseEvent *event, const chatterino::Link &link, + chatterino::MessageLayout *layout) { if (event->button() != Qt::LeftButton) { return; } switch (link.type) { - case messages::Link::UserInfo: { + case chatterino::Link::UserInfo: { auto user = link.value; auto *userPopup = new UserInfoPopup; @@ -1155,12 +1155,12 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link break; } - case messages::Link::Url: { + case chatterino::Link::Url: { QDesktopServices::openUrl(QUrl(link.value)); break; } - case messages::Link::UserAction: { + case chatterino::Link::UserAction: { QString value = link.value; value.replace("{user}", layout->getMessage()->loginName); this->channel_->sendMessage(value); @@ -1170,7 +1170,7 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const messages::Link &link } } -bool ChannelView::tryGetMessageAt(QPoint p, std::shared_ptr &_message, +bool ChannelView::tryGetMessageAt(QPoint p, std::shared_ptr &_message, QPoint &relativePos, int &index) { auto messagesSnapshot = this->getMessagesSnapshot(); diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 90f5261c3..cf75d9e72 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -36,13 +36,13 @@ public: void clearSelection(); void setEnableScrollingToBottom(bool); bool getEnableScrollingToBottom() const; - void setOverrideFlags(boost::optional value); - const boost::optional &getOverrideFlags() const; + void setOverrideFlags(boost::optional value); + const boost::optional &getOverrideFlags() const; void pause(int msecTimeout); void updateLastReadMessage(); void setChannel(ChannelPtr channel_); - messages::LimitedQueueSnapshot getMessagesSnapshot(); + chatterino::LimitedQueueSnapshot getMessagesSnapshot(); void layoutMessages(); void clearMessages(); @@ -50,7 +50,7 @@ public: pajlada::Signals::Signal mouseDown; pajlada::Signals::NoArgSignal selectionChanged; pajlada::Signals::Signal tabHighlightRequested; - pajlada::Signals::Signal linkClicked; + pajlada::Signals::Signal linkClicked; protected: void themeRefreshEvent() override; @@ -70,10 +70,10 @@ protected: void hideEvent(QHideEvent *) override; - void handleLinkClick(QMouseEvent *event, const messages::Link &link, - messages::MessageLayout *layout); + void handleLinkClick(QMouseEvent *event, const chatterino::Link &link, + chatterino::MessageLayout *layout); - bool tryGetMessageAt(QPoint p, std::shared_ptr &message, + bool tryGetMessageAt(QPoint p, std::shared_ptr &message, QPoint &relativePos, int &index); private: @@ -92,24 +92,24 @@ private: int messagesAddedSinceSelectionPause_ = 0; QTimer pauseTimeout_; - boost::optional overrideFlags_; - messages::MessageLayoutPtr lastReadMessage_; + boost::optional overrideFlags_; + chatterino::MessageLayoutPtr lastReadMessage_; - messages::LimitedQueueSnapshot snapshot_; + chatterino::LimitedQueueSnapshot snapshot_; void detachChannel(); void actuallyLayoutMessages(bool causedByScollbar = false); void drawMessages(QPainter &painter); - void setSelection(const messages::SelectionItem &start, const messages::SelectionItem &end); - messages::MessageElement::Flags getFlags() const; + void setSelection(const chatterino::SelectionItem &start, const chatterino::SelectionItem &end); + chatterino::MessageElement::Flags getFlags() const; bool isPaused(); void handleMouseClick(QMouseEvent *event, - const messages::MessageLayoutElement *hoverLayoutElement, - messages::MessageLayout *layout); - void addContextMenuItems(const messages::MessageLayoutElement *hoveredElement, - messages::MessageLayout *layout); + const chatterino::MessageLayoutElement *hoverLayoutElement, + chatterino::MessageLayout *layout); + void addContextMenuItems(const chatterino::MessageLayoutElement *hoveredElement, + chatterino::MessageLayout *layout); // void beginPause(); // void endPause(); @@ -132,10 +132,10 @@ private: QPointF lastPressPosition_; QPointF lastRightPressPosition_; - messages::Selection selection_; + chatterino::Selection selection_; bool selecting_ = false; - messages::LimitedQueue messages; + chatterino::LimitedQueue messages; pajlada::Signals::Connection messageAppendedConnection_; pajlada::Signals::Connection messageAddedAtStartConnection_; @@ -147,7 +147,7 @@ private: std::vector connections_; std::vector channelConnections_; - std::unordered_set> messagesOnScreen_; + std::unordered_set> messagesOnScreen_; int getLayoutWidth() const; diff --git a/src/widgets/helper/DebugPopup.cpp b/src/widgets/helper/DebugPopup.cpp index 453dc13e3..31162c2eb 100644 --- a/src/widgets/helper/DebugPopup.cpp +++ b/src/widgets/helper/DebugPopup.cpp @@ -17,7 +17,7 @@ DebugPopup::DebugPopup() timer->setInterval(1000); QObject::connect(timer, &QTimer::timeout, - [text] { text->setText(util::DebugCount::getDebugText()); }); + [text] { text->setText(DebugCount::getDebugText()); }); timer->start(); text->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont)); diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index e74425e97..f70e7a552 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -60,7 +60,7 @@ NotebookTab::NotebookTab(Notebook *notebook) // QObject::connect(enableHighlightsOnNewMessageAction, &QAction::toggled, [this](bool // newValue) { - // debug::Log("New value is {}", newValue); // + // Log("New value is {}", newValue); // // }); } @@ -86,7 +86,7 @@ void NotebookTab::updateSize() width = (metrics.width(this->getTitle()) + int(16 * scale)); } - width = util::clamp(width, this->height(), int(150 * scale)); + width = clamp(width, this->height(), int(150 * scale)); if (this->width() != width) { this->resize(width, int(NOTEBOOK_TAB_HEIGHT * scale)); @@ -221,8 +221,8 @@ void NotebookTab::paintEvent(QPaintEvent *) // int fullHeight = (int)(scale * 48); // select the right tab colors - singletons::ThemeManager::TabColors colors; - singletons::ThemeManager::TabColors regular = this->themeManager->tabs.regular; + chatterino::ThemeManager::TabColors colors; + chatterino::ThemeManager::TabColors regular = this->themeManager->tabs.regular; if (this->selected_) { colors = this->themeManager->tabs.selected; diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index 017a6d02b..a2d476f18 100644 --- a/src/widgets/helper/SearchPopup.cpp +++ b/src/widgets/helper/SearchPopup.cpp @@ -73,7 +73,7 @@ void SearchPopup::performSearch() ChannelPtr channel(new Channel("search", Channel::None)); for (size_t i = 0; i < this->snapshot.getLength(); i++) { - messages::MessagePtr message = this->snapshot[i]; + chatterino::MessagePtr message = this->snapshot[i]; if (text.isEmpty() || message->searchText.indexOf(this->searchInput->text(), 0, Qt::CaseInsensitive) != -1) { diff --git a/src/widgets/helper/SearchPopup.hpp b/src/widgets/helper/SearchPopup.hpp index e893092aa..d65d03667 100644 --- a/src/widgets/helper/SearchPopup.hpp +++ b/src/widgets/helper/SearchPopup.hpp @@ -21,7 +21,7 @@ public: void setChannel(std::shared_ptr channel); private: - messages::LimitedQueueSnapshot snapshot; + chatterino::LimitedQueueSnapshot snapshot; QLineEdit *searchInput; ChannelView *channelView; diff --git a/src/widgets/helper/SettingsDialogTab.cpp b/src/widgets/helper/SettingsDialogTab.cpp index 9d22aa831..e84734666 100644 --- a/src/widgets/helper/SettingsDialogTab.cpp +++ b/src/widgets/helper/SettingsDialogTab.cpp @@ -7,7 +7,7 @@ namespace chatterino { -SettingsDialogTab::SettingsDialogTab(SettingsDialog *_dialog, settingspages::SettingsPage *_page, +SettingsDialogTab::SettingsDialogTab(SettingsDialog *_dialog, SettingsPage *_page, QString imageFileName) : BaseWidget(_dialog) , dialog(_dialog) @@ -33,7 +33,7 @@ void SettingsDialogTab::setSelected(bool _selected) emit selectedChanged(selected); } -settingspages::SettingsPage *SettingsDialogTab::getSettingsPage() +SettingsPage *SettingsDialogTab::getSettingsPage() { return this->page; } diff --git a/src/widgets/helper/SettingsDialogTab.hpp b/src/widgets/helper/SettingsDialogTab.hpp index 03dfe3b28..5078813c3 100644 --- a/src/widgets/helper/SettingsDialogTab.hpp +++ b/src/widgets/helper/SettingsDialogTab.hpp @@ -16,11 +16,11 @@ class SettingsDialogTab : public BaseWidget Q_OBJECT public: - SettingsDialogTab(SettingsDialog *dialog, settingspages::SettingsPage *page, + SettingsDialogTab(SettingsDialog *dialog, SettingsPage *page, QString imageFileName); void setSelected(bool selected); - settingspages::SettingsPage *getSettingsPage(); + SettingsPage *getSettingsPage(); signals: void selectedChanged(bool); @@ -36,7 +36,7 @@ private: // Parent settings dialog SettingsDialog *dialog; - settingspages::SettingsPage *page; + SettingsPage *page; bool selected = false; }; diff --git a/src/widgets/settingspages/AboutPage.cpp b/src/widgets/settingspages/AboutPage.cpp index 3b5d0f793..0ef83a068 100644 --- a/src/widgets/settingspages/AboutPage.cpp +++ b/src/widgets/settingspages/AboutPage.cpp @@ -17,11 +17,11 @@ namespace chatterino { AboutPage::AboutPage() : SettingsPage("About", ":/images/about.svg") { - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto scroll = layoutCreator.emplace(); auto widget = scroll.emplaceScrollAreaWidget(); - util::removeScrollAreaBackground(scroll.getElement(), widget.getElement()); + removeScrollAreaBackground(scroll.getElement(), widget.getElement()); auto layout = widget.setLayoutType(); { diff --git a/src/widgets/settingspages/AccountsPage.cpp b/src/widgets/settingspages/AccountsPage.cpp index f346a127d..7cecafdd2 100644 --- a/src/widgets/settingspages/AccountsPage.cpp +++ b/src/widgets/settingspages/AccountsPage.cpp @@ -21,11 +21,11 @@ AccountsPage::AccountsPage() { auto *app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto layout = layoutCreator.emplace().withoutMargin(); - helper::EditableModelView *view = - layout.emplace(app->accounts->createModel(nullptr)).getElement(); + EditableModelView *view = + layout.emplace(app->accounts->createModel(nullptr)).getElement(); view->getTableView()->horizontalHeader()->setVisible(false); view->getTableView()->horizontalHeader()->setStretchLastSection(true); diff --git a/src/widgets/settingspages/AppearancePage.cpp b/src/widgets/settingspages/AppearancePage.cpp index e18ccf411..c140df3d0 100644 --- a/src/widgets/settingspages/AppearancePage.cpp +++ b/src/widgets/settingspages/AppearancePage.cpp @@ -35,11 +35,11 @@ AppearancePage::AppearancePage() : SettingsPage("Look", ":/images/theme.svg") { auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto scroll = layoutCreator.emplace(); auto widget = scroll.emplaceScrollAreaWidget(); - util::removeScrollAreaBackground(scroll.getElement(), widget.getElement()); + removeScrollAreaBackground(scroll.getElement(), widget.getElement()); auto layout = widget.setLayoutType(); @@ -226,7 +226,7 @@ QLayout *AppearancePage::createFontChanger() button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed); QObject::connect(button, &QPushButton::clicked, [=]() { - QFontDialog dialog(app->fonts->getFont(singletons::FontManager::ChatMedium, 1.)); + QFontDialog dialog(app->fonts->getFont(chatterino::FontManager::ChatMedium, 1.)); dialog.setWindowFlag(Qt::WindowStaysOnTopHint); @@ -250,10 +250,10 @@ QLayout *AppearancePage::createUiScaleSlider() layout->addWidget(slider); layout->addWidget(label); - slider->setMinimum(singletons::WindowManager::uiScaleMin); - slider->setMaximum(singletons::WindowManager::uiScaleMax); + slider->setMinimum(chatterino::WindowManager::uiScaleMin); + slider->setMaximum(chatterino::WindowManager::uiScaleMax); slider->setValue( - singletons::WindowManager::clampUiScale(getApp()->settings->uiScale.getValue())); + chatterino::WindowManager::clampUiScale(getApp()->settings->uiScale.getValue())); label->setMinimumWidth(100); @@ -262,7 +262,7 @@ QLayout *AppearancePage::createUiScaleSlider() getApp()->settings->uiScale.connect( [label](auto, auto) { - label->setText(QString::number(singletons::WindowManager::getUiScaleValue())); + label->setText(QString::number(chatterino::WindowManager::getUiScaleValue())); }, this->connections_); diff --git a/src/widgets/settingspages/BehaviourPage.cpp b/src/widgets/settingspages/BehaviourPage.cpp index 592a11a34..905e9d771 100644 --- a/src/widgets/settingspages/BehaviourPage.cpp +++ b/src/widgets/settingspages/BehaviourPage.cpp @@ -24,7 +24,7 @@ BehaviourPage::BehaviourPage() : SettingsPage("Feel", ":/images/behave.svg") { auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto layout = layoutCreator.setLayoutType(); diff --git a/src/widgets/settingspages/BrowserextensionPage.cpp b/src/widgets/settingspages/BrowserextensionPage.cpp index caaa07b32..988a34172 100644 --- a/src/widgets/settingspages/BrowserextensionPage.cpp +++ b/src/widgets/settingspages/BrowserextensionPage.cpp @@ -15,7 +15,7 @@ namespace chatterino { BrowserExtensionPage::BrowserExtensionPage() : SettingsPage("Browser Extension", "") { - auto layout = util::LayoutCreator(this).setLayoutType(); + auto layout = LayoutCreator(this).setLayoutType(); auto label = layout.emplace("The browser extension will replace the default Twitch.tv chat with " diff --git a/src/widgets/settingspages/CommandPage.cpp b/src/widgets/settingspages/CommandPage.cpp index 9aee2a138..800bba137 100644 --- a/src/widgets/settingspages/CommandPage.cpp +++ b/src/widgets/settingspages/CommandPage.cpp @@ -31,17 +31,17 @@ CommandPage::CommandPage() { auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto layout = layoutCreator.emplace().withoutMargin(); - helper::EditableModelView *view = - layout.emplace(app->commands->createModel(nullptr)).getElement(); + EditableModelView *view = + layout.emplace(app->commands->createModel(nullptr)).getElement(); view->setTitles({"Trigger", "Command"}); view->getTableView()->horizontalHeader()->setStretchLastSection(true); view->addButtonPressed.connect([] { getApp()->commands->items.appendItem( - controllers::commands::Command{"/command", "I made a new command HeyGuys"}); + Command{"/command", "I made a new command HeyGuys"}); }); layout.append(this->createCheckBox("Also match the trigger at the end of the message", diff --git a/src/widgets/settingspages/EmotesPage.cpp b/src/widgets/settingspages/EmotesPage.cpp index 3cdc0ccd8..a1f1c104b 100644 --- a/src/widgets/settingspages/EmotesPage.cpp +++ b/src/widgets/settingspages/EmotesPage.cpp @@ -7,8 +7,8 @@ namespace chatterino { EmotesPage::EmotesPage() : SettingsPage("Emotes", ":/images/emote.svg") { - // singletons::SettingManager &settings = singletons::SettingManager::getInstance(); - // util::LayoutCreator layoutCreator(this); + // chatterino::SettingManager &settings = chatterino::SettingManager::getInstance(); + // LayoutCreator layoutCreator(this); // auto layout = layoutCreator.emplace().withoutMargin(); // // clang-format off diff --git a/src/widgets/settingspages/ExternaltoolsPage.cpp b/src/widgets/settingspages/ExternaltoolsPage.cpp index b263a9985..354b8cbc1 100644 --- a/src/widgets/settingspages/ExternaltoolsPage.cpp +++ b/src/widgets/settingspages/ExternaltoolsPage.cpp @@ -23,7 +23,7 @@ ExternalToolsPage::ExternalToolsPage() { auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto layout = layoutCreator.setLayoutType(); { diff --git a/src/widgets/settingspages/HighlightingPage.cpp b/src/widgets/settingspages/HighlightingPage.cpp index 0572e0cab..4246cd6f0 100644 --- a/src/widgets/settingspages/HighlightingPage.cpp +++ b/src/widgets/settingspages/HighlightingPage.cpp @@ -30,7 +30,7 @@ HighlightingPage::HighlightingPage() : SettingsPage("Highlights", ":/images/notifications.svg") { auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto layout = layoutCreator.emplace().withoutMargin(); { @@ -43,9 +43,9 @@ HighlightingPage::HighlightingPage() // HIGHLIGHTS auto highlights = tabs.appendTab(new QVBoxLayout, "Highlights"); { - helper::EditableModelView *view = + EditableModelView *view = highlights - .emplace(app->highlights->createModel(nullptr)) + .emplace(app->highlights->createModel(nullptr)) .getElement(); view->setTitles({"Pattern", "Flash taskbar", "Play sound", "Regex"}); @@ -61,7 +61,7 @@ HighlightingPage::HighlightingPage() view->addButtonPressed.connect([] { getApp()->highlights->phrases.appendItem( - controllers::highlights::HighlightPhrase{"my phrase", true, false, false}); + HighlightPhrase{"my phrase", true, false, false}); }); } auto disabledUsers = tabs.appendTab(new QVBoxLayout, "Disabled Users"); diff --git a/src/widgets/settingspages/IgnoreusersPage.cpp b/src/widgets/settingspages/IgnoreusersPage.cpp index 1f0f93f44..708016857 100644 --- a/src/widgets/settingspages/IgnoreusersPage.cpp +++ b/src/widgets/settingspages/IgnoreusersPage.cpp @@ -28,7 +28,7 @@ IgnoreUsersPage::IgnoreUsersPage() { auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto layout = layoutCreator.setLayoutType(); // auto group = layout.emplace("Ignored users").setLayoutType(); @@ -63,8 +63,8 @@ IgnoreUsersPage::IgnoreUsersPage() // messages auto messages = tabs.appendTab(new QVBoxLayout, "Messages"); { - helper::EditableModelView *view = - messages.emplace(app->ignores->createModel(nullptr)) + EditableModelView *view = + messages.emplace(app->ignores->createModel(nullptr)) .getElement(); view->setTitles({"Pattern", "Regex"}); view->getTableView()->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); @@ -78,7 +78,7 @@ IgnoreUsersPage::IgnoreUsersPage() view->addButtonPressed.connect([] { getApp()->ignores->phrases.appendItem( - controllers::ignores::IgnorePhrase{"my phrase", false}); + IgnorePhrase{"my phrase", false}); }); } diff --git a/src/widgets/settingspages/KeyboardsettingsPage.cpp b/src/widgets/settingspages/KeyboardsettingsPage.cpp index aeffaf7f6..fbf611f5e 100644 --- a/src/widgets/settingspages/KeyboardsettingsPage.cpp +++ b/src/widgets/settingspages/KeyboardsettingsPage.cpp @@ -10,7 +10,7 @@ namespace chatterino { KeyboardSettingsPage::KeyboardSettingsPage() : SettingsPage("Keybindings", "") { - auto layout = util::LayoutCreator(this).setLayoutType(); + auto layout = LayoutCreator(this).setLayoutType(); auto form = layout.emplace(); diff --git a/src/widgets/settingspages/LogsPage.cpp b/src/widgets/settingspages/LogsPage.cpp index 1706b2041..ddd1f95a1 100644 --- a/src/widgets/settingspages/LogsPage.cpp +++ b/src/widgets/settingspages/LogsPage.cpp @@ -28,7 +28,7 @@ //{ // auto app = getApp(); -// util::LayoutCreator layoutCreator(this); +// LayoutCreator layoutCreator(this); // auto layout = layoutCreator.emplace().withoutMargin(); // auto logPath = app->paths->logsFolderPath; diff --git a/src/widgets/settingspages/ModerationPage.cpp b/src/widgets/settingspages/ModerationPage.cpp index e6f719d5e..781ef2c12 100644 --- a/src/widgets/settingspages/ModerationPage.cpp +++ b/src/widgets/settingspages/ModerationPage.cpp @@ -35,7 +35,7 @@ ModerationPage::ModerationPage() : SettingsPage("Moderation", "") { auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto tabs = layoutCreator.emplace(); @@ -119,7 +119,7 @@ ModerationPage::ModerationPage() /*auto taggedUsers = tabs.appendTab(new QVBoxLayout, "Tagged users"); { - helper::EditableModelView *view = *taggedUsers.emplace( + EditableModelView *view = *taggedUsers.emplace( app->taggedUsers->createModel(nullptr)); view->setTitles({"Name"}); @@ -127,7 +127,7 @@ ModerationPage::ModerationPage() view->addButtonPressed.connect([] { getApp()->taggedUsers->users.appendItem( - controllers::taggedusers::TaggedUser(ProviderId::Twitch, "example", "xD")); + TaggedUser(ProviderId::Twitch, "example", "xD")); }); }*/ } diff --git a/src/widgets/settingspages/SpecialChannelsPage.cpp b/src/widgets/settingspages/SpecialChannelsPage.cpp index c9ddcea5f..ccf859848 100644 --- a/src/widgets/settingspages/SpecialChannelsPage.cpp +++ b/src/widgets/settingspages/SpecialChannelsPage.cpp @@ -15,7 +15,7 @@ SpecialChannelsPage::SpecialChannelsPage() { auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto layout = layoutCreator.setLayoutType(); auto mentions = layout.emplace("Mentions channel").setLayoutType(); diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index cb1396d30..2e72a829f 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -416,9 +416,9 @@ void Split::doOpenPopupPlayer() void Split::doOpenStreamlink() { try { - streamlink::Start(this->getChannel()->name); - } catch (const streamlink::Exception &ex) { - debug::Log("Error in doOpenStreamlink: {}", ex.what()); + Start(this->getChannel()->name); + } catch (const Exception &ex) { + Log("Error in doOpenStreamlink: {}", ex.what()); } } @@ -449,7 +449,7 @@ void Split::doOpenViewerList() } auto loadingLabel = new QLabel("Loading..."); - util::twitch::get("https://tmi.twitch.tv/group/user/" + this->getChannel()->name + "/chatters", + get("https://tmi.twitch.tv/group/user/" + this->getChannel()->name + "/chatters", this, [=](QJsonObject obj) { QJsonObject chattersObj = obj.value("chatters").toObject(); diff --git a/src/widgets/splits/SplitColumn.hpp b/src/widgets/splits/SplitColumn.hpp index 2fc191a07..8ab6a45f1 100644 --- a/src/widgets/splits/SplitColumn.hpp +++ b/src/widgets/splits/SplitColumn.hpp @@ -11,13 +11,13 @@ class SplitColumn public: SplitColumn() = default; - void insert(widgets::Split *split, int index = -1); + void insert(Split *split, int index = -1); void remove(int index); double getFlex(); void setFlex(double flex); private: - std::vector items; + std::vector items; }; } // namespace chatterino diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index f4a68c301..b1797b6a1 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -104,7 +104,7 @@ void SplitContainer::resetMouseStatus() void SplitContainer::appendNewSplit(bool openChannelNameDialog) { - util::assertInGuiThread(); + assertInGuiThread(); Split *split = new Split(this); this->appendSplit(split); @@ -138,7 +138,7 @@ void SplitContainer::insertSplit(Split *split, Direction direction, Split *relat void SplitContainer::insertSplit(Split *split, Direction direction, Node *relativeTo) { - util::assertInGuiThread(); + assertInGuiThread(); split->setContainer(this); @@ -161,7 +161,7 @@ void SplitContainer::insertSplit(Split *split, Direction direction, Node *relati void SplitContainer::addSplit(Split *split) { - util::assertInGuiThread(); + assertInGuiThread(); split->setParent(this); split->show(); @@ -202,7 +202,7 @@ void SplitContainer::setPreferedTargetRecursive(Node *node) SplitContainer::Position SplitContainer::releaseSplit(Split *split) { - util::assertInGuiThread(); + assertInGuiThread(); Node *node = this->baseNode.findNodeContainingSplit(split); assert(node != nullptr); @@ -230,7 +230,7 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split) SplitContainer::Position SplitContainer::deleteSplit(Split *split) { - util::assertInGuiThread(); + assertInGuiThread(); assert(split != nullptr); split->deleteLater(); @@ -239,7 +239,7 @@ SplitContainer::Position SplitContainer::deleteSplit(Split *split) void SplitContainer::selectNextSplit(Direction direction) { - util::assertInGuiThread(); + assertInGuiThread(); if (Node *node = this->baseNode.findNodeContainingSplit(this->selected)) { this->selectSplitRecursive(node, direction); @@ -565,7 +565,7 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node) if (type == "split") { auto *split = new Split(this); - split->setChannel(singletons::WindowManager::decodeChannel(obj.value("data").toObject())); + split->setChannel(chatterino::WindowManager::decodeChannel(obj.value("data").toObject())); this->appendSplit(split); } else if (type == "horizontal" || type == "vertical") { @@ -582,7 +582,7 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node) if (_type == "split") { auto *split = new Split(this); split->setChannel( - singletons::WindowManager::decodeChannel(_obj.value("data").toObject())); + chatterino::WindowManager::decodeChannel(_obj.value("data").toObject())); Node *_node = new Node(); _node->parent = node; @@ -606,7 +606,7 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node) if (node->getChildren().size() < 2) { auto *split = new Split(this); split->setChannel( - singletons::WindowManager::decodeChannel(obj.value("data").toObject())); + chatterino::WindowManager::decodeChannel(obj.value("data").toObject())); this->insertSplit(split, direction, node); } diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index 894601b1a..199a0459d 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -33,7 +33,7 @@ SplitHeader::SplitHeader(Split *_split) auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto layout = layoutCreator.emplace().withoutMargin(); { // dropdown label @@ -234,7 +234,7 @@ void SplitHeader::scaleChangedEvent(float scale) this->dropdownButton->setFixedWidth(w); this->moderationButton->setFixedWidth(w); // this->titleLabel->setFont( - // singletons::FontManager::getInstance().getFont(FontStyle::Medium, scale)); + // chatterino::FontManager::getInstance().getFont(FontStyle::Medium, scale)); } void SplitHeader::updateChannelText() diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 4133ecee1..bedacea51 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -40,7 +40,7 @@ SplitInput::SplitInput(Split *_chatWidget) void SplitInput::initLayout() { auto app = getApp(); - util::LayoutCreator layoutCreator(this); + LayoutCreator layoutCreator(this); auto layout = layoutCreator.setLayoutType().withoutMargin().assign(&this->ui_.hbox); @@ -67,19 +67,19 @@ void SplitInput::initLayout() // set edit font this->ui_.textEdit->setFont( - app->fonts->getFont(singletons::FontManager::Type::ChatMedium, this->getScale())); + app->fonts->getFont(chatterino::FontManager::Type::ChatMedium, this->getScale())); this->managedConnections_.push_back(app->fonts->fontChanged.connect([=]() { this->ui_.textEdit->setFont( - app->fonts->getFont(singletons::FontManager::Type::ChatMedium, this->getScale())); + app->fonts->getFont(chatterino::FontManager::Type::ChatMedium, this->getScale())); })); // open emote popup QObject::connect(this->ui_.emoteButton, &RippleEffectLabel::clicked, [this] { if (!this->emotePopup_) { this->emotePopup_ = std::make_unique(); - this->emotePopup_->linkClicked.connect([this](const messages::Link &link) { - if (link.type == messages::Link::InsertText) { + this->emotePopup_->linkClicked.connect([this](const chatterino::Link &link) { + if (link.type == chatterino::Link::InsertText) { this->insertText(link.value + " "); } });