From 44f5a15da3a7acbdb23fa7fccecfb4deb57106c7 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sat, 11 Aug 2018 22:23:06 +0200 Subject: [PATCH] turning a lot of includes into forward declares --- src/Application.cpp | 3 + src/Application.hpp | 3 +- src/common/Aliases.hpp | 2 + src/common/Channel.hpp | 4 +- src/common/Common.hpp | 4 +- src/common/CompletionModel.cpp | 1 + src/common/CompletionModel.hpp | 2 - src/common/NetworkCommon.hpp | 3 +- src/common/NetworkManager.hpp | 9 -- src/common/NetworkRequest.cpp | 2 + src/common/NetworkRequest.hpp | 3 +- .../accounts/AccountController.cpp | 2 + .../accounts/AccountController.hpp | 5 +- src/controllers/accounts/AccountModel.cpp | 1 + src/controllers/accounts/AccountModel.hpp | 1 + .../commands/CommandController.cpp | 3 + .../highlights/HighlightController.hpp | 9 +- src/controllers/ignores/IgnoreController.hpp | 5 +- .../moderationactions/ModerationAction.cpp | 1 + .../moderationactions/ModerationAction.hpp | 4 +- src/messages/Emote.hpp | 3 - src/messages/EmoteCache.hpp | 93 ---------------- src/messages/Image.cpp | 1 + src/messages/Image.hpp | 4 +- src/messages/Link.hpp | 1 - src/messages/Message.hpp | 4 +- src/messages/MessageBuilder.cpp | 9 +- src/messages/MessageBuilder.hpp | 8 +- src/messages/MessageColor.cpp | 2 + src/messages/MessageColor.hpp | 3 +- src/messages/MessageElement.cpp | 2 + src/messages/MessageElement.hpp | 10 +- src/messages/layouts/MessageLayout.cpp | 48 +++++---- src/messages/layouts/MessageLayout.hpp | 17 +-- .../layouts/MessageLayoutContainer.cpp | 6 +- .../layouts/MessageLayoutContainer.hpp | 14 +-- src/messages/layouts/MessageLayoutElement.cpp | 2 + src/messages/layouts/MessageLayoutElement.hpp | 6 +- src/providers/bttv/BttvEmotes.cpp | 1 + src/providers/bttv/BttvEmotes.hpp | 2 + src/providers/chatterino/ChatterinoBadges.cpp | 46 ++++---- src/providers/chatterino/ChatterinoBadges.hpp | 12 +-- src/providers/emoji/Emojis.cpp | 1 + src/providers/emoji/Emojis.hpp | 4 +- src/providers/ffz/FfzEmotes.cpp | 1 + src/providers/irc/AbstractIrcServer.cpp | 2 + src/providers/irc/AbstractIrcServer.hpp | 4 +- src/providers/twitch/IrcMessageHandler.cpp | 1 + src/providers/twitch/PartialTwitchUser.cpp | 1 + src/providers/twitch/PubsubHelpers.cpp | 1 + src/providers/twitch/PubsubHelpers.hpp | 4 +- src/providers/twitch/TwitchAccount.cpp | 1 + src/providers/twitch/TwitchAccount.hpp | 1 + src/providers/twitch/TwitchAccountManager.cpp | 1 + src/providers/twitch/TwitchAccountManager.hpp | 1 + src/providers/twitch/TwitchApi.cpp | 1 + src/providers/twitch/TwitchApi.hpp | 1 + src/providers/twitch/TwitchBadges.cpp | 2 + src/providers/twitch/TwitchBadges.hpp | 4 +- src/providers/twitch/TwitchChannel.cpp | 1 + src/providers/twitch/TwitchChannel.hpp | 14 +-- src/providers/twitch/TwitchEmotes.cpp | 1 + src/providers/twitch/TwitchEmotes.hpp | 8 +- src/providers/twitch/TwitchMessageBuilder.cpp | 2 + src/providers/twitch/TwitchMessageBuilder.hpp | 7 +- src/providers/twitch/TwitchServer.cpp | 1 + src/providers/twitch/TwitchServer.hpp | 4 +- src/singletons/Fonts.cpp | 41 +++---- src/singletons/Fonts.hpp | 51 +++++---- src/singletons/Settings.hpp | 1 - src/singletons/Updates.cpp | 1 + src/singletons/WindowManager.cpp | 29 +++-- src/singletons/WindowManager.hpp | 17 ++- src/util/InitUpdateButton.cpp | 5 +- src/util/InitUpdateButton.hpp | 1 - src/widgets/AccountSwitchWidget.cpp | 1 + src/widgets/AttachedWindow.hpp | 8 +- src/widgets/BaseWindow.cpp | 19 ++-- src/widgets/BaseWindow.hpp | 6 +- src/widgets/Notebook.cpp | 20 ++-- src/widgets/Notebook.hpp | 13 +-- src/widgets/Scrollbar.cpp | 12 +-- src/widgets/Scrollbar.hpp | 1 - src/widgets/StreamView.cpp | 1 + src/widgets/TooltipWidget.cpp | 2 +- src/widgets/Window.cpp | 64 +++++------ src/widgets/Window.hpp | 24 ++--- src/widgets/dialogs/EmotePopup.cpp | 3 + src/widgets/dialogs/EmotePopup.hpp | 7 +- src/widgets/dialogs/LoginDialog.cpp | 1 + src/widgets/dialogs/LogsPopup.cpp | 2 + src/widgets/dialogs/LogsPopup.hpp | 9 +- src/widgets/dialogs/NotificationPopup.cpp | 2 + src/widgets/dialogs/NotificationPopup.hpp | 8 +- src/widgets/dialogs/SelectChannelDialog.cpp | 2 + src/widgets/dialogs/SelectChannelDialog.hpp | 6 +- src/widgets/dialogs/UserInfoPopup.cpp | 1 + src/widgets/dialogs/UserInfoPopup.hpp | 3 +- src/widgets/helper/ChannelView.cpp | 89 ++++++++------- src/widgets/helper/ChannelView.hpp | 27 +++-- src/widgets/helper/NotebookButton.cpp | 1 + src/widgets/helper/NotebookTab.cpp | 2 + src/widgets/helper/ScrollbarHighlight.hpp | 2 - src/widgets/helper/SearchPopup.cpp | 1 + src/widgets/helper/SearchPopup.hpp | 4 +- src/widgets/helper/TitlebarButton.cpp | 16 +-- src/widgets/helper/TitlebarButton.hpp | 26 ++--- src/widgets/settingspages/IgnoresPage.cpp | 1 + src/widgets/settingspages/LookPage.cpp | 6 +- src/widgets/splits/Split.cpp | 102 +++++++++--------- src/widgets/splits/Split.hpp | 21 ++-- src/widgets/splits/SplitContainer.cpp | 1 + src/widgets/splits/SplitContainer.hpp | 11 +- src/widgets/splits/SplitHeader.cpp | 3 + src/widgets/splits/SplitInput.cpp | 14 ++- src/widgets/splits/SplitInput.hpp | 8 +- src/widgets/splits/SplitOverlay.cpp | 1 + 117 files changed, 591 insertions(+), 536 deletions(-) delete mode 100644 src/messages/EmoteCache.hpp diff --git a/src/Application.cpp b/src/Application.cpp index 85b4f382c..22ae0c34b 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -6,11 +6,13 @@ #include "controllers/ignores/IgnoreController.hpp" #include "controllers/moderationactions/ModerationActions.hpp" #include "controllers/taggedusers/TaggedUsersController.hpp" +#include "debug/Log.hpp" #include "messages/MessageBuilder.hpp" #include "providers/bttv/BttvEmotes.hpp" #include "providers/ffz/FfzEmotes.hpp" #include "providers/twitch/PubsubClient.hpp" #include "providers/twitch/TwitchServer.hpp" +#include "singletons/Emotes.hpp" #include "singletons/Fonts.hpp" #include "singletons/Logging.hpp" #include "singletons/NativeMessaging.hpp" @@ -21,6 +23,7 @@ #include "singletons/WindowManager.hpp" #include "util/IsBigEndian.hpp" #include "util/PostToThread.hpp" +#include "widgets/Window.hpp" #include diff --git a/src/Application.hpp b/src/Application.hpp index 2a62503bf..e32f29bdd 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -1,7 +1,6 @@ #pragma once #include "common/Singleton.hpp" -#include "singletons/Resources.hpp" #include #include @@ -26,7 +25,7 @@ class AccountManager; class Emotes; class Settings; class Fonts; -class Resources; +class Resources2; class Application { diff --git a/src/common/Aliases.hpp b/src/common/Aliases.hpp index 8a61a9639..2dea876b7 100644 --- a/src/common/Aliases.hpp +++ b/src/common/Aliases.hpp @@ -32,3 +32,5 @@ QStringAlias(UserName); QStringAlias(UserId); QStringAlias(Url); QStringAlias(Tooltip); +QStringAlias(EmoteId); +QStringAlias(EmoteName); diff --git a/src/common/Channel.hpp b/src/common/Channel.hpp index cb93c1694..c1dd06651 100644 --- a/src/common/Channel.hpp +++ b/src/common/Channel.hpp @@ -1,9 +1,7 @@ #pragma once #include "common/CompletionModel.hpp" -#include "messages/Image.hpp" #include "messages/LimitedQueue.hpp" -#include "messages/Message.hpp" #include #include @@ -12,7 +10,9 @@ #include namespace chatterino { + struct Message; +using MessagePtr = std::shared_ptr; class Channel : public std::enable_shared_from_this { diff --git a/src/common/Common.hpp b/src/common/Common.hpp index 251727c24..46de4a7cb 100644 --- a/src/common/Common.hpp +++ b/src/common/Common.hpp @@ -3,7 +3,6 @@ #include "common/Aliases.hpp" #include "common/Outcome.hpp" #include "common/ProviderId.hpp" -#include "debug/Log.hpp" #include #include @@ -39,4 +38,7 @@ std::weak_ptr weakOf(T *element) return element->shared_from_this(); } +struct Message; +using MessagePtr = std::shared_ptr; + } // namespace chatterino diff --git a/src/common/CompletionModel.cpp b/src/common/CompletionModel.cpp index 9e2f4d024..04425a624 100644 --- a/src/common/CompletionModel.cpp +++ b/src/common/CompletionModel.cpp @@ -5,6 +5,7 @@ #include "controllers/accounts/AccountController.hpp" #include "controllers/commands/CommandController.hpp" #include "debug/Log.hpp" +#include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchServer.hpp" #include "singletons/Emotes.hpp" diff --git a/src/common/CompletionModel.hpp b/src/common/CompletionModel.hpp index d9baac7b3..977768474 100644 --- a/src/common/CompletionModel.hpp +++ b/src/common/CompletionModel.hpp @@ -1,7 +1,5 @@ #pragma once -#include "common/Common.hpp" - #include #include diff --git a/src/common/NetworkCommon.hpp b/src/common/NetworkCommon.hpp index 30d1e9267..b214f5472 100644 --- a/src/common/NetworkCommon.hpp +++ b/src/common/NetworkCommon.hpp @@ -2,12 +2,11 @@ #include -#include "Common.hpp" - class QNetworkReply; namespace chatterino { +class Outcome; class NetworkResult; using NetworkSuccessCallback = std::function; diff --git a/src/common/NetworkManager.hpp b/src/common/NetworkManager.hpp index 12c0c6a51..530aaae1f 100644 --- a/src/common/NetworkManager.hpp +++ b/src/common/NetworkManager.hpp @@ -1,16 +1,7 @@ #pragma once -#include "common/NetworkRequester.hpp" -#include "common/NetworkWorker.hpp" -#include "debug/Log.hpp" - -#include -#include #include -#include #include -#include -#include namespace chatterino { diff --git a/src/common/NetworkRequest.cpp b/src/common/NetworkRequest.cpp index f54192190..0a2e45533 100644 --- a/src/common/NetworkRequest.cpp +++ b/src/common/NetworkRequest.cpp @@ -1,7 +1,9 @@ #include "common/NetworkRequest.hpp" #include "Application.hpp" +#include "common/NetworkData.hpp" #include "common/NetworkManager.hpp" +#include "common/Outcome.hpp" #include "debug/Log.hpp" #include "providers/twitch/TwitchCommon.hpp" #include "singletons/Paths.hpp" diff --git a/src/common/NetworkRequest.hpp b/src/common/NetworkRequest.hpp index 09b2cccee..f1940621d 100644 --- a/src/common/NetworkRequest.hpp +++ b/src/common/NetworkRequest.hpp @@ -1,14 +1,13 @@ #pragma once -#include "Application.hpp" #include "common/NetworkCommon.hpp" -#include "common/NetworkData.hpp" #include "common/NetworkRequester.hpp" #include "common/NetworkResult.hpp" #include "common/NetworkTimer.hpp" #include "common/NetworkWorker.hpp" namespace chatterino { +class NetworkData; class NetworkRequest { diff --git a/src/controllers/accounts/AccountController.cpp b/src/controllers/accounts/AccountController.cpp index 6cd1f2558..7d2c84266 100644 --- a/src/controllers/accounts/AccountController.cpp +++ b/src/controllers/accounts/AccountController.cpp @@ -1,6 +1,8 @@ #include "AccountController.hpp" +#include "controllers/accounts/Account.hpp" #include "controllers/accounts/AccountModel.hpp" +#include "providers/twitch/TwitchAccount.hpp" namespace chatterino { diff --git a/src/controllers/accounts/AccountController.hpp b/src/controllers/accounts/AccountController.hpp index 023ad9c9e..b47ec86be 100644 --- a/src/controllers/accounts/AccountController.hpp +++ b/src/controllers/accounts/AccountController.hpp @@ -1,16 +1,15 @@ #pragma once -#include "common/Singleton.hpp" - #include #include "common/SignalVector.hpp" -#include "controllers/accounts/Account.hpp" +#include "common/Singleton.hpp" #include "providers/twitch/TwitchAccountManager.hpp" #include "util/SharedPtrElementLess.hpp" namespace chatterino { +class Account; class Settings; class Paths; diff --git a/src/controllers/accounts/AccountModel.cpp b/src/controllers/accounts/AccountModel.cpp index d63f2c288..23ded2881 100644 --- a/src/controllers/accounts/AccountModel.cpp +++ b/src/controllers/accounts/AccountModel.cpp @@ -1,5 +1,6 @@ #include "AccountModel.hpp" +#include "controllers/accounts/Account.hpp" #include "util/StandardItemHelper.hpp" namespace chatterino { diff --git a/src/controllers/accounts/AccountModel.hpp b/src/controllers/accounts/AccountModel.hpp index c0b4538d5..a8b020410 100644 --- a/src/controllers/accounts/AccountModel.hpp +++ b/src/controllers/accounts/AccountModel.hpp @@ -8,6 +8,7 @@ namespace chatterino { +class Account; class AccountController; class AccountModel : public SignalVectorModel> diff --git a/src/controllers/commands/CommandController.cpp b/src/controllers/commands/CommandController.cpp index 3aaefca8b..f931aa073 100644 --- a/src/controllers/commands/CommandController.cpp +++ b/src/controllers/commands/CommandController.cpp @@ -5,7 +5,10 @@ #include "controllers/accounts/AccountController.hpp" #include "controllers/commands/Command.hpp" #include "controllers/commands/CommandModel.hpp" +#include "debug/Log.hpp" +#include "messages/Message.hpp" #include "messages/MessageBuilder.hpp" +#include "messages/MessageElement.hpp" #include "providers/twitch/TwitchApi.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchServer.hpp" diff --git a/src/controllers/highlights/HighlightController.hpp b/src/controllers/highlights/HighlightController.hpp index 09d686cb2..963f23aaa 100644 --- a/src/controllers/highlights/HighlightController.hpp +++ b/src/controllers/highlights/HighlightController.hpp @@ -1,15 +1,16 @@ #pragma once -#include "common/Singleton.hpp" - +#include "common/ChatterinoSetting.hpp" #include "common/SignalVector.hpp" +#include "common/Singleton.hpp" #include "controllers/highlights/HighlightBlacklistUser.hpp" #include "controllers/highlights/HighlightPhrase.hpp" -#include "messages/Message.hpp" -#include "singletons/Settings.hpp" namespace chatterino { +struct Message; +using MessagePtr = std::shared_ptr; + class Settings; class Paths; diff --git a/src/controllers/ignores/IgnoreController.hpp b/src/controllers/ignores/IgnoreController.hpp index e7a0472e6..10c83ac10 100644 --- a/src/controllers/ignores/IgnoreController.hpp +++ b/src/controllers/ignores/IgnoreController.hpp @@ -1,10 +1,9 @@ #pragma once -#include "common/Singleton.hpp" - +#include "common/ChatterinoSetting.hpp" #include "common/SignalVector.hpp" +#include "common/Singleton.hpp" #include "controllers/ignores/IgnorePhrase.hpp" -#include "singletons/Settings.hpp" namespace chatterino { diff --git a/src/controllers/moderationactions/ModerationAction.cpp b/src/controllers/moderationactions/ModerationAction.cpp index 49d302b34..cc2b8463e 100644 --- a/src/controllers/moderationactions/ModerationAction.cpp +++ b/src/controllers/moderationactions/ModerationAction.cpp @@ -2,6 +2,7 @@ #include #include "Application.hpp" +#include "messages/Image.hpp" #include "singletons/Resources.hpp" namespace chatterino { diff --git a/src/controllers/moderationactions/ModerationAction.hpp b/src/controllers/moderationactions/ModerationAction.hpp index f509f79c5..6a36157df 100644 --- a/src/controllers/moderationactions/ModerationAction.hpp +++ b/src/controllers/moderationactions/ModerationAction.hpp @@ -4,11 +4,13 @@ #include #include -#include "messages/Image.hpp" #include "util/RapidjsonHelpers.hpp" namespace chatterino { +class Image; +using ImagePtr = std::shared_ptr; + class ModerationAction { public: diff --git a/src/messages/Emote.hpp b/src/messages/Emote.hpp index 89cadc623..143d3ea64 100644 --- a/src/messages/Emote.hpp +++ b/src/messages/Emote.hpp @@ -7,9 +7,6 @@ #include #include -QStringAlias(EmoteId); -QStringAlias(EmoteName); - namespace chatterino { struct Emote { diff --git a/src/messages/EmoteCache.hpp b/src/messages/EmoteCache.hpp deleted file mode 100644 index 1bbb01fd4..000000000 --- a/src/messages/EmoteCache.hpp +++ /dev/null @@ -1,93 +0,0 @@ -#pragma once - -#include -#include -#include -#include - -#include "common/UniqueAccess.hpp" -#include "messages/Emote.hpp" - -namespace chatterino { - -template -class MapReplacement -{ -public: - MapReplacement(std::unordered_map &items) - : oldItems_(items) - { - } - - void add(const TKey &key, const Emote &data) - { - this->add(key, Emote(data)); - } - - void add(const TKey &key, Emote &&data) - { - auto it = this->oldItems_.find(key); - if (it != this->oldItems_.end() && *it->second == data) { - this->newItems_[key] = it->second; - } else { - this->newItems_[key] = std::make_shared(std::move(data)); - } - } - - void apply() - { - this->oldItems_ = std::move(this->newItems_); - } - -private: - std::unordered_map &oldItems_; - std::unordered_map newItems_; -}; - -template -class EmoteCache -{ -public: - using Iterator = typename std::unordered_map::iterator; - using ConstIterator = typename std::unordered_map::iterator; - - Iterator begin() - { - return this->items_.begin(); - } - - ConstIterator begin() const - { - return this->items_.begin(); - } - - Iterator end() - { - return this->items_.end(); - } - - ConstIterator end() const - { - return this->items_.end(); - } - - boost::optional get(const TKey &key) const - { - auto it = this->items_.find(key); - - if (it == this->items_.end()) - return boost::none; - else - return it->second; - } - - MapReplacement makeReplacment() - { - return MapReplacement(this->items_); - } - -private: - std::unordered_map items_; -}; - -} // namespace chatterino diff --git a/src/messages/Image.cpp b/src/messages/Image.cpp index 572432cdd..b48234536 100644 --- a/src/messages/Image.cpp +++ b/src/messages/Image.cpp @@ -1,6 +1,7 @@ #include "messages/Image.hpp" #include "Application.hpp" +#include "common/Common.hpp" #include "common/NetworkRequest.hpp" #include "debug/AssertInGuiThread.hpp" #include "debug/Benchmark.hpp" diff --git a/src/messages/Image.hpp b/src/messages/Image.hpp index 3d869f798..68b96392b 100644 --- a/src/messages/Image.hpp +++ b/src/messages/Image.hpp @@ -1,18 +1,18 @@ #pragma once -#include "common/Common.hpp" - #include #include #include #include #include #include +#include #include #include #include #include +#include "common/Aliases.hpp" #include "common/NullablePtr.hpp" namespace chatterino { diff --git a/src/messages/Link.hpp b/src/messages/Link.hpp index a6c503540..a07d21cf3 100644 --- a/src/messages/Link.hpp +++ b/src/messages/Link.hpp @@ -1,7 +1,6 @@ #pragma once #include -#include namespace chatterino { diff --git a/src/messages/Message.hpp b/src/messages/Message.hpp index 76039ec41..7aacc47e5 100644 --- a/src/messages/Message.hpp +++ b/src/messages/Message.hpp @@ -1,16 +1,16 @@ #pragma once #include "common/FlagsEnum.hpp" -#include "messages/MessageElement.hpp" -#include "providers/twitch/PubsubActions.hpp" #include "widgets/helper/ScrollbarHighlight.hpp" #include +#include #include #include #include namespace chatterino { +class MessageElement; enum class MessageFlag : uint16_t { None = 0, diff --git a/src/messages/MessageBuilder.cpp b/src/messages/MessageBuilder.cpp index f4ebd2301..49c96c946 100644 --- a/src/messages/MessageBuilder.cpp +++ b/src/messages/MessageBuilder.cpp @@ -1,6 +1,9 @@ #include "MessageBuilder.hpp" #include "common/LinkParser.hpp" +#include "messages/Message.hpp" +#include "messages/MessageElement.hpp" +#include "providers/twitch/PubsubActions.hpp" #include "singletons/Emotes.hpp" #include "singletons/Resources.hpp" #include "singletons/Theme.hpp" @@ -17,7 +20,7 @@ MessagePtr makeSystemMessage(const QString &text) } MessageBuilder::MessageBuilder() - : message_(std::make_unique()) + : message_(std::make_shared()) { } @@ -165,7 +168,9 @@ Message &MessageBuilder::message() MessagePtr MessageBuilder::release() { - return MessagePtr(this->message_.release()); + std::shared_ptr ptr; + this->message_.swap(ptr); + return ptr; } void MessageBuilder::append(std::unique_ptr element) diff --git a/src/messages/MessageBuilder.hpp b/src/messages/MessageBuilder.hpp index a2e78ec29..d3cbdb8d0 100644 --- a/src/messages/MessageBuilder.hpp +++ b/src/messages/MessageBuilder.hpp @@ -1,11 +1,15 @@ #pragma once -#include "messages/Message.hpp" +#include "messages/MessageElement.hpp" #include #include namespace chatterino { +struct BanAction; +struct UnbanAction; +struct Message; +using MessagePtr = std::shared_ptr; struct SystemMessageTag { }; @@ -56,7 +60,7 @@ public: } private: - std::unique_ptr message_; + std::shared_ptr message_; }; } // namespace chatterino diff --git a/src/messages/MessageColor.cpp b/src/messages/MessageColor.cpp index f22654b51..fe793b30e 100644 --- a/src/messages/MessageColor.cpp +++ b/src/messages/MessageColor.cpp @@ -1,5 +1,7 @@ #include "MessageColor.hpp" +#include "singletons/Theme.hpp" + namespace chatterino { MessageColor::MessageColor(const QColor &color) diff --git a/src/messages/MessageColor.hpp b/src/messages/MessageColor.hpp index e7d828745..dd19692c9 100644 --- a/src/messages/MessageColor.hpp +++ b/src/messages/MessageColor.hpp @@ -1,10 +1,9 @@ #pragma once -#include "singletons/Theme.hpp" - #include namespace chatterino { +class Theme; struct MessageColor { enum Type { Custom, Text, Link, System }; diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index e31076107..24b526c29 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -3,9 +3,11 @@ #include "Application.hpp" #include "controllers/moderationactions/ModerationActions.hpp" #include "debug/Benchmark.hpp" +#include "messages/Emote.hpp" #include "messages/layouts/MessageLayoutContainer.hpp" #include "messages/layouts/MessageLayoutElement.hpp" #include "singletons/Settings.hpp" +#include "singletons/Theme.hpp" #include "util/DebugCount.hpp" namespace chatterino { diff --git a/src/messages/MessageElement.hpp b/src/messages/MessageElement.hpp index 79f222789..8d96d1135 100644 --- a/src/messages/MessageElement.hpp +++ b/src/messages/MessageElement.hpp @@ -1,8 +1,6 @@ #pragma once #include "common/FlagsEnum.hpp" -#include "messages/Emote.hpp" -#include "messages/Image.hpp" #include "messages/Link.hpp" #include "messages/MessageColor.hpp" #include "singletons/Fonts.hpp" @@ -11,14 +9,20 @@ #include #include #include - #include #include +#include namespace chatterino { class Channel; struct MessageLayoutContainer; +class Image; +using ImagePtr = std::shared_ptr; + +struct Emote; +using EmotePtr = std::shared_ptr; + enum class MessageElementFlag { None = 0, Misc = (1 << 0), diff --git a/src/messages/layouts/MessageLayout.cpp b/src/messages/layouts/MessageLayout.cpp index 9847c1950..c077ac4fb 100644 --- a/src/messages/layouts/MessageLayout.cpp +++ b/src/messages/layouts/MessageLayout.cpp @@ -2,8 +2,12 @@ #include "Application.hpp" #include "debug/Benchmark.hpp" +#include "messages/Message.hpp" +#include "messages/MessageElement.hpp" +#include "messages/layouts/MessageLayoutContainer.hpp" #include "singletons/Emotes.hpp" #include "singletons/Settings.hpp" +#include "singletons/Theme.hpp" #include "singletons/WindowManager.hpp" #include "util/DebugCount.hpp" @@ -24,6 +28,7 @@ namespace chatterino { MessageLayout::MessageLayout(MessagePtr message) : message_(message) , buffer_(nullptr) + , container_(std::make_shared()) { DebugCount::increase("message layout"); } @@ -41,7 +46,7 @@ const Message *MessageLayout::getMessage() // Height int MessageLayout::getHeight() const { - return container_.getHeight(); + return container_->getHeight(); } // Layout @@ -82,9 +87,9 @@ bool MessageLayout::layout(int width, float scale, MessageElementFlags flags) return false; } - int oldHeight = this->container_.getHeight(); + int oldHeight = this->container_->getHeight(); this->actuallyLayout(width, flags); - if (widthChanged || this->container_.getHeight() != oldHeight) { + if (widthChanged || this->container_->getHeight() != oldHeight) { this->deleteBuffer(); } this->invalidateBuffer(); @@ -103,22 +108,22 @@ void MessageLayout::actuallyLayout(int width, MessageElementFlags _flags) messageFlags.unset(MessageFlag::Collapsed); } - this->container_.begin(width, this->scale_, messageFlags); + this->container_->begin(width, this->scale_, messageFlags); for (const auto &element : this->message_->elements) { - element->addToContainer(this->container_, _flags); + element->addToContainer(*this->container_, _flags); } - if (this->height_ != this->container_.getHeight()) { + if (this->height_ != this->container_->getHeight()) { this->deleteBuffer(); } - this->container_.end(); - this->height_ = this->container_.getHeight(); + this->container_->end(); + this->height_ = this->container_->getHeight(); // collapsed state this->flags.unset(MessageLayoutFlag::Collapsed); - if (this->container_.isCollapsed()) { + if (this->container_->isCollapsed()) { this->flags.set(MessageLayoutFlag::Collapsed); } } @@ -135,11 +140,12 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex, if (!pixmap) { #ifdef Q_OS_MACOS pixmap = new QPixmap(int(width * painter.device()->devicePixelRatioF()), - int(container_.getHeight() * + int(container_->getHeight() * painter.device()->devicePixelRatioF())); pixmap->setDevicePixelRatio(painter.device()->devicePixelRatioF()); #else - pixmap = new QPixmap(width, std::max(16, this->container_.getHeight())); + pixmap = + new QPixmap(width, std::max(16, this->container_->getHeight())); #endif this->buffer_ = std::shared_ptr(pixmap); @@ -157,7 +163,7 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex, // this->container.getHeight(), *pixmap); // draw gif emotes - this->container_.paintAnimatedElements(painter, y); + this->container_->paintAnimatedElements(painter, y); // draw disabled if (this->message_->flags.has(MessageFlag::Disabled)) { @@ -167,12 +173,12 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex, // draw selection if (!selection.isEmpty()) { - this->container_.paintSelection(painter, messageIndex, selection, y); + this->container_->paintSelection(painter, messageIndex, selection, y); } // draw message seperation line if (app->settings->separateMessages.getValue()) { - painter.fillRect(0, y, this->container_.getWidth(), 1, + painter.fillRect(0, y, this->container_->getWidth(), 1, app->themes->splits.messageSeperator); } @@ -186,7 +192,7 @@ void MessageLayout::paint(QPainter &painter, int width, int y, int messageIndex, QBrush brush(color, static_cast( app->settings->lastMessagePattern.getValue())); - painter.fillRect(0, y + this->container_.getHeight() - 1, + painter.fillRect(0, y + this->container_->getHeight() - 1, pixmap->width(), 1, brush); } @@ -217,7 +223,7 @@ void MessageLayout::updateBuffer(QPixmap *buffer, int /*messageIndex*/, painter.fillRect(buffer->rect(), backgroundColor); // draw message - this->container_.paintElements(painter); + this->container_->paintElements(painter); #ifdef FOURTF // debug @@ -252,7 +258,7 @@ void MessageLayout::deleteCache() this->deleteBuffer(); #ifdef XD - this->container_.clear(); + this->container_->clear(); #endif } @@ -265,22 +271,22 @@ void MessageLayout::deleteCache() const MessageLayoutElement *MessageLayout::getElementAt(QPoint point) { // go through all words and return the first one that contains the point. - return this->container_.getElementAt(point); + return this->container_->getElementAt(point); } int MessageLayout::getLastCharacterIndex() const { - return this->container_.getLastCharacterIndex(); + return this->container_->getLastCharacterIndex(); } int MessageLayout::getSelectionIndex(QPoint position) { - return this->container_.getSelectionIndex(position); + return this->container_->getSelectionIndex(position); } void MessageLayout::addSelectionText(QString &str, int from, int to) { - this->container_.addSelectionText(str, from, to); + this->container_->addSelectionText(str, from, to); } } // namespace chatterino diff --git a/src/messages/layouts/MessageLayout.hpp b/src/messages/layouts/MessageLayout.hpp index 0f0d5cab3..2ab015856 100644 --- a/src/messages/layouts/MessageLayout.hpp +++ b/src/messages/layouts/MessageLayout.hpp @@ -1,19 +1,24 @@ #pragma once #include "common/FlagsEnum.hpp" -#include "messages/Message.hpp" -#include "messages/Selection.hpp" -#include "messages/layouts/MessageLayoutContainer.hpp" -#include "messages/layouts/MessageLayoutElement.hpp" #include - #include #include #include namespace chatterino { +struct Message; +using MessagePtr = std::shared_ptr; + +struct Selection; +struct MessageLayoutContainer; +class MessageLayoutElement; + +enum class MessageElementFlag; +using MessageElementFlags = FlagsEnum; + enum class MessageLayoutFlag : uint8_t { RequiresBufferUpdate = 1 << 1, RequiresLayout = 1 << 2, @@ -57,7 +62,7 @@ public: private: // variables MessagePtr message_; - MessageLayoutContainer container_; + std::shared_ptr container_; std::shared_ptr buffer_ = nullptr; bool bufferValid_ = false; diff --git a/src/messages/layouts/MessageLayoutContainer.cpp b/src/messages/layouts/MessageLayoutContainer.cpp index 699cfc604..2092524c9 100644 --- a/src/messages/layouts/MessageLayoutContainer.cpp +++ b/src/messages/layouts/MessageLayoutContainer.cpp @@ -1,9 +1,13 @@ #include "MessageLayoutContainer.hpp" #include "Application.hpp" -#include "MessageLayoutElement.hpp" +#include "messages/Message.hpp" +#include "messages/MessageElement.hpp" #include "messages/Selection.hpp" +#include "messages/layouts/MessageLayoutElement.hpp" +#include "singletons/Fonts.hpp" #include "singletons/Settings.hpp" +#include "singletons/Theme.hpp" #include #include diff --git a/src/messages/layouts/MessageLayoutContainer.hpp b/src/messages/layouts/MessageLayoutContainer.hpp index f52f181e6..cab849ed0 100644 --- a/src/messages/layouts/MessageLayoutContainer.hpp +++ b/src/messages/layouts/MessageLayoutContainer.hpp @@ -1,18 +1,20 @@ #pragma once -#include -#include - #include #include +#include +#include -#include "messages/Message.hpp" +#include "common/FlagsEnum.hpp" #include "messages/Selection.hpp" +#include "messages/layouts/MessageLayoutElement.hpp" class QPainter; namespace chatterino { -class MessageLayoutElement; + +enum class MessageFlag : uint16_t; +using MessageFlags = FlagsEnum; struct Margin { int top; @@ -92,7 +94,7 @@ private: // variables float scale_ = 1.f; int width_ = 0; - MessageFlags flags_ = MessageFlag::None; + MessageFlags flags_{}; int line_ = 0; int height_ = 0; int currentX_ = 0; diff --git a/src/messages/layouts/MessageLayoutElement.cpp b/src/messages/layouts/MessageLayoutElement.cpp index e8d333e2b..385451141 100644 --- a/src/messages/layouts/MessageLayoutElement.cpp +++ b/src/messages/layouts/MessageLayoutElement.cpp @@ -1,7 +1,9 @@ #include "messages/layouts/MessageLayoutElement.hpp" #include "Application.hpp" +#include "messages/Image.hpp" #include "messages/MessageElement.hpp" +#include "singletons/Theme.hpp" #include "util/DebugCount.hpp" #include diff --git a/src/messages/layouts/MessageLayoutElement.hpp b/src/messages/layouts/MessageLayoutElement.hpp index 44b4c9316..7167adaa9 100644 --- a/src/messages/layouts/MessageLayoutElement.hpp +++ b/src/messages/layouts/MessageLayoutElement.hpp @@ -3,19 +3,19 @@ #include #include #include - #include #include -#include "messages/Image.hpp" #include "messages/Link.hpp" #include "messages/MessageColor.hpp" -#include "singletons/Fonts.hpp" class QPainter; namespace chatterino { class MessageElement; +class Image; +using ImagePtr = std::shared_ptr; +enum class FontStyle : uint8_t; class MessageLayoutElement : boost::noncopyable { diff --git a/src/providers/bttv/BttvEmotes.cpp b/src/providers/bttv/BttvEmotes.cpp index 1d9115c09..70c7cdbdb 100644 --- a/src/providers/bttv/BttvEmotes.cpp +++ b/src/providers/bttv/BttvEmotes.cpp @@ -1,5 +1,6 @@ #include "providers/bttv/BttvEmotes.hpp" +#include "common/Common.hpp" #include "common/NetworkRequest.hpp" #include "debug/Log.hpp" #include "messages/Image.hpp" diff --git a/src/providers/bttv/BttvEmotes.hpp b/src/providers/bttv/BttvEmotes.hpp index 7392cd6bc..ff4809411 100644 --- a/src/providers/bttv/BttvEmotes.hpp +++ b/src/providers/bttv/BttvEmotes.hpp @@ -1,6 +1,8 @@ #pragma once +#include #include + #include "common/Atomic.hpp" #include "messages/Emote.hpp" diff --git a/src/providers/chatterino/ChatterinoBadges.cpp b/src/providers/chatterino/ChatterinoBadges.cpp index 98b1841d4..37dc8f6f0 100644 --- a/src/providers/chatterino/ChatterinoBadges.cpp +++ b/src/providers/chatterino/ChatterinoBadges.cpp @@ -14,39 +14,41 @@ ChatterinoBadges::ChatterinoBadges() boost::optional ChatterinoBadges::getBadge(const UserName &username) { - return this->badges.access()->get(username); + return boost::none; + // return this->badges.access()->get(username); } void ChatterinoBadges::loadChatterinoBadges() { - static QString url("https://fourtf.com/chatterino/badges.json"); + // static QString url("https://fourtf.com/chatterino/badges.json"); - NetworkRequest req(url); - req.setCaller(QThread::currentThread()); + // NetworkRequest req(url); + // req.setCaller(QThread::currentThread()); - req.onSuccess([this](auto result) { - auto jsonRoot = result.parseJson(); - auto badges = this->badges.access(); - auto replacement = badges->makeReplacment(); + // req.onSuccess([this](auto result) { + // auto jsonRoot = result.parseJson(); + // auto badges = this->badges.access(); + // auto replacement = badges->makeReplacment(); - for (auto jsonBadge_ : jsonRoot.value("badges").toArray()) { - auto jsonBadge = jsonBadge_.toObject(); + // for (auto jsonBadge_ : jsonRoot.value("badges").toArray()) { + // auto jsonBadge = jsonBadge_.toObject(); - auto emote = Emote{ - EmoteName{}, ImageSet{Url{jsonBadge.value("image").toString()}}, - Tooltip{jsonBadge.value("tooltip").toString()}, Url{}}; + // auto emote = Emote{ + // EmoteName{}, + // ImageSet{Url{jsonBadge.value("image").toString()}}, + // Tooltip{jsonBadge.value("tooltip").toString()}, Url{}}; - for (auto jsonUser : jsonBadge.value("users").toArray()) { - replacement.add(UserName{jsonUser.toString()}, - std::move(emote)); - } - } + // for (auto jsonUser : jsonBadge.value("users").toArray()) { + // replacement.add(UserName{jsonUser.toString()}, + // std::move(emote)); + // } + // } - replacement.apply(); - return Success; - }); + // replacement.apply(); + // return Success; + //}); - req.execute(); + // req.execute(); } } // namespace chatterino diff --git a/src/providers/chatterino/ChatterinoBadges.hpp b/src/providers/chatterino/ChatterinoBadges.hpp index 3162c75b1..89870fd16 100644 --- a/src/providers/chatterino/ChatterinoBadges.hpp +++ b/src/providers/chatterino/ChatterinoBadges.hpp @@ -1,14 +1,14 @@ #pragma once #include -#include -#include "common/Common.hpp" -#include "common/UniqueAccess.hpp" -#include "messages/Emote.hpp" -#include "messages/EmoteCache.hpp" + +#include "common/Aliases.hpp" namespace chatterino { +struct Emote; +using EmotePtr = std::shared_ptr; + class ChatterinoBadges { public: @@ -19,7 +19,7 @@ public: private: void loadChatterinoBadges(); - UniqueAccess> badges; + // UniqueAccess> badges; }; } // namespace chatterino diff --git a/src/providers/emoji/Emojis.cpp b/src/providers/emoji/Emojis.cpp index 06d4e798b..d0403e75c 100644 --- a/src/providers/emoji/Emojis.cpp +++ b/src/providers/emoji/Emojis.cpp @@ -2,6 +2,7 @@ #include "Application.hpp" #include "debug/Log.hpp" +#include "messages/Emote.hpp" #include "singletons/Settings.hpp" #include diff --git a/src/providers/emoji/Emojis.hpp b/src/providers/emoji/Emojis.hpp index 18bd33522..62443b9aa 100644 --- a/src/providers/emoji/Emojis.hpp +++ b/src/providers/emoji/Emojis.hpp @@ -1,6 +1,5 @@ #pragma once -#include "messages/Emote.hpp" #include "util/ConcurrentMap.hpp" #include @@ -12,6 +11,9 @@ namespace chatterino { +struct Emote; +using EmotePtr = std::shared_ptr; + struct EmojiData { // actual byte-representation of the emoji (i.e. \154075\156150 which is // :male:) diff --git a/src/providers/ffz/FfzEmotes.cpp b/src/providers/ffz/FfzEmotes.cpp index 24341a817..c22fe91fe 100644 --- a/src/providers/ffz/FfzEmotes.cpp +++ b/src/providers/ffz/FfzEmotes.cpp @@ -3,6 +3,7 @@ #include #include "common/NetworkRequest.hpp" +#include "common/Outcome.hpp" #include "debug/Log.hpp" #include "messages/Image.hpp" diff --git a/src/providers/irc/AbstractIrcServer.cpp b/src/providers/irc/AbstractIrcServer.cpp index b7995282f..25c810a4d 100644 --- a/src/providers/irc/AbstractIrcServer.cpp +++ b/src/providers/irc/AbstractIrcServer.cpp @@ -1,6 +1,8 @@ #include "AbstractIrcServer.hpp" +#include "common/Channel.hpp" #include "common/Common.hpp" +#include "debug/Log.hpp" #include "messages/LimitedQueueSnapshot.hpp" #include "messages/Message.hpp" #include "messages/MessageBuilder.hpp" diff --git a/src/providers/irc/AbstractIrcServer.hpp b/src/providers/irc/AbstractIrcServer.hpp index 580cdd0fe..109f869ef 100644 --- a/src/providers/irc/AbstractIrcServer.hpp +++ b/src/providers/irc/AbstractIrcServer.hpp @@ -1,6 +1,5 @@ #pragma once -#include "common/Channel.hpp" #include "providers/irc/IrcConnection2.hpp" #include @@ -11,6 +10,9 @@ namespace chatterino { +class Channel; +using ChannelPtr = std::shared_ptr; + class AbstractIrcServer { public: diff --git a/src/providers/twitch/IrcMessageHandler.cpp b/src/providers/twitch/IrcMessageHandler.cpp index 35c7c51d9..1679884b8 100644 --- a/src/providers/twitch/IrcMessageHandler.cpp +++ b/src/providers/twitch/IrcMessageHandler.cpp @@ -10,6 +10,7 @@ #include "providers/twitch/TwitchMessageBuilder.hpp" #include "providers/twitch/TwitchServer.hpp" #include "singletons/Resources.hpp" +#include "singletons/Settings.hpp" #include "singletons/WindowManager.hpp" #include "util/IrcHelpers.hpp" diff --git a/src/providers/twitch/PartialTwitchUser.cpp b/src/providers/twitch/PartialTwitchUser.cpp index c3d9e5102..6aca624b1 100644 --- a/src/providers/twitch/PartialTwitchUser.cpp +++ b/src/providers/twitch/PartialTwitchUser.cpp @@ -1,5 +1,6 @@ #include "providers/twitch/PartialTwitchUser.hpp" +#include "common/Common.hpp" #include "common/NetworkRequest.hpp" #include "debug/Log.hpp" #include "providers/twitch/TwitchCommon.hpp" diff --git a/src/providers/twitch/PubsubHelpers.cpp b/src/providers/twitch/PubsubHelpers.cpp index cf4560f6b..f9b4e784a 100644 --- a/src/providers/twitch/PubsubHelpers.cpp +++ b/src/providers/twitch/PubsubHelpers.cpp @@ -1,6 +1,7 @@ #include "providers/twitch/PubsubHelpers.hpp" #include "providers/twitch/PubsubActions.hpp" +#include "providers/twitch/TwitchAccount.hpp" #include "util/RapidjsonHelpers.hpp" namespace chatterino { diff --git a/src/providers/twitch/PubsubHelpers.hpp b/src/providers/twitch/PubsubHelpers.hpp index 8b9b3f322..3e92e332c 100644 --- a/src/providers/twitch/PubsubHelpers.hpp +++ b/src/providers/twitch/PubsubHelpers.hpp @@ -1,16 +1,14 @@ #pragma once -#include "debug/Log.hpp" -#include "providers/twitch/TwitchAccount.hpp" #include "util/RapidjsonHelpers.hpp" #include #include - #include namespace chatterino { +class TwitchAccount; struct ActionUser; const rapidjson::Value &getArgs(const rapidjson::Value &data); diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp index 0258c6e72..238d9a6be 100644 --- a/src/providers/twitch/TwitchAccount.cpp +++ b/src/providers/twitch/TwitchAccount.cpp @@ -4,6 +4,7 @@ #include "Application.hpp" #include "common/NetworkRequest.hpp" +#include "common/Outcome.hpp" #include "debug/Log.hpp" #include "providers/twitch/PartialTwitchUser.hpp" #include "providers/twitch/TwitchCommon.hpp" diff --git a/src/providers/twitch/TwitchAccount.hpp b/src/providers/twitch/TwitchAccount.hpp index c59ca9d38..1ea718b73 100644 --- a/src/providers/twitch/TwitchAccount.hpp +++ b/src/providers/twitch/TwitchAccount.hpp @@ -1,5 +1,6 @@ #pragma once +#include "common/Aliases.hpp" #include "common/Atomic.hpp" #include "common/UniqueAccess.hpp" #include "controllers/accounts/Account.hpp" diff --git a/src/providers/twitch/TwitchAccountManager.cpp b/src/providers/twitch/TwitchAccountManager.cpp index 18210c2fd..097aa89ea 100644 --- a/src/providers/twitch/TwitchAccountManager.cpp +++ b/src/providers/twitch/TwitchAccountManager.cpp @@ -2,6 +2,7 @@ #include "common/Common.hpp" #include "debug/Log.hpp" +#include "providers/twitch/TwitchAccount.hpp" #include "providers/twitch/TwitchCommon.hpp" namespace chatterino { diff --git a/src/providers/twitch/TwitchAccountManager.hpp b/src/providers/twitch/TwitchAccountManager.hpp index 32961f092..7c79ea249 100644 --- a/src/providers/twitch/TwitchAccountManager.hpp +++ b/src/providers/twitch/TwitchAccountManager.hpp @@ -17,6 +17,7 @@ namespace chatterino { +class TwitchAccount; class AccountController; class TwitchAccountManager diff --git a/src/providers/twitch/TwitchApi.cpp b/src/providers/twitch/TwitchApi.cpp index dc0329b69..33e982191 100644 --- a/src/providers/twitch/TwitchApi.cpp +++ b/src/providers/twitch/TwitchApi.cpp @@ -1,5 +1,6 @@ #include "providers/twitch/TwitchApi.hpp" +#include "common/Common.hpp" #include "common/NetworkRequest.hpp" #include "debug/Log.hpp" #include "providers/twitch/TwitchCommon.hpp" diff --git a/src/providers/twitch/TwitchApi.hpp b/src/providers/twitch/TwitchApi.hpp index 67b26c1ca..fd7ad599c 100644 --- a/src/providers/twitch/TwitchApi.hpp +++ b/src/providers/twitch/TwitchApi.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include namespace chatterino { diff --git a/src/providers/twitch/TwitchBadges.cpp b/src/providers/twitch/TwitchBadges.cpp index fd9fe7461..8853f1add 100644 --- a/src/providers/twitch/TwitchBadges.cpp +++ b/src/providers/twitch/TwitchBadges.cpp @@ -5,6 +5,8 @@ #include #include #include "common/NetworkRequest.hpp" +#include "common/Outcome.hpp" +#include "messages/Emote.hpp" namespace chatterino { diff --git a/src/providers/twitch/TwitchBadges.hpp b/src/providers/twitch/TwitchBadges.hpp index a228365da..62196f8d8 100644 --- a/src/providers/twitch/TwitchBadges.hpp +++ b/src/providers/twitch/TwitchBadges.hpp @@ -1,12 +1,14 @@ #pragma once #include -#include #include #include "util/QStringHash.hpp" namespace chatterino { +struct Emote; +using EmotePtr = std::shared_ptr; + class Settings; class Paths; diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index 7e0a1efc1..0bb7ffe9c 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -1,5 +1,6 @@ #include "providers/twitch/TwitchChannel.hpp" +#include "Application.hpp" #include "common/Common.hpp" #include "common/NetworkRequest.hpp" #include "controllers/accounts/AccountController.hpp" diff --git a/src/providers/twitch/TwitchChannel.hpp b/src/providers/twitch/TwitchChannel.hpp index 8b2edeab4..940da72bf 100644 --- a/src/providers/twitch/TwitchChannel.hpp +++ b/src/providers/twitch/TwitchChannel.hpp @@ -2,21 +2,23 @@ #include +#include "common/Aliases.hpp" #include "common/Atomic.hpp" #include "common/Channel.hpp" -#include "common/Common.hpp" +#include "common/Outcome.hpp" #include "common/UniqueAccess.hpp" -#include "messages/Emote.hpp" -#include "singletons/Emotes.hpp" -#include "util/ConcurrentMap.hpp" - -#include +#include #include +#include #include namespace chatterino { +struct Emote; +using EmotePtr = std::shared_ptr; +class EmoteMap; + class TwitchServer; class TwitchChannel final : public Channel, pajlada::Signals::SignalHolder diff --git a/src/providers/twitch/TwitchEmotes.cpp b/src/providers/twitch/TwitchEmotes.cpp index 08c28286f..ce63d6864 100644 --- a/src/providers/twitch/TwitchEmotes.cpp +++ b/src/providers/twitch/TwitchEmotes.cpp @@ -3,6 +3,7 @@ #include "common/NetworkRequest.hpp" #include "debug/Benchmark.hpp" #include "debug/Log.hpp" +#include "messages/Emote.hpp" #include "messages/Image.hpp" #include "util/RapidjsonHelpers.hpp" diff --git a/src/providers/twitch/TwitchEmotes.hpp b/src/providers/twitch/TwitchEmotes.hpp index 69cf65e5e..90cafe440 100644 --- a/src/providers/twitch/TwitchEmotes.hpp +++ b/src/providers/twitch/TwitchEmotes.hpp @@ -3,18 +3,18 @@ #include #include +#include "common/Aliases.hpp" #include "common/UniqueAccess.hpp" -#include "messages/Emote.hpp" -#include "providers/twitch/EmoteValue.hpp" -#include "providers/twitch/TwitchAccount.hpp" #include "providers/twitch/TwitchEmotes.hpp" -#include "util/ConcurrentMap.hpp" #define TWITCH_EMOTE_TEMPLATE \ "https://static-cdn.jtvnw.net/emoticons/v1/{id}/{scale}" namespace chatterino { +struct Emote; +using EmotePtr = std::shared_ptr; + class TwitchEmotes { public: diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index e475b724d..67cd2998d 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -5,6 +5,7 @@ #include "controllers/highlights/HighlightController.hpp" #include "controllers/ignores/IgnoreController.hpp" #include "debug/Log.hpp" +#include "messages/Message.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "singletons/Emotes.hpp" #include "singletons/Resources.hpp" @@ -12,6 +13,7 @@ #include "singletons/Theme.hpp" #include "singletons/WindowManager.hpp" #include "util/IrcHelpers.hpp" +#include "widgets/Window.hpp" #include #include diff --git a/src/providers/twitch/TwitchMessageBuilder.hpp b/src/providers/twitch/TwitchMessageBuilder.hpp index 385fed932..30b476f97 100644 --- a/src/providers/twitch/TwitchMessageBuilder.hpp +++ b/src/providers/twitch/TwitchMessageBuilder.hpp @@ -1,15 +1,18 @@ #pragma once +#include "common/Aliases.hpp" +#include "common/Outcome.hpp" #include "messages/MessageBuilder.hpp" -#include "singletons/Emotes.hpp" #include - #include #include namespace chatterino { +struct Emote; +using EmotePtr = std::shared_ptr; + class Channel; class TwitchChannel; diff --git a/src/providers/twitch/TwitchServer.cpp b/src/providers/twitch/TwitchServer.cpp index 4e3bcddad..e9325443c 100644 --- a/src/providers/twitch/TwitchServer.cpp +++ b/src/providers/twitch/TwitchServer.cpp @@ -7,6 +7,7 @@ #include "providers/twitch/IrcMessageHandler.hpp" #include "providers/twitch/PubsubClient.hpp" #include "providers/twitch/TwitchAccount.hpp" +#include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchHelpers.hpp" #include "providers/twitch/TwitchMessageBuilder.hpp" #include "util/PostToThread.hpp" diff --git a/src/providers/twitch/TwitchServer.hpp b/src/providers/twitch/TwitchServer.hpp index 7e204173f..72c4078bc 100644 --- a/src/providers/twitch/TwitchServer.hpp +++ b/src/providers/twitch/TwitchServer.hpp @@ -1,10 +1,10 @@ #pragma once #include "common/Atomic.hpp" +#include "common/Channel.hpp" #include "common/Singleton.hpp" +#include "pajlada/signals/signalholder.hpp" #include "providers/irc/AbstractIrcServer.hpp" -#include "providers/twitch/TwitchAccount.hpp" -#include "providers/twitch/TwitchChannel.hpp" #include #include diff --git a/src/singletons/Fonts.cpp b/src/singletons/Fonts.cpp index 69f327285..3c9efa79e 100644 --- a/src/singletons/Fonts.cpp +++ b/src/singletons/Fonts.cpp @@ -2,6 +2,7 @@ #include "Application.hpp" #include "debug/AssertInGuiThread.hpp" +#include "singletons/Settings.hpp" #include "singletons/WindowManager.hpp" #include @@ -26,7 +27,7 @@ Fonts::Fonts() : chatFontFamily("/appearance/currentFontFamily", DEFAULT_FONT_FAMILY) , chatFontSize("/appearance/currentFontSize", DEFAULT_FONT_SIZE) { - this->fontsByType_.resize(size_t(EndType)); + this->fontsByType_.resize(size_t(FontStyle::EndType)); } void Fonts::initialize(Settings &, Paths &) @@ -61,21 +62,21 @@ void Fonts::initialize(Settings &, Paths &) }); } -QFont Fonts::getFont(Fonts::Type type, float scale) +QFont Fonts::getFont(FontStyle type, float scale) { return this->getOrCreateFontData(type, scale).font; } -QFontMetrics Fonts::getFontMetrics(Fonts::Type type, float scale) +QFontMetrics Fonts::getFontMetrics(FontStyle type, float scale) { return this->getOrCreateFontData(type, scale).metrics; } -Fonts::FontData &Fonts::getOrCreateFontData(Type type, float scale) +Fonts::FontData &Fonts::getOrCreateFontData(FontStyle type, float scale) { assertInGuiThread(); - assert(type >= 0 && type < EndType); + assert(type < FontStyle::EndType); auto &map = this->fontsByType_[size_t(type)]; @@ -94,22 +95,22 @@ Fonts::FontData &Fonts::getOrCreateFontData(Type type, float scale) return result.first->second; } -Fonts::FontData Fonts::createFontData(Type type, float scale) +Fonts::FontData Fonts::createFontData(FontStyle type, float scale) { // check if it's a chat (scale the setting) - if (type >= ChatStart && type <= ChatEnd) { - static std::unordered_map sizeScale{ - {ChatSmall, {0.6f, false, QFont::Normal}}, - {ChatMediumSmall, {0.8f, false, QFont::Normal}}, - {ChatMedium, {1, false, QFont::Normal}}, - {ChatMediumBold, + if (type >= FontStyle::ChatStart && type <= FontStyle::ChatEnd) { + static std::unordered_map sizeScale{ + {FontStyle::ChatSmall, {0.6f, false, QFont::Normal}}, + {FontStyle::ChatMediumSmall, {0.8f, false, QFont::Normal}}, + {FontStyle::ChatMedium, {1, false, QFont::Normal}}, + {FontStyle::ChatMediumBold, {1, false, QFont::Weight(getApp()->settings->boldScale.getValue())}}, - {ChatMediumItalic, {1, true, QFont::Normal}}, - {ChatLarge, {1.2f, false, QFont::Normal}}, - {ChatVeryLarge, {1.4f, false, QFont::Normal}}, + {FontStyle::ChatMediumItalic, {1, true, QFont::Normal}}, + {FontStyle::ChatLarge, {1.2f, false, QFont::Normal}}, + {FontStyle::ChatVeryLarge, {1.4f, false, QFont::Normal}}, }; - sizeScale[ChatMediumBold] = { + sizeScale[FontStyle::ChatMediumBold] = { 1, false, QFont::Weight(getApp()->settings->boldScale.getValue())}; auto data = sizeScale[type]; return FontData( @@ -126,11 +127,11 @@ Fonts::FontData Fonts::createFontData(Type type, float scale) constexpr float multiplier = 1.f; #endif - static std::unordered_map defaultSize{ - {Tiny, {8, "Monospace", false, QFont::Normal}}, - {UiMedium, + static std::unordered_map defaultSize{ + {FontStyle::Tiny, {8, "Monospace", false, QFont::Normal}}, + {FontStyle::UiMedium, {int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}}, - {UiTabs, + {FontStyle::UiTabs, {int(9 * multiplier), DEFAULT_FONT_FAMILY, false, QFont::Normal}}, }; diff --git a/src/singletons/Fonts.hpp b/src/singletons/Fonts.hpp index 59c6550c3..61ba393d6 100644 --- a/src/singletons/Fonts.hpp +++ b/src/singletons/Fonts.hpp @@ -16,6 +16,27 @@ namespace chatterino { class Settings; class Paths; +enum class FontStyle : uint8_t { + Tiny, + ChatSmall, + ChatMediumSmall, + ChatMedium, + ChatMediumBold, + ChatMediumItalic, + ChatLarge, + ChatVeryLarge, + + UiMedium, + UiTabs, + + // don't remove this value + EndType, + + // make sure to update these values accordingly! + ChatStart = ChatSmall, + ChatEnd = ChatVeryLarge, +}; + class Fonts final : public Singleton { public: @@ -24,29 +45,9 @@ public: virtual void initialize(Settings &settings, Paths &paths) override; // font data gets set in createFontData(...) - enum Type : uint8_t { - Tiny, - ChatSmall, - ChatMediumSmall, - ChatMedium, - ChatMediumBold, - ChatMediumItalic, - ChatLarge, - ChatVeryLarge, - UiMedium, - UiTabs, - - // don't remove this value - EndType, - - // make sure to update these values accordingly! - ChatStart = ChatSmall, - ChatEnd = ChatVeryLarge, - }; - - QFont getFont(Type type, float scale); - QFontMetrics getFontMetrics(Type type, float scale); + QFont getFont(FontStyle type, float scale); + QFontMetrics getFontMetrics(FontStyle type, float scale); pajlada::Settings::Setting chatFontFamily; pajlada::Settings::Setting chatFontSize; @@ -78,12 +79,10 @@ private: QFont::Weight weight; }; - FontData &getOrCreateFontData(Type type, float scale); - FontData createFontData(Type type, float scale); + FontData &getOrCreateFontData(FontStyle type, float scale); + FontData createFontData(FontStyle type, float scale); std::vector> fontsByType_; }; -using FontStyle = Fonts::Type; - } // namespace chatterino diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index fbc813b4a..28d0e43d3 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -5,7 +5,6 @@ #include "common/ChatterinoSetting.hpp" #include "controllers/highlights/HighlightPhrase.hpp" #include "controllers/moderationactions/ModerationAction.hpp" -#include "messages/MessageElement.hpp" #include #include diff --git a/src/singletons/Updates.cpp b/src/singletons/Updates.cpp index d56a8f510..5782b4bea 100644 --- a/src/singletons/Updates.cpp +++ b/src/singletons/Updates.cpp @@ -1,6 +1,7 @@ #include "Updates.hpp" #include "common/NetworkRequest.hpp" +#include "common/Outcome.hpp" #include "common/Version.hpp" #include "singletons/Paths.hpp" #include "util/CombinePath.hpp" diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index 8ff34c7bf..17bf1ea83 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -3,13 +3,20 @@ #include "Application.hpp" #include "debug/AssertInGuiThread.hpp" #include "debug/Log.hpp" +#include "messages/MessageElement.hpp" #include "providers/twitch/TwitchServer.hpp" #include "singletons/Fonts.hpp" #include "singletons/Paths.hpp" +#include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "util/Clamp.hpp" #include "widgets/AccountSwitchPopupWidget.hpp" +#include "widgets/Notebook.hpp" +#include "widgets/Window.hpp" #include "widgets/dialogs/SettingsDialog.hpp" +#include "widgets/helper/NotebookTab.hpp" +#include "widgets/splits/Split.hpp" +#include "widgets/splits/SplitContainer.hpp" #include #include @@ -174,7 +181,7 @@ Window &WindowManager::getSelectedWindow() return *this->selectedWindow_; } -Window &WindowManager::createWindow(Window::Type type) +Window &WindowManager::createWindow(WindowType type) { assertInGuiThread(); @@ -182,7 +189,7 @@ Window &WindowManager::createWindow(Window::Type type) this->windows_.push_back(window); window->show(); - if (type != Window::Type::Main) { + if (type != WindowType::Main) { window->setAttribute(Qt::WA_DeleteOnClose); QObject::connect(window, &QWidget::destroyed, [this, window] { @@ -239,16 +246,16 @@ void WindowManager::initialize(Settings &settings, Paths &paths) // get type QString type_val = window_obj.value("type").toString(); - Window::Type type = - type_val == "main" ? Window::Type::Main : Window::Type::Popup; + WindowType type = + type_val == "main" ? WindowType::Main : WindowType::Popup; - if (type == Window::Type::Main && mainWindow_ != nullptr) { - type = Window::Type::Popup; + if (type == WindowType::Main && mainWindow_ != nullptr) { + type = WindowType::Popup; } Window &window = createWindow(type); - if (type == Window::Type::Main) { + if (type == WindowType::Main) { mainWindow_ = &window; } @@ -308,7 +315,7 @@ void WindowManager::initialize(Settings &settings, Paths &paths) } if (mainWindow_ == nullptr) { - mainWindow_ = &createWindow(Window::Type::Main); + mainWindow_ = &createWindow(WindowType::Main); mainWindow_->getNotebook().addPage(true); } @@ -344,15 +351,15 @@ void WindowManager::save() // window type switch (window->getType()) { - case Window::Type::Main: + case WindowType::Main: window_obj.insert("type", "main"); break; - case Window::Type::Popup: + case WindowType::Popup: window_obj.insert("type", "popup"); break; - case Window::Type::Attached:; + case WindowType::Attached:; } // window geometry diff --git a/src/singletons/WindowManager.hpp b/src/singletons/WindowManager.hpp index eef2be2f1..74149876e 100644 --- a/src/singletons/WindowManager.hpp +++ b/src/singletons/WindowManager.hpp @@ -1,13 +1,20 @@ #pragma once +#include "common/Channel.hpp" +#include "common/FlagsEnum.hpp" #include "common/Singleton.hpp" -#include "widgets/Window.hpp" #include "widgets/splits/SplitContainer.hpp" namespace chatterino { class Settings; class Paths; +class Window; +class SplitContainer; + +enum class MessageElementFlag; +using MessageElementFlags = FlagsEnum; +enum class WindowType; class WindowManager final : public Singleton { @@ -34,7 +41,7 @@ public: Window &getMainWindow(); Window &getSelectedWindow(); - Window &createWindow(Window::Type type); + Window &createWindow(WindowType type); int windowCount(); Window *windowAt(int index); @@ -63,10 +70,10 @@ private: std::vector windows_; - Window *mainWindow_ = nullptr; - Window *selectedWindow_ = nullptr; + Window *mainWindow_{}; + Window *selectedWindow_{}; - MessageElementFlags wordFlags_ = MessageElementFlag::Default; + MessageElementFlags wordFlags_{}; pajlada::Settings::SettingListener wordFlagsListener_; }; diff --git a/src/util/InitUpdateButton.cpp b/src/util/InitUpdateButton.cpp index 25d131635..54f06976d 100644 --- a/src/util/InitUpdateButton.cpp +++ b/src/util/InitUpdateButton.cpp @@ -6,15 +6,12 @@ namespace chatterino { void initUpdateButton(Button &button, - std::unique_ptr &handle, pajlada::Signals::SignalHolder &signalHolder) { button.hide(); // show update prompt when clicking the button - QObject::connect(&button, &Button::clicked, [&button, &handle] { - (void)(handle); - + QObject::connect(&button, &Button::clicked, [&button] { auto dialog = new UpdateDialog(); dialog->setActionOnFocusLoss(BaseWindow::Delete); dialog->move(button.mapToGlobal( diff --git a/src/util/InitUpdateButton.hpp b/src/util/InitUpdateButton.hpp index e95fcd7bd..9a88382a2 100644 --- a/src/util/InitUpdateButton.hpp +++ b/src/util/InitUpdateButton.hpp @@ -14,7 +14,6 @@ class Button; class UpdateDialog; void initUpdateButton(Button &button, - std::unique_ptr &handle, pajlada::Signals::SignalHolder &signalHolder); } // namespace chatterino diff --git a/src/widgets/AccountSwitchWidget.cpp b/src/widgets/AccountSwitchWidget.cpp index 9c307ba73..3e201ded3 100644 --- a/src/widgets/AccountSwitchWidget.cpp +++ b/src/widgets/AccountSwitchWidget.cpp @@ -3,6 +3,7 @@ #include "Application.hpp" #include "common/Common.hpp" #include "controllers/accounts/AccountController.hpp" +#include "providers/twitch/TwitchAccount.hpp" #include "providers/twitch/TwitchCommon.hpp" namespace chatterino { diff --git a/src/widgets/AttachedWindow.hpp b/src/widgets/AttachedWindow.hpp index 80b030fca..64da52f6a 100644 --- a/src/widgets/AttachedWindow.hpp +++ b/src/widgets/AttachedWindow.hpp @@ -1,12 +1,14 @@ #pragma once +#include #include -#include "common/Channel.hpp" -#include "widgets/splits/Split.hpp" - namespace chatterino { +class Split; +class Channel; +using ChannelPtr = std::shared_ptr; + class AttachedWindow : public QWidget { AttachedWindow(void *_target, int _yOffset); diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index eccde0f97..5c80bc9a7 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -4,6 +4,7 @@ #include "boost/algorithm/algorithm.hpp" #include "debug/Log.hpp" #include "singletons/Settings.hpp" +#include "singletons/Theme.hpp" #include "singletons/WindowManager.hpp" #include "util/PostToThread.hpp" #include "util/WindowsHelper.hpp" @@ -110,11 +111,11 @@ void BaseWindow::init() // buttons TitleBarButton *_minButton = new TitleBarButton; - _minButton->setButtonStyle(TitleBarButton::Minimize); + _minButton->setButtonStyle(TitleBarButtonStyle::Minimize); TitleBarButton *_maxButton = new TitleBarButton; - _maxButton->setButtonStyle(TitleBarButton::Maximize); + _maxButton->setButtonStyle(TitleBarButtonStyle::Maximize); TitleBarButton *_exitButton = new TitleBarButton; - _exitButton->setButtonStyle(TitleBarButton::Close); + _exitButton->setButtonStyle(TitleBarButtonStyle::Close); QObject::connect(_minButton, &TitleBarButton::clicked, this, [this] { @@ -353,8 +354,8 @@ void BaseWindow::mouseMoveEvent(QMouseEvent *event) BaseWidget::mouseMoveEvent(event); } -TitleBarButton *BaseWindow::addTitleBarButton( - const TitleBarButton::Style &style, std::function onClicked) +TitleBarButton *BaseWindow::addTitleBarButton(const TitleBarButtonStyle &style, + std::function onClicked) { TitleBarButton *button = new TitleBarButton; button->setScaleIndependantSize(30, 30); @@ -389,10 +390,10 @@ void BaseWindow::changeEvent(QEvent *) #ifdef USEWINSDK if (this->ui_.maxButton) { - this->ui_.maxButton->setButtonStyle(this->windowState() & - Qt::WindowMaximized - ? TitleBarButton::Unmaximize - : TitleBarButton::Maximize); + this->ui_.maxButton->setButtonStyle( + this->windowState() & Qt::WindowMaximized + ? TitleBarButtonStyle::Unmaximize + : TitleBarButtonStyle::Maximize); } #endif diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index eac2ee55e..088c07c86 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -1,7 +1,6 @@ #pragma once #include "BaseWidget.hpp" -#include "widgets/helper/TitlebarButton.hpp" #include #include @@ -15,6 +14,7 @@ namespace chatterino { class Button; class EffectLabel; class TitleBarButton; +enum class TitleBarButtonStyle; class BaseWindow : public BaseWidget { @@ -36,7 +36,7 @@ public: QWidget *getLayoutContainer(); bool hasCustomWindowFrame(); - TitleBarButton *addTitleBarButton(const TitleBarButton::Style &style, + TitleBarButton *addTitleBarButton(const TitleBarButtonStyle &style, std::function onClicked); EffectLabel *addTitleBarLabel(std::function onClicked); @@ -114,6 +114,6 @@ private: pajlada::Signals::SignalHolder connections_; std::vector managedConnections_; -}; +}; // namespace chatterino } // namespace chatterino diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index d99d1f021..8cd5a6075 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -2,6 +2,7 @@ #include "Application.hpp" #include "debug/Log.hpp" +#include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "singletons/WindowManager.hpp" #include "util/InitUpdateButton.hpp" @@ -27,11 +28,11 @@ namespace chatterino { Notebook::Notebook(QWidget *parent) : BaseWidget(parent) - , addButton_(this) + , addButton_(new NotebookButton(this)) { - this->addButton_.setIcon(NotebookButton::Icon::Plus); + this->addButton_->setIcon(NotebookButton::Icon::Plus); - this->addButton_.setHidden(true); + this->addButton_->setHidden(true); auto *shortcut_next = new QShortcut(QKeySequence("Ctrl+Tab"), this); QObject::connect(shortcut_next, &QShortcut::activated, @@ -290,14 +291,14 @@ void Notebook::setShowAddButton(bool value) { this->showAddButton_ = value; - this->addButton_.setHidden(!value); + this->addButton_->setHidden(!value); } void Notebook::scaleChangedEvent(float scale) { float h = NOTEBOOK_TAB_HEIGHT * this->getScale(); - this->addButton_.setFixedSize(h, h); + this->addButton_->setFixedSize(h, h); for (auto &i : this->items_) { i.tab->updateSize(); @@ -353,7 +354,7 @@ void Notebook::performLayout(bool animated) } if (this->showAddButton_) { - this->addButton_.move(x, y); + this->addButton_->move(x, y); } if (this->lineY_ != y + tabHeight) { @@ -368,7 +369,7 @@ void Notebook::performLayout(bool animated) } if (this->showAddButton_) { - this->addButton_.raise(); + this->addButton_->raise(); } if (this->selectedPage_ != nullptr) { @@ -389,7 +390,7 @@ void Notebook::paintEvent(QPaintEvent *event) NotebookButton *Notebook::getAddButton() { - return &this->addButton_; + return this->addButton_; } NotebookButton *Notebook::addCustomButton() @@ -460,8 +461,7 @@ void SplitNotebook::addCustomButtons() // updates auto updateBtn = this->addCustomButton(); - initUpdateButton(*updateBtn, this->updateDialogHandle_, - this->signalHolder_); + initUpdateButton(*updateBtn, this->signalHolder_); } SplitContainer *SplitNotebook::addPage(bool select) diff --git a/src/widgets/Notebook.hpp b/src/widgets/Notebook.hpp index 749d12594..022c075a2 100644 --- a/src/widgets/Notebook.hpp +++ b/src/widgets/Notebook.hpp @@ -2,10 +2,6 @@ #include "pajlada/signals/signal.hpp" #include "widgets/BaseWidget.hpp" -#include "widgets/dialogs/UpdateDialog.hpp" -#include "widgets/helper/NotebookButton.hpp" -#include "widgets/helper/NotebookTab.hpp" -#include "widgets/splits/SplitContainer.hpp" #include #include @@ -15,6 +11,10 @@ namespace chatterino { class Window; +class UpdateDialog; +class NotebookButton; +class NotebookTab; +class SplitContainer; class Notebook : public BaseWidget { @@ -22,6 +22,7 @@ class Notebook : public BaseWidget public: explicit Notebook(QWidget *parent); + ~Notebook() override = default; NotebookTab *addPage(QWidget *page, QString title = QString(), bool select = false); @@ -74,7 +75,7 @@ private: QList items_; QWidget *selectedPage_ = nullptr; - NotebookButton addButton_; + NotebookButton *addButton_; std::vector customButtons_; bool allowUserTabManagement_ = false; @@ -94,7 +95,7 @@ private: void addCustomButtons(); pajlada::Signals::SignalHolder signalHolder_; - std::unique_ptr updateDialogHandle_; + std::shared_ptr updateDialogHandle_; std::vector connections_; }; diff --git a/src/widgets/Scrollbar.cpp b/src/widgets/Scrollbar.cpp index 9c46cff80..879aa9af2 100644 --- a/src/widgets/Scrollbar.cpp +++ b/src/widgets/Scrollbar.cpp @@ -1,6 +1,7 @@ #include "widgets/Scrollbar.hpp" #include "Application.hpp" +#include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "widgets/helper/ChannelView.hpp" @@ -103,8 +104,7 @@ void Scrollbar::setSmallChange(qreal value) void Scrollbar::setDesiredValue(qreal value, bool animated) { - auto app = getApp(); - animated &= app->settings->enableSmoothScrolling.getValue(); + animated &= getSettings()->enableSmoothScrolling.getValue(); value = std::max(this->minimum_, std::min(this->maximum_ - this->largeChange_, value)); @@ -221,8 +221,6 @@ void Scrollbar::printCurrentState(const QString &prefix) const void Scrollbar::paintEvent(QPaintEvent *) { - auto *app = getApp(); - bool mouseOver = this->mouseOverIndex_ != -1; int xOffset = mouseOver ? 0 : width() - int(4 * this->getScale()); @@ -267,9 +265,11 @@ void Scrollbar::paintEvent(QPaintEvent *) QColor color = [&] { switch (highlight.getColor()) { case ScrollbarHighlight::Highlight: - return app->themes->scrollbars.highlights.highlight; + return getApp() + ->themes->scrollbars.highlights.highlight; case ScrollbarHighlight::Subscription: - return app->themes->scrollbars.highlights.subscription; + return getApp() + ->themes->scrollbars.highlights.subscription; } return QColor(); }(); diff --git a/src/widgets/Scrollbar.hpp b/src/widgets/Scrollbar.hpp index fe72477c3..114a1dfe6 100644 --- a/src/widgets/Scrollbar.hpp +++ b/src/widgets/Scrollbar.hpp @@ -1,7 +1,6 @@ #pragma once #include "messages/LimitedQueue.hpp" -#include "singletons/Settings.hpp" #include "widgets/BaseWidget.hpp" #include "widgets/helper/ScrollbarHighlight.hpp" diff --git a/src/widgets/StreamView.cpp b/src/widgets/StreamView.cpp index ad3f1966c..9277ba825 100644 --- a/src/widgets/StreamView.cpp +++ b/src/widgets/StreamView.cpp @@ -3,6 +3,7 @@ #include "common/Channel.hpp" #include "util/Helpers.hpp" #include "util/LayoutCreator.hpp" +#include "widgets/helper/ChannelView.hpp" #include "widgets/splits/Split.hpp" #ifdef USEWEBENGINE diff --git a/src/widgets/TooltipWidget.cpp b/src/widgets/TooltipWidget.cpp index 0b3b83639..3479826b8 100644 --- a/src/widgets/TooltipWidget.cpp +++ b/src/widgets/TooltipWidget.cpp @@ -79,7 +79,7 @@ void TooltipWidget::updateFont() auto app = getApp(); this->setFont( - app->fonts->getFont(Fonts::Type::ChatMediumSmall, this->getScale())); + app->fonts->getFont(FontStyle::ChatMediumSmall, this->getScale())); } void TooltipWidget::setText(QString text) diff --git a/src/widgets/Window.cpp b/src/widgets/Window.cpp index 7088e5cb6..876f2a078 100644 --- a/src/widgets/Window.cpp +++ b/src/widgets/Window.cpp @@ -14,8 +14,11 @@ #include "widgets/dialogs/SettingsDialog.hpp" #include "widgets/dialogs/UpdateDialog.hpp" #include "widgets/dialogs/WelcomeDialog.hpp" +#include "widgets/helper/EffectLabel.hpp" #include "widgets/helper/Shortcut.hpp" +#include "widgets/helper/TitlebarButton.hpp" #include "widgets/splits/Split.hpp" +#include "widgets/splits/SplitContainer.hpp" #include #include @@ -28,10 +31,10 @@ namespace chatterino { -Window::Window(Type type) +Window::Window(WindowType type) : BaseWindow(nullptr, BaseWindow::EnableCustomFrame) , type_(type) - , notebook_(this) + , notebook_(new SplitNotebook(this)) { this->addCustomTitlebarButtons(); this->addDebugStuff(); @@ -42,26 +45,26 @@ Window::Window(Type type) [this] { this->onAccountSelected(); }); this->onAccountSelected(); - if (type == Type::Main) { + if (type == WindowType::Main) { this->resize(int(600 * this->getScale()), int(500 * this->getScale())); } else { this->resize(int(300 * this->getScale()), int(500 * this->getScale())); } } -Window::Type Window::getType() +WindowType Window::getType() { return this->type_; } SplitNotebook &Window::getNotebook() { - return this->notebook_; + return *this->notebook_; } void Window::repaintVisibleChatWidgets(Channel *channel) { - auto page = this->notebook_.getOrAddSelectedPage(); + auto page = this->notebook_->getOrAddSelectedPage(); for (const auto &split : page->getSplits()) { if (channel == nullptr || channel == split->getChannel().get()) { @@ -77,7 +80,7 @@ bool Window::event(QEvent *event) break; case QEvent::WindowDeactivate: { - auto page = this->notebook_.getOrAddSelectedPage(); + auto page = this->notebook_->getOrAddSelectedPage(); if (page != nullptr) { std::vector splits = page->getSplits(); @@ -135,7 +138,7 @@ void Window::showEvent(QShowEvent *event) void Window::closeEvent(QCloseEvent *) { - if (this->type_ == Type::Main) { + if (this->type_ == WindowType::Main) { auto app = getApp(); app->windows->save(); app->windows->closeAll(); @@ -143,7 +146,7 @@ void Window::closeEvent(QCloseEvent *) this->closed.invoke(); - if (this->type_ == Type::Main) { + if (this->type_ == WindowType::Main) { QApplication::exit(); } } @@ -152,35 +155,34 @@ void Window::addLayout() { QVBoxLayout *layout = new QVBoxLayout(this); - layout->addWidget(&this->notebook_); + layout->addWidget(this->notebook_); this->getLayoutContainer()->setLayout(layout); // set margin layout->setMargin(0); - this->notebook_.setAllowUserTabManagement(true); - this->notebook_.setShowAddButton(true); + this->notebook_->setAllowUserTabManagement(true); + this->notebook_->setShowAddButton(true); } void Window::addCustomTitlebarButtons() { if (!this->hasCustomWindowFrame()) return; - if (this->type_ != Type::Main) return; + if (this->type_ != WindowType::Main) return; // settings - this->addTitleBarButton(TitleBarButton::Settings, [] { - getApp()->windows->showSettingsDialog(); // - }); + this->addTitleBarButton(TitleBarButtonStyle::Settings, + [] { getApp()->windows->showSettingsDialog(); }); // updates - auto update = this->addTitleBarButton(TitleBarButton::None, [] {}); + auto update = this->addTitleBarButton(TitleBarButtonStyle::None, [] {}); - initUpdateButton(*update, this->updateDialogHandle_, this->signalHolder_); + initUpdateButton(*update, this->signalHolder_); // account this->userLabel_ = this->addTitleBarLabel([this] { getApp()->windows->showAccountSelectPopup(this->userLabel_->mapToGlobal( - this->userLabel_->rect().bottomLeft())); // + this->userLabel_->rect().bottomLeft())); }); this->userLabel_->setMinimumWidth(20 * getScale()); } @@ -252,27 +254,27 @@ void Window::addShortcuts() // Switch tab createWindowShortcut(this, "CTRL+T", [this] { - this->notebook_.getOrAddSelectedPage()->appendNewSplit(true); + this->notebook_->getOrAddSelectedPage()->appendNewSplit(true); }); createWindowShortcut(this, "CTRL+1", - [this] { this->notebook_.selectIndex(0); }); + [this] { this->notebook_->selectIndex(0); }); createWindowShortcut(this, "CTRL+2", - [this] { this->notebook_.selectIndex(1); }); + [this] { this->notebook_->selectIndex(1); }); createWindowShortcut(this, "CTRL+3", - [this] { this->notebook_.selectIndex(2); }); + [this] { this->notebook_->selectIndex(2); }); createWindowShortcut(this, "CTRL+4", - [this] { this->notebook_.selectIndex(3); }); + [this] { this->notebook_->selectIndex(3); }); createWindowShortcut(this, "CTRL+5", - [this] { this->notebook_.selectIndex(4); }); + [this] { this->notebook_->selectIndex(4); }); createWindowShortcut(this, "CTRL+6", - [this] { this->notebook_.selectIndex(5); }); + [this] { this->notebook_->selectIndex(5); }); createWindowShortcut(this, "CTRL+7", - [this] { this->notebook_.selectIndex(6); }); + [this] { this->notebook_->selectIndex(6); }); createWindowShortcut(this, "CTRL+8", - [this] { this->notebook_.selectIndex(7); }); + [this] { this->notebook_->selectIndex(7); }); createWindowShortcut(this, "CTRL+9", - [this] { this->notebook_.selectIndex(8); }); + [this] { this->notebook_->selectIndex(8); }); // Zoom in { @@ -296,11 +298,11 @@ void Window::addShortcuts() // New tab createWindowShortcut(this, "CTRL+SHIFT+T", - [this] { this->notebook_.addPage(true); }); + [this] { this->notebook_->addPage(true); }); // Close tab createWindowShortcut(this, "CTRL+SHIFT+W", - [this] { this->notebook_.removeCurrentPage(); }); + [this] { this->notebook_->removeCurrentPage(); }); } void Window::onAccountSelected() diff --git a/src/widgets/Window.hpp b/src/widgets/Window.hpp index 438f6b3e2..f9267a81f 100644 --- a/src/widgets/Window.hpp +++ b/src/widgets/Window.hpp @@ -1,13 +1,6 @@ #pragma once -#include "util/Helpers.hpp" #include "widgets/BaseWindow.hpp" -#include "widgets/Notebook.hpp" -#include "widgets/dialogs/UpdateDialog.hpp" - -//#ifdef USEWINSDK -//#include -//#endif #include #include @@ -16,17 +9,20 @@ namespace chatterino { class Theme; +class UpdateDialog; +class SplitNotebook; +class Channel; + +enum class WindowType { Main, Popup, Attached }; class Window : public BaseWindow { Q_OBJECT public: - enum class Type { Main, Popup, Attached }; + explicit Window(WindowType type); - explicit Window(Window::Type type); - - Type getType(); + WindowType getType(); SplitNotebook &getNotebook(); void repaintVisibleChatWidgets(Channel *channel = nullptr); @@ -45,11 +41,11 @@ private: void addLayout(); void onAccountSelected(); - Type type_; + WindowType type_; - SplitNotebook notebook_; + SplitNotebook *notebook_; EffectLabel *userLabel_ = nullptr; - std::unique_ptr updateDialogHandle_; + std::shared_ptr updateDialogHandle_; pajlada::Signals::SignalHolder signalHolder_; diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index 8c3fc87e1..92435065d 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -3,9 +3,12 @@ #include "Application.hpp" #include "controllers/accounts/AccountController.hpp" #include "debug/Benchmark.hpp" +#include "messages/Message.hpp" #include "messages/MessageBuilder.hpp" #include "providers/twitch/TwitchChannel.hpp" +#include "singletons/Emotes.hpp" #include "widgets/Notebook.hpp" +#include "widgets/helper/ChannelView.hpp" #include #include diff --git a/src/widgets/dialogs/EmotePopup.hpp b/src/widgets/dialogs/EmotePopup.hpp index 98331efa7..b8ea9ebf9 100644 --- a/src/widgets/dialogs/EmotePopup.hpp +++ b/src/widgets/dialogs/EmotePopup.hpp @@ -1,13 +1,16 @@ #pragma once -#include "common/Channel.hpp" #include "widgets/BaseWindow.hpp" -#include "widgets/helper/ChannelView.hpp" #include namespace chatterino { +class Link; +class ChannelView; +class Channel; +using ChannelPtr = std::shared_ptr; + class EmotePopup : public BaseWindow { public: diff --git a/src/widgets/dialogs/LoginDialog.cpp b/src/widgets/dialogs/LoginDialog.cpp index 1b73f143f..daf3c201e 100644 --- a/src/widgets/dialogs/LoginDialog.cpp +++ b/src/widgets/dialogs/LoginDialog.cpp @@ -1,5 +1,6 @@ #include "widgets/dialogs/LoginDialog.hpp" +#include "Application.hpp" #include "common/Common.hpp" #include "common/NetworkRequest.hpp" #include "controllers/accounts/AccountController.hpp" diff --git a/src/widgets/dialogs/LogsPopup.cpp b/src/widgets/dialogs/LogsPopup.cpp index 04aa78fb4..be799be53 100644 --- a/src/widgets/dialogs/LogsPopup.cpp +++ b/src/widgets/dialogs/LogsPopup.cpp @@ -1,6 +1,7 @@ #include "LogsPopup.hpp" #include "IrcMessage" +#include "common/Channel.hpp" #include "common/NetworkRequest.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchMessageBuilder.hpp" @@ -14,6 +15,7 @@ namespace chatterino { LogsPopup::LogsPopup() + : channel_(Channel::getEmpty()) { this->initLayout(); this->resize(400, 600); diff --git a/src/widgets/dialogs/LogsPopup.hpp b/src/widgets/dialogs/LogsPopup.hpp index 5ec39102e..395e1a384 100644 --- a/src/widgets/dialogs/LogsPopup.hpp +++ b/src/widgets/dialogs/LogsPopup.hpp @@ -1,6 +1,5 @@ #pragma once -#include "common/Channel.hpp" #include "widgets/BaseWindow.hpp" namespace chatterino { @@ -8,6 +7,12 @@ namespace chatterino { class Channel; class ChannelView; +class Channel; +using ChannelPtr = std::shared_ptr; + +struct Message; +using MessagePtr = std::shared_ptr; + class LogsPopup : public BaseWindow { public: @@ -17,7 +22,7 @@ public: private: ChannelView *channelView_ = nullptr; - ChannelPtr channel_ = Channel::getEmpty(); + ChannelPtr channel_; QString userName_; int roomID_; diff --git a/src/widgets/dialogs/NotificationPopup.cpp b/src/widgets/dialogs/NotificationPopup.cpp index 46ff7e8af..fb1822f40 100644 --- a/src/widgets/dialogs/NotificationPopup.cpp +++ b/src/widgets/dialogs/NotificationPopup.cpp @@ -1,5 +1,7 @@ #include "NotificationPopup.hpp" +#include "common/Channel.hpp" +#include "messages/Message.hpp" #include "widgets/helper/ChannelView.hpp" #include diff --git a/src/widgets/dialogs/NotificationPopup.hpp b/src/widgets/dialogs/NotificationPopup.hpp index 04a35b3a7..0f98a81bd 100644 --- a/src/widgets/dialogs/NotificationPopup.hpp +++ b/src/widgets/dialogs/NotificationPopup.hpp @@ -1,13 +1,17 @@ #pragma once -#include "common/Channel.hpp" -#include "messages/Message.hpp" #include "widgets/BaseWindow.hpp" namespace chatterino { class ChannelView; +class Channel; +using ChannelPtr = std::shared_ptr; + +struct Message; +using MessagePtr = std::shared_ptr; + class NotificationPopup : public BaseWindow { public: diff --git a/src/widgets/dialogs/SelectChannelDialog.cpp b/src/widgets/dialogs/SelectChannelDialog.cpp index 367b626b2..e760a823e 100644 --- a/src/widgets/dialogs/SelectChannelDialog.cpp +++ b/src/widgets/dialogs/SelectChannelDialog.cpp @@ -2,8 +2,10 @@ #include "Application.hpp" #include "providers/twitch/TwitchServer.hpp" +#include "singletons/Theme.hpp" #include "util/LayoutCreator.hpp" #include "widgets/Notebook.hpp" +#include "widgets/helper/NotebookTab.hpp" #include #include diff --git a/src/widgets/dialogs/SelectChannelDialog.hpp b/src/widgets/dialogs/SelectChannelDialog.hpp index 94f21595c..5d5890d9a 100644 --- a/src/widgets/dialogs/SelectChannelDialog.hpp +++ b/src/widgets/dialogs/SelectChannelDialog.hpp @@ -1,8 +1,8 @@ #pragma once +#include "Application.hpp" #include "common/Channel.hpp" #include "widgets/BaseWindow.hpp" -#include "widgets/Notebook.hpp" #include @@ -11,7 +11,9 @@ namespace chatterino { -class SelectChannelDialog : public BaseWindow +class Notebook; + +class SelectChannelDialog final : public BaseWindow { public: SelectChannelDialog(QWidget *parent = nullptr); diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index e822da8b7..e7d3681ea 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -1,6 +1,7 @@ #include "UserInfoPopup.hpp" #include "Application.hpp" +#include "common/Channel.hpp" #include "common/NetworkRequest.hpp" #include "controllers/accounts/AccountController.hpp" #include "controllers/highlights/HighlightController.hpp" diff --git a/src/widgets/dialogs/UserInfoPopup.hpp b/src/widgets/dialogs/UserInfoPopup.hpp index 3dd13a464..59437d3da 100644 --- a/src/widgets/dialogs/UserInfoPopup.hpp +++ b/src/widgets/dialogs/UserInfoPopup.hpp @@ -1,6 +1,5 @@ #pragma once -#include "common/Channel.hpp" #include "widgets/BaseWindow.hpp" #include @@ -9,6 +8,8 @@ class QCheckBox; namespace chatterino { +class Channel; +using ChannelPtr = std::shared_ptr; class Label; class UserInfoPopup final : public BaseWindow diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 3803f2a21..45bc7b677 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1,18 +1,24 @@ #include "ChannelView.hpp" #include "Application.hpp" +#include "common/Common.hpp" #include "debug/Benchmark.hpp" #include "debug/Log.hpp" +#include "messages/Emote.hpp" #include "messages/LimitedQueueSnapshot.hpp" #include "messages/Message.hpp" +#include "messages/MessageElement.hpp" #include "messages/layouts/MessageLayout.hpp" +#include "messages/layouts/MessageLayoutElement.hpp" #include "providers/twitch/TwitchServer.hpp" #include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "singletons/WindowManager.hpp" #include "util/DistanceBetweenPoints.hpp" +#include "widgets/Scrollbar.hpp" #include "widgets/TooltipWidget.hpp" #include "widgets/dialogs/UserInfoPopup.hpp" +#include "widgets/helper/EffectLabel.hpp" #include "widgets/splits/Split.hpp" #include @@ -93,7 +99,7 @@ void addEmoteContextMenuItems(const Emote &emote, ChannelView::ChannelView(BaseWidget *parent) : BaseWidget(parent) - , scrollBar_(this) + , scrollBar_(new Scrollbar(this)) { this->setMouseTracking(true); @@ -124,7 +130,7 @@ void ChannelView::initializeLayout() QObject::connect(this->goToBottom_, &EffectLabel::clicked, this, [=] { QTimer::singleShot(180, [=] { - this->scrollBar_.scrollToBottom( + this->scrollBar_->scrollToBottom( getApp() ->settings->enableSmoothScrollingNewMessages.getValue()); }); @@ -133,18 +139,18 @@ void ChannelView::initializeLayout() void ChannelView::initializeScrollbar() { - this->scrollBar_.getCurrentValueChanged().connect([this] { + this->scrollBar_->getCurrentValueChanged().connect([this] { this->actuallyLayoutMessages(true); this->goToBottom_->setVisible(this->enableScrollingToBottom_ && - this->scrollBar_.isVisible() && - !this->scrollBar_.isAtBottom()); + this->scrollBar_->isVisible() && + !this->scrollBar_->isAtBottom()); this->queueUpdate(); }); - this->scrollBar_.getDesiredValueChanged().connect([this] { - this->pausedByScrollingUp_ = !this->scrollBar_.isAtBottom(); + this->scrollBar_->getDesiredValueChanged().connect([this] { + this->pausedByScrollingUp_ = !this->scrollBar_->isAtBottom(); }); } @@ -212,7 +218,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar) auto messagesSnapshot = this->getMessagesSnapshot(); if (messagesSnapshot.getLength() == 0) { - this->scrollBar_.setVisible(false); + this->scrollBar_->setVisible(false); return; } @@ -225,9 +231,9 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar) // The scrollbar was not visible // The scrollbar was visible and at the bottom this->showingLatestMessages_ = - this->scrollBar_.isAtBottom() || !this->scrollBar_.isVisible(); + this->scrollBar_->isAtBottom() || !this->scrollBar_->isVisible(); - size_t start = size_t(this->scrollBar_.getCurrentValue()); + size_t start = size_t(this->scrollBar_->getCurrentValue()); int layoutWidth = this->getLayoutWidth(); MessageElementFlags flags = this->getFlags(); @@ -235,7 +241,7 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar) // layout the visible messages in the view if (messagesSnapshot.getLength() > start) { int y = int(-(messagesSnapshot[start]->getHeight() * - (fmod(this->scrollBar_.getCurrentValue(), 1)))); + (fmod(this->scrollBar_->getCurrentValue(), 1)))); for (size_t i = start; i < messagesSnapshot.getLength(); ++i) { auto message = messagesSnapshot[i]; @@ -262,8 +268,9 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar) h -= message->getHeight(); if (h < 0) { - this->scrollBar_.setLargeChange((messagesSnapshot.getLength() - i) + - qreal(h) / message->getHeight()); + this->scrollBar_->setLargeChange( + (messagesSnapshot.getLength() - i) + + qreal(h) / message->getHeight()); // this->scrollBar.setDesiredValue(this->scrollBar.getDesiredValue()); showScrollbar = true; @@ -271,20 +278,20 @@ void ChannelView::actuallyLayoutMessages(bool causedByScrollbar) } } - this->scrollBar_.setVisible(showScrollbar); + this->scrollBar_->setVisible(showScrollbar); if (!showScrollbar && !causedByScrollbar) { - this->scrollBar_.setDesiredValue(0); + this->scrollBar_->setDesiredValue(0); } - this->scrollBar_.setMaximum(messagesSnapshot.getLength()); + this->scrollBar_->setMaximum(messagesSnapshot.getLength()); // If we were showing the latest messages and the scrollbar now wants to be // rendered, scroll to bottom if (this->enableScrollingToBottom_ && this->showingLatestMessages_ && showScrollbar) { if (!this->isPaused()) { - this->scrollBar_.scrollToBottom( + this->scrollBar_->scrollToBottom( // this->messageWasAdded && app->settings->enableSmoothScrollingNewMessages.getValue()); } @@ -309,7 +316,7 @@ void ChannelView::clearMessages() Scrollbar &ChannelView::getScrollBar() { - return this->scrollBar_; + return *this->scrollBar_; } QString ChannelView::getSelectedText() @@ -378,7 +385,7 @@ const boost::optional &ChannelView::getOverrideFlags() LimitedQueueSnapshot ChannelView::getMessagesSnapshot() { - if (!this->isPaused() /*|| this->scrollBar_.isVisible()*/) { + if (!this->isPaused() /*|| this->scrollBar_->isVisible()*/) { this->snapshot_ = this->messages.getSnapshot(); } @@ -413,10 +420,10 @@ void ChannelView::setChannel(ChannelPtr newChannel) if (this->messages.pushBack(MessageLayoutPtr(messageRef), deleted)) { // if (!this->isPaused()) { - if (this->scrollBar_.isAtBottom()) { - this->scrollBar_.scrollToBottom(); + if (this->scrollBar_->isAtBottom()) { + this->scrollBar_->scrollToBottom(); } else { - this->scrollBar_.offset(-1); + this->scrollBar_->offset(-1); } // } } @@ -431,7 +438,7 @@ void ChannelView::setChannel(ChannelPtr newChannel) } } - this->scrollBar_.addHighlight(message->getScrollBarHighlight()); + this->scrollBar_->addHighlight(message->getScrollBarHighlight()); this->messageWasAdded_ = true; this->layoutMessages(); @@ -449,10 +456,10 @@ void ChannelView::setChannel(ChannelPtr newChannel) if (!this->isPaused()) { if (this->messages.pushFront(messageRefs).size() > 0) { - if (this->scrollBar_.isAtBottom()) { - this->scrollBar_.scrollToBottom(); + if (this->scrollBar_->isAtBottom()) { + this->scrollBar_->scrollToBottom(); } else { - this->scrollBar_.offset(qreal(messages.size())); + this->scrollBar_->offset(qreal(messages.size())); } } } @@ -464,7 +471,7 @@ void ChannelView::setChannel(ChannelPtr newChannel) messages.at(i)->getScrollBarHighlight()); } - this->scrollBar_.addHighlightsAtStart(highlights); + this->scrollBar_->addHighlightsAtStart(highlights); this->messageWasAdded_ = true; this->layoutMessages(); @@ -503,7 +510,7 @@ void ChannelView::setChannel(ChannelPtr newChannel) newItem->flags.set(MessageLayoutFlag::AlternateBackground); } - this->scrollBar_.replaceHighlight( + this->scrollBar_->replaceHighlight( index, replacement->getScrollBarHighlight()); this->messages.replaceItem(message, newItem); @@ -563,12 +570,12 @@ void ChannelView::updateLastReadMessage() void ChannelView::resizeEvent(QResizeEvent *) { - this->scrollBar_.setGeometry(this->width() - this->scrollBar_.width(), 0, - this->scrollBar_.width(), this->height()); + this->scrollBar_->setGeometry(this->width() - this->scrollBar_->width(), 0, + this->scrollBar_->width(), this->height()); this->goToBottom_->setGeometry(0, this->height() - 32, this->width(), 32); - this->scrollBar_.raise(); + this->scrollBar_->raise(); this->layoutMessages(); @@ -625,9 +632,9 @@ bool ChannelView::isPaused() void ChannelView::updatePauseStatus() { if (this->isPaused()) { - this->scrollBar_.pauseHighlights(); + this->scrollBar_->pauseHighlights(); } else { - this->scrollBar_.unpauseHighlights(); + this->scrollBar_->unpauseHighlights(); } } @@ -651,14 +658,14 @@ void ChannelView::drawMessages(QPainter &painter) auto messagesSnapshot = this->getMessagesSnapshot(); - size_t start = size_t(this->scrollBar_.getCurrentValue()); + size_t start = size_t(this->scrollBar_->getCurrentValue()); if (start >= messagesSnapshot.getLength()) { return; } int y = int(-(messagesSnapshot[start].get()->getHeight() * - (fmod(this->scrollBar_.getCurrentValue(), 1)))); + (fmod(this->scrollBar_->getCurrentValue(), 1)))); MessageLayout *end = nullptr; bool windowFocused = this->window() == QApplication::activeWindow(); @@ -729,12 +736,12 @@ void ChannelView::wheelEvent(QWheelEvent *event) return; } - if (this->scrollBar_.isVisible()) { + if (this->scrollBar_->isVisible()) { auto app = getApp(); float mouseMultiplier = app->settings->mouseScrollMultiplier; - qreal desired = this->scrollBar_.getDesiredValue(); + qreal desired = this->scrollBar_->getDesiredValue(); qreal delta = event->delta() * qreal(1.5) * mouseMultiplier; auto snapshot = this->getMessagesSnapshot(); @@ -792,7 +799,7 @@ void ChannelView::wheelEvent(QWheelEvent *event) } } - this->scrollBar_.setDesiredValue(desired, true); + this->scrollBar_->setDesiredValue(desired, true); } } @@ -1192,14 +1199,14 @@ bool ChannelView::tryGetMessageAt(QPoint p, { auto messagesSnapshot = this->getMessagesSnapshot(); - size_t start = this->scrollBar_.getCurrentValue(); + size_t start = this->scrollBar_->getCurrentValue(); if (start >= messagesSnapshot.getLength()) { return false; } int y = -(messagesSnapshot[start]->getHeight() * - (fmod(this->scrollBar_.getCurrentValue(), 1))); + (fmod(this->scrollBar_->getCurrentValue(), 1))); for (size_t i = start; i < messagesSnapshot.getLength(); ++i) { auto message = messagesSnapshot[i]; @@ -1219,7 +1226,7 @@ bool ChannelView::tryGetMessageAt(QPoint p, int ChannelView::getLayoutWidth() const { - if (this->scrollBar_.isVisible()) + if (this->scrollBar_->isVisible()) return int(this->width() - 8 * this->getScale()); return this->width(); diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index cb8ad990f..46e51bebe 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -1,14 +1,10 @@ #pragma once -#include "common/Channel.hpp" -#include "messages/Image.hpp" +#include "common/FlagsEnum.hpp" +#include "messages/LimitedQueue.hpp" #include "messages/LimitedQueueSnapshot.hpp" -#include "messages/MessageElement.hpp" #include "messages/Selection.hpp" -#include "messages/layouts/MessageLayout.hpp" #include "widgets/BaseWidget.hpp" -#include "widgets/Scrollbar.hpp" -#include "widgets/helper/EffectLabel.hpp" #include #include @@ -20,8 +16,23 @@ #include namespace chatterino { +enum class HighlightState; -class ChannelView : public BaseWidget +class Channel; +using ChannelPtr = std::shared_ptr; + +class MessageLayout; +using MessageLayoutPtr = std::shared_ptr; + +enum class MessageElementFlag; +using MessageElementFlags = FlagsEnum; + +class Scrollbar; +class EffectLabel; +struct Link; +class MessageLayoutElement; + +class ChannelView final : public BaseWidget { Q_OBJECT @@ -121,7 +132,7 @@ private: ChannelPtr channel_; - Scrollbar scrollBar_; + Scrollbar *scrollBar_; EffectLabel *goToBottom_; // This variable can be used to decide whether or not we should render the diff --git a/src/widgets/helper/NotebookButton.cpp b/src/widgets/helper/NotebookButton.cpp index 926c42c24..c7ef9e1db 100644 --- a/src/widgets/helper/NotebookButton.cpp +++ b/src/widgets/helper/NotebookButton.cpp @@ -2,6 +2,7 @@ #include "singletons/Theme.hpp" #include "widgets/Notebook.hpp" #include "widgets/helper/Button.hpp" +#include "widgets/splits/Split.hpp" #include "widgets/splits/SplitContainer.hpp" #include diff --git a/src/widgets/helper/NotebookTab.cpp b/src/widgets/helper/NotebookTab.cpp index 5581f5e50..865eb6048 100644 --- a/src/widgets/helper/NotebookTab.cpp +++ b/src/widgets/helper/NotebookTab.cpp @@ -3,6 +3,7 @@ #include "Application.hpp" #include "common/Common.hpp" #include "debug/Log.hpp" +#include "singletons/Fonts.hpp" #include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "util/Clamp.hpp" @@ -10,6 +11,7 @@ #include "widgets/Notebook.hpp" #include "widgets/dialogs/SettingsDialog.hpp" #include "widgets/dialogs/TextInputDialog.hpp" +#include "widgets/splits/SplitContainer.hpp" #include #include diff --git a/src/widgets/helper/ScrollbarHighlight.hpp b/src/widgets/helper/ScrollbarHighlight.hpp index b88cdae09..e34cf913b 100644 --- a/src/widgets/helper/ScrollbarHighlight.hpp +++ b/src/widgets/helper/ScrollbarHighlight.hpp @@ -1,7 +1,5 @@ #pragma once -#include - namespace chatterino { class ScrollbarHighlight diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index b67addb18..81439407a 100644 --- a/src/widgets/helper/SearchPopup.cpp +++ b/src/widgets/helper/SearchPopup.cpp @@ -6,6 +6,7 @@ #include #include "common/Channel.hpp" +#include "messages/Message.hpp" #include "widgets/helper/ChannelView.hpp" namespace chatterino { diff --git a/src/widgets/helper/SearchPopup.hpp b/src/widgets/helper/SearchPopup.hpp index 0a7065c55..1f2837fbe 100644 --- a/src/widgets/helper/SearchPopup.hpp +++ b/src/widgets/helper/SearchPopup.hpp @@ -1,7 +1,6 @@ #pragma once #include "messages/LimitedQueueSnapshot.hpp" -#include "messages/Message.hpp" #include "widgets/BaseWindow.hpp" #include @@ -13,6 +12,9 @@ namespace chatterino { class Channel; class ChannelView; +struct Message; +using MessagePtr = std::shared_ptr; + class SearchPopup : public BaseWindow { public: diff --git a/src/widgets/helper/TitlebarButton.cpp b/src/widgets/helper/TitlebarButton.cpp index c92e94ba6..d5ab4cc4a 100644 --- a/src/widgets/helper/TitlebarButton.cpp +++ b/src/widgets/helper/TitlebarButton.cpp @@ -9,12 +9,12 @@ TitleBarButton::TitleBarButton() { } -TitleBarButton::Style TitleBarButton::getButtonStyle() const +TitleBarButtonStyle TitleBarButton::getButtonStyle() const { return this->style_; } -void TitleBarButton::setButtonStyle(Style _style) +void TitleBarButton::setButtonStyle(TitleBarButtonStyle _style) { this->style_ = _style; this->update(); @@ -35,16 +35,16 @@ void TitleBarButton::paintEvent(QPaintEvent *event) painter.setRenderHint(QPainter::Antialiasing, false); switch (this->style_) { - case Minimize: { + case TitleBarButtonStyle::Minimize: { painter.fillRect(centerX - xD / 2, xD * 3 / 2, xD, 1, color); break; } - case Maximize: { + case TitleBarButtonStyle::Maximize: { painter.setPen(color); painter.drawRect(centerX - xD / 2, xD, xD - 1, xD - 1); break; } - case Unmaximize: { + case TitleBarButtonStyle::Unmaximize: { int xD2 = xD * 1 / 5; int xD3 = xD * 4 / 5; @@ -54,7 +54,7 @@ void TitleBarButton::paintEvent(QPaintEvent *event) painter.drawRect(centerX - xD / 2, xD + xD2, xD3, xD3); break; } - case Close: { + case TitleBarButtonStyle::Close: { QRect rect(centerX - xD / 2, xD, xD - 1, xD - 1); painter.setPen(QPen(color, 1)); @@ -62,7 +62,7 @@ void TitleBarButton::paintEvent(QPaintEvent *event) painter.drawLine(rect.topRight(), rect.bottomLeft()); break; } - case User: { + case TitleBarButtonStyle::User: { color = "#999"; painter.setRenderHint(QPainter::Antialiasing); @@ -88,7 +88,7 @@ void TitleBarButton::paintEvent(QPaintEvent *event) break; } - case Settings: { + case TitleBarButtonStyle::Settings: { color = "#999"; painter.setRenderHint(QPainter::Antialiasing); painter.setRenderHint(QPainter::HighQualityAntialiasing); diff --git a/src/widgets/helper/TitlebarButton.hpp b/src/widgets/helper/TitlebarButton.hpp index 33777660f..ed1261e9e 100644 --- a/src/widgets/helper/TitlebarButton.hpp +++ b/src/widgets/helper/TitlebarButton.hpp @@ -4,29 +4,29 @@ namespace chatterino { +enum class TitleBarButtonStyle { + None = 0, + Minimize = 1, + Maximize = 2, + Unmaximize = 4, + Close = 8, + User = 16, + Settings = 32 +}; + class TitleBarButton : public Button { public: - enum Style { - None = 0, - Minimize = 1, - Maximize = 2, - Unmaximize = 4, - Close = 8, - User = 16, - Settings = 32 - }; - TitleBarButton(); - Style getButtonStyle() const; - void setButtonStyle(Style style_); + TitleBarButtonStyle getButtonStyle() const; + void setButtonStyle(TitleBarButtonStyle style_); protected: void paintEvent(QPaintEvent *) override; private: - Style style_; + TitleBarButtonStyle style_; }; } // namespace chatterino diff --git a/src/widgets/settingspages/IgnoresPage.cpp b/src/widgets/settingspages/IgnoresPage.cpp index 51d7cda71..b23ecbb89 100644 --- a/src/widgets/settingspages/IgnoresPage.cpp +++ b/src/widgets/settingspages/IgnoresPage.cpp @@ -4,6 +4,7 @@ #include "controllers/accounts/AccountController.hpp" #include "controllers/ignores/IgnoreController.hpp" #include "controllers/ignores/IgnoreModel.hpp" +#include "providers/twitch/TwitchAccount.hpp" #include "singletons/Settings.hpp" #include "util/LayoutCreator.hpp" #include "widgets/helper/EditableModelView.hpp" diff --git a/src/widgets/settingspages/LookPage.cpp b/src/widgets/settingspages/LookPage.cpp index 8cdcfd5f9..08a6ec77a 100644 --- a/src/widgets/settingspages/LookPage.cpp +++ b/src/widgets/settingspages/LookPage.cpp @@ -1,10 +1,14 @@ #include "LookPage.hpp" #include "Application.hpp" +#include "messages/Image.hpp" #include "messages/MessageBuilder.hpp" +#include "singletons/Resources.hpp" +#include "singletons/Theme.hpp" #include "singletons/WindowManager.hpp" #include "util/LayoutCreator.hpp" #include "util/RemoveScrollAreaBackground.hpp" +#include "widgets/helper/ChannelView.hpp" #include "widgets/helper/Line.hpp" #include @@ -416,7 +420,7 @@ QLayout *LookPage::createFontChanger() button->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Policy::Fixed); QObject::connect(button, &QPushButton::clicked, [=]() { - QFontDialog dialog(app->fonts->getFont(Fonts::ChatMedium, 1.)); + QFontDialog dialog(app->fonts->getFont(FontStyle::ChatMedium, 1.)); dialog.setWindowFlag(Qt::WindowStaysOnTopHint); diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 38b390697..01a2faaad 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -1,8 +1,8 @@ #include "widgets/splits/Split.hpp" -#include "Application.hpp" #include "common/Common.hpp" #include "common/NetworkRequest.hpp" +#include "debug/Log.hpp" #include "providers/twitch/EmoteValue.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchMessageBuilder.hpp" @@ -11,15 +11,20 @@ #include "singletons/Theme.hpp" #include "singletons/WindowManager.hpp" #include "util/StreamLink.hpp" +#include "widgets/Notebook.hpp" #include "widgets/Window.hpp" #include "widgets/dialogs/QualityPopup.hpp" #include "widgets/dialogs/SelectChannelDialog.hpp" #include "widgets/dialogs/TextInputDialog.hpp" #include "widgets/dialogs/UserInfoPopup.hpp" +#include "widgets/helper/ChannelView.hpp" #include "widgets/helper/DebugPopup.hpp" +#include "widgets/helper/ResizingTextEdit.hpp" #include "widgets/helper/SearchPopup.hpp" #include "widgets/helper/Shortcut.hpp" #include "widgets/splits/SplitContainer.hpp" +#include "widgets/splits/SplitHeader.hpp" +#include "widgets/splits/SplitInput.hpp" #include "widgets/splits/SplitOverlay.hpp" #include @@ -37,7 +42,6 @@ #include namespace chatterino { - pajlada::Signals::Signal Split::modifierStatusChanged; Qt::KeyboardModifiers Split::modifierStatus = Qt::NoModifier; @@ -51,20 +55,20 @@ Split::Split(QWidget *parent) : BaseWidget(parent) , container_(nullptr) , channel_(Channel::getEmpty()) - , vbox_(this) - , header_(this) - , view_(this) - , input_(this) + , vbox_(new QVBoxLayout(this)) + , header_(new SplitHeader(this)) + , view_(new ChannelView(this)) + , input_(new SplitInput(this)) , overlay_(new SplitOverlay(this)) { this->setMouseTracking(true); - this->vbox_.setSpacing(0); - this->vbox_.setMargin(1); + this->vbox_->setSpacing(0); + this->vbox_->setMargin(1); - this->vbox_.addWidget(&this->header_); - this->vbox_.addWidget(&this->view_, 1); - this->vbox_.addWidget(&this->input_); + this->vbox_->addWidget(this->header_); + this->vbox_->addWidget(this->view_, 1); + this->vbox_->addWidget(this->input_); // Initialize chat widget-wide hotkeys // CTRL+W: Close Split @@ -89,41 +93,41 @@ Split::Split(QWidget *parent) // CreateShortcut(this, "ALT+SHIFT+UP", &Split::doIncFlexY); // CreateShortcut(this, "ALT+SHIFT+DOWN", &Split::doDecFlexY); - this->input_.ui_.textEdit->installEventFilter(parent); + this->input_->ui_.textEdit->installEventFilter(parent); - this->view_.mouseDown.connect([this](QMouseEvent *) { + this->view_->mouseDown.connect([this](QMouseEvent *) { // this->giveFocus(Qt::MouseFocusReason); }); - this->view_.selectionChanged.connect([this]() { - if (view_.hasSelection()) { - this->input_.clearSelection(); + this->view_->selectionChanged.connect([this]() { + if (view_->hasSelection()) { + this->input_->clearSelection(); } }); - this->input_.textChanged.connect([=](const QString &newText) { + this->input_->textChanged.connect([=](const QString &newText) { if (getSettings()->showEmptyInput) { return; } if (newText.length() == 0) { - this->input_.hide(); - } else if (this->input_.isHidden()) { - this->input_.show(); + this->input_->hide(); + } else if (this->input_->isHidden()) { + this->input_->show(); } }); getSettings()->showEmptyInput.connect( [this](const bool &showEmptyInput, auto) { - if (!showEmptyInput && this->input_.getInputText().length() == 0) { - this->input_.hide(); + if (!showEmptyInput && this->input_->getInputText().length() == 0) { + this->input_->hide(); } else { - this->input_.show(); + this->input_->show(); } }, this->managedConnections_); - this->header_.updateModerationModeIcon(); + this->header_->updateModerationModeIcon(); this->overlay_->hide(); this->setSizePolicy(QSizePolicy::MinimumExpanding, @@ -139,9 +143,9 @@ Split::Split(QWidget *parent) } }); - this->input_.ui_.textEdit->focused.connect( + this->input_->ui_.textEdit->focused.connect( [this] { this->focused.invoke(); }); - this->input_.ui_.textEdit->focusLost.connect( + this->input_->ui_.textEdit->focusLost.connect( [this] { this->focusLost.invoke(); }); } @@ -155,7 +159,7 @@ Split::~Split() ChannelView &Split::getChannelView() { - return this->view_; + return *this->view_; } SplitContainer *Split::getContainer() @@ -187,7 +191,7 @@ void Split::setChannel(IndirectChannel newChannel) { this->channel_ = newChannel; - this->view_.setChannel(newChannel.get()); + this->view_->setChannel(newChannel.get()); this->usermodeChangedConnection_.disconnect(); this->roomModeChangedConnection_.disconnect(); @@ -197,12 +201,12 @@ void Split::setChannel(IndirectChannel newChannel) if (tc != nullptr) { this->usermodeChangedConnection_ = tc->userStateChanged.connect([this] { - this->header_.updateModerationModeIcon(); - this->header_.updateRoomModes(); + this->header_->updateModerationModeIcon(); + this->header_->updateRoomModes(); }); this->roomModeChangedConnection_ = tc->roomModesChanged.connect( - [this] { this->header_.updateRoomModes(); }); + [this] { this->header_->updateRoomModes(); }); } this->indirectChannelChangedConnection_ = @@ -210,9 +214,9 @@ void Split::setChannel(IndirectChannel newChannel) QTimer::singleShot(0, [this] { this->setChannel(this->channel_); }); }); - this->header_.updateModerationModeIcon(); - this->header_.updateChannelText(); - this->header_.updateRoomModes(); + this->header_->updateModerationModeIcon(); + this->header_->updateChannelText(); + this->header_->updateRoomModes(); this->channelChanged.invoke(); } @@ -221,8 +225,8 @@ void Split::setModerationMode(bool value) { if (value != this->moderationMode_) { this->moderationMode_ = value; - this->header_.updateModerationModeIcon(); - this->view_.layoutMessages(); + this->header_->updateModerationModeIcon(); + this->view_->layoutMessages(); } } @@ -233,7 +237,7 @@ bool Split::getModerationMode() const void Split::insertTextToInput(const QString &text) { - this->input_.insertText(text); + this->input_->insertText(text); } void Split::showChangeChannelPopup(const char *dialogTitle, bool empty, @@ -267,27 +271,27 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty, void Split::layoutMessages() { - this->view_.layoutMessages(); + this->view_->layoutMessages(); } void Split::updateGifEmotes() { - this->view_.queueUpdate(); + this->view_->queueUpdate(); } void Split::updateLastReadMessage() { - this->view_.updateLastReadMessage(); + this->view_->updateLastReadMessage(); } void Split::giveFocus(Qt::FocusReason reason) { - this->input_.ui_.textEdit->setFocus(reason); + this->input_->ui_.textEdit->setFocus(reason); } bool Split::hasFocus() const { - return this->input_.ui_.textEdit->hasFocus(); + return this->input_->ui_.textEdit->hasFocus(); } void Split::paintEvent(QPaintEvent *) @@ -305,13 +309,13 @@ void Split::mouseMoveEvent(QMouseEvent *event) void Split::keyPressEvent(QKeyEvent *event) { - this->view_.unsetCursor(); + this->view_->unsetCursor(); this->handleModifiers(QGuiApplication::queryKeyboardModifiers()); } void Split::keyReleaseEvent(QKeyEvent *event) { - this->view_.unsetCursor(); + this->view_->unsetCursor(); this->handleModifiers(QGuiApplication::queryKeyboardModifiers()); } @@ -389,7 +393,7 @@ void Split::changeChannel() void Split::popup() { auto app = getApp(); - Window &window = app->windows->createWindow(Window::Type::Popup); + Window &window = app->windows->createWindow(WindowType::Popup); Split *split = new Split(static_cast( window.getNotebook().getOrAddSelectedPage())); @@ -402,7 +406,7 @@ void Split::popup() void Split::clear() { - this->view_.clearMessages(); + this->view_->clearMessages(); } void Split::openInBrowser() @@ -442,8 +446,8 @@ void Split::showViewerList() QDockWidget::DockWidgetFloatable); viewerDock->resize( 0.5 * this->width(), - this->height() - this->header_.height() - this->input_.height()); - viewerDock->move(0, this->header_.height()); + this->height() - this->header_->height() - this->input_->height()); + viewerDock->move(0, this->header_->height()); auto multiWidget = new QWidget(viewerDock); auto dockVbox = new QVBoxLayout(viewerDock); @@ -543,7 +547,7 @@ void Split::showUserInfoPopup(const UserName &user) void Split::copyToClipboard() { - QApplication::clipboard()->setText(this->view_.getSelectedText()); + QApplication::clipboard()->setText(this->view_->getSelectedText()); } void Split::showSearch() diff --git a/src/widgets/splits/Split.hpp b/src/widgets/splits/Split.hpp index ca185dbdb..8c4ebf84a 100644 --- a/src/widgets/splits/Split.hpp +++ b/src/widgets/splits/Split.hpp @@ -1,17 +1,9 @@ #pragma once +#include "common/Aliases.hpp" #include "common/Channel.hpp" #include "common/NullablePtr.hpp" -#include "messages/LimitedQueueSnapshot.hpp" -#include "messages/MessageElement.hpp" -#include "messages/layouts/MessageLayout.hpp" -#include "messages/layouts/MessageLayoutElement.hpp" -#include "util/RapidJsonSerializeQString.hpp" #include "widgets/BaseWidget.hpp" -#include "widgets/helper/ChannelView.hpp" -#include "widgets/helper/EffectLabel.hpp" -#include "widgets/splits/SplitHeader.hpp" -#include "widgets/splits/SplitInput.hpp" #include #include @@ -20,6 +12,9 @@ namespace chatterino { +class ChannelView; +class SplitHeader; +class SplitInput; class SplitContainer; class SplitOverlay; class SelectChannelDialog; @@ -103,10 +98,10 @@ private: SplitContainer *container_; IndirectChannel channel_; - QVBoxLayout vbox_; - SplitHeader header_; - ChannelView view_; - SplitInput input_; + QVBoxLayout *vbox_; + SplitHeader *header_; + ChannelView *view_; + SplitInput *input_; SplitOverlay *overlay_; NullablePtr selectChannelDialog_; diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index ecbadc21d..cac6f2dfb 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -7,6 +7,7 @@ #include "util/Helpers.hpp" #include "util/LayoutCreator.hpp" #include "widgets/Notebook.hpp" +#include "widgets/helper/ChannelView.hpp" #include "widgets/helper/NotebookTab.hpp" #include "widgets/splits/Split.hpp" diff --git a/src/widgets/splits/SplitContainer.hpp b/src/widgets/splits/SplitContainer.hpp index 7bd2ced1a..1f0a2e701 100644 --- a/src/widgets/splits/SplitContainer.hpp +++ b/src/widgets/splits/SplitContainer.hpp @@ -1,8 +1,6 @@ #pragma once #include "widgets/BaseWidget.hpp" -#include "widgets/helper/NotebookTab.hpp" -#include "widgets/splits/Split.hpp" #include #include @@ -13,21 +11,24 @@ #include #include -#include - #include #include +#include class QJsonObject; namespace chatterino { +class Split; +class NotebookTab; +class Notebook; + // // Note: This class is a spaghetti container. There is a lot of spaghetti code // inside but it doesn't expose any of it publicly. // -class SplitContainer : public BaseWidget, pajlada::Signals::SignalHolder +class SplitContainer final : public BaseWidget, pajlada::Signals::SignalHolder { Q_OBJECT diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index 882f0b9eb..d99448221 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -5,17 +5,20 @@ #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchServer.hpp" #include "singletons/Resources.hpp" +#include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "util/LayoutCreator.hpp" #include "util/LayoutHelper.hpp" #include "widgets/Label.hpp" #include "widgets/TooltipWidget.hpp" +#include "widgets/helper/EffectLabel.hpp" #include "widgets/splits/Split.hpp" #include "widgets/splits/SplitContainer.hpp" #include #include #include +#include #include #include #include diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 65bc37e5c..8fbc62f02 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -2,14 +2,20 @@ #include "Application.hpp" #include "controllers/commands/CommandController.hpp" +#include "messages/Link.hpp" #include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchServer.hpp" #include "singletons/Settings.hpp" #include "singletons/Theme.hpp" #include "util/LayoutCreator.hpp" #include "widgets/Notebook.hpp" +#include "widgets/dialogs/EmotePopup.hpp" +#include "widgets/helper/ChannelView.hpp" +#include "widgets/helper/EffectLabel.hpp" +#include "widgets/helper/ResizingTextEdit.hpp" #include "widgets/splits/Split.hpp" #include "widgets/splits/SplitContainer.hpp" +#include "widgets/splits/SplitInput.hpp" #include #include @@ -70,11 +76,11 @@ void SplitInput::initLayout() // set edit font this->ui_.textEdit->setFont( - app->fonts->getFont(Fonts::Type::ChatMedium, this->getScale())); + app->fonts->getFont(FontStyle::ChatMedium, this->getScale())); this->managedConnections_.push_back(app->fonts->fontChanged.connect([=]() { this->ui_.textEdit->setFont( - app->fonts->getFont(Fonts::Type::ChatMedium, this->getScale())); + app->fonts->getFont(FontStyle::ChatMedium, this->getScale())); })); // open emote popup @@ -98,7 +104,7 @@ void SplitInput::initLayout() QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable, [this](bool available) { if (available) { - this->split_->view_.clearSelection(); + this->split_->view_->clearSelection(); } }); @@ -273,7 +279,7 @@ void SplitInput::installKeyPressedEvent() } } else if (event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier) { - if (this->split_->view_.hasSelection()) { + if (this->split_->view_->hasSelection()) { this->split_->copyToClipboard(); event->accept(); } diff --git a/src/widgets/splits/SplitInput.hpp b/src/widgets/splits/SplitInput.hpp index ddcf2c97d..6ad6f4f83 100644 --- a/src/widgets/splits/SplitInput.hpp +++ b/src/widgets/splits/SplitInput.hpp @@ -1,9 +1,6 @@ #pragma once #include "widgets/BaseWidget.hpp" -#include "widgets/dialogs/EmotePopup.hpp" -#include "widgets/helper/ResizingTextEdit.hpp" -#include "widgets/helper/EffectLabel.hpp" #include #include @@ -16,6 +13,9 @@ namespace chatterino { class Split; +class EmotePopup; +class EffectLabel; +class ResizingTextEdit; class SplitInput : public BaseWidget { @@ -45,7 +45,7 @@ private: void updateEmoteButton(); Split *const split_; - std::unique_ptr emotePopup_; + std::shared_ptr emotePopup_; struct { ResizingTextEdit *textEdit; diff --git a/src/widgets/splits/SplitOverlay.cpp b/src/widgets/splits/SplitOverlay.cpp index 268811b20..1b38c0ca2 100644 --- a/src/widgets/splits/SplitOverlay.cpp +++ b/src/widgets/splits/SplitOverlay.cpp @@ -10,6 +10,7 @@ #include "Application.hpp" #include "singletons/Resources.hpp" +#include "singletons/Theme.hpp" #include "widgets/splits/Split.hpp" #include "widgets/splits/SplitContainer.hpp"