From 5604ae6a67097507ec687d4fb8c42689a4bb3086 Mon Sep 17 00:00:00 2001 From: fourtf Date: Thu, 28 Jun 2018 19:38:57 +0200 Subject: [PATCH] removed functions from SettingsManager that shouldn't be there --- chatterino.pro | 10 +- src/Application.cpp | 34 +++-- src/Application.hpp | 20 +-- src/common/Channel.cpp | 14 +- src/common/Channel.hpp | 22 +-- src/common/CompletionModel.cpp | 2 +- src/common/Emotemap.cpp | 6 +- src/common/Emotemap.hpp | 10 +- .../commands/CommandController.cpp | 12 +- .../highlights/HighlightController.cpp | 2 +- .../highlights/HighlightController.hpp | 4 +- src/controllers/ignores/IgnoreController.hpp | 2 +- .../moderationactions/ModerationAction.cpp | 101 +++++++++++++ .../moderationactions/ModerationAction.hpp | 68 +++++++++ .../moderationactions/ModerationActions.cpp | 28 ++++ .../moderationactions/ModerationActions.hpp | 23 +++ src/messages/Image.cpp | 2 +- src/messages/LimitedQueue.hpp | 2 +- src/messages/Message.cpp | 6 +- src/messages/MessageColor.cpp | 2 +- src/messages/MessageColor.hpp | 2 +- src/messages/MessageElement.cpp | 3 +- src/providers/bttv/BttvEmotes.cpp | 12 +- src/providers/emoji/Emojis.cpp | 2 +- src/providers/ffz/FfzEmotes.cpp | 6 +- src/providers/twitch/IrcMessageHandler.cpp | 22 +-- src/providers/twitch/TwitchAccountManager.hpp | 2 +- src/providers/twitch/TwitchChannel.cpp | 18 +-- src/providers/twitch/TwitchChannel.hpp | 2 +- src/providers/twitch/TwitchEmotes.cpp | 6 +- src/providers/twitch/TwitchMessageBuilder.cpp | 4 +- src/providers/twitch/TwitchMessageBuilder.hpp | 10 +- src/providers/twitch/TwitchServer.cpp | 4 +- src/singletons/EmoteManager.cpp | 5 + src/singletons/EmoteManager.hpp | 2 + src/singletons/FontManager.hpp | 2 +- src/singletons/IrcManager.cpp | 2 +- src/singletons/LoggingManager.cpp | 2 +- src/singletons/LoggingManager.hpp | 2 +- src/singletons/NativeMessagingManager.cpp | 4 +- src/singletons/ResourceManager.cpp | 14 +- src/singletons/ResourceManager.hpp | 56 +++---- src/singletons/SettingsManager.cpp | 137 ++---------------- src/singletons/SettingsManager.hpp | 30 +--- src/singletons/WindowManager.cpp | 60 ++++++++ src/singletons/WindowManager.hpp | 8 + src/singletons/helper/ChatterinoSetting.hpp | 9 ++ src/singletons/helper/LoggingChannel.cpp | 2 +- src/singletons/helper/LoggingChannel.hpp | 2 +- src/singletons/helper/ModerationAction.cpp | 49 ------- src/singletons/helper/ModerationAction.hpp | 29 ---- src/widgets/BaseWidget.hpp | 2 +- src/widgets/BaseWindow.cpp | 4 +- src/widgets/Scrollbar.cpp | 2 +- src/widgets/Scrollbar.hpp | 6 +- src/widgets/TooltipWidget.cpp | 2 +- src/widgets/Window.cpp | 4 +- src/widgets/dialogs/EmotePopup.cpp | 12 +- src/widgets/dialogs/EmotePopup.hpp | 2 +- src/widgets/dialogs/LastRunCrashDialog.cpp | 22 +-- src/widgets/dialogs/NotificationPopup.cpp | 2 +- src/widgets/dialogs/NotificationPopup.hpp | 2 +- src/widgets/dialogs/SettingsDialog.cpp | 2 +- src/widgets/helper/ChannelView.cpp | 60 ++++---- src/widgets/helper/ChannelView.hpp | 38 ++--- src/widgets/helper/NotebookTab.cpp | 4 +- src/widgets/helper/ResizingTextEdit.cpp | 2 +- src/widgets/helper/SearchPopup.cpp | 2 +- src/widgets/helper/SearchPopup.hpp | 2 +- src/widgets/settingspages/AppearancePage.cpp | 10 +- src/widgets/settingspages/EmotesPage.cpp | 2 +- src/widgets/settingspages/ModerationPage.cpp | 31 ++-- src/widgets/splits/SplitContainer.cpp | 6 +- src/widgets/splits/SplitHeader.cpp | 2 +- src/widgets/splits/SplitInput.cpp | 8 +- 75 files changed, 600 insertions(+), 507 deletions(-) create mode 100644 src/controllers/moderationactions/ModerationAction.cpp create mode 100644 src/controllers/moderationactions/ModerationAction.hpp create mode 100644 src/controllers/moderationactions/ModerationActions.cpp create mode 100644 src/controllers/moderationactions/ModerationActions.hpp delete mode 100644 src/singletons/helper/ModerationAction.cpp delete mode 100644 src/singletons/helper/ModerationAction.hpp diff --git a/chatterino.pro b/chatterino.pro index a4a629877..857d08ae2 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -152,7 +152,7 @@ SOURCES += \ src/singletons/helper/ChatterinoSetting.cpp \ src/singletons/helper/GifTimer.cpp \ src/singletons/helper/LoggingChannel.cpp \ - src/singletons/helper/ModerationAction.cpp \ + src/controllers/moderationactions/ModerationAction.cpp \ src/singletons/IrcManager.cpp \ src/singletons/LoggingManager.cpp \ src/singletons/NativeMessagingManager.cpp \ @@ -223,7 +223,8 @@ SOURCES += \ src/widgets/StreamView.cpp \ src/widgets/TooltipWidget.cpp \ src/widgets/Window.cpp \ - src/common/LinkParser.cpp + src/common/LinkParser.cpp \ + src/controllers/moderationactions/ModerationActions.cpp HEADERS += \ src/Application.hpp \ @@ -305,7 +306,7 @@ HEADERS += \ src/singletons/helper/ChatterinoSetting.hpp \ src/singletons/helper/GifTimer.hpp \ src/singletons/helper/LoggingChannel.hpp \ - src/singletons/helper/ModerationAction.hpp \ + src/controllers/moderationactions/ModerationAction.hpp \ src/singletons/IrcManager.hpp \ src/singletons/LoggingManager.hpp \ src/singletons/NativeMessagingManager.hpp \ @@ -392,7 +393,8 @@ HEADERS += \ src/widgets/Window.hpp \ src/providers/twitch/TwitchCommon.hpp \ src/util/IsBigEndian.hpp \ - src/common/LinkParser.hpp + src/common/LinkParser.hpp \ + src/controllers/moderationactions/ModerationActions.hpp RESOURCES += \ resources/resources.qrc \ diff --git a/src/Application.cpp b/src/Application.cpp index 064c79452..8725ffc7f 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -4,6 +4,7 @@ #include "controllers/commands/CommandController.hpp" #include "controllers/highlights/HighlightController.hpp" #include "controllers/ignores/IgnoreController.hpp" +#include "controllers/moderationactions/ModerationActions.hpp" #include "controllers/taggedusers/TaggedUsersController.hpp" #include "providers/twitch/Pubsub.hpp" #include "providers/twitch/TwitchServer.hpp" @@ -43,19 +44,21 @@ void Application::construct() isAppConstructed = true; // 1. Instantiate all classes - 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->settings = getSettings(); + this->paths = PathManager::getInstance(); + + this->themes = new ThemeManager; + this->windows = new WindowManager; + this->logging = new 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->emotes = new EmoteManager; + this->fonts = new FontManager; + this->resources = new ResourceManager; + this->moderationActions = new ModerationActions; this->twitch.server = new TwitchServer; this->twitch.pubsub = new PubSub; @@ -91,9 +94,10 @@ void Application::initialize() this->accounts->load(); this->twitch.server->initialize(); + this->moderationActions->initialize(); // XXX - this->settings->updateWordTypeMask(); + this->windows->updateWordTypeMask(); #ifdef Q_OS_WIN #ifdef QT_DEBUG @@ -123,7 +127,7 @@ void Application::initialize() QString text = QString("%1 cleared the chat").arg(action.source.name); - auto msg = chatterino::Message::createSystemMessage(text); + auto msg = Message::createSystemMessage(text); postToThread([chan, msg] { chan->addMessage(msg); }); }); @@ -142,7 +146,7 @@ void Application::initialize() text.append(" (" + QString::number(action.duration) + " seconds)"); } - auto msg = chatterino::Message::createSystemMessage(text); + auto msg = Message::createSystemMessage(text); postToThread([chan, msg] { chan->addMessage(msg); }); }); @@ -161,7 +165,7 @@ void Application::initialize() text = QString("%1 unmodded %2").arg(action.source.name, action.target.name); } - auto msg = chatterino::Message::createSystemMessage(text); + auto msg = Message::createSystemMessage(text); postToThread([chan, msg] { chan->addMessage(msg); }); }); @@ -172,8 +176,8 @@ void Application::initialize() return; } - auto msg = chatterino::Message::createTimeoutMessage(action); - msg->flags |= chatterino::Message::PubSub; + auto msg = Message::createTimeoutMessage(action); + msg->flags |= Message::PubSub; postToThread([chan, msg] { chan->addOrReplaceTimeout(msg); }); }); @@ -185,7 +189,7 @@ void Application::initialize() return; } - auto msg = chatterino::Message::createUntimeoutMessage(action); + auto msg = Message::createUntimeoutMessage(action); postToThread([chan, msg] { chan->addMessage(msg); }); }); diff --git a/src/Application.hpp b/src/Application.hpp index 36662c20a..7b7ac1757 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -15,6 +15,7 @@ class HighlightController; class IgnoreController; class TaggedUsersController; class AccountController; +class ModerationActions; class ThemeManager; class WindowManager; @@ -44,20 +45,21 @@ public: friend void test(); - chatterino::PathManager *paths = nullptr; - chatterino::ThemeManager *themes = nullptr; - chatterino::WindowManager *windows = nullptr; - chatterino::LoggingManager *logging = nullptr; + PathManager *paths = nullptr; + ThemeManager *themes = nullptr; + WindowManager *windows = nullptr; + 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; + EmoteManager *emotes = nullptr; + NativeMessagingManager *nativeMessaging = nullptr; + SettingManager *settings = nullptr; + FontManager *fonts = nullptr; + ResourceManager *resources = nullptr; + ModerationActions *moderationActions = nullptr; /// Provider-specific struct { diff --git a/src/common/Channel.cpp b/src/common/Channel.cpp index 96cecc1a7..b76432a26 100644 --- a/src/common/Channel.cpp +++ b/src/common/Channel.cpp @@ -53,7 +53,7 @@ bool Channel::isEmpty() const return this->name.isEmpty(); } -chatterino::LimitedQueueSnapshot Channel::getMessageSnapshot() +LimitedQueueSnapshot Channel::getMessageSnapshot() { return this->messages.getSnapshot(); } @@ -81,7 +81,7 @@ void Channel::addMessage(MessagePtr message) this->messageAppended.invoke(message); } -void Channel::addOrReplaceTimeout(chatterino::MessagePtr message) +void Channel::addOrReplaceTimeout(MessagePtr message) { LimitedQueueSnapshot snapshot = this->getMessageSnapshot(); int snapshotLength = snapshot.getLength(); @@ -118,7 +118,7 @@ void Channel::addOrReplaceTimeout(chatterino::MessagePtr message) int count = s->count + 1; - chatterino::MessagePtr replacement(Message::createSystemMessage( + 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(chatterino::MessagePtr message, chatterino::MessagePtr replacement) +void Channel::replaceMessage(MessagePtr message, MessagePtr replacement) { int index = this->messages.replaceItem(message, replacement); @@ -180,7 +180,7 @@ void Channel::replaceMessage(chatterino::MessagePtr message, chatterino::Message } } -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 7acb8e69b..66e82e235 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; - chatterino::LimitedQueueSnapshot getMessageSnapshot(); + LimitedQueueSnapshot getMessageSnapshot(); - void addMessage(chatterino::MessagePtr message); - void addMessagesAtStart(std::vector &messages); - void addOrReplaceTimeout(chatterino::MessagePtr message); + void addMessage(MessagePtr message); + void addMessagesAtStart(std::vector &messages); + void addOrReplaceTimeout(MessagePtr message); void disableAllMessages(); - void replaceMessage(chatterino::MessagePtr message, chatterino::MessagePtr replacement); - virtual void addRecentChatter(const std::shared_ptr &message); + void replaceMessage(MessagePtr message, MessagePtr replacement); + virtual void addRecentChatter(const std::shared_ptr &message); QString name; QStringList modList; @@ -69,7 +69,7 @@ protected: virtual void onConnected(); private: - chatterino::LimitedQueue messages; + LimitedQueue messages; Type type; }; diff --git a/src/common/CompletionModel.cpp b/src/common/CompletionModel.cpp index 62472b9eb..6c7eb83ab 100644 --- a/src/common/CompletionModel.cpp +++ b/src/common/CompletionModel.cpp @@ -75,7 +75,7 @@ void CompletionModel::refresh() // Channel-specific: Usernames // fourtf: only works with twitch chat - // auto c = chatterino::ChannelManager::getInstance().getTwitchChannel(this->channelName); + // auto c = ChannelManager::getInstance().getTwitchChannel(this->channelName); // auto usernames = c->getUsernamesForCompletions(); // for (const auto &name : usernames) { // assert(!name.displayName.isEmpty()); diff --git a/src/common/Emotemap.cpp b/src/common/Emotemap.cpp index a04c037eb..ce7ec011e 100644 --- a/src/common/Emotemap.cpp +++ b/src/common/Emotemap.cpp @@ -5,7 +5,7 @@ namespace chatterino { -EmoteData::EmoteData(chatterino::Image *_image) +EmoteData::EmoteData(Image *_image) : image1x(_image) { } @@ -16,7 +16,7 @@ bool EmoteData::isValid() const return this->image1x != nullptr; } -chatterino::Image *EmoteData::getImage(float scale) const +Image *EmoteData::getImage(float scale) const { int quality = getApp()->settings->preferredEmoteQuality; @@ -31,7 +31,7 @@ chatterino::Image *EmoteData::getImage(float scale) const }(); } - chatterino::Image *_image; + 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 2f25d0071..d5862a9f2 100644 --- a/src/common/Emotemap.hpp +++ b/src/common/Emotemap.hpp @@ -8,15 +8,15 @@ namespace chatterino { struct EmoteData { EmoteData() = default; - EmoteData(chatterino::Image *_image); + EmoteData(Image *_image); // Emotes must have a 1x image to be valid bool isValid() const; - chatterino::Image *getImage(float scale) const; + Image *getImage(float scale) const; - chatterino::Image *image1x = nullptr; - chatterino::Image *image2x = nullptr; - chatterino::Image *image3x = nullptr; + Image *image1x = nullptr; + Image *image2x = nullptr; + Image *image3x = nullptr; // Link to the emote page i.e. https://www.frankerfacez.com/emoticon/144722-pajaCringe QString pageLink; diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index ad53c094e..e653f6e40 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -152,7 +152,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, if (commandName == "/debug-args") { QString msg = QApplication::instance()->arguments().join(' '); - channel->addMessage(chatterino::Message::createSystemMessage(msg)); + channel->addMessage(Message::createSystemMessage(msg)); return ""; } else if (commandName == "/uptime") { @@ -161,7 +161,7 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, QString messageText = streamStatus.live ? streamStatus.uptime : "Channel is not live."; - channel->addMessage(chatterino::Message::createSystemMessage(messageText)); + channel->addMessage(Message::createSystemMessage(messageText)); return ""; } else if (commandName == "/ignore" && words.size() >= 2) { @@ -171,13 +171,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, auto target = words.at(1); if (user->isAnon()) { - channel->addMessage(chatterino::Message::createSystemMessage( + channel->addMessage(Message::createSystemMessage( "You must be logged in to ignore someone")); return ""; } user->ignore(target, [channel](auto resultCode, const QString &message) { - channel->addMessage(chatterino::Message::createSystemMessage(message)); + channel->addMessage(Message::createSystemMessage(message)); }); return ""; @@ -188,13 +188,13 @@ QString CommandController::execCommand(const QString &text, ChannelPtr channel, auto target = words.at(1); if (user->isAnon()) { - channel->addMessage(chatterino::Message::createSystemMessage( + channel->addMessage(Message::createSystemMessage( "You must be logged in to ignore someone")); return ""; } user->unignore(target, [channel](auto resultCode, const QString &message) { - channel->addMessage(chatterino::Message::createSystemMessage(message)); + channel->addMessage(Message::createSystemMessage(message)); }); return ""; diff --git a/src/controllers/highlights/HighlightController.cpp b/src/controllers/highlights/HighlightController.cpp index b037669d4..1f8c8fa00 100644 --- a/src/controllers/highlights/HighlightController.cpp +++ b/src/controllers/highlights/HighlightController.cpp @@ -32,7 +32,7 @@ HighlightModel *HighlightController::createModel(QObject *parent) return model; } -void HighlightController::addHighlight(const chatterino::MessagePtr &msg) +void HighlightController::addHighlight(const MessagePtr &msg) { // static NotificationPopup popup; diff --git a/src/controllers/highlights/HighlightController.hpp b/src/controllers/highlights/HighlightController.hpp index 20239ae45..1d693b0e9 100644 --- a/src/controllers/highlights/HighlightController.hpp +++ b/src/controllers/highlights/HighlightController.hpp @@ -20,12 +20,12 @@ public: HighlightModel *createModel(QObject *parent); - void addHighlight(const chatterino::MessagePtr &msg); + void addHighlight(const MessagePtr &msg); private: bool initialized = false; - chatterino::ChatterinoSetting> highlightsSetting = { + ChatterinoSetting> highlightsSetting = { "/highlighting/highlights"}; }; diff --git a/src/controllers/ignores/IgnoreController.hpp b/src/controllers/ignores/IgnoreController.hpp index e07729c0e..01f630919 100644 --- a/src/controllers/ignores/IgnoreController.hpp +++ b/src/controllers/ignores/IgnoreController.hpp @@ -20,7 +20,7 @@ public: private: bool initialized = false; - chatterino::ChatterinoSetting> ignoresSetting = {"/ignore/phrases"}; + ChatterinoSetting> ignoresSetting = {"/ignore/phrases"}; }; } // namespace chatterino diff --git a/src/controllers/moderationactions/ModerationAction.cpp b/src/controllers/moderationactions/ModerationAction.cpp new file mode 100644 index 000000000..4401163f1 --- /dev/null +++ b/src/controllers/moderationactions/ModerationAction.cpp @@ -0,0 +1,101 @@ +#include "ModerationAction.hpp" + +#include "Application.hpp" +#include "singletons/ResourceManager.hpp" + +namespace chatterino { + +// ModerationAction::ModerationAction(Image *_image, const QString &_action) +// : _isImage(true) +// , image(_image) +// , action(_action) +//{ +//} + +// ModerationAction::ModerationAction(const QString &_line1, const QString &_line2, +// const QString &_action) +// : _isImage(false) +// , image(nullptr) +// , line1(_line1) +// , line2(_line2) +// , action(_action) +//{ +//} + +ModerationAction::ModerationAction(const QString &action) + : action_(action) +{ + static QRegularExpression replaceRegex("[!/.]"); + static QRegularExpression timeoutRegex("^[./]timeout.* (\\d+)"); + + auto timeoutMatch = timeoutRegex.match(action); + + if (timeoutMatch.hasMatch()) { + // if (multipleTimeouts > 1) { + QString line1; + QString line2; + + int amount = timeoutMatch.captured(1).toInt(); + + if (amount < 60) { + this->line1_ = QString::number(amount); + this->line2_ = "s"; + } else if (amount < 60 * 60) { + this->line1_ = QString::number(amount / 60); + this->line2_ = "m"; + } else if (amount < 60 * 60 * 24) { + this->line1_ = QString::number(amount / 60 / 60); + this->line2_ = "h"; + } else { + this->line1_ = QString::number(amount / 60 / 60 / 24); + this->line2_ = "d"; + } + + this->line1_ = line1; + this->line2_ = line2; + // } else { + // this->_moderationActions.emplace_back(app->resources->buttonTimeout, str); + // } + } else if (action.startsWith("/ban ")) { + this->image_ = getApp()->resources->buttonBan; + } else { + QString xD = action; + + xD.replace(replaceRegex, ""); + + this->line1_ = xD.mid(0, 2); + this->line2_ = xD.mid(2, 2); + } +} + +bool ModerationAction::operator==(const ModerationAction &other) const +{ + return this == std::addressof(other); +} + +bool ModerationAction::isImage() const +{ + return this->image_ != nullptr; +} + +Image *ModerationAction::getImage() const +{ + return this->image_; +} + +const QString &ModerationAction::getLine1() const +{ + return this->line1_; +} + +const QString &ModerationAction::getLine2() const +{ + return this->line2_; +} + +const QString &ModerationAction::getAction() const +{ + return this->action_; +} + +} // namespace chatterino diff --git a/src/controllers/moderationactions/ModerationAction.hpp b/src/controllers/moderationactions/ModerationAction.hpp new file mode 100644 index 000000000..fe51be353 --- /dev/null +++ b/src/controllers/moderationactions/ModerationAction.hpp @@ -0,0 +1,68 @@ +#pragma once + +#include +#include + +#include "util/RapidjsonHelpers.hpp" + +namespace chatterino { + +class Image; + +class ModerationAction +{ +public: + ModerationAction(const QString &action_); + + bool operator==(const ModerationAction &other) const; + + bool isImage() const; + Image *getImage() const; + const QString &getLine1() const; + const QString &getLine2() const; + const QString &getAction() const; + +private: + bool isImage_; + Image *image_; + QString line1_; + QString line2_; + QString action_; +}; + +} // namespace chatterino + +namespace pajlada { +namespace Settings { + +template <> +struct Serialize { + static rapidjson::Value get(const chatterino::ModerationAction &value, + rapidjson::Document::AllocatorType &a) + { + rapidjson::Value ret(rapidjson::kObjectType); + + AddMember(ret, "pattern", value.getAction(), a); + + return ret; + } +}; + +template <> +struct Deserialize { + static chatterino::ModerationAction get(const rapidjson::Value &value) + { + if (!value.IsObject()) { + return chatterino::ModerationAction(QString()); + } + + QString pattern; + + chatterino::rj::getSafe(value, "pattern", pattern); + + return chatterino::ModerationAction(pattern); + } +}; + +} // namespace Settings +} // namespace pajlada diff --git a/src/controllers/moderationactions/ModerationActions.cpp b/src/controllers/moderationactions/ModerationActions.cpp new file mode 100644 index 000000000..fc418f03b --- /dev/null +++ b/src/controllers/moderationactions/ModerationActions.cpp @@ -0,0 +1,28 @@ +#include "ModerationActions.hpp" + +#include "Application.hpp" +#include "singletons/SettingsManager.hpp" + +#include + +namespace chatterino { + +ModerationActions::ModerationActions() +{ +} + +void ModerationActions::initialize() +{ + assert(!this->initialized); + this->initialized = true; + + for (auto &val : this->setting.getValue()) { + this->items.insertItem(val); + } + + this->items.delayedItemsChanged.connect([this] { // + this->setting.setValue(this->items.getVector()); + }); +} + +} // namespace chatterino diff --git a/src/controllers/moderationactions/ModerationActions.hpp b/src/controllers/moderationactions/ModerationActions.hpp new file mode 100644 index 000000000..948f98e2d --- /dev/null +++ b/src/controllers/moderationactions/ModerationActions.hpp @@ -0,0 +1,23 @@ +#pragma once + +#include "common/SignalVector2.hpp" +#include "controllers/moderationactions/ModerationAction.hpp" +#include "singletons/helper/ChatterinoSetting.hpp" + +namespace chatterino { + +class ModerationActions +{ +public: + ModerationActions(); + + void initialize(); + + UnsortedSignalVector items; + +private: + ChatterinoSetting> setting = {"/moderation/actions"}; + bool initialized = false; +}; + +} // namespace chatterino diff --git a/src/messages/Image.cpp b/src/messages/Image.cpp index 718d25ef7..08e17d93e 100644 --- a/src/messages/Image.cpp +++ b/src/messages/Image.cpp @@ -108,7 +108,7 @@ void Image::loadImage() this->loadedPixmap = pixmap; } - chatterino::Image::FrameData data; + Image::FrameData data; data.duration = std::max(20, reader.nextImageDelay()); data.image = pixmap; diff --git a/src/messages/LimitedQueue.hpp b/src/messages/LimitedQueue.hpp index 84474e8fc..ff7c28d5e 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) - chatterino::LimitedQueueSnapshot getSnapshot() + LimitedQueueSnapshot getSnapshot() { std::lock_guard lock(this->mutex); diff --git a/src/messages/Message.cpp b/src/messages/Message.cpp index a7b8a5b8b..563a1084e 100644 --- a/src/messages/Message.cpp +++ b/src/messages/Message.cpp @@ -175,8 +175,7 @@ MessagePtr Message::createTimeoutMessage(const BanAction &action, uint32_t count } } - msg->addElement(new chatterino::TextElement(text, chatterino::MessageElement::Text, - chatterino::MessageColor::System)); + msg->addElement(new TextElement(text, MessageElement::Text, MessageColor::System)); msg->searchText = text; return msg; @@ -204,8 +203,7 @@ MessagePtr Message::createUntimeoutMessage(const UnbanAction &action) .arg(action.target.name); } - msg->addElement(new chatterino::TextElement(text, chatterino::MessageElement::Text, - chatterino::MessageColor::System)); + msg->addElement(new TextElement(text, MessageElement::Text, MessageColor::System)); msg->searchText = text; return msg; diff --git a/src/messages/MessageColor.cpp b/src/messages/MessageColor.cpp index 161e562fa..b6700a9ad 100644 --- a/src/messages/MessageColor.cpp +++ b/src/messages/MessageColor.cpp @@ -13,7 +13,7 @@ MessageColor::MessageColor(Type _type) { } -const QColor &MessageColor::getColor(chatterino::ThemeManager &themeManager) const +const QColor &MessageColor::getColor(ThemeManager &themeManager) const { switch (this->type) { case Type::Custom: diff --git a/src/messages/MessageColor.hpp b/src/messages/MessageColor.hpp index e2100bf96..ce28613ca 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(chatterino::ThemeManager &themeManager) const; + const QColor &getColor(ThemeManager &themeManager) const; private: Type type; diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index de6f113a1..d3b6d1e7d 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -2,6 +2,7 @@ #include "Application.hpp" #include "common/Emotemap.hpp" +#include "controllers/moderationactions/ModerationActions.hpp" #include "debug/Benchmark.hpp" #include "messages/layouts/MessageLayoutContainer.hpp" #include "messages/layouts/MessageLayoutElement.hpp" @@ -248,7 +249,7 @@ void TwitchModerationElement::addToContainer(MessageLayoutContainer &container, if (_flags & MessageElement::ModeratorTools) { QSize size((int)(container.getScale() * 16), (int)(container.getScale() * 16)); - for (const chatterino::ModerationAction &m : getApp()->settings->getModerationActions()) { + for (const ModerationAction &m : getApp()->moderationActions->items.getVector()) { if (m.isImage()) { container.addElement((new ImageLayoutElement(*this, m.getImage(), size)) ->setLink(Link(Link::UserAction, m.getAction()))); diff --git a/src/providers/bttv/BttvEmotes.cpp b/src/providers/bttv/BttvEmotes.cpp index 5a2783c63..ba44459b7 100644 --- a/src/providers/bttv/BttvEmotes.cpp +++ b/src/providers/bttv/BttvEmotes.cpp @@ -36,11 +36,11 @@ void BTTVEmotes::loadGlobalEmotes() QString code = emote.toObject().value("code").toString(); EmoteData emoteData; - emoteData.image1x = new chatterino::Image(getEmoteLink(urlTemplate, id, "1x"), 1, code, + emoteData.image1x = new Image(getEmoteLink(urlTemplate, id, "1x"), 1, code, code + "
Global BTTV Emote"); - emoteData.image2x = new chatterino::Image(getEmoteLink(urlTemplate, id, "2x"), 0.5, + emoteData.image2x = new Image(getEmoteLink(urlTemplate, id, "2x"), 0.5, code, code + "
Global BTTV Emote"); - emoteData.image3x = new chatterino::Image(getEmoteLink(urlTemplate, id, "3x"), 0.25, + emoteData.image3x = new Image(getEmoteLink(urlTemplate, id, "3x"), 0.25, code, code + "
Global BTTV Emote"); emoteData.pageLink = "https://manage.betterttv.net/emotes/" + id; @@ -90,17 +90,17 @@ void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptrChannel BTTV Emote"); link = linkTemplate; link.detach(); emoteData.image2x = - new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "2x"), + new Image(link.replace("{{id}}", id).replace("{{image}}", "2x"), 0.5, code, code + "
Channel BTTV Emote"); link = linkTemplate; link.detach(); emoteData.image3x = - new chatterino::Image(link.replace("{{id}}", id).replace("{{image}}", "3x"), + new 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/emoji/Emojis.cpp b/src/providers/emoji/Emojis.cpp index 9b274ced6..ab9f13f86 100644 --- a/src/providers/emoji/Emojis.cpp +++ b/src/providers/emoji/Emojis.cpp @@ -260,7 +260,7 @@ void Emojis::loadEmojiSet() urlPrefix = it->second; } QString url = urlPrefix + code + ".png"; - emoji->emoteData.image1x = new chatterino::Image( + emoji->emoteData.image1x = new Image( url, 0.35, emoji->value, ":" + emoji->shortCodes[0] + ":
Emoji"); }); }); diff --git a/src/providers/ffz/FfzEmotes.cpp b/src/providers/ffz/FfzEmotes.cpp index 4f7398ce8..121f851b4 100644 --- a/src/providers/ffz/FfzEmotes.cpp +++ b/src/providers/ffz/FfzEmotes.cpp @@ -29,14 +29,14 @@ void fillInEmoteData(const QJsonObject &urls, const QString &code, const QString assert(!url1x.isEmpty()); - emoteData.image1x = new chatterino::Image(url1x, 1, code, tooltip); + emoteData.image1x = new Image(url1x, 1, code, tooltip); if (!url2x.isEmpty()) { - emoteData.image2x = new chatterino::Image(url2x, 0.5, code, tooltip); + emoteData.image2x = new Image(url2x, 0.5, code, tooltip); } if (!url3x.isEmpty()) { - emoteData.image3x = new chatterino::Image(url3x, 0.25, code, tooltip); + emoteData.image3x = new Image(url3x, 0.25, code, tooltip); } } diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index 1225e7877..e5f9903e9 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; } - chatterino::MessageParseArgs args; + 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()) { - chatterino::MessagePtr msg = builder.build(); + MessagePtr msg = builder.build(); if (isSub) { - msg->flags |= chatterino::Message::Subscription; - msg->flags &= ~chatterino::Message::Highlighted; + msg->flags |= Message::Subscription; + msg->flags &= ~Message::Highlighted; } else { - if (msg->flags & chatterino::Message::Highlighted) { + if (msg->flags & Message::Highlighted) { server.mentionsChannel->addMessage(msg); getApp()->highlights->addHighlight(msg); } @@ -200,7 +200,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message) { auto app = getApp(); Log("Received whisper!"); - chatterino::MessageParseArgs args; + MessageParseArgs args; args.isReceivedWhisper = true; @@ -209,9 +209,9 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message) TwitchMessageBuilder builder(c, message, args, message->parameter(1), false); if (!builder.isIgnored()) { - chatterino::MessagePtr _message = builder.build(); + MessagePtr _message = builder.build(); - if (_message->flags & chatterino::Message::Highlighted) { + if (_message->flags & Message::Highlighted) { app->twitch.server->mentionsChannel->addMessage(_message); } @@ -219,7 +219,7 @@ void IrcMessageHandler::handleWhisperMessage(Communi::IrcMessage *message) c->addMessage(_message); - _message->flags |= chatterino::Message::DoNotTriggerNotification; + _message->flags |= Message::DoNotTriggerNotification; if (app->settings->inlineWhispers) { app->twitch.server->forEachChannel([_message](ChannelPtr channel) { @@ -254,9 +254,9 @@ void IrcMessageHandler::handleUserNoticeMessage(Communi::IrcMessage *message, Tw if (it != tags.end()) { auto newMessage = - chatterino::Message::createSystemMessage(parseTagString(it.value().toString())); + Message::createSystemMessage(parseTagString(it.value().toString())); - newMessage->flags |= chatterino::Message::Subscription; + newMessage->flags |= Message::Subscription; QString channelName; diff --git a/src/providers/twitch/TwitchAccountManager.hpp b/src/providers/twitch/TwitchAccountManager.hpp index 1cfd00ec8..3b09bf13a 100644 --- a/src/providers/twitch/TwitchAccountManager.hpp +++ b/src/providers/twitch/TwitchAccountManager.hpp @@ -64,7 +64,7 @@ private: std::shared_ptr anonymousUser; mutable std::mutex mutex; - friend class chatterino::AccountController; + friend class AccountController; }; } // namespace chatterino diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 77a245849..2f78ddc1e 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -95,7 +95,7 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection #if 0 for (int i = 0; i < 1000; i++) { - this->addMessage(chatterino::Message::createSystemMessage("asdf")); + this->addMessage(Message::createSystemMessage("asdf")); } #endif } @@ -144,7 +144,7 @@ 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( - chatterino::Message::createSystemMessage("You need to log in to send messages. You can " + Message::createSystemMessage("You need to log in to send messages. You can " "link your Twitch account in the settings.")); return; } @@ -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 = chatterino::Message::createSystemMessage("Users joined: " + + auto message = Message::createSystemMessage("Users joined: " + this->joinedUsers.join(", ")); - message->flags |= chatterino::Message::Collapsed; + message->flags |= 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 = chatterino::Message::createSystemMessage("Users parted: " + + auto message = Message::createSystemMessage("Users parted: " + this->partedUsers.join(", ")); - message->flags |= chatterino::Message::Collapsed; + message->flags |= Message::Collapsed; this->addMessage(message); this->partedUsers.clear(); @@ -449,14 +449,14 @@ 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); - chatterino::MessageParseArgs args; + 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 415927c19..f6b6b09f8 100644 --- a/src/providers/twitch/TwitchChannel.hpp +++ b/src/providers/twitch/TwitchChannel.hpp @@ -60,7 +60,7 @@ 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); diff --git a/src/providers/twitch/TwitchEmotes.cpp b/src/providers/twitch/TwitchEmotes.cpp index cae80a61d..4703b2e9b 100644 --- a/src/providers/twitch/TwitchEmotes.cpp +++ b/src/providers/twitch/TwitchEmotes.cpp @@ -123,15 +123,15 @@ EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emoteName return _twitchEmoteFromCache.getOrAdd(id, [&emoteName, &_emoteName, &id] { EmoteData newEmoteData; auto cleanCode = cleanUpCode(emoteName); - newEmoteData.image1x = new chatterino::Image(getEmoteLink(id, "1.0"), 1, emoteName, + newEmoteData.image1x = new Image(getEmoteLink(id, "1.0"), 1, emoteName, _emoteName + "
Twitch Emote 1x"); newEmoteData.image1x->setCopyString(cleanCode); - newEmoteData.image2x = new chatterino::Image(getEmoteLink(id, "2.0"), .5, emoteName, + newEmoteData.image2x = new Image(getEmoteLink(id, "2.0"), .5, emoteName, _emoteName + "
Twitch Emote 2x"); newEmoteData.image2x->setCopyString(cleanCode); - newEmoteData.image3x = new chatterino::Image(getEmoteLink(id, "3.0"), .25, emoteName, + newEmoteData.image3x = new Image(getEmoteLink(id, "3.0"), .25, emoteName, _emoteName + "
Twitch Emote 3x"); newEmoteData.image3x->setCopyString(cleanCode); diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index dc93aea97..177fe269d 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -22,7 +22,7 @@ namespace chatterino { TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage, - const chatterino::MessageParseArgs &_args) + const MessageParseArgs &_args) : channel(_channel) , twitchChannel(dynamic_cast(_channel)) , ircMessage(_ircMessage) @@ -37,7 +37,7 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, const Communi::IrcMessage *_ircMessage, - const chatterino::MessageParseArgs &_args, + const MessageParseArgs &_args, QString content, bool isAction) : channel(_channel) , twitchChannel(dynamic_cast(_channel)) diff --git a/src/providers/twitch/TwitchMessageBuilder.hpp b/src/providers/twitch/TwitchMessageBuilder.hpp index 58669400f..6f3a97e5d 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 chatterino::MessageBuilder +class TwitchMessageBuilder : public MessageBuilder { public: enum UsernameDisplayMode : int { @@ -26,22 +26,22 @@ public: TwitchMessageBuilder() = delete; explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage, - const chatterino::MessageParseArgs &_args); + const MessageParseArgs &_args); explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcMessage *_ircMessage, - const chatterino::MessageParseArgs &_args, QString content, + const MessageParseArgs &_args, QString content, bool isAction); Channel *channel; TwitchChannel *twitchChannel; const Communi::IrcMessage *ircMessage; - chatterino::MessageParseArgs args; + MessageParseArgs args; const QVariantMap tags; QString messageID; QString userName; bool isIgnored() const; - chatterino::MessagePtr build(); + MessagePtr build(); private: QString roomID; diff --git a/src/providers/twitch/TwitchServer.cpp b/src/providers/twitch/TwitchServer.cpp index 60133a14f..e16c7760c 100644 --- a/src/providers/twitch/TwitchServer.cpp +++ b/src/providers/twitch/TwitchServer.cpp @@ -195,7 +195,7 @@ void TwitchServer::onMessageSendRequested(TwitchChannel *channel, const QString if (!lastMessage.empty() && lastMessage.back() + minMessageOffset > now) { if (this->lastErrorTimeSpeed_ + 30s < now) { auto errorMessage = - chatterino::Message::createSystemMessage("sending messages too fast"); + Message::createSystemMessage("sending messages too fast"); channel->addMessage(errorMessage); @@ -213,7 +213,7 @@ void TwitchServer::onMessageSendRequested(TwitchChannel *channel, const QString if (lastMessage.size() >= maxMessageCount) { if (this->lastErrorTimeAmount_ + 30s < now) { auto errorMessage = - chatterino::Message::createSystemMessage("sending too many messages"); + Message::createSystemMessage("sending too many messages"); channel->addMessage(errorMessage); diff --git a/src/singletons/EmoteManager.cpp b/src/singletons/EmoteManager.cpp index ac7d74aa0..f0ffe3490 100644 --- a/src/singletons/EmoteManager.cpp +++ b/src/singletons/EmoteManager.cpp @@ -20,4 +20,9 @@ void EmoteManager::initialize() this->gifTimer.initialize(); } +bool EmoteManager::isIgnoredEmote(const QString &) +{ + return false; +} + } // namespace chatterino diff --git a/src/singletons/EmoteManager.hpp b/src/singletons/EmoteManager.hpp index 1372d7619..0315259cd 100644 --- a/src/singletons/EmoteManager.hpp +++ b/src/singletons/EmoteManager.hpp @@ -17,6 +17,8 @@ public: void initialize(); + bool isIgnoredEmote(const QString &emote); + TwitchEmotes twitch; BTTVEmotes bttv; FFZEmotes ffz; diff --git a/src/singletons/FontManager.hpp b/src/singletons/FontManager.hpp index 6e46283c2..cd5ebc03d 100644 --- a/src/singletons/FontManager.hpp +++ b/src/singletons/FontManager.hpp @@ -77,6 +77,6 @@ private: std::vector> fontsByType; }; -using FontStyle = chatterino::FontManager::Type; +using FontStyle = FontManager::Type; } // namespace chatterino diff --git a/src/singletons/IrcManager.cpp b/src/singletons/IrcManager.cpp index c9997a45c..8e2ffd635 100644 --- a/src/singletons/IrcManager.cpp +++ b/src/singletons/IrcManager.cpp @@ -22,7 +22,7 @@ //#include -// using namespace chatterino::messages; +// using namespace messages; // void IrcManager::refreshIgnoredUsers(const QString &username, const QString &oauthClient, // const QString &oauthToken) diff --git a/src/singletons/LoggingManager.cpp b/src/singletons/LoggingManager.cpp index 272659acb..df240458c 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, chatterino::MessagePtr message) +void LoggingManager::addMessage(const QString &channelName, MessagePtr message) { auto app = getApp(); diff --git a/src/singletons/LoggingManager.hpp b/src/singletons/LoggingManager.hpp index f52d4dc85..5ba9ea5a4 100644 --- a/src/singletons/LoggingManager.hpp +++ b/src/singletons/LoggingManager.hpp @@ -20,7 +20,7 @@ public: void initialize(); - void addMessage(const QString &channelName, chatterino::MessagePtr message); + void addMessage(const QString &channelName, MessagePtr message); private: std::map> loggingChannels; diff --git a/src/singletons/NativeMessagingManager.cpp b/src/singletons/NativeMessagingManager.cpp index ce5ee03b5..0b1acca10 100644 --- a/src/singletons/NativeMessagingManager.cpp +++ b/src/singletons/NativeMessagingManager.cpp @@ -124,9 +124,9 @@ void NativeMessagingManager::openGuiMessageQueue() void NativeMessagingManager::sendToGuiProcess(const QByteArray &array) { - ipc::message_queue messageQueue(ipc::open_only, "chatterino_gui"); - try { + ipc::message_queue messageQueue(ipc::open_only, "chatterino_gui"); + messageQueue.try_send(array.data(), array.size(), 1); } catch (ipc::interprocess_exception &ex) { qDebug() << "send to gui process:" << ex.what(); diff --git a/src/singletons/ResourceManager.cpp b/src/singletons/ResourceManager.cpp index ca1bcaa1b..d8b88893a 100644 --- a/src/singletons/ResourceManager.cpp +++ b/src/singletons/ResourceManager.cpp @@ -8,9 +8,9 @@ namespace chatterino { namespace { -inline chatterino::Image *lli(const char *pixmapPath, qreal scale = 1) +inline Image *lli(const char *pixmapPath, qreal scale = 1) { - return new chatterino::Image(new QPixmap(pixmapPath), scale); + return new Image(new QPixmap(pixmapPath), scale); } template @@ -221,7 +221,7 @@ inline bool ParseSingleCheermoteSet(ResourceManager::JSONCheermoteSet &set, qreal chatterinoScale = 1 / scaleNumber; - auto image = new chatterino::Image(url, chatterinoScale); + auto image = new 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 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())) + : badgeImage1x(new Image(root.value("image_url_1x").toString())) + , badgeImage2x(new Image(root.value("image_url_2x").toString())) + , badgeImage4x(new 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()) @@ -438,7 +438,7 @@ void ResourceManager::loadChatterinoBadges() const QString &badgeVariantImageURL = badgeVariant.value("image").toString(); auto badgeVariantPtr = std::make_shared( - badgeVariantTooltip, new chatterino::Image(badgeVariantImageURL)); + badgeVariantTooltip, new Image(badgeVariantImageURL)); QJsonArray badgeVariantUsers = badgeVariant.value("users").toArray(); diff --git a/src/singletons/ResourceManager.hpp b/src/singletons/ResourceManager.hpp index 54300c954..689db1630 100644 --- a/src/singletons/ResourceManager.hpp +++ b/src/singletons/ResourceManager.hpp @@ -35,39 +35,39 @@ public: QPixmap unmod; } buttons; - 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; + Image *badgeStaff; + Image *badgeAdmin; + Image *badgeGlobalModerator; + Image *badgeModerator; + Image *badgeTurbo; + Image *badgeBroadcaster; + Image *badgePremium; + Image *badgeVerified; + Image *badgeSubscriber; + Image *badgeCollapsed; - chatterino::Image *cheerBadge100000; - chatterino::Image *cheerBadge10000; - chatterino::Image *cheerBadge5000; - chatterino::Image *cheerBadge1000; - chatterino::Image *cheerBadge100; - chatterino::Image *cheerBadge1; + Image *cheerBadge100000; + Image *cheerBadge10000; + Image *cheerBadge5000; + Image *cheerBadge1000; + Image *cheerBadge100; + Image *cheerBadge1; - chatterino::Image *moderationmode_enabled; - chatterino::Image *moderationmode_disabled; + Image *moderationmode_enabled; + Image *moderationmode_disabled; - chatterino::Image *splitHeaderContext; + Image *splitHeaderContext; - std::map cheerBadges; + std::map cheerBadges; struct BadgeVersion { BadgeVersion() = delete; explicit BadgeVersion(QJsonObject &&root); - chatterino::Image *badgeImage1x; - chatterino::Image *badgeImage2x; - chatterino::Image *badgeImage4x; + Image *badgeImage1x; + Image *badgeImage2x; + Image *badgeImage4x; std::string description; std::string title; std::string clickAction; @@ -82,8 +82,8 @@ public: bool dynamicBadgesLoaded = false; - chatterino::Image *buttonBan; - chatterino::Image *buttonTimeout; + Image *buttonBan; + 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; @@ -135,14 +135,14 @@ public: // Chatterino badges struct ChatterinoBadge { - ChatterinoBadge(const std::string &_tooltip, chatterino::Image *_image) + ChatterinoBadge(const std::string &_tooltip, Image *_image) : tooltip(_tooltip) , image(_image) { } std::string tooltip; - chatterino::Image *image; + Image *image; }; // username diff --git a/src/singletons/SettingsManager.cpp b/src/singletons/SettingsManager.cpp index 946f19f00..074127e2a 100644 --- a/src/singletons/SettingsManager.cpp +++ b/src/singletons/SettingsManager.cpp @@ -18,22 +18,17 @@ void _actuallyRegisterSetting(std::weak_ptr set SettingManager::SettingManager() { qDebug() << "init SettingManager"; +} - this->wordFlagsListener.addSetting(this->showTimestamps); - this->wordFlagsListener.addSetting(this->showBadges); - this->wordFlagsListener.addSetting(this->enableBttvEmotes); - this->wordFlagsListener.addSetting(this->enableEmojis); - this->wordFlagsListener.addSetting(this->enableFfzEmotes); - this->wordFlagsListener.addSetting(this->enableTwitchEmotes); - this->wordFlagsListener.cb = [this](auto) { - this->updateWordTypeMask(); // - }; +SettingManager &SettingManager::getInstance() +{ + static SettingManager instance; + + return instance; } void SettingManager::initialize() { - this->moderationActions.connect([this](auto, auto) { this->updateModerationActions(); }); - this->timestampFormat.connect([](auto, auto) { auto app = getApp(); app->windows->layoutChannelViews(); @@ -50,16 +45,6 @@ void SettingManager::initialize() [](auto, auto) { getApp()->windows->forceLayoutChannelViews(); }); } -MessageElement::Flags SettingManager::getWordFlags() -{ - return this->wordFlags; -} - -bool SettingManager::isIgnoredEmote(const QString &) -{ - return false; -} - void SettingManager::load() { auto app = getApp(); @@ -68,42 +53,6 @@ void SettingManager::load() pajlada::Settings::SettingManager::load(qPrintable(settingsPath)); } -void SettingManager::updateWordTypeMask() -{ - uint32_t newMaskUint = MessageElement::Text; - - if (this->showTimestamps) { - newMaskUint |= MessageElement::Timestamp; - } - - newMaskUint |= - enableTwitchEmotes ? MessageElement::TwitchEmoteImage : MessageElement::TwitchEmoteText; - newMaskUint |= enableFfzEmotes ? MessageElement::FfzEmoteImage : MessageElement::FfzEmoteText; - newMaskUint |= - enableBttvEmotes ? MessageElement::BttvEmoteImage : MessageElement::BttvEmoteText; - newMaskUint |= enableEmojis ? MessageElement::EmojiImage : MessageElement::EmojiText; - - newMaskUint |= MessageElement::BitsAmount; - newMaskUint |= enableGifAnimations ? MessageElement::BitsAnimated : MessageElement::BitsStatic; - - if (this->showBadges) { - newMaskUint |= MessageElement::Badges; - } - - newMaskUint |= MessageElement::Username; - - newMaskUint |= MessageElement::AlwaysShow; - newMaskUint |= MessageElement::Collapsed; - - MessageElement::Flags newMask = static_cast(newMaskUint); - - if (newMask != this->wordFlags) { - this->wordFlags = newMask; - - this->wordFlagsChanged.invoke(); - } -} - void SettingManager::saveSnapshot() { rapidjson::Document *d = new rapidjson::Document(rapidjson::kObjectType); @@ -125,7 +74,7 @@ void SettingManager::saveSnapshot() Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d)); } -void SettingManager::recallSnapshot() +void SettingManager::restoreSnapshot() { if (!this->snapshot) { return; @@ -151,77 +100,9 @@ void SettingManager::recallSnapshot() } } -std::vector SettingManager::getModerationActions() const +SettingManager *getSettings() { - return this->_moderationActions; -} - -void SettingManager::updateModerationActions() -{ - auto app = getApp(); - - this->_moderationActions.clear(); - - static QRegularExpression newLineRegex("(\r\n?|\n)+"); - static QRegularExpression replaceRegex("[!/.]"); - static QRegularExpression timeoutRegex("^[./]timeout.* (\\d+)"); - QStringList list = this->moderationActions.getValue().split(newLineRegex); - - int multipleTimeouts = 0; - - for (QString &str : list) { - if (timeoutRegex.match(str).hasMatch()) { - multipleTimeouts++; - if (multipleTimeouts > 1) { - break; - } - } - } - - for (int i = 0; i < list.size(); i++) { - QString &str = list[i]; - - if (str.isEmpty()) { - continue; - } - - auto timeoutMatch = timeoutRegex.match(str); - - if (timeoutMatch.hasMatch()) { - if (multipleTimeouts > 1) { - QString line1; - QString line2; - - int amount = timeoutMatch.captured(1).toInt(); - - if (amount < 60) { - line1 = QString::number(amount); - line2 = "s"; - } else if (amount < 60 * 60) { - line1 = QString::number(amount / 60); - line2 = "m"; - } else if (amount < 60 * 60 * 24) { - line1 = QString::number(amount / 60 / 60); - line2 = "h"; - } else { - line1 = QString::number(amount / 60 / 60 / 24); - line2 = "d"; - } - - this->_moderationActions.emplace_back(line1, line2, str); - } else { - this->_moderationActions.emplace_back(app->resources->buttonTimeout, str); - } - } else if (str.startsWith("/ban ")) { - this->_moderationActions.emplace_back(app->resources->buttonBan, str); - } else { - QString xD = str; - - xD.replace(replaceRegex, ""); - - this->_moderationActions.emplace_back(xD.mid(0, 2), xD.mid(2, 2), str); - } - } + return &SettingManager::getInstance(); } } // namespace chatterino diff --git a/src/singletons/SettingsManager.hpp b/src/singletons/SettingsManager.hpp index ba00128ea..31b2caec4 100644 --- a/src/singletons/SettingsManager.hpp +++ b/src/singletons/SettingsManager.hpp @@ -1,9 +1,9 @@ #pragma once #include "controllers/highlights/HighlightPhrase.hpp" +#include "controllers/moderationactions/ModerationAction.hpp" #include "messages/MessageElement.hpp" #include "singletons/helper/ChatterinoSetting.hpp" -#include "singletons/helper/ModerationAction.hpp" #include #include @@ -14,19 +14,10 @@ void _actuallyRegisterSetting(std::weak_ptr set class SettingManager { - using BoolSetting = ChatterinoSetting; - using FloatSetting = ChatterinoSetting; - using IntSetting = ChatterinoSetting; - using StringSetting = ChatterinoSetting; - using QStringSetting = ChatterinoSetting; - -public: SettingManager(); - ~SettingManager() = delete; - - chatterino::MessageElement::Flags getWordFlags(); - bool isIgnoredEmote(const QString &emote); +public: + static SettingManager &getInstance(); void initialize(); void load(); @@ -94,7 +85,6 @@ public: BoolSetting enableTwitchIgnoredUsers = {"/ignore/enableTwitchIgnoredUsers", true}; /// Moderation - QStringSetting moderationActions = {"/moderation/actions", "/ban {user}\n/timeout {user} 300"}; QStringSetting timeoutAction = {"/moderation/timeoutAction", "Disable"}; /// Highlighting @@ -128,23 +118,15 @@ public: IntSetting startUpNotification = {"/misc/startUpNotification", 0}; QStringSetting currentVersion = {"/misc/currentVersion", ""}; - void updateWordTypeMask(); - void saveSnapshot(); - void recallSnapshot(); - - std::vector getModerationActions() const; - pajlada::Signals::NoArgSignal wordFlagsChanged; + void restoreSnapshot(); private: - std::vector _moderationActions; std::unique_ptr snapshot; void updateModerationActions(); - - chatterino::MessageElement::Flags wordFlags = chatterino::MessageElement::Default; - - pajlada::Settings::SettingListener wordFlagsListener; }; +SettingManager *getSettings(); + } // namespace chatterino diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 7b2ba5a09..47ef6d740 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -59,6 +59,66 @@ void WindowManager::showAccountSelectPopup(QPoint point) WindowManager::WindowManager() { qDebug() << "init WindowManager"; + + auto settings = getSettings(); + + this->wordFlagsListener.addSetting(settings->showTimestamps); + this->wordFlagsListener.addSetting(settings->showBadges); + this->wordFlagsListener.addSetting(settings->enableBttvEmotes); + this->wordFlagsListener.addSetting(settings->enableEmojis); + this->wordFlagsListener.addSetting(settings->enableFfzEmotes); + this->wordFlagsListener.addSetting(settings->enableTwitchEmotes); + this->wordFlagsListener.cb = [this](auto) { + this->updateWordTypeMask(); // + }; +} + +MessageElement::Flags WindowManager::getWordFlags() +{ + return this->wordFlags; +} + +void WindowManager::updateWordTypeMask() +{ + using MEF = MessageElement::Flags; + auto settings = getSettings(); + + // text + auto flags = MEF::Text | MEF::Text; + + // timestamp + if (settings->showTimestamps) { + flags |= MEF::Timestamp; + } + + // emotes + flags |= settings->enableTwitchEmotes ? MEF::TwitchEmoteImage : MEF::TwitchEmoteText; + flags |= settings->enableFfzEmotes ? MEF::FfzEmoteImage : MEF::FfzEmoteText; + flags |= settings->enableBttvEmotes ? MEF::BttvEmoteImage : MEF::BttvEmoteText; + flags |= settings->enableEmojis ? MEF::EmojiImage : MEF::EmojiText; + + // bits + flags |= MEF::BitsAmount; + flags |= settings->enableGifAnimations ? MEF::BitsAnimated : MEF::BitsStatic; + + // badges + flags |= settings->showBadges ? MEF::Badges : MEF::None; + + // username + flags |= MEF::Username; + + // misc + flags |= MEF::AlwaysShow; + flags |= MEF::Collapsed; + + // update flags + MessageElement::Flags newFlags = static_cast(flags); + + if (newFlags != this->wordFlags) { + this->wordFlags = newFlags; + + this->wordFlagsChanged.invoke(); + } } void WindowManager::layoutChannelViews(Channel *channel) diff --git a/src/singletons/WindowManager.hpp b/src/singletons/WindowManager.hpp index 79e15034b..3538b2f45 100644 --- a/src/singletons/WindowManager.hpp +++ b/src/singletons/WindowManager.hpp @@ -44,6 +44,11 @@ public: static float getUiScaleValue(); static float getUiScaleValue(int scale); + MessageElement::Flags getWordFlags(); + void updateWordTypeMask(); + + pajlada::Signals::NoArgSignal wordFlagsChanged; + private: bool initialized = false; @@ -56,6 +61,9 @@ private: void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj); + MessageElement::Flags wordFlags = MessageElement::Default; + pajlada::Settings::SettingListener wordFlagsListener; + public: static void encodeChannel(IndirectChannel channel, QJsonObject &obj); static IndirectChannel decodeChannel(const QJsonObject &obj); diff --git a/src/singletons/helper/ChatterinoSetting.hpp b/src/singletons/helper/ChatterinoSetting.hpp index 373d9f6fd..9bd4c0225 100644 --- a/src/singletons/helper/ChatterinoSetting.hpp +++ b/src/singletons/helper/ChatterinoSetting.hpp @@ -1,5 +1,8 @@ #pragma once +#include +#include + namespace chatterino { void _registerSetting(std::weak_ptr setting); @@ -41,4 +44,10 @@ public: using pajlada::Settings::Setting::operator const Type; }; +using BoolSetting = ChatterinoSetting; +using FloatSetting = ChatterinoSetting; +using IntSetting = ChatterinoSetting; +using StringSetting = ChatterinoSetting; +using QStringSetting = ChatterinoSetting; + } // namespace chatterino diff --git a/src/singletons/helper/LoggingChannel.cpp b/src/singletons/helper/LoggingChannel.cpp index d477e63f1..b62262e6b 100644 --- a/src/singletons/helper/LoggingChannel.cpp +++ b/src/singletons/helper/LoggingChannel.cpp @@ -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 98d9f0203..9acafa417 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 deleted file mode 100644 index c61cc653a..000000000 --- a/src/singletons/helper/ModerationAction.cpp +++ /dev/null @@ -1,49 +0,0 @@ -#include "ModerationAction.hpp" - -#include "singletons/ResourceManager.hpp" - -namespace chatterino { - -ModerationAction::ModerationAction(chatterino::Image *_image, const QString &_action) - : _isImage(true) - , image(_image) - , action(_action) -{ -} - -ModerationAction::ModerationAction(const QString &_line1, const QString &_line2, - const QString &_action) - : _isImage(false) - , image(nullptr) - , line1(_line1) - , line2(_line2) - , action(_action) -{ -} - -bool ModerationAction::isImage() const -{ - return this->_isImage; -} - -chatterino::Image *ModerationAction::getImage() const -{ - return this->image; -} - -const QString &ModerationAction::getLine1() const -{ - return this->line1; -} - -const QString &ModerationAction::getLine2() const -{ - return this->line2; -} - -const QString &ModerationAction::getAction() const -{ - return this->action; -} - -} // namespace chatterino diff --git a/src/singletons/helper/ModerationAction.hpp b/src/singletons/helper/ModerationAction.hpp deleted file mode 100644 index 52b5449d1..000000000 --- a/src/singletons/helper/ModerationAction.hpp +++ /dev/null @@ -1,29 +0,0 @@ -#pragma once - -#include - -namespace chatterino { - -class Image; - -class ModerationAction -{ -public: - ModerationAction(chatterino::Image *image, const QString &action); - ModerationAction(const QString &line1, const QString &line2, const QString &action); - - bool isImage() const; - chatterino::Image *getImage() const; - const QString &getLine1() const; - const QString &getLine2() const; - const QString &getAction() const; - -private: - bool _isImage; - chatterino::Image *image; - QString line1; - QString line2; - QString action; -}; - -} // namespace chatterino diff --git a/src/widgets/BaseWidget.hpp b/src/widgets/BaseWidget.hpp index 4767e676b..bc1faa5ac 100644 --- a/src/widgets/BaseWidget.hpp +++ b/src/widgets/BaseWidget.hpp @@ -41,7 +41,7 @@ protected: void setScale(float value); - chatterino::ThemeManager *themeManager; + ThemeManager *themeManager; private: void init(); diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index fd7603ec0..8aa65cdc5 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -249,10 +249,10 @@ void BaseWindow::wheelEvent(QWheelEvent *event) if (event->modifiers() & Qt::ControlModifier) { if (event->delta() > 0) { - getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale( + getApp()->settings->uiScale.setValue(WindowManager::clampUiScale( getApp()->settings->uiScale.getValue() + 1)); } else { - getApp()->settings->uiScale.setValue(chatterino::WindowManager::clampUiScale( + getApp()->settings->uiScale.setValue(WindowManager::clampUiScale( getApp()->settings->uiScale.getValue() - 1)); } } diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index f47705e04..ed0da5b57 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -52,7 +52,7 @@ void Scrollbar::unpauseHighlights() this->highlightsPaused_ = false; } -chatterino::LimitedQueueSnapshot Scrollbar::getHighlightSnapshot() +LimitedQueueSnapshot Scrollbar::getHighlightSnapshot() { if (!this->highlightsPaused_) { this->highlightSnapshot_ = this->highlights_.getSnapshot(); diff --git a/src/widgets/Scrollbar.hpp b/src/widgets/Scrollbar.hpp index e4e742f8a..a5627bd77 100644 --- a/src/widgets/Scrollbar.hpp +++ b/src/widgets/Scrollbar.hpp @@ -68,10 +68,10 @@ private: QPropertyAnimation currentValueAnimation_; - chatterino::LimitedQueue highlights_; + LimitedQueue highlights_; bool highlightsPaused_{false}; - chatterino::LimitedQueueSnapshot highlightSnapshot_; - chatterino::LimitedQueueSnapshot getHighlightSnapshot(); + LimitedQueueSnapshot highlightSnapshot_; + LimitedQueueSnapshot getHighlightSnapshot(); bool atBottom_{false}; diff --git a/src/widgets/TooltipWidget.cpp b/src/widgets/TooltipWidget.cpp index 6eec31923..acaf1a1b6 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(chatterino::FontManager::Type::ChatMediumSmall, this->getScale())); + app->fonts->getFont(FontManager::Type::ChatMediumSmall, this->getScale())); } void TooltipWidget::setText(QString text) diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 75bc3b10f..b0c52baeb 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(chatterino::WindowManager::clampUiScale( + getApp()->settings->uiScale.setValue(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(chatterino::WindowManager::clampUiScale( + getApp()->settings->uiScale.setValue(WindowManager::clampUiScale( getApp()->settings->uiScale.getValue() - 1)); }); } diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index a32efd449..8c79b3c29 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -58,7 +58,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel) auto addEmotes = [&](EmoteMap &map, const QString &title, const QString &emoteDesc) { // TITLE - chatterino::MessageBuilder builder1; + MessageBuilder builder1; builder1.append(new TextElement(title, MessageElement::Text)); @@ -66,7 +66,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel) emoteChannel->addMessage(builder1.getMessage()); // EMOTES - chatterino::MessageBuilder builder2; + MessageBuilder builder2; builder2.getMessage()->flags |= Message::Centered; builder2.getMessage()->flags |= Message::DisableCompactEmotes; @@ -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 - chatterino::MessageBuilder builder1; + MessageBuilder builder1; QString setText; if (set->text.isEmpty()) { @@ -105,7 +105,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel) emoteChannel->addMessage(builder1.getMessage()); // EMOTES - chatterino::MessageBuilder builder2; + MessageBuilder builder2; builder2.getMessage()->flags |= Message::Centered; builder2.getMessage()->flags |= Message::DisableCompactEmotes; @@ -137,14 +137,14 @@ void EmotePopup::loadEmojis() ChannelPtr emojiChannel(new Channel("", Channel::None)); // title - chatterino::MessageBuilder builder1; + MessageBuilder builder1; builder1.append(new TextElement("emojis", MessageElement::Text)); builder1.getMessage()->flags |= Message::Centered; emojiChannel->addMessage(builder1.getMessage()); // emojis - chatterino::MessageBuilder builder; + 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 6e584db96..02b48731f 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 bcfce0185..0d36bd81f 100644 --- a/src/widgets/dialogs/LastRunCrashDialog.cpp +++ b/src/widgets/dialogs/LastRunCrashDialog.cpp @@ -16,7 +16,7 @@ LastRunCrashDialog::LastRunCrashDialog() this->setWindowFlag(Qt::WindowContextHelpButtonHint, false); this->setWindowTitle("Chatterino"); - auto &updateManager = chatterino::UpdateManager::getInstance(); + auto &updateManager = UpdateManager::getInstance(); auto layout = LayoutCreator(this).setLayoutType(); @@ -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 = chatterino::UpdateManager::getInstance(); + // auto &updateManager = UpdateManager::getInstance(); // updateManager.installUpdates(); // this->setEnabled(false); @@ -43,36 +43,36 @@ LastRunCrashDialog::LastRunCrashDialog() // Updates // auto updateUpdateLabel = [update]() mutable { - // auto &updateManager = chatterino::UpdateManager::getInstance(); + // auto &updateManager = UpdateManager::getInstance(); // switch (updateManager.getStatus()) { - // case chatterino::UpdateManager::None: { + // case UpdateManager::None: { // update->setText("Not checking for updates."); // } break; - // case chatterino::UpdateManager::Searching: { + // case UpdateManager::Searching: { // update->setText("Checking for updates..."); // } break; - // case chatterino::UpdateManager::UpdateAvailable: { + // case UpdateManager::UpdateAvailable: { // update->setText("Update available."); // } break; - // case chatterino::UpdateManager::NoUpdateAvailable: { + // case UpdateManager::NoUpdateAvailable: { // update->setText("No update abailable."); // } break; - // case chatterino::UpdateManager::SearchFailed: { + // case 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 chatterino::UpdateManager::Downloading: { + // case UpdateManager::Downloading: { // update->setText( // "Downloading the update. Chatterino will close once the download is // done."); // } break; - // case chatterino::UpdateManager::DownloadFailed: { + // case UpdateManager::DownloadFailed: { // update->setText("Download failed."); // } break; - // case chatterino::UpdateManager::WriteFileFailed: { + // case UpdateManager::WriteFileFailed: { // update->setText("Writing the update file to the hard drive failed."); // } break; // } diff --git a/src/widgets/dialogs/NotificationPopup.cpp b/src/widgets/dialogs/NotificationPopup.cpp index 5404a09d8..2970a4fd0 100644 --- a/src/widgets/dialogs/NotificationPopup.cpp +++ b/src/widgets/dialogs/NotificationPopup.cpp @@ -38,7 +38,7 @@ void NotificationPopup::updatePosition() } } -void NotificationPopup::addMessage(chatterino::MessagePtr msg) +void NotificationPopup::addMessage(MessagePtr msg) { this->channel->addMessage(msg); diff --git a/src/widgets/dialogs/NotificationPopup.hpp b/src/widgets/dialogs/NotificationPopup.hpp index bec14ccd1..dae060bd4 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(chatterino::MessagePtr msg); + void addMessage(MessagePtr msg); void updatePosition(); private: diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 4a1f9fb4b..8dd7fb9c0 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -218,7 +218,7 @@ void SettingsDialog::cancelButtonClicked() tab->getSettingsPage()->cancel(); } - getApp()->settings->recallSnapshot(); + getApp()->settings->restoreSnapshot(); this->close(); } diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 4dedc9030..de606282e 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -41,7 +41,7 @@ ChannelView::ChannelView(BaseWidget *parent) this->setMouseTracking(true); - this->connections_.push_back(app->settings->wordFlagsChanged.connect([this] { + this->connections_.push_back(app->windows->wordFlagsChanged.connect([this] { this->layoutMessages(); this->update(); })); @@ -271,8 +271,7 @@ QString ChannelView::getSelectedText() { QString result = ""; - chatterino::LimitedQueueSnapshot messagesSnapshot = - this->getMessagesSnapshot(); + LimitedQueueSnapshot messagesSnapshot = this->getMessagesSnapshot(); Selection _selection = this->selection_; @@ -318,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_; } -chatterino::LimitedQueueSnapshot ChannelView::getMessagesSnapshot() +LimitedQueueSnapshot ChannelView::getMessagesSnapshot() { if (!this->isPaused() /*|| this->scrollBar_.isVisible()*/) { this->snapshot_ = this->messages.getSnapshot(); @@ -531,7 +530,7 @@ void ChannelView::setSelection(const SelectionItem &start, const SelectionItem & this->selectionChanged.invoke(); } -chatterino::MessageElement::Flags ChannelView::getFlags() const +MessageElement::Flags ChannelView::getFlags() const { auto app = getApp(); @@ -539,7 +538,7 @@ chatterino::MessageElement::Flags ChannelView::getFlags() const return this->overrideFlags_.get(); } - MessageElement::Flags flags = app->settings->getWordFlags(); + MessageElement::Flags flags = app->windows->getWordFlags(); Split *split = dynamic_cast(this->parentWidget()); @@ -599,11 +598,11 @@ void ChannelView::drawMessages(QPainter &painter) int y = int(-(messagesSnapshot[start].get()->getHeight() * (fmod(this->scrollBar_.getCurrentValue(), 1)))); - chatterino::MessageLayout *end = nullptr; + MessageLayout *end = nullptr; bool windowFocused = this->window() == QApplication::activeWindow(); for (size_t i = start; i < messagesSnapshot.getLength(); ++i) { - chatterino::MessageLayout *layout = messagesSnapshot[i].get(); + MessageLayout *layout = messagesSnapshot[i].get(); bool isLastMessage = false; if (app->settings->showLastMessageIndicator) { @@ -634,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(); } @@ -642,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); @@ -759,7 +758,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event) } auto tooltipWidget = TooltipWidget::getInstance(); - std::shared_ptr layout; + std::shared_ptr layout; QPoint relativePos; int messageIndex; @@ -788,7 +787,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event) } // check if word underneath cursor - const chatterino::MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); + const MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); if (hoverLayoutElement == nullptr) { this->setCursor(Qt::ArrowCursor); @@ -821,7 +820,7 @@ void ChannelView::mousePressEvent(QMouseEvent *event) this->mouseDown.invoke(event); - std::shared_ptr layout; + std::shared_ptr layout; QPoint relativePos; int messageIndex; @@ -908,7 +907,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) // find message this->layoutMessages(); - std::shared_ptr layout; + std::shared_ptr layout; QPoint relativePos; int messageIndex; @@ -927,7 +926,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) return; } - const chatterino::MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); + const MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); if (hoverLayoutElement == nullptr) { return; @@ -937,9 +936,8 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event) this->handleMouseClick(event, hoverLayoutElement, layout.get()); } -void ChannelView::handleMouseClick(QMouseEvent *event, - const chatterino::MessageLayoutElement *hoveredElement, - chatterino::MessageLayout *layout) +void ChannelView::handleMouseClick(QMouseEvent *event, const MessageLayoutElement *hoveredElement, + MessageLayout *layout) { switch (event->button()) { case Qt::LeftButton: { @@ -971,8 +969,8 @@ void ChannelView::handleMouseClick(QMouseEvent *event, } } -void ChannelView::addContextMenuItems(const chatterino::MessageLayoutElement *hoveredElement, - chatterino::MessageLayout *layout) +void ChannelView::addContextMenuItems(const MessageLayoutElement *hoveredElement, + MessageLayout *layout) { const auto &creator = hoveredElement->getCreator(); auto creatorFlags = creator.getFlags(); @@ -982,7 +980,7 @@ void ChannelView::addContextMenuItems(const chatterino::MessageLayoutElement *ho // 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 +1097,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,8 +1110,7 @@ void ChannelView::mouseDoubleClickEvent(QMouseEvent *event) return; } - const chatterino::MessageLayoutElement *hoverLayoutElement = - layout->getElementAt(relativePos); + const MessageLayoutElement *hoverLayoutElement = layout->getElementAt(relativePos); if (hoverLayoutElement == nullptr) { return; @@ -1133,15 +1130,14 @@ void ChannelView::hideEvent(QHideEvent *) this->messagesOnScreen_.clear(); } -void ChannelView::handleLinkClick(QMouseEvent *event, const chatterino::Link &link, - chatterino::MessageLayout *layout) +void ChannelView::handleLinkClick(QMouseEvent *event, const Link &link, MessageLayout *layout) { if (event->button() != Qt::LeftButton) { return; } switch (link.type) { - case chatterino::Link::UserInfo: { + case Link::UserInfo: { auto user = link.value; auto *userPopup = new UserInfoPopup; @@ -1155,12 +1151,12 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const chatterino::Link &li break; } - case chatterino::Link::Url: { + case Link::Url: { QDesktopServices::openUrl(QUrl(link.value)); break; } - case chatterino::Link::UserAction: { + case Link::UserAction: { QString value = link.value; value.replace("{user}", layout->getMessage()->loginName); this->channel_->sendMessage(value); @@ -1170,7 +1166,7 @@ void ChannelView::handleLinkClick(QMouseEvent *event, const chatterino::Link &li } } -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 b3ae61894..f115156de 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_); - chatterino::LimitedQueueSnapshot getMessagesSnapshot(); + 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 chatterino::Link &link, - chatterino::MessageLayout *layout); + void handleLinkClick(QMouseEvent *event, const Link &link, + 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_; - chatterino::MessageLayoutPtr lastReadMessage_; + boost::optional overrideFlags_; + MessageLayoutPtr lastReadMessage_; - chatterino::LimitedQueueSnapshot snapshot_; + LimitedQueueSnapshot snapshot_; void detachChannel(); void actuallyLayoutMessages(bool causedByScollbar = false); void drawMessages(QPainter &painter); - void setSelection(const chatterino::SelectionItem &start, const chatterino::SelectionItem &end); - chatterino::MessageElement::Flags getFlags() const; + void setSelection(const SelectionItem &start, const SelectionItem &end); + MessageElement::Flags getFlags() const; bool isPaused(); void handleMouseClick(QMouseEvent *event, - const chatterino::MessageLayoutElement *hoverLayoutElement, - chatterino::MessageLayout *layout); - void addContextMenuItems(const chatterino::MessageLayoutElement *hoveredElement, - chatterino::MessageLayout *layout); + const MessageLayoutElement *hoverLayoutElement, + MessageLayout *layout); + void addContextMenuItems(const MessageLayoutElement *hoveredElement, + MessageLayout *layout); // void beginPause(); // void endPause(); @@ -132,10 +132,10 @@ private: QPointF lastPressPosition_; QPointF lastRightPressPosition_; - chatterino::Selection selection_; + Selection selection_; bool selecting_ = false; - chatterino::LimitedQueue messages; + 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/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index f70e7a552..ef471e15b 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -221,8 +221,8 @@ void NotebookTab::paintEvent(QPaintEvent *) // int fullHeight = (int)(scale * 48); // select the right tab colors - chatterino::ThemeManager::TabColors colors; - chatterino::ThemeManager::TabColors regular = this->themeManager->tabs.regular; + ThemeManager::TabColors colors; + ThemeManager::TabColors regular = this->themeManager->tabs.regular; if (this->selected_) { colors = this->themeManager->tabs.selected; diff --git a/src/widgets/helper/ResizingTextEdit.cpp b/src/widgets/helper/ResizingTextEdit.cpp index 7c10d0e15..07544c72b 100644 --- a/src/widgets/helper/ResizingTextEdit.cpp +++ b/src/widgets/helper/ResizingTextEdit.cpp @@ -94,7 +94,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event) } auto *completionModel = - static_cast(this->completer->model()); + static_cast(this->completer->model()); if (!this->completionInProgress) { // First type pressing tab after modifying a message, we refresh our completion model diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index a2d476f18..865cc0c8e 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++) { - chatterino::MessagePtr message = this->snapshot[i]; + 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 d65d03667..509cc6e56 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: - chatterino::LimitedQueueSnapshot snapshot; + LimitedQueueSnapshot snapshot; QLineEdit *searchInput; ChannelView *channelView; diff --git a/src/widgets/settingspages/AppearancePage.cpp b/src/widgets/settingspages/AppearancePage.cpp index c140df3d0..a434b52a1 100644 --- a/src/widgets/settingspages/AppearancePage.cpp +++ b/src/widgets/settingspages/AppearancePage.cpp @@ -226,7 +226,7 @@ QLayout *AppearancePage::createFontChanger() button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed); QObject::connect(button, &QPushButton::clicked, [=]() { - QFontDialog dialog(app->fonts->getFont(chatterino::FontManager::ChatMedium, 1.)); + QFontDialog dialog(app->fonts->getFont(FontManager::ChatMedium, 1.)); dialog.setWindowFlag(Qt::WindowStaysOnTopHint); @@ -250,10 +250,10 @@ QLayout *AppearancePage::createUiScaleSlider() layout->addWidget(slider); layout->addWidget(label); - slider->setMinimum(chatterino::WindowManager::uiScaleMin); - slider->setMaximum(chatterino::WindowManager::uiScaleMax); + slider->setMinimum(WindowManager::uiScaleMin); + slider->setMaximum(WindowManager::uiScaleMax); slider->setValue( - chatterino::WindowManager::clampUiScale(getApp()->settings->uiScale.getValue())); + 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(chatterino::WindowManager::getUiScaleValue())); + label->setText(QString::number(WindowManager::getUiScaleValue())); }, this->connections_); diff --git a/src/widgets/settingspages/EmotesPage.cpp b/src/widgets/settingspages/EmotesPage.cpp index a1f1c104b..bf2a93bfe 100644 --- a/src/widgets/settingspages/EmotesPage.cpp +++ b/src/widgets/settingspages/EmotesPage.cpp @@ -7,7 +7,7 @@ namespace chatterino { EmotesPage::EmotesPage() : SettingsPage("Emotes", ":/images/emote.svg") { - // chatterino::SettingManager &settings = chatterino::SettingManager::getInstance(); + // SettingManager &settings = SettingManager::getInstance(); // LayoutCreator layoutCreator(this); // auto layout = layoutCreator.emplace().withoutMargin(); diff --git a/src/widgets/settingspages/ModerationPage.cpp b/src/widgets/settingspages/ModerationPage.cpp index 781ef2c12..fed6c185d 100644 --- a/src/widgets/settingspages/ModerationPage.cpp +++ b/src/widgets/settingspages/ModerationPage.cpp @@ -97,25 +97,26 @@ ModerationPage::ModerationPage() // app->settings->timeoutAction)); // } - auto modButtons = - modMode.emplace("Custom moderator buttons").setLayoutType(); - { - auto label2 = - modButtons.emplace("One action per line. {user} will be replaced with the " - "username.
Example `/timeout {user} 120`
"); - label2->setWordWrap(true); + // auto modButtons = + // modMode.emplace("Custom moderator buttons").setLayoutType(); + // { + // auto label2 = + // modButtons.emplace("One action per line. {user} will be replaced with the + // " + // "username.
Example `/timeout {user} 120`
"); + // label2->setWordWrap(true); - auto text = modButtons.emplace().getElement(); + // auto text = modButtons.emplace().getElement(); - text->setPlainText(app->settings->moderationActions); + // text->setPlainText(app->moderationActions->items); - QObject::connect(text, &QTextEdit::textChanged, this, - [this] { this->itemsChangedTimer.start(200); }); + // QObject::connect(text, &QTextEdit::textChanged, this, + // [this] { this->itemsChangedTimer.start(200); }); - QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, this, [text, app]() { - app->settings->moderationActions = text->toPlainText(); - }); - } + // QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, this, [text, app]() { + // app->windows->moderationActions = text->toPlainText(); + // }); + // } /*auto taggedUsers = tabs.appendTab(new QVBoxLayout, "Tagged users"); { diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index 0929d40d2..9c4c69ec0 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -565,7 +565,7 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node) if (type == "split") { auto *split = new Split(this); - split->setChannel(chatterino::WindowManager::decodeChannel(obj.value("data").toObject())); + split->setChannel(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( - chatterino::WindowManager::decodeChannel(_obj.value("data").toObject())); + 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( - chatterino::WindowManager::decodeChannel(obj.value("data").toObject())); + 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 a96b6314d..8b6a31185 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -234,7 +234,7 @@ void SplitHeader::scaleChangedEvent(float scale) this->dropdownButton->setFixedWidth(w); this->moderationButton->setFixedWidth(w); // this->titleLabel->setFont( - // chatterino::FontManager::getInstance().getFont(FontStyle::Medium, scale)); + // FontManager::getInstance().getFont(FontStyle::Medium, scale)); } void SplitHeader::updateChannelText() diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 28f432914..544ac89b7 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -67,19 +67,19 @@ void SplitInput::initLayout() // set edit font this->ui_.textEdit->setFont( - app->fonts->getFont(chatterino::FontManager::Type::ChatMedium, this->getScale())); + app->fonts->getFont(FontManager::Type::ChatMedium, this->getScale())); this->managedConnections_.push_back(app->fonts->fontChanged.connect([=]() { this->ui_.textEdit->setFont( - app->fonts->getFont(chatterino::FontManager::Type::ChatMedium, this->getScale())); + app->fonts->getFont(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 chatterino::Link &link) { - if (link.type == chatterino::Link::InsertText) { + this->emotePopup_->linkClicked.connect([this](const Link &link) { + if (link.type == Link::InsertText) { this->insertText(link.value + " "); } });