From 280bb4cf8e92763d464ae08285bda45c341282af Mon Sep 17 00:00:00 2001 From: fourtf Date: Fri, 6 Jul 2018 19:23:47 +0200 Subject: [PATCH] Renamed private members --- chatterino.pro | 12 +- src/Application.cpp | 6 +- src/Application.hpp | 6 +- src/controllers/ignores/IgnoreController.cpp | 8 +- src/controllers/ignores/IgnoreController.hpp | 4 +- src/controllers/ignores/IgnorePhrase.hpp | 31 +- .../moderationactions/ModerationAction.hpp | 2 +- .../moderationactions/ModerationActions.cpp | 8 +- .../moderationactions/ModerationActions.hpp | 4 +- src/controllers/taggedusers/TaggedUser.cpp | 27 +- src/controllers/taggedusers/TaggedUser.hpp | 13 +- .../taggedusers/TaggedUsersModel.cpp | 2 +- src/messages/LimitedQueue.hpp | 118 ++--- src/messages/LimitedQueueSnapshot.hpp | 30 +- src/messages/Message.cpp | 4 +- src/messages/Message.hpp | 2 +- src/messages/MessageBuilder.cpp | 10 +- src/messages/MessageBuilder.hpp | 2 +- src/messages/MessageColor.cpp | 14 +- src/messages/MessageColor.hpp | 6 +- src/messages/MessageElement.cpp | 106 ++-- src/messages/MessageElement.hpp | 41 +- .../layouts/MessageLayoutContainer.cpp | 230 ++++----- .../layouts/MessageLayoutContainer.hpp | 43 +- src/messages/layouts/MessageLayoutElement.cpp | 16 +- src/messages/layouts/MessageLayoutElement.hpp | 16 +- src/providers/bttv/BttvEmotes.cpp | 2 +- src/providers/bttv/BttvEmotes.hpp | 2 +- src/providers/emoji/Emojis.cpp | 24 +- src/providers/emoji/Emojis.hpp | 18 +- src/providers/ffz/FfzEmotes.cpp | 2 +- src/providers/ffz/FfzEmotes.hpp | 2 +- src/providers/twitch/EmoteValue.hpp | 12 +- .../twitch/{Pubsub.cpp => PubsubClient.cpp} | 48 +- .../twitch/{Pubsub.hpp => PubsubClient.hpp} | 18 +- src/providers/twitch/TwitchAccount.cpp | 50 +- src/providers/twitch/TwitchAccount.hpp | 16 +- src/providers/twitch/TwitchAccountManager.cpp | 20 +- src/providers/twitch/TwitchAccountManager.hpp | 6 +- src/providers/twitch/TwitchChannel.cpp | 108 ++--- src/providers/twitch/TwitchChannel.hpp | 47 +- src/providers/twitch/TwitchEmotes.cpp | 2 +- src/providers/twitch/TwitchEmotes.hpp | 6 +- src/providers/twitch/TwitchMessageBuilder.cpp | 60 +-- src/providers/twitch/TwitchMessageBuilder.hpp | 19 +- src/providers/twitch/TwitchServer.hpp | 4 +- src/singletons/Fonts.cpp | 8 +- src/singletons/Fonts.hpp | 2 +- src/singletons/Logging.cpp | 6 +- src/singletons/Logging.hpp | 2 +- src/singletons/Paths.cpp | 6 +- src/singletons/Paths.hpp | 6 +- src/singletons/Settings.cpp | 6 +- src/singletons/Settings.hpp | 4 +- src/singletons/Theme.cpp | 22 +- src/singletons/Theme.hpp | 13 +- src/singletons/WindowManager.cpp | 64 +-- src/singletons/WindowManager.hpp | 48 +- src/util/ConcurrentMap.hpp | 38 +- src/util/DebugCount.cpp | 4 +- src/util/DebugCount.hpp | 27 +- src/util/LayoutCreator.hpp | 38 +- src/util/PostToThread.hpp | 6 +- src/util/StreamLink.cpp | 20 +- src/util/StreamLink.hpp | 4 +- src/widgets/AccountSwitchPopupWidget.cpp | 8 +- src/widgets/AccountSwitchPopupWidget.hpp | 2 +- src/widgets/AttachedWindow.hpp | 30 +- src/widgets/BaseWindow.cpp | 2 +- src/widgets/BaseWindow.hpp | 2 +- src/widgets/Label.hpp | 6 +- src/widgets/Notebook.cpp | 136 +++--- src/widgets/Notebook.hpp | 23 +- src/widgets/Scrollbar.hpp | 6 +- src/widgets/TooltipWidget.cpp | 14 +- src/widgets/TooltipWidget.hpp | 6 +- src/widgets/dialogs/EmotePopup.cpp | 24 +- src/widgets/dialogs/EmotePopup.hpp | 4 +- src/widgets/dialogs/LoginDialog.cpp | 116 ++--- src/widgets/dialogs/LoginDialog.hpp | 6 +- src/widgets/dialogs/LogsPopup.hpp | 10 +- src/widgets/dialogs/NotificationPopup.cpp | 10 +- src/widgets/dialogs/NotificationPopup.hpp | 4 +- src/widgets/dialogs/QualityPopup.cpp | 6 +- src/widgets/dialogs/QualityPopup.hpp | 8 +- src/widgets/dialogs/SelectChannelDialog.cpp | 28 +- src/widgets/dialogs/SelectChannelDialog.hpp | 8 +- src/widgets/dialogs/SettingsDialog.cpp | 34 +- src/widgets/dialogs/SettingsDialog.hpp | 28 +- src/widgets/dialogs/TextInputDialog.cpp | 46 +- src/widgets/dialogs/TextInputDialog.hpp | 21 +- src/widgets/dialogs/UserInfoPopup.cpp | 6 +- src/widgets/dialogs/UserInfoPopup.hpp | 11 +- src/widgets/helper/ChannelView.hpp | 41 +- src/widgets/helper/ComboBoxItemDelegate.hpp | 2 +- src/widgets/helper/DropOverlay.cpp | 13 - src/widgets/helper/DropOverlay.hpp | 11 - src/widgets/helper/DropPreview.cpp | 53 -- src/widgets/helper/DropPreview.hpp | 26 - src/widgets/helper/EditableModelView.cpp | 28 +- src/widgets/helper/EditableModelView.hpp | 4 +- src/widgets/helper/NotebookButton.hpp | 2 +- src/widgets/helper/NotebookTab.hpp | 13 +- src/widgets/helper/ResizingTextEdit.cpp | 46 +- src/widgets/helper/ResizingTextEdit.hpp | 6 +- src/widgets/helper/RippleEffectButton.hpp | 14 +- src/widgets/helper/RippleEffectLabel.cpp | 14 +- src/widgets/helper/RippleEffectLabel.hpp | 6 +- src/widgets/helper/ScrollbarHighlight.cpp | 16 +- src/widgets/helper/ScrollbarHighlight.hpp | 6 +- src/widgets/helper/SearchPopup.cpp | 22 +- src/widgets/helper/SearchPopup.hpp | 8 +- src/widgets/helper/SettingsDialogTab.cpp | 22 +- src/widgets/helper/SettingsDialogTab.hpp | 12 +- src/widgets/helper/TitlebarButton.cpp | 6 +- src/widgets/helper/TitlebarButton.hpp | 4 +- src/widgets/settingspages/AboutPage.cpp | 2 +- src/widgets/settingspages/AboutPage.hpp | 6 +- src/widgets/settingspages/AccountsPage.hpp | 6 +- src/widgets/settingspages/CommandPage.cpp | 2 +- src/widgets/settingspages/CommandPage.hpp | 2 +- .../settingspages/ExternalToolsPage.cpp | 2 +- .../settingspages/HighlightingPage.cpp | 2 +- .../settingspages/HighlightingPage.hpp | 2 +- src/widgets/settingspages/IgnoresPage.cpp | 4 +- src/widgets/settingspages/IgnoresPage.hpp | 2 +- src/widgets/settingspages/LookPage.cpp | 4 +- src/widgets/settingspages/ModerationPage.cpp | 2 +- src/widgets/settingspages/ModerationPage.hpp | 2 +- src/widgets/settingspages/SettingsPage.cpp | 16 +- src/widgets/settingspages/SettingsPage.hpp | 8 +- src/widgets/splits/Split.cpp | 184 +++---- src/widgets/splits/Split.hpp | 48 +- src/widgets/splits/SplitContainer.cpp | 457 +++++++++--------- src/widgets/splits/SplitContainer.hpp | 86 ++-- src/widgets/splits/SplitHeader.cpp | 158 +++--- src/widgets/splits/SplitHeader.hpp | 29 +- src/widgets/splits/SplitInput.cpp | 4 +- src/widgets/splits/SplitInput.hpp | 9 +- src/widgets/splits/SplitOverlay.cpp | 32 +- src/widgets/splits/SplitOverlay.hpp | 15 +- 141 files changed, 1754 insertions(+), 1861 deletions(-) rename src/providers/twitch/{Pubsub.cpp => PubsubClient.cpp} (94%) rename src/providers/twitch/{Pubsub.hpp => PubsubClient.hpp} (94%) delete mode 100644 src/widgets/helper/DropOverlay.cpp delete mode 100644 src/widgets/helper/DropOverlay.hpp delete mode 100644 src/widgets/helper/DropPreview.cpp delete mode 100644 src/widgets/helper/DropPreview.hpp diff --git a/chatterino.pro b/chatterino.pro index cb275c2e1..a7be1fb49 100644 --- a/chatterino.pro +++ b/chatterino.pro @@ -138,7 +138,6 @@ SOURCES += \ src/providers/irc/IrcConnection2.cpp \ src/providers/irc/IrcServer.cpp \ src/providers/twitch/IrcMessageHandler.cpp \ - src/providers/twitch/Pubsub.cpp \ src/providers/twitch/PubsubActions.cpp \ src/providers/twitch/PubsubHelpers.cpp \ src/providers/twitch/TwitchAccount.cpp \ @@ -177,8 +176,6 @@ SOURCES += \ src/widgets/helper/ChannelView.cpp \ src/widgets/helper/ComboBoxItemDelegate.cpp \ src/widgets/helper/DebugPopup.cpp \ - src/widgets/helper/DropOverlay.cpp \ - src/widgets/helper/DropPreview.cpp \ src/widgets/helper/EditableModelView.cpp \ src/widgets/helper/NotebookButton.cpp \ src/widgets/helper/NotebookTab.cpp \ @@ -229,7 +226,8 @@ SOURCES += \ src/widgets/settingspages/FeelPage.cpp \ src/util/InitUpdateButton.cpp \ src/widgets/dialogs/UpdateDialog.cpp \ - src/widgets/settingspages/IgnoresPage.cpp + src/widgets/settingspages/IgnoresPage.cpp \ + src/providers/twitch/PubsubClient.cpp HEADERS += \ src/Application.hpp \ @@ -296,7 +294,6 @@ HEADERS += \ src/providers/irc/IrcServer.hpp \ src/providers/twitch/EmoteValue.hpp \ src/providers/twitch/IrcMessageHandler.hpp \ - src/providers/twitch/Pubsub.hpp \ src/providers/twitch/PubsubActions.hpp \ src/providers/twitch/PubsubHelpers.hpp \ src/providers/twitch/TwitchAccount.hpp \ @@ -347,8 +344,6 @@ HEADERS += \ src/widgets/helper/ChannelView.hpp \ src/widgets/helper/ComboBoxItemDelegate.hpp \ src/widgets/helper/DebugPopup.hpp \ - src/widgets/helper/DropOverlay.hpp \ - src/widgets/helper/DropPreview.hpp \ src/widgets/helper/EditableModelView.hpp \ src/widgets/helper/Line.hpp \ src/widgets/helper/NotebookButton.hpp \ @@ -407,7 +402,8 @@ HEADERS += \ src/widgets/settingspages/FeelPage.hpp \ src/util/InitUpdateButton.hpp \ src/widgets/dialogs/UpdateDialog.hpp \ - src/widgets/settingspages/IgnoresPage.hpp + src/widgets/settingspages/IgnoresPage.hpp \ + src/providers/twitch/PubsubClient.hpp RESOURCES += \ resources/resources.qrc \ diff --git a/src/Application.cpp b/src/Application.cpp index 7b01174dc..6f59e0127 100644 --- a/src/Application.cpp +++ b/src/Application.cpp @@ -6,7 +6,7 @@ #include "controllers/ignores/IgnoreController.hpp" #include "controllers/moderationactions/ModerationActions.hpp" #include "controllers/taggedusers/TaggedUsersController.hpp" -#include "providers/twitch/Pubsub.hpp" +#include "providers/twitch/PubsubClient.hpp" #include "providers/twitch/TwitchServer.hpp" #include "singletons/Emotes.hpp" #include "singletons/Fonts.hpp" @@ -33,8 +33,8 @@ static Application *staticApp = nullptr; // It will create the instances of the major classes, and connect their signals to each other Application::Application(int _argc, char **_argv) - : argc(_argc) - , argv(_argv) + : argc_(_argc) + , argv_(_argv) { } diff --git a/src/Application.hpp b/src/Application.hpp index 582f2d06a..f792bc576 100644 --- a/src/Application.hpp +++ b/src/Application.hpp @@ -32,7 +32,7 @@ class Application Application(int _argc, char **_argv); public: - static void instantiate(int argc, char **argv); + static void instantiate(int argc_, char **argv_); ~Application() = delete; @@ -72,8 +72,8 @@ public: static void runNativeMessagingHost(); private: - int argc; - char **argv; + int argc_; + char **argv_; }; Application *getApp(); diff --git a/src/controllers/ignores/IgnoreController.cpp b/src/controllers/ignores/IgnoreController.cpp index dc6ec7e36..3c721a1c0 100644 --- a/src/controllers/ignores/IgnoreController.cpp +++ b/src/controllers/ignores/IgnoreController.cpp @@ -9,15 +9,15 @@ namespace chatterino { void IgnoreController::initialize() { - assert(!this->initialized); - this->initialized = true; + assert(!this->initialized_); + this->initialized_ = true; - for (const IgnorePhrase &phrase : this->ignoresSetting.getValue()) { + for (const IgnorePhrase &phrase : this->ignoresSetting_.getValue()) { this->phrases.appendItem(phrase); } this->phrases.delayedItemsChanged.connect([this] { // - this->ignoresSetting.setValue(this->phrases.getVector()); + this->ignoresSetting_.setValue(this->phrases.getVector()); }); } diff --git a/src/controllers/ignores/IgnoreController.hpp b/src/controllers/ignores/IgnoreController.hpp index 59623160d..0a9ed2775 100644 --- a/src/controllers/ignores/IgnoreController.hpp +++ b/src/controllers/ignores/IgnoreController.hpp @@ -18,9 +18,9 @@ public: IgnoreModel *createModel(QObject *parent); private: - bool initialized = false; + bool initialized_ = false; - ChatterinoSetting> ignoresSetting = {"/ignore/phrases"}; + ChatterinoSetting> ignoresSetting_ = {"/ignore/phrases"}; }; } // namespace chatterino diff --git a/src/controllers/ignores/IgnorePhrase.hpp b/src/controllers/ignores/IgnorePhrase.hpp index 9e4986718..d02bc1902 100644 --- a/src/controllers/ignores/IgnorePhrase.hpp +++ b/src/controllers/ignores/IgnorePhrase.hpp @@ -13,43 +13,44 @@ namespace chatterino { class IgnorePhrase { - QString pattern; - bool _isRegex; - QRegularExpression regex; - public: bool operator==(const IgnorePhrase &other) const { - return std::tie(this->pattern, this->_isRegex) == std::tie(other.pattern, other._isRegex); + return std::tie(this->pattern_, this->isRegex_) == std::tie(other.pattern_, other.isRegex_); } - IgnorePhrase(const QString &_pattern, bool isRegex) - : pattern(_pattern) - , _isRegex(isRegex) - , regex(_isRegex ? _pattern : "\\b" + QRegularExpression::escape(_pattern) + "\\b", - QRegularExpression::CaseInsensitiveOption | - QRegularExpression::UseUnicodePropertiesOption) + IgnorePhrase(const QString &pattern, bool isRegex) + : pattern_(pattern) + , isRegex_(isRegex) + , regex_(isRegex_ ? pattern : "\\b" + QRegularExpression::escape(pattern) + "\\b", + QRegularExpression::CaseInsensitiveOption | + QRegularExpression::UseUnicodePropertiesOption) { } const QString &getPattern() const { - return this->pattern; + return this->pattern_; } bool isRegex() const { - return this->_isRegex; + return this->isRegex_; } bool isValid() const { - return !this->pattern.isEmpty() && this->regex.isValid(); + return !this->pattern_.isEmpty() && this->regex_.isValid(); } bool isMatch(const QString &subject) const { - return this->isValid() && this->regex.match(subject).hasMatch(); + return this->isValid() && this->regex_.match(subject).hasMatch(); } + +private: + QString pattern_; + bool isRegex_; + QRegularExpression regex_; }; } // namespace chatterino diff --git a/src/controllers/moderationactions/ModerationAction.hpp b/src/controllers/moderationactions/ModerationAction.hpp index 012060054..bde1040c9 100644 --- a/src/controllers/moderationactions/ModerationAction.hpp +++ b/src/controllers/moderationactions/ModerationAction.hpp @@ -12,7 +12,7 @@ class Image; class ModerationAction { public: - ModerationAction(const QString &action_); + ModerationAction(const QString &action); bool operator==(const ModerationAction &other) const; diff --git a/src/controllers/moderationactions/ModerationActions.cpp b/src/controllers/moderationactions/ModerationActions.cpp index 2b7b38ee5..7cef80faf 100644 --- a/src/controllers/moderationactions/ModerationActions.cpp +++ b/src/controllers/moderationactions/ModerationActions.cpp @@ -14,15 +14,15 @@ ModerationActions::ModerationActions() void ModerationActions::initialize() { - assert(!this->initialized); - this->initialized = true; + assert(!this->initialized_); + this->initialized_ = true; - for (auto &val : this->setting.getValue()) { + for (auto &val : this->setting_.getValue()) { this->items.insertItem(val); } this->items.delayedItemsChanged.connect([this] { // - this->setting.setValue(this->items.getVector()); + this->setting_.setValue(this->items.getVector()); }); } diff --git a/src/controllers/moderationactions/ModerationActions.hpp b/src/controllers/moderationactions/ModerationActions.hpp index 1dcf77dc9..935567c38 100644 --- a/src/controllers/moderationactions/ModerationActions.hpp +++ b/src/controllers/moderationactions/ModerationActions.hpp @@ -20,8 +20,8 @@ public: ModerationActionModel *createModel(QObject *parent); private: - ChatterinoSetting> setting = {"/moderation/actions"}; - bool initialized = false; + ChatterinoSetting> setting_ = {"/moderation/actions"}; + bool initialized_ = false; }; } // namespace chatterino diff --git a/src/controllers/taggedusers/TaggedUser.cpp b/src/controllers/taggedusers/TaggedUser.cpp index b020cab32..9694c4fe0 100644 --- a/src/controllers/taggedusers/TaggedUser.cpp +++ b/src/controllers/taggedusers/TaggedUser.cpp @@ -4,17 +4,32 @@ namespace chatterino { -TaggedUser::TaggedUser(ProviderId _provider, const QString &_name, const QString &_id) - : provider(_provider) - , name(_name) - , id(_id) +TaggedUser::TaggedUser(ProviderId provider, const QString &name, const QString &id) + : providerId_(provider) + , name_(name) + , id_(id) { } bool TaggedUser::operator<(const TaggedUser &other) const { - return std::tie(this->provider, this->name, this->id) < - std::tie(other.provider, other.name, other.id); + return std::tie(this->providerId_, this->name_, this->id_) < + std::tie(other.providerId_, other.name_, other.id_); +} + +ProviderId TaggedUser::getProviderId() const +{ + return this->providerId_; +} + +QString TaggedUser::getName() const +{ + return this->name_; +} + +QString TaggedUser::getId() const +{ + return this->id_; } } // namespace chatterino diff --git a/src/controllers/taggedusers/TaggedUser.hpp b/src/controllers/taggedusers/TaggedUser.hpp index 192cfd7f1..fdbb39bae 100644 --- a/src/controllers/taggedusers/TaggedUser.hpp +++ b/src/controllers/taggedusers/TaggedUser.hpp @@ -9,13 +9,18 @@ namespace chatterino { class TaggedUser { public: - TaggedUser(ProviderId provider, const QString &name, const QString &id); + TaggedUser(ProviderId providerId, const QString &name, const QString &id); bool operator<(const TaggedUser &other) const; - ProviderId provider; - QString name; - QString id; + ProviderId getProviderId() const; + QString getName() const; + QString getId() const; + +private: + ProviderId providerId_; + QString name_; + QString id_; }; } // namespace chatterino diff --git a/src/controllers/taggedusers/TaggedUsersModel.cpp b/src/controllers/taggedusers/TaggedUsersModel.cpp index f0ae0b60f..b3ef872f9 100644 --- a/src/controllers/taggedusers/TaggedUsersModel.cpp +++ b/src/controllers/taggedusers/TaggedUsersModel.cpp @@ -21,7 +21,7 @@ TaggedUser TaggedUsersModel::getItemFromRow(std::vector &row, // turns a row in the model into a vector item void TaggedUsersModel::getRowFromItem(const TaggedUser &item, std::vector &row) { - setStringItem(row[0], item.name); + setStringItem(row[0], item.getName()); } void TaggedUsersModel::afterInit() diff --git a/src/messages/LimitedQueue.hpp b/src/messages/LimitedQueue.hpp index ff7c28d5e..4870c6809 100644 --- a/src/messages/LimitedQueue.hpp +++ b/src/messages/LimitedQueue.hpp @@ -31,55 +31,55 @@ protected: typedef std::shared_ptr> ChunkVector; public: - LimitedQueue(int _limit = 1000) - : limit(_limit) + LimitedQueue(int limit = 1000) + : limit_(limit) { this->clear(); } void clear() { - std::lock_guard lock(this->mutex); + std::lock_guard lock(this->mutex_); - this->chunks = std::make_shared>>>(); + this->chunks_ = std::make_shared>>>(); Chunk chunk = std::make_shared>(); - chunk->resize(this->chunkSize); - this->chunks->push_back(chunk); - this->firstChunkOffset = 0; - this->lastChunkEnd = 0; + chunk->resize(this->chunkSize_); + this->chunks_->push_back(chunk); + this->firstChunkOffset_ = 0; + this->lastChunkEnd_ = 0; } // return true if an item was deleted // deleted will be set if the item was deleted bool pushBack(const T &item, T &deleted) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(this->mutex_); - Chunk lastChunk = this->chunks->back(); + Chunk lastChunk = this->chunks_->back(); // still space in the last chunk - if (lastChunk->size() <= this->lastChunkEnd) { + if (lastChunk->size() <= this->lastChunkEnd_) { // create new chunk vector ChunkVector newVector = std::make_shared>>>(); // copy chunks - for (Chunk &chunk : *this->chunks) { + for (Chunk &chunk : *this->chunks_) { newVector->push_back(chunk); } // push back new chunk Chunk newChunk = std::make_shared>(); - newChunk->resize(this->chunkSize); + newChunk->resize(this->chunkSize_); newVector->push_back(newChunk); // replace current chunk vector - this->chunks = newVector; - this->lastChunkEnd = 0; - lastChunk = this->chunks->back(); + this->chunks_ = newVector; + this->lastChunkEnd_ = 0; + lastChunk = this->chunks_->back(); } - lastChunk->at(this->lastChunkEnd++) = item; + lastChunk->at(this->lastChunkEnd_++) = item; return this->deleteFirstItem(deleted); } @@ -90,41 +90,41 @@ public: std::vector acceptedItems; if (this->space() > 0) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(this->mutex_); // create new vector to clone chunks into ChunkVector newChunks = std::make_shared>>>(); - newChunks->resize(this->chunks->size()); + newChunks->resize(this->chunks_->size()); // copy chunks except for first one - for (size_t i = 1; i < this->chunks->size(); i++) { - newChunks->at(i) = this->chunks->at(i); + for (size_t i = 1; i < this->chunks_->size(); i++) { + newChunks->at(i) = this->chunks_->at(i); } // create new chunk for the first one size_t offset = std::min(this->space(), items.size()); Chunk newFirstChunk = std::make_shared>(); - newFirstChunk->resize(this->chunks->front()->size() + offset); + newFirstChunk->resize(this->chunks_->front()->size() + offset); for (size_t i = 0; i < offset; i++) { newFirstChunk->at(i) = items[items.size() - offset + i]; acceptedItems.push_back(items[items.size() - offset + i]); } - for (size_t i = 0; i < this->chunks->at(0)->size(); i++) { - newFirstChunk->at(i + offset) = this->chunks->at(0)->at(i); + for (size_t i = 0; i < this->chunks_->at(0)->size(); i++) { + newFirstChunk->at(i + offset) = this->chunks_->at(0)->at(i); } newChunks->at(0) = newFirstChunk; - this->chunks = newChunks; + this->chunks_ = newChunks; // qDebug() << acceptedItems.size(); // qDebug() << this->chunks->at(0)->size(); - if (this->chunks->size() == 1) { - this->lastChunkEnd += offset; + if (this->chunks_->size() == 1) { + this->lastChunkEnd_ += offset; } } @@ -134,15 +134,15 @@ public: // replace an single item, return index if successful, -1 if unsuccessful int replaceItem(const T &item, const T &replacement) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(this->mutex_); int x = 0; - for (size_t i = 0; i < this->chunks->size(); i++) { - Chunk &chunk = this->chunks->at(i); + for (size_t i = 0; i < this->chunks_->size(); i++) { + Chunk &chunk = this->chunks_->at(i); - size_t start = i == 0 ? this->firstChunkOffset : 0; - size_t end = i == chunk->size() - 1 ? this->lastChunkEnd : chunk->size(); + size_t start = i == 0 ? this->firstChunkOffset_ : 0; + size_t end = i == chunk->size() - 1 ? this->lastChunkEnd_ : chunk->size(); for (size_t j = start; j < end; j++) { if (chunk->at(j) == item) { @@ -154,7 +154,7 @@ public: } newChunk->at(j) = replacement; - this->chunks->at(i) = newChunk; + this->chunks_->at(i) = newChunk; return x; } @@ -168,15 +168,15 @@ public: // replace an item at index, return true if worked bool replaceItem(size_t index, const T &replacement) { - std::lock_guard lock(this->mutex); + std::lock_guard lock(this->mutex_); size_t x = 0; - for (size_t i = 0; i < this->chunks->size(); i++) { - Chunk &chunk = this->chunks->at(i); + for (size_t i = 0; i < this->chunks_->size(); i++) { + Chunk &chunk = this->chunks_->at(i); - size_t start = i == 0 ? this->firstChunkOffset : 0; - size_t end = i == chunk->size() - 1 ? this->lastChunkEnd : chunk->size(); + size_t start = i == 0 ? this->firstChunkOffset_ : 0; + size_t end = i == chunk->size() - 1 ? this->lastChunkEnd_ : chunk->size(); for (size_t j = start; j < end; j++) { if (x == index) { @@ -188,7 +188,7 @@ public: } newChunk->at(j) = replacement; - this->chunks->at(i) = newChunk; + this->chunks_->at(i) = newChunk; return true; } @@ -202,26 +202,26 @@ public: LimitedQueueSnapshot getSnapshot() { - std::lock_guard lock(this->mutex); + std::lock_guard lock(this->mutex_); - return LimitedQueueSnapshot(this->chunks, this->limit - this->space(), - this->firstChunkOffset, this->lastChunkEnd); + return LimitedQueueSnapshot(this->chunks_, this->limit_ - this->space(), + this->firstChunkOffset_, this->lastChunkEnd_); } private: size_t space() { size_t totalSize = 0; - for (Chunk &chunk : *this->chunks) { + for (Chunk &chunk : *this->chunks_) { totalSize += chunk->size(); } - totalSize -= this->chunks->back()->size() - this->lastChunkEnd; - if (this->chunks->size() != 1) { - totalSize -= this->firstChunkOffset; + totalSize -= this->chunks_->back()->size() - this->lastChunkEnd_; + if (this->chunks_->size() != 1) { + totalSize -= this->firstChunkOffset_; } - return this->limit - totalSize; + return this->limit_ - totalSize; } bool deleteFirstItem(T &deleted) @@ -231,39 +231,39 @@ private: return false; } - deleted = this->chunks->front()->at(this->firstChunkOffset); + deleted = this->chunks_->front()->at(this->firstChunkOffset_); - this->firstChunkOffset++; + this->firstChunkOffset_++; // need to delete the first chunk - if (this->firstChunkOffset == this->chunks->front()->size() - 1) { + if (this->firstChunkOffset_ == this->chunks_->front()->size() - 1) { // copy the chunk vector ChunkVector newVector = std::make_shared>>>(); // delete first chunk bool first = true; - for (Chunk &chunk : *this->chunks) { + for (Chunk &chunk : *this->chunks_) { if (!first) { newVector->push_back(chunk); } first = false; } - this->chunks = newVector; - this->firstChunkOffset = 0; + this->chunks_ = newVector; + this->firstChunkOffset_ = 0; } return true; } - ChunkVector chunks; - std::mutex mutex; + ChunkVector chunks_; + std::mutex mutex_; - size_t firstChunkOffset; - size_t lastChunkEnd; - size_t limit; + size_t firstChunkOffset_; + size_t lastChunkEnd_; + size_t limit_; - const size_t chunkSize = 100; + const size_t chunkSize_ = 100; }; } // namespace chatterino diff --git a/src/messages/LimitedQueueSnapshot.hpp b/src/messages/LimitedQueueSnapshot.hpp index cd73e6d1f..cd735445e 100644 --- a/src/messages/LimitedQueueSnapshot.hpp +++ b/src/messages/LimitedQueueSnapshot.hpp @@ -12,28 +12,28 @@ class LimitedQueueSnapshot public: LimitedQueueSnapshot() = default; - LimitedQueueSnapshot(std::shared_ptr>>> _chunks, - size_t _length, size_t _firstChunkOffset, size_t _lastChunkEnd) - : chunks(_chunks) - , length(_length) - , firstChunkOffset(_firstChunkOffset) - , lastChunkEnd(_lastChunkEnd) + LimitedQueueSnapshot(std::shared_ptr>>> chunks, + size_t length, size_t firstChunkOffset, size_t lastChunkEnd) + : chunks_(chunks) + , length_(length) + , firstChunkOffset_(firstChunkOffset) + , lastChunkEnd_(lastChunkEnd) { } std::size_t getLength() { - return this->length; + return this->length_; } T const &operator[](std::size_t index) const { - index += this->firstChunkOffset; + index += this->firstChunkOffset_; size_t x = 0; - for (size_t i = 0; i < this->chunks->size(); i++) { - auto &chunk = this->chunks->at(i); + for (size_t i = 0; i < this->chunks_->size(); i++) { + auto &chunk = this->chunks_->at(i); if (x <= index && x + chunk->size() > index) { return chunk->at(index - x); @@ -43,15 +43,15 @@ public: assert(false && "out of range"); - return this->chunks->at(0)->at(0); + return this->chunks_->at(0)->at(0); } private: - std::shared_ptr>>> chunks; + std::shared_ptr>>> chunks_; - size_t length = 0; - size_t firstChunkOffset = 0; - size_t lastChunkEnd = 0; + size_t length_ = 0; + size_t firstChunkOffset_ = 0; + size_t lastChunkEnd_ = 0; }; } // namespace chatterino diff --git a/src/messages/Message.cpp b/src/messages/Message.cpp index 563a1084e..fcf5fbc9e 100644 --- a/src/messages/Message.cpp +++ b/src/messages/Message.cpp @@ -9,12 +9,12 @@ namespace chatterino { void Message::addElement(MessageElement *element) { - this->elements.push_back(std::unique_ptr(element)); + this->elements_.push_back(std::unique_ptr(element)); } const std::vector> &Message::getElements() const { - return this->elements; + return this->elements_; } SBHighlight Message::getScrollBarHighlight() const diff --git a/src/messages/Message.hpp b/src/messages/Message.hpp index 022f3bad3..102a8d32f 100644 --- a/src/messages/Message.hpp +++ b/src/messages/Message.hpp @@ -62,7 +62,7 @@ struct Message { ScrollbarHighlight getScrollBarHighlight() const; private: - std::vector> elements; + std::vector> elements_; public: static std::shared_ptr createSystemMessage(const QString &text); diff --git a/src/messages/MessageBuilder.cpp b/src/messages/MessageBuilder.cpp index 636bd91c0..0054b887d 100644 --- a/src/messages/MessageBuilder.cpp +++ b/src/messages/MessageBuilder.cpp @@ -10,18 +10,18 @@ namespace chatterino { MessageBuilder::MessageBuilder() - : message(new Message) + : message_(new Message) { } MessagePtr MessageBuilder::getMessage() { - return this->message; + return this->message_; } void MessageBuilder::append(MessageElement *element) { - this->message->addElement(element); + this->message_->addElement(element); } void MessageBuilder::appendTimestamp() @@ -32,9 +32,9 @@ void MessageBuilder::appendTimestamp() void MessageBuilder::setHighlight(bool value) { if (value) { - this->message->flags |= Message::Highlighted; + this->message_->flags |= Message::Highlighted; } else { - this->message->flags &= ~Message::Highlighted; + this->message_->flags &= ~Message::Highlighted; } } diff --git a/src/messages/MessageBuilder.hpp b/src/messages/MessageBuilder.hpp index 3104aab83..d2a617ec3 100644 --- a/src/messages/MessageBuilder.hpp +++ b/src/messages/MessageBuilder.hpp @@ -31,7 +31,7 @@ public: } protected: - MessagePtr message; + MessagePtr message_; }; } // namespace chatterino diff --git a/src/messages/MessageColor.cpp b/src/messages/MessageColor.cpp index fd3b248b5..f22654b51 100644 --- a/src/messages/MessageColor.cpp +++ b/src/messages/MessageColor.cpp @@ -2,22 +2,22 @@ namespace chatterino { -MessageColor::MessageColor(const QColor &_color) - : type(Type::Custom) - , customColor(_color) +MessageColor::MessageColor(const QColor &color) + : type_(Type::Custom) + , customColor_(color) { } -MessageColor::MessageColor(Type _type) - : type(_type) +MessageColor::MessageColor(Type type) + : type_(type) { } const QColor &MessageColor::getColor(Theme &themeManager) const { - switch (this->type) { + switch (this->type_) { case Type::Custom: - return this->customColor; + return this->customColor_; case Type::Text: return themeManager.messages.textColors.regular; case Type::System: diff --git a/src/messages/MessageColor.hpp b/src/messages/MessageColor.hpp index f6ce3b68f..e7d828745 100644 --- a/src/messages/MessageColor.hpp +++ b/src/messages/MessageColor.hpp @@ -10,13 +10,13 @@ struct MessageColor { enum Type { Custom, Text, Link, System }; MessageColor(const QColor &color); - MessageColor(Type type = Text); + MessageColor(Type type_ = Text); const QColor &getColor(Theme &themeManager) const; private: - Type type; - QColor customColor; + Type type_; + QColor customColor_; }; } // namespace chatterino diff --git a/src/messages/MessageElement.cpp b/src/messages/MessageElement.cpp index 90420df17..5081f5e47 100644 --- a/src/messages/MessageElement.cpp +++ b/src/messages/MessageElement.cpp @@ -10,8 +10,8 @@ namespace chatterino { -MessageElement::MessageElement(Flags _flags) - : flags(_flags) +MessageElement::MessageElement(Flags flags) + : flags_(flags) { DebugCount::increase("message elements"); } @@ -21,15 +21,15 @@ MessageElement::~MessageElement() DebugCount::decrease("message elements"); } -MessageElement *MessageElement::setLink(const Link &_link) +MessageElement *MessageElement::setLink(const Link &link) { - this->link = _link; + this->link_ = link; return this; } -MessageElement *MessageElement::setTooltip(const QString &_tooltip) +MessageElement *MessageElement::setTooltip(const QString &tooltip) { - this->tooltip = _tooltip; + this->tooltip_ = tooltip; return this; } @@ -41,12 +41,12 @@ MessageElement *MessageElement::setTrailingSpace(bool value) const QString &MessageElement::getTooltip() const { - return this->tooltip; + return this->tooltip_; } const Link &MessageElement::getLink() const { - return this->link; + return this->link_; } bool MessageElement::hasTrailingSpace() const @@ -56,58 +56,58 @@ bool MessageElement::hasTrailingSpace() const MessageElement::Flags MessageElement::getFlags() const { - return this->flags; + return this->flags_; } // IMAGE -ImageElement::ImageElement(Image *_image, MessageElement::Flags flags) +ImageElement::ImageElement(Image *image, MessageElement::Flags flags) : MessageElement(flags) - , image(_image) + , image_(image) { - this->setTooltip(_image->getTooltip()); + this->setTooltip(image->getTooltip()); } -void ImageElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags) +void ImageElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) { - if (_flags & this->getFlags()) { - QSize size(this->image->getScaledWidth() * container.getScale(), - this->image->getScaledHeight() * container.getScale()); + if (flags & this->getFlags()) { + QSize size(this->image_->getScaledWidth() * container.getScale(), + this->image_->getScaledHeight() * container.getScale()); container.addElement( - (new ImageLayoutElement(*this, this->image, size))->setLink(this->getLink())); + (new ImageLayoutElement(*this, this->image_, size))->setLink(this->getLink())); } } // EMOTE -EmoteElement::EmoteElement(const EmoteData &_data, MessageElement::Flags flags) +EmoteElement::EmoteElement(const EmoteData &data, MessageElement::Flags flags) : MessageElement(flags) - , data(_data) + , data(data) { - if (_data.isValid()) { + if (data.isValid()) { this->setTooltip(data.image1x->getTooltip()); - this->textElement.reset( - new TextElement(_data.image1x->getCopyString(), MessageElement::Misc)); + this->textElement_.reset( + new TextElement(data.image1x->getCopyString(), MessageElement::Misc)); } } -void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags) +void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) { - if (_flags & this->getFlags()) { - if (_flags & MessageElement::EmoteImages) { + if (flags & this->getFlags()) { + if (flags & MessageElement::EmoteImages) { if (!this->data.isValid()) { return; } - Image *_image = this->data.getImage(container.getScale()); + Image *image = this->data.getImage(container.getScale()); - QSize size(int(container.getScale() * _image->getScaledWidth()), - int(container.getScale() * _image->getScaledHeight())); + QSize size(int(container.getScale() * image->getScaledWidth()), + int(container.getScale() * image->getScaledHeight())); container.addElement( - (new ImageLayoutElement(*this, _image, size))->setLink(this->getLink())); + (new ImageLayoutElement(*this, image, size))->setLink(this->getLink())); } else { - if (this->textElement) { - this->textElement->addToContainer(container, MessageElement::Misc); + if (this->textElement_) { + this->textElement_->addToContainer(container, MessageElement::Misc); } } } @@ -115,31 +115,31 @@ void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElem // TEXT TextElement::TextElement(const QString &text, MessageElement::Flags flags, - const MessageColor &_color, FontStyle _style) + const MessageColor &color, FontStyle style) : MessageElement(flags) - , color(_color) - , style(_style) + , color_(color) + , style_(style) { for (QString word : text.split(' ')) { - this->words.push_back({word, -1}); + this->words_.push_back({word, -1}); // fourtf: add logic to store multiple spaces after message } } -void TextElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags) +void TextElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) { auto app = getApp(); - if (_flags & this->getFlags()) { - QFontMetrics metrics = app->fonts->getFontMetrics(this->style, container.getScale()); + if (flags & this->getFlags()) { + QFontMetrics metrics = app->fonts->getFontMetrics(this->style_, container.getScale()); - for (Word &word : this->words) { + for (Word &word : this->words_) { auto getTextLayoutElement = [&](QString text, int width, bool trailingSpace) { - QColor color = this->color.getColor(*app->themes); + QColor color = this->color_.getColor(*app->themes); app->themes->normalizeColor(color); auto e = (new TextLayoutElement(*this, text, QSize(width, metrics.height()), color, - this->style, container.getScale())) + this->style_, container.getScale())) ->setLink(this->getLink()); e->setTrailingSpace(trailingSpace); return e; @@ -206,25 +206,25 @@ void TextElement::addToContainer(MessageLayoutContainer &container, MessageEleme } // TIMESTAMP -TimestampElement::TimestampElement(QTime _time) +TimestampElement::TimestampElement(QTime time) : MessageElement(MessageElement::Timestamp) - , time(_time) - , element(this->formatTime(_time)) + , time_(time) + , element_(this->formatTime(time)) { - assert(this->element != nullptr); + assert(this->element_ != nullptr); } void TimestampElement::addToContainer(MessageLayoutContainer &container, - MessageElement::Flags _flags) + MessageElement::Flags flags) { - if (_flags & this->getFlags()) { + if (flags & this->getFlags()) { auto app = getApp(); - if (app->settings->timestampFormat != this->format) { - this->format = app->settings->timestampFormat.getValue(); - this->element.reset(this->formatTime(this->time)); + if (app->settings->timestampFormat != this->format_) { + this->format_ = app->settings->timestampFormat.getValue(); + this->element_.reset(this->formatTime(this->time_)); } - this->element->addToContainer(container, _flags); + this->element_->addToContainer(container, flags); } } @@ -244,9 +244,9 @@ TwitchModerationElement::TwitchModerationElement() } void TwitchModerationElement::addToContainer(MessageLayoutContainer &container, - MessageElement::Flags _flags) + MessageElement::Flags flags) { - if (_flags & MessageElement::ModeratorTools) { + if (flags & MessageElement::ModeratorTools) { QSize size(int(container.getScale() * 16), int(container.getScale() * 16)); for (const ModerationAction &m : getApp()->moderationActions->items.getVector()) { diff --git a/src/messages/MessageElement.hpp b/src/messages/MessageElement.hpp index c14cb6f28..d933c8dc3 100644 --- a/src/messages/MessageElement.hpp +++ b/src/messages/MessageElement.hpp @@ -120,34 +120,26 @@ protected: bool trailingSpace = true; private: - Link link; - QString tooltip; - Flags flags; + Link link_; + QString tooltip_; + Flags flags_; }; // contains a simple image class ImageElement : public MessageElement { - Image *image; - public: ImageElement(Image *image, MessageElement::Flags flags); void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override; + +private: + Image *image_; }; // contains a text, it will split it into words class TextElement : public MessageElement { - MessageColor color; - FontStyle style; - - struct Word { - QString text; - int width = -1; - }; - std::vector words; - public: TextElement(const QString &text, MessageElement::Flags flags, const MessageColor &color = MessageColor::Text, @@ -155,6 +147,16 @@ public: ~TextElement() override = default; void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override; + +private: + MessageColor color_; + FontStyle style_; + + struct Word { + QString text; + int width = -1; + }; + std::vector words_; }; // contains emote data and will pick the emote based on : @@ -162,15 +164,16 @@ public: // b) which size it wants class EmoteElement : public MessageElement { - std::unique_ptr textElement; - public: - EmoteElement(const EmoteData &data, MessageElement::Flags flags); + EmoteElement(const EmoteData &data, MessageElement::Flags flags_); ~EmoteElement() override = default; - void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override; + void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags_) override; const EmoteData data; + +private: + std::unique_ptr textElement_; }; // contains a text, formated depending on the preferences @@ -182,7 +185,7 @@ public: void addToContainer(MessageLayoutContainer &container, MessageElement::Flags flags) override; - TextElement *formatTime(const QTime &time_); + TextElement *formatTime(const QTime &time); private: QTime time_; diff --git a/src/messages/layouts/MessageLayoutContainer.cpp b/src/messages/layouts/MessageLayoutContainer.cpp index 97b68ec7b..19ecfae98 100644 --- a/src/messages/layouts/MessageLayoutContainer.cpp +++ b/src/messages/layouts/MessageLayoutContainer.cpp @@ -15,46 +15,46 @@ namespace chatterino { int MessageLayoutContainer::getHeight() const { - return this->height; + return this->height_; } int MessageLayoutContainer::getWidth() const { - return this->width; + return this->width_; } float MessageLayoutContainer::getScale() const { - return this->scale; + return this->scale_; } // methods -void MessageLayoutContainer::begin(int _width, float _scale, Message::MessageFlags _flags) +void MessageLayoutContainer::begin(int width, float scale, Message::MessageFlags flags) { this->clear(); - this->width = _width; - this->scale = _scale; - this->flags = _flags; - auto mediumFontMetrics = getApp()->fonts->getFontMetrics(FontStyle::ChatMedium, _scale); - this->textLineHeight = mediumFontMetrics.height(); - this->spaceWidth = mediumFontMetrics.width(' '); - this->dotdotdotWidth = mediumFontMetrics.width("..."); - this->_canAddMessages = true; - this->_isCollapsed = false; + this->width_ = width; + this->scale_ = scale; + this->flags_ = flags; + auto mediumFontMetrics = getApp()->fonts->getFontMetrics(FontStyle::ChatMedium, scale); + this->textLineHeight_ = mediumFontMetrics.height(); + this->spaceWidth_ = mediumFontMetrics.width(' '); + this->dotdotdotWidth_ = mediumFontMetrics.width("..."); + this->canAddMessages_ = true; + this->isCollapsed_ = false; } void MessageLayoutContainer::clear() { - this->elements.clear(); - this->lines.clear(); + this->elements_.clear(); + this->lines_.clear(); - this->height = 0; - this->line = 0; - this->currentX = 0; - this->currentY = 0; - this->lineStart = 0; - this->lineHeight = 0; - this->charIndex = 0; + this->height_ = 0; + this->line_ = 0; + this->currentX_ = 0; + this->currentY_ = 0; + this->lineStart_ = 0; + this->lineHeight_ = 0; + this->charIndex_ = 0; } void MessageLayoutContainer::addElement(MessageLayoutElement *element) @@ -73,7 +73,7 @@ void MessageLayoutContainer::addElementNoLineBreak(MessageLayoutElement *element bool MessageLayoutContainer::canAddElements() { - return this->_canAddMessages; + return this->canAddMessages_; } void MessageLayoutContainer::_addElement(MessageLayoutElement *element, bool forceAdd) @@ -84,34 +84,34 @@ void MessageLayoutContainer::_addElement(MessageLayoutElement *element, bool for } // top margin - if (this->elements.size() == 0) { - this->currentY = this->margin.top * this->scale; + if (this->elements_.size() == 0) { + this->currentY_ = this->margin.top * this->scale_; } int newLineHeight = element->getRect().height(); // compact emote offset - bool isCompactEmote = !(this->flags & Message::DisableCompactEmotes) && + bool isCompactEmote = !(this->flags_ & Message::DisableCompactEmotes) && element->getCreator().getFlags() & MessageElement::EmoteImages; if (isCompactEmote) { - newLineHeight -= COMPACT_EMOTES_OFFSET * this->scale; + newLineHeight -= COMPACT_EMOTES_OFFSET * this->scale_; } // update line height - this->lineHeight = std::max(this->lineHeight, newLineHeight); + this->lineHeight_ = std::max(this->lineHeight_, newLineHeight); // set move element - element->setPosition(QPoint(this->currentX, this->currentY - element->getRect().height())); + element->setPosition(QPoint(this->currentX_, this->currentY_ - element->getRect().height())); // add element - this->elements.push_back(std::unique_ptr(element)); + this->elements_.push_back(std::unique_ptr(element)); // set current x - this->currentX += element->getRect().width(); + this->currentX_ += element->getRect().width(); if (element->hasTrailingSpace()) { - this->currentX += this->spaceWidth; + this->currentX_ += this->spaceWidth_; } } @@ -119,66 +119,66 @@ void MessageLayoutContainer::breakLine() { int xOffset = 0; - if (this->flags & Message::Centered && this->elements.size() > 0) { - xOffset = (width - this->elements.at(this->elements.size() - 1)->getRect().right()) / 2; + if (this->flags_ & Message::Centered && this->elements_.size() > 0) { + xOffset = (width_ - this->elements_.at(this->elements_.size() - 1)->getRect().right()) / 2; } - for (size_t i = lineStart; i < this->elements.size(); i++) { - MessageLayoutElement *element = this->elements.at(i).get(); + for (size_t i = lineStart_; i < this->elements_.size(); i++) { + MessageLayoutElement *element = this->elements_.at(i).get(); - bool isCompactEmote = !(this->flags & Message::DisableCompactEmotes) && + bool isCompactEmote = !(this->flags_ & Message::DisableCompactEmotes) && element->getCreator().getFlags() & MessageElement::EmoteImages; int yExtra = 0; if (isCompactEmote) { - yExtra = (COMPACT_EMOTES_OFFSET / 2) * this->scale; + yExtra = (COMPACT_EMOTES_OFFSET / 2) * this->scale_; } // if (element->getCreator().getFlags() & MessageElement::Badges) { - if (element->getRect().height() < this->textLineHeight) { - yExtra -= (this->textLineHeight - element->getRect().height()) / 2; + if (element->getRect().height() < this->textLineHeight_) { + yExtra -= (this->textLineHeight_ - element->getRect().height()) / 2; } element->setPosition(QPoint(element->getRect().x() + xOffset + this->margin.left, - element->getRect().y() + this->lineHeight + yExtra)); + element->getRect().y() + this->lineHeight_ + yExtra)); } - if (this->lines.size() != 0) { - this->lines.back().endIndex = this->lineStart; - this->lines.back().endCharIndex = this->charIndex; + if (this->lines_.size() != 0) { + this->lines_.back().endIndex = this->lineStart_; + this->lines_.back().endCharIndex = this->charIndex_; } - this->lines.push_back({(int)lineStart, 0, this->charIndex, 0, - QRect(-100000, this->currentY, 200000, lineHeight)}); + this->lines_.push_back({(int)lineStart_, 0, this->charIndex_, 0, + QRect(-100000, this->currentY_, 200000, lineHeight_)}); - for (int i = this->lineStart; i < this->elements.size(); i++) { - this->charIndex += this->elements[i]->getSelectionIndexCount(); + for (int i = this->lineStart_; i < this->elements_.size(); i++) { + this->charIndex_ += this->elements_[i]->getSelectionIndexCount(); } - this->lineStart = this->elements.size(); + this->lineStart_ = this->elements_.size(); // this->currentX = (int)(this->scale * 8); - if (this->canCollapse() && line + 1 >= MAX_UNCOLLAPSED_LINES) { - this->_canAddMessages = false; + if (this->canCollapse() && line_ + 1 >= MAX_UNCOLLAPSED_LINES) { + this->canAddMessages_ = false; return; } - this->currentX = 0; - this->currentY += this->lineHeight; - this->height = this->currentY + (this->margin.bottom * this->scale); - this->lineHeight = 0; - this->line++; + this->currentX_ = 0; + this->currentY_ += this->lineHeight_; + this->height_ = this->currentY_ + (this->margin.bottom * this->scale_); + this->lineHeight_ = 0; + this->line_++; } bool MessageLayoutContainer::atStartOfLine() { - return this->lineStart == this->elements.size(); + return this->lineStart_ == this->elements_.size(); } bool MessageLayoutContainer::fitsInLine(int _width) { - return this->currentX + _width <= - (this->width - this->margin.left - this->margin.right - - (this->line + 1 == MAX_UNCOLLAPSED_LINES ? this->dotdotdotWidth : 0)); + return this->currentX_ + _width <= + (this->width_ - this->margin.left - this->margin.right - + (this->line_ + 1 == MAX_UNCOLLAPSED_LINES ? this->dotdotdotWidth_ : 0)); } void MessageLayoutContainer::end() @@ -188,42 +188,42 @@ void MessageLayoutContainer::end() static QString dotdotdotText("..."); auto *element = new TextLayoutElement( - dotdotdot, dotdotdotText, QSize(this->dotdotdotWidth, this->textLineHeight), - QColor("#00D80A"), FontStyle::ChatMediumBold, this->scale); + dotdotdot, dotdotdotText, QSize(this->dotdotdotWidth_, this->textLineHeight_), + QColor("#00D80A"), FontStyle::ChatMediumBold, this->scale_); // getApp()->themes->messages.textColors.system this->_addElement(element, true); - this->_isCollapsed = true; + this->isCollapsed_ = true; } if (!this->atStartOfLine()) { this->breakLine(); } - this->height += this->lineHeight; + this->height_ += this->lineHeight_; - if (this->lines.size() != 0) { - this->lines[0].rect.setTop(-100000); - this->lines.back().rect.setBottom(100000); - this->lines.back().endIndex = this->elements.size(); - this->lines.back().endCharIndex = this->charIndex; + if (this->lines_.size() != 0) { + this->lines_[0].rect.setTop(-100000); + this->lines_.back().rect.setBottom(100000); + this->lines_.back().endIndex = this->elements_.size(); + this->lines_.back().endCharIndex = this->charIndex_; } } bool MessageLayoutContainer::canCollapse() { return getApp()->settings->collpseMessagesMinLines.getValue() > 0 && - this->flags & Message::MessageFlags::Collapsed; + this->flags_ & Message::MessageFlags::Collapsed; } bool MessageLayoutContainer::isCollapsed() { - return this->_isCollapsed; + return this->isCollapsed_; } MessageLayoutElement *MessageLayoutContainer::getElementAt(QPoint point) { - for (std::unique_ptr &element : this->elements) { + for (std::unique_ptr &element : this->elements_) { if (element->getRect().contains(point)) { return element.get(); } @@ -235,7 +235,7 @@ MessageLayoutElement *MessageLayoutContainer::getElementAt(QPoint point) // painting void MessageLayoutContainer::paintElements(QPainter &painter) { - for (const std::unique_ptr &element : this->elements) { + for (const std::unique_ptr &element : this->elements_) { #ifdef FOURTF painter.setPen(QColor(0, 255, 0)); painter.drawRect(element->getRect()); @@ -247,7 +247,7 @@ void MessageLayoutContainer::paintElements(QPainter &painter) void MessageLayoutContainer::paintAnimatedElements(QPainter &painter, int yOffset) { - for (const std::unique_ptr &element : this->elements) { + for (const std::unique_ptr &element : this->elements_) { element->paintAnimated(painter, yOffset); } } @@ -267,13 +267,13 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, // fully selected if (selection.selectionMin.messageIndex < messageIndex && selection.selectionMax.messageIndex > messageIndex) { - for (Line &line : this->lines) { + for (Line &line : this->lines_) { QRect rect = line.rect; rect.setTop(std::max(0, rect.top()) + yOffset); - rect.setBottom(std::min(this->height, rect.bottom()) + yOffset); - rect.setLeft(this->elements[line.startIndex]->getRect().left()); - rect.setRight(this->elements[line.endIndex - 1]->getRect().right()); + rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset); + rect.setLeft(this->elements_[line.startIndex]->getRect().left()); + rect.setRight(this->elements_[line.endIndex - 1]->getRect().right()); painter.fillRect(rect, selectionColor); } @@ -285,24 +285,24 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, // start in this message if (selection.selectionMin.messageIndex == messageIndex) { - for (; lineIndex < this->lines.size(); lineIndex++) { - Line &line = this->lines[lineIndex]; + for (; lineIndex < this->lines_.size(); lineIndex++) { + Line &line = this->lines_[lineIndex]; index = line.startCharIndex; bool returnAfter = false; bool breakAfter = false; - int x = this->elements[line.startIndex]->getRect().left(); - int r = this->elements[line.endIndex - 1]->getRect().right(); + int x = this->elements_[line.startIndex]->getRect().left(); + int r = this->elements_[line.endIndex - 1]->getRect().right(); if (line.endCharIndex < selection.selectionMin.charIndex) { continue; } for (int i = line.startIndex; i < line.endIndex; i++) { - int c = this->elements[i]->getSelectionIndexCount(); + int c = this->elements_[i]->getSelectionIndexCount(); if (index + c > selection.selectionMin.charIndex) { - x = this->elements[i]->getXFromIndex(selection.selectionMin.charIndex - index); + x = this->elements_[i]->getXFromIndex(selection.selectionMin.charIndex - index); // ends in same line if (selection.selectionMax.messageIndex == messageIndex && @@ -311,10 +311,10 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, returnAfter = true; index = line.startCharIndex; for (int i = line.startIndex; i < line.endIndex; i++) { - int c = this->elements[i]->getSelectionIndexCount(); + int c = this->elements_[i]->getSelectionIndexCount(); if (index + c > selection.selectionMax.charIndex) { - r = this->elements[i]->getXFromIndex( + r = this->elements_[i]->getXFromIndex( selection.selectionMax.charIndex - index); break; } @@ -325,14 +325,14 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, if (selection.selectionMax.messageIndex != messageIndex) { int lineIndex2 = lineIndex + 1; - for (; lineIndex2 < this->lines.size(); lineIndex2++) { - Line &line = this->lines[lineIndex2]; + for (; lineIndex2 < this->lines_.size(); lineIndex2++) { + Line &line = this->lines_[lineIndex2]; QRect rect = line.rect; rect.setTop(std::max(0, rect.top()) + yOffset); - rect.setBottom(std::min(this->height, rect.bottom()) + yOffset); - rect.setLeft(this->elements[line.startIndex]->getRect().left()); - rect.setRight(this->elements[line.endIndex - 1]->getRect().right()); + rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset); + rect.setLeft(this->elements_[line.startIndex]->getRect().left()); + rect.setRight(this->elements_[line.endIndex - 1]->getRect().right()); painter.fillRect(rect, selectionColor); } @@ -350,7 +350,7 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, QRect rect = line.rect; rect.setTop(std::max(0, rect.top()) + yOffset); - rect.setBottom(std::min(this->height, rect.bottom()) + yOffset); + rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset); rect.setLeft(x); rect.setRight(r); @@ -367,8 +367,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, } // start in this message - for (; lineIndex < this->lines.size(); lineIndex++) { - Line &line = this->lines[lineIndex]; + for (; lineIndex < this->lines_.size(); lineIndex++) { + Line &line = this->lines_[lineIndex]; index = line.startCharIndex; // just draw the garbage @@ -376,21 +376,21 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, QRect rect = line.rect; rect.setTop(std::max(0, rect.top()) + yOffset); - rect.setBottom(std::min(this->height, rect.bottom()) + yOffset); - rect.setLeft(this->elements[line.startIndex]->getRect().left()); - rect.setRight(this->elements[line.endIndex - 1]->getRect().right()); + rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset); + rect.setLeft(this->elements_[line.startIndex]->getRect().left()); + rect.setRight(this->elements_[line.endIndex - 1]->getRect().right()); painter.fillRect(rect, selectionColor); continue; } - int r = this->elements[line.endIndex - 1]->getRect().right(); + int r = this->elements_[line.endIndex - 1]->getRect().right(); for (int i = line.startIndex; i < line.endIndex; i++) { - int c = this->elements[i]->getSelectionIndexCount(); + int c = this->elements_[i]->getSelectionIndexCount(); if (index + c > selection.selectionMax.charIndex) { - r = this->elements[i]->getXFromIndex(selection.selectionMax.charIndex - index); + r = this->elements_[i]->getXFromIndex(selection.selectionMax.charIndex - index); break; } @@ -400,8 +400,8 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, QRect rect = line.rect; rect.setTop(std::max(0, rect.top()) + yOffset); - rect.setBottom(std::min(this->height, rect.bottom()) + yOffset); - rect.setLeft(this->elements[line.startIndex]->getRect().left()); + rect.setBottom(std::min(this->height_, rect.bottom()) + yOffset); + rect.setLeft(this->elements_[line.startIndex]->getRect().left()); rect.setRight(r); painter.fillRect(rect, selectionColor); @@ -412,23 +412,23 @@ void MessageLayoutContainer::paintSelection(QPainter &painter, int messageIndex, // selection int MessageLayoutContainer::getSelectionIndex(QPoint point) { - if (this->elements.size() == 0) { + if (this->elements_.size() == 0) { return 0; } - auto line = this->lines.begin(); + auto line = this->lines_.begin(); - for (; line != this->lines.end(); line++) { + for (; line != this->lines_.end(); line++) { if (line->rect.contains(point)) { break; } } - int lineStart = line == this->lines.end() ? this->lines.back().startIndex : line->startIndex; - if (line != this->lines.end()) { + int lineStart = line == this->lines_.end() ? this->lines_.back().startIndex : line->startIndex; + if (line != this->lines_.end()) { line++; } - int lineEnd = line == this->lines.end() ? this->elements.size() : line->startIndex; + int lineEnd = line == this->lines_.end() ? this->elements_.size() : line->startIndex; int index = 0; @@ -440,17 +440,17 @@ int MessageLayoutContainer::getSelectionIndex(QPoint point) // before line if (i < lineStart) { - index += this->elements[i]->getSelectionIndexCount(); + index += this->elements_[i]->getSelectionIndexCount(); continue; } // this is the word - if (point.x() < this->elements[i]->getRect().right()) { - index += this->elements[i]->getMouseOverIndex(point); + if (point.x() < this->elements_[i]->getRect().right()) { + index += this->elements_[i]->getMouseOverIndex(point); break; } - index += this->elements[i]->getSelectionIndexCount(); + index += this->elements_[i]->getSelectionIndexCount(); } return index; @@ -459,10 +459,10 @@ int MessageLayoutContainer::getSelectionIndex(QPoint point) // fourtf: no idea if this is acurate LOL int MessageLayoutContainer::getLastCharacterIndex() const { - if (this->lines.size() == 0) { + if (this->lines_.size() == 0) { return 0; } - return this->lines.back().endCharIndex; + return this->lines_.back().endCharIndex; } void MessageLayoutContainer::addSelectionText(QString &str, int from, int to) @@ -470,7 +470,7 @@ void MessageLayoutContainer::addSelectionText(QString &str, int from, int to) int index = 0; bool first = true; - for (std::unique_ptr &ele : this->elements) { + for (std::unique_ptr &ele : this->elements_) { int c = ele->getSelectionIndexCount(); if (first) { diff --git a/src/messages/layouts/MessageLayoutContainer.hpp b/src/messages/layouts/MessageLayoutContainer.hpp index eb4728569..3e00effce 100644 --- a/src/messages/layouts/MessageLayoutContainer.hpp +++ b/src/messages/layouts/MessageLayoutContainer.hpp @@ -51,7 +51,7 @@ struct MessageLayoutContainer { float getScale() const; // methods - void begin(int width, float scale, Message::MessageFlags flags); + void begin(int width_, float scale_, Message::MessageFlags flags_); void end(); void clear(); @@ -60,7 +60,7 @@ struct MessageLayoutContainer { void addElementNoLineBreak(MessageLayoutElement *element); void breakLine(); bool atStartOfLine(); - bool fitsInLine(int width); + bool fitsInLine(int width_); MessageLayoutElement *getElementAt(QPoint point); // painting @@ -86,28 +86,27 @@ private: // helpers void _addElement(MessageLayoutElement *element, bool forceAdd = false); - - // variables - float scale = 1.f; - int width = 0; - Message::MessageFlags flags = Message::MessageFlags::None; - int line = 0; - int height = 0; - int currentX = 0; - int currentY = 0; - int charIndex = 0; - size_t lineStart = 0; - int lineHeight = 0; - int spaceWidth = 4; - int textLineHeight = 0; - int dotdotdotWidth = 0; - bool _canAddMessages = true; - bool _isCollapsed = false; - bool canCollapse(); - std::vector> elements; - std::vector lines; + // variables + float scale_ = 1.f; + int width_ = 0; + Message::MessageFlags flags_ = Message::MessageFlags::None; + int line_ = 0; + int height_ = 0; + int currentX_ = 0; + int currentY_ = 0; + int charIndex_ = 0; + size_t lineStart_ = 0; + int lineHeight_ = 0; + int spaceWidth_ = 4; + int textLineHeight_ = 0; + int dotdotdotWidth_ = 0; + bool canAddMessages_ = true; + bool isCollapsed_ = false; + + std::vector> elements_; + std::vector lines_; }; } // namespace chatterino diff --git a/src/messages/layouts/MessageLayoutElement.cpp b/src/messages/layouts/MessageLayoutElement.cpp index 72803b0be..c71858eec 100644 --- a/src/messages/layouts/MessageLayoutElement.cpp +++ b/src/messages/layouts/MessageLayoutElement.cpp @@ -11,13 +11,13 @@ namespace chatterino { const QRect &MessageLayoutElement::getRect() const { - return this->rect; + return this->rect_; } -MessageLayoutElement::MessageLayoutElement(MessageElement &_creator, const QSize &size) - : creator(_creator) +MessageLayoutElement::MessageLayoutElement(MessageElement &creator, const QSize &size) + : creator_(creator) { - this->rect.setSize(size); + this->rect_.setSize(size); DebugCount::increase("message layout elements"); } @@ -28,12 +28,12 @@ MessageLayoutElement::~MessageLayoutElement() MessageElement &MessageLayoutElement::getCreator() const { - return this->creator; + return this->creator_; } void MessageLayoutElement::setPosition(QPoint point) { - this->rect.moveTopLeft(point); + this->rect_.moveTopLeft(point); } bool MessageLayoutElement::hasTrailingSpace() const @@ -50,13 +50,13 @@ MessageLayoutElement *MessageLayoutElement::setTrailingSpace(bool value) MessageLayoutElement *MessageLayoutElement::setLink(const Link &_link) { - this->link = _link; + this->link_ = _link; return this; } const Link &MessageLayoutElement::getLink() const { - return this->link; + return this->link_; } // diff --git a/src/messages/layouts/MessageLayoutElement.hpp b/src/messages/layouts/MessageLayoutElement.hpp index 4d012b953..3d14b0f32 100644 --- a/src/messages/layouts/MessageLayoutElement.hpp +++ b/src/messages/layouts/MessageLayoutElement.hpp @@ -20,7 +20,7 @@ class Image; class MessageLayoutElement : boost::noncopyable { public: - MessageLayoutElement(MessageElement &creator, const QSize &size); + MessageLayoutElement(MessageElement &creator_, const QSize &size); virtual ~MessageLayoutElement(); const QRect &getRect() const; @@ -29,7 +29,7 @@ public: bool hasTrailingSpace() const; MessageLayoutElement *setTrailingSpace(bool value); - MessageLayoutElement *setLink(const Link &link); + MessageLayoutElement *setLink(const Link &link_); virtual void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const = 0; virtual int getSelectionIndexCount() = 0; @@ -43,16 +43,16 @@ protected: bool trailingSpace = true; private: - QRect rect; - Link link; - MessageElement &creator; + QRect rect_; + Link link_; + MessageElement &creator_; }; // IMAGE class ImageLayoutElement : public MessageLayoutElement { public: - ImageLayoutElement(MessageElement &creator, Image *image, const QSize &size); + ImageLayoutElement(MessageElement &creator_, Image *image, const QSize &size); protected: void addCopyTextToString(QString &str, int from = 0, int to = INT_MAX) const override; @@ -70,7 +70,7 @@ private: class TextLayoutElement : public MessageLayoutElement { public: - TextLayoutElement(MessageElement &creator, QString &text, const QSize &size, QColor color, + TextLayoutElement(MessageElement &creator_, QString &text, const QSize &size, QColor color, FontStyle style, float scale); protected: @@ -93,7 +93,7 @@ private: class TextIconLayoutElement : public MessageLayoutElement { public: - TextIconLayoutElement(MessageElement &creator, const QString &line1, const QString &line2, + TextIconLayoutElement(MessageElement &creator_, const QString &line1, const QString &line2, float scale, const QSize &size); protected: diff --git a/src/providers/bttv/BttvEmotes.cpp b/src/providers/bttv/BttvEmotes.cpp index 5780da47a..9138ccafe 100644 --- a/src/providers/bttv/BttvEmotes.cpp +++ b/src/providers/bttv/BttvEmotes.cpp @@ -85,7 +85,7 @@ void BTTVEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptrchannelEmoteCache.getOrAdd(id, [&] { + auto emote = this->channelEmoteCache_.getOrAdd(id, [&] { EmoteData emoteData; QString link = linkTemplate; link.detach(); diff --git a/src/providers/bttv/BttvEmotes.hpp b/src/providers/bttv/BttvEmotes.hpp index f89281513..134e5a157 100644 --- a/src/providers/bttv/BttvEmotes.hpp +++ b/src/providers/bttv/BttvEmotes.hpp @@ -21,7 +21,7 @@ public: void loadChannelEmotes(const QString &channelName, std::weak_ptr channelEmoteMap); private: - EmoteMap channelEmoteCache; + EmoteMap channelEmoteCache_; }; } // namespace chatterino diff --git a/src/providers/emoji/Emojis.cpp b/src/providers/emoji/Emojis.cpp index 277ba614c..10a0f28e6 100644 --- a/src/providers/emoji/Emojis.cpp +++ b/src/providers/emoji/Emojis.cpp @@ -121,11 +121,11 @@ void Emojis::loadEmojis() parseEmoji(emojiData, unparsedEmoji); for (const auto &shortCode : emojiData->shortCodes) { - this->emojiShortCodeToEmoji.insert(shortCode, emojiData); + this->emojiShortCodeToEmoji_.insert(shortCode, emojiData); this->shortCodes.emplace_back(shortCode); } - this->emojiFirstByte[emojiData->value.at(0)].append(emojiData); + this->emojiFirstByte_[emojiData->value.at(0)].append(emojiData); this->emojis.insert(emojiData->unifiedCode, emojiData); @@ -145,11 +145,11 @@ void Emojis::loadEmojis() parseEmoji(variationEmojiData, variation, emojiData->shortCodes[0] + "_" + toneNameIt->second); - this->emojiShortCodeToEmoji.insert(variationEmojiData->shortCodes[0], + this->emojiShortCodeToEmoji_.insert(variationEmojiData->shortCodes[0], variationEmojiData); this->shortCodes.push_back(variationEmojiData->shortCodes[0]); - this->emojiFirstByte[variationEmojiData->value.at(0)].append(variationEmojiData); + this->emojiFirstByte_[variationEmojiData->value.at(0)].append(variationEmojiData); this->emojis.insert(variationEmojiData->unifiedCode, variationEmojiData); } @@ -179,8 +179,8 @@ void Emojis::loadEmojiOne2Capabilities() QString shortCode = parts[0]; - auto emojiIt = this->emojiShortCodeToEmoji.find(shortCode); - if (emojiIt != this->emojiShortCodeToEmoji.end()) { + auto emojiIt = this->emojiShortCodeToEmoji_.find(shortCode); + if (emojiIt != this->emojiShortCodeToEmoji_.end()) { std::shared_ptr emoji = *emojiIt; emoji->capabilities.insert("EmojiOne 2"); continue; @@ -190,7 +190,7 @@ void Emojis::loadEmojiOne2Capabilities() void Emojis::sortEmojis() { - for (auto &p : this->emojiFirstByte) { + for (auto &p : this->emojiFirstByte_) { std::stable_sort(p.begin(), p.end(), [](const auto &lhs, const auto &rhs) { return lhs->value.length() > rhs->value.length(); }); @@ -277,8 +277,8 @@ void Emojis::parse(std::vector> &parsedWords, con continue; } - auto it = this->emojiFirstByte.find(character); - if (it == this->emojiFirstByte.end()) { + auto it = this->emojiFirstByte_.find(character); + if (it == this->emojiFirstByte_.end()) { // No emoji starts with this character continue; } @@ -348,7 +348,7 @@ void Emojis::parse(std::vector> &parsedWords, con QString Emojis::replaceShortCodes(const QString &text) { QString ret(text); - auto it = this->findShortCodesRegex.globalMatch(text); + auto it = this->findShortCodesRegex_.globalMatch(text); int32_t offset = 0; @@ -359,9 +359,9 @@ QString Emojis::replaceShortCodes(const QString &text) QString matchString = capturedString.toLower().mid(1, capturedString.size() - 2); - auto emojiIt = this->emojiShortCodeToEmoji.constFind(matchString); + auto emojiIt = this->emojiShortCodeToEmoji_.constFind(matchString); - if (emojiIt == this->emojiShortCodeToEmoji.constEnd()) { + if (emojiIt == this->emojiShortCodeToEmoji_.constEnd()) { continue; } diff --git a/src/providers/emoji/Emojis.hpp b/src/providers/emoji/Emojis.hpp index 8d76179f7..dc56c4e5d 100644 --- a/src/providers/emoji/Emojis.hpp +++ b/src/providers/emoji/Emojis.hpp @@ -35,12 +35,12 @@ class Emojis { public: void initialize(); + void load(); + void parse(std::vector> &parsedWords, const QString &text); EmojiMap emojis; - std::vector shortCodes; - - void load(); + QString replaceShortCodes(const QString &text); private: void loadEmojis(); @@ -48,20 +48,14 @@ private: void sortEmojis(); void loadEmojiSet(); -public: - QString replaceShortCodes(const QString &text); - - void parse(std::vector> &parsedWords, const QString &text); - -private: /// Emojis - QRegularExpression findShortCodesRegex{":([-+\\w]+):"}; + QRegularExpression findShortCodesRegex_{":([-+\\w]+):"}; // shortCodeToEmoji maps strings like "sunglasses" to its emoji - QMap> emojiShortCodeToEmoji; + QMap> emojiShortCodeToEmoji_; // Maps the first character of the emoji unicode string to a vector of possible emojis - QMap>> emojiFirstByte; + QMap>> emojiFirstByte_; }; } // namespace chatterino diff --git a/src/providers/ffz/FfzEmotes.cpp b/src/providers/ffz/FfzEmotes.cpp index 121f851b4..8ff6c8ebf 100644 --- a/src/providers/ffz/FfzEmotes.cpp +++ b/src/providers/ffz/FfzEmotes.cpp @@ -112,7 +112,7 @@ void FFZEmotes::loadChannelEmotes(const QString &channelName, std::weak_ptrchannelEmoteCache.getOrAdd(id, [id, &code, &urls] { + auto emote = this->channelEmoteCache_.getOrAdd(id, [id, &code, &urls] { EmoteData emoteData; fillInEmoteData(urls, code, code + "
Channel FFZ Emote", emoteData); emoteData.pageLink = diff --git a/src/providers/ffz/FfzEmotes.hpp b/src/providers/ffz/FfzEmotes.hpp index 10e15f836..b216de0b0 100644 --- a/src/providers/ffz/FfzEmotes.hpp +++ b/src/providers/ffz/FfzEmotes.hpp @@ -21,7 +21,7 @@ public: void loadChannelEmotes(const QString &channelName, std::weak_ptr channelEmoteMap); private: - ConcurrentMap channelEmoteCache; + ConcurrentMap channelEmoteCache_; }; } // namespace chatterino diff --git a/src/providers/twitch/EmoteValue.hpp b/src/providers/twitch/EmoteValue.hpp index decf79851..bf64445f1 100644 --- a/src/providers/twitch/EmoteValue.hpp +++ b/src/providers/twitch/EmoteValue.hpp @@ -8,23 +8,23 @@ struct EmoteValue { public: int getSet() { - return _set; + return set_; } int getId() { - return _id; + return id_; } const QString &getChannelName() { - return _channelName; + return channelName_; } private: - int _set; - int _id; - QString _channelName; + int set_; + int id_; + QString channelName_; }; } // namespace chatterino diff --git a/src/providers/twitch/Pubsub.cpp b/src/providers/twitch/PubsubClient.cpp similarity index 94% rename from src/providers/twitch/Pubsub.cpp rename to src/providers/twitch/PubsubClient.cpp index c99fa6cbc..726f54915 100644 --- a/src/providers/twitch/Pubsub.cpp +++ b/src/providers/twitch/PubsubClient.cpp @@ -1,4 +1,4 @@ -#include "providers/twitch/Pubsub.hpp" +#include "providers/twitch/PubsubClient.hpp" #include "debug/Log.hpp" #include "providers/twitch/PubsubActions.hpp" @@ -24,41 +24,41 @@ static std::map sentMessages; namespace detail { -PubSubClient::PubSubClient(WebsocketClient &_websocketClient, WebsocketHandle _handle) - : websocketClient(_websocketClient) - , handle(_handle) +PubSubClient::PubSubClient(WebsocketClient &websocketClient, WebsocketHandle handle) + : websocketClient_(websocketClient) + , handle_(handle) { } void PubSubClient::start() { - assert(!this->started); + assert(!this->started_); - this->started = true; + this->started_ = true; this->ping(); } void PubSubClient::stop() { - assert(this->started); + assert(this->started_); - this->started = false; + this->started_ = false; } bool PubSubClient::listen(rapidjson::Document &message) { int numRequestedListens = message["data"]["topics"].Size(); - if (this->numListens + numRequestedListens > MAX_PUBSUB_LISTENS) { + if (this->numListens_ + numRequestedListens > MAX_PUBSUB_LISTENS) { // This PubSubClient is already at its peak listens return false; } - this->numListens += numRequestedListens; + this->numListens_ += numRequestedListens; for (const auto &topic : message["data"]["topics"].GetArray()) { - this->listeners.emplace_back(Listener{topic.GetString(), false, false, false}); + this->listeners_.emplace_back(Listener{topic.GetString(), false, false, false}); } auto uuid = CreateUUID(); @@ -77,11 +77,11 @@ void PubSubClient::unlistenPrefix(const std::string &prefix) { std::vector topics; - for (auto it = this->listeners.begin(); it != this->listeners.end();) { + for (auto it = this->listeners_.begin(); it != this->listeners_.end();) { const auto &listener = *it; if (listener.topic.find(prefix) == 0) { topics.push_back(listener.topic); - it = this->listeners.erase(it); + it = this->listeners_.erase(it); } else { ++it; } @@ -105,16 +105,16 @@ void PubSubClient::unlistenPrefix(const std::string &prefix) void PubSubClient::handlePong() { - assert(this->awaitingPong); + assert(this->awaitingPong_); Log("Got pong!"); - this->awaitingPong = false; + this->awaitingPong_ = false; } bool PubSubClient::isListeningToTopic(const std::string &payload) { - for (const auto &listener : this->listeners) { + for (const auto &listener : this->listeners_) { if (listener.topic == payload) { return true; } @@ -125,29 +125,29 @@ bool PubSubClient::isListeningToTopic(const std::string &payload) void PubSubClient::ping() { - assert(this->started); + assert(this->started_); if (!this->send(pingPayload)) { return; } - this->awaitingPong = true; + this->awaitingPong_ = true; auto self = this->shared_from_this(); - runAfter(this->websocketClient.get_io_service(), std::chrono::seconds(15), [self](auto timer) { - if (!self->started) { + runAfter(this->websocketClient_.get_io_service(), std::chrono::seconds(15), [self](auto timer) { + if (!self->started_) { return; } - if (self->awaitingPong) { + if (self->awaitingPong_) { Log("No pong respnose, disconnect!"); // TODO(pajlada): Label this connection as "disconnect me" } }); - runAfter(this->websocketClient.get_io_service(), std::chrono::minutes(5), [self](auto timer) { - if (!self->started) { + runAfter(this->websocketClient_.get_io_service(), std::chrono::minutes(5), [self](auto timer) { + if (!self->started_) { return; } @@ -158,7 +158,7 @@ void PubSubClient::ping() bool PubSubClient::send(const char *payload) { WebsocketErrorCode ec; - this->websocketClient.send(this->handle, payload, websocketpp::frame::opcode::text, ec); + this->websocketClient_.send(this->handle_, payload, websocketpp::frame::opcode::text, ec); if (ec) { Log("Error sending message {}: {}", payload, ec.message()); diff --git a/src/providers/twitch/Pubsub.hpp b/src/providers/twitch/PubsubClient.hpp similarity index 94% rename from src/providers/twitch/Pubsub.hpp rename to src/providers/twitch/PubsubClient.hpp index 82fd50fa9..3d39b7efb 100644 --- a/src/providers/twitch/Pubsub.hpp +++ b/src/providers/twitch/PubsubClient.hpp @@ -40,15 +40,6 @@ struct Listener { class PubSubClient : public std::enable_shared_from_this { - WebsocketClient &websocketClient; - WebsocketHandle handle; - uint16_t numListens = 0; - - std::vector listeners; - - std::atomic awaitingPong{false}; - std::atomic started{false}; - public: PubSubClient(WebsocketClient &_websocketClient, WebsocketHandle _handle); @@ -65,6 +56,15 @@ public: private: void ping(); bool send(const char *payload); + + WebsocketClient &websocketClient_; + WebsocketHandle handle_; + uint16_t numListens_ = 0; + + std::vector listeners_; + + std::atomic awaitingPong_{false}; + std::atomic started_{false}; }; } // namespace detail diff --git a/src/providers/twitch/TwitchAccount.cpp b/src/providers/twitch/TwitchAccount.cpp index 61fef4709..f49227444 100644 --- a/src/providers/twitch/TwitchAccount.cpp +++ b/src/providers/twitch/TwitchAccount.cpp @@ -8,14 +8,14 @@ namespace chatterino { -TwitchAccount::TwitchAccount(const QString &_username, const QString &_oauthToken, - const QString &_oauthClient, const QString &_userID) +TwitchAccount::TwitchAccount(const QString &username, const QString &oauthToken, + const QString &oauthClient, const QString &userID) : Account(ProviderId::Twitch) - , oauthClient(_oauthClient) - , oauthToken(_oauthToken) - , userName(_username) - , userId(_userID) - , _isAnon(_username == ANONYMOUS_USERNAME) + , oauthClient_(oauthClient) + , oauthToken_(oauthToken) + , userName_(username) + , userId_(userID) + , isAnon_(username == ANONYMOUS_USERNAME) { } @@ -26,49 +26,49 @@ QString TwitchAccount::toString() const const QString &TwitchAccount::getUserName() const { - return this->userName; + return this->userName_; } const QString &TwitchAccount::getOAuthClient() const { - return this->oauthClient; + return this->oauthClient_; } const QString &TwitchAccount::getOAuthToken() const { - return this->oauthToken; + return this->oauthToken_; } const QString &TwitchAccount::getUserId() const { - return this->userId; + return this->userId_; } bool TwitchAccount::setOAuthClient(const QString &newClientID) { - if (this->oauthClient.compare(newClientID) == 0) { + if (this->oauthClient_.compare(newClientID) == 0) { return false; } - this->oauthClient = newClientID; + this->oauthClient_ = newClientID; return true; } bool TwitchAccount::setOAuthToken(const QString &newOAuthToken) { - if (this->oauthToken.compare(newOAuthToken) == 0) { + if (this->oauthToken_.compare(newOAuthToken) == 0) { return false; } - this->oauthToken = newOAuthToken; + this->oauthToken_ = newOAuthToken; return true; } bool TwitchAccount::isAnon() const { - return this->_isAnon; + return this->isAnon_; } void TwitchAccount::loadIgnores() @@ -95,8 +95,8 @@ void TwitchAccount::loadIgnores() } { - std::lock_guard lock(this->ignoresMutex); - this->ignores.clear(); + std::lock_guard lock(this->ignoresMutex_); + this->ignores_.clear(); for (const auto &block : blocks.GetArray()) { if (!block.IsObject()) { @@ -112,7 +112,7 @@ void TwitchAccount::loadIgnores() continue; } - this->ignores.insert(ignoredUser); + this->ignores_.insert(ignoredUser); } } @@ -168,9 +168,9 @@ void TwitchAccount::ignoreByID(const QString &targetUserID, const QString &targe return false; } { - std::lock_guard lock(this->ignoresMutex); + std::lock_guard lock(this->ignoresMutex_); - auto res = this->ignores.insert(ignoredUser); + auto res = this->ignores_.insert(ignoredUser); if (!res.second) { const TwitchUser &existingUser = *(res.first); existingUser.update(ignoredUser); @@ -219,9 +219,9 @@ void TwitchAccount::unignoreByID( TwitchUser ignoredUser; ignoredUser.id = targetUserID; { - std::lock_guard lock(this->ignoresMutex); + std::lock_guard lock(this->ignoresMutex_); - this->ignores.erase(ignoredUser); + this->ignores_.erase(ignoredUser); } onFinished(UnignoreResult_Success, "Successfully unignored user " + targetName); @@ -262,9 +262,9 @@ void TwitchAccount::checkFollow(const QString targetUserID, std::set TwitchAccount::getIgnores() const { - std::lock_guard lock(this->ignoresMutex); + std::lock_guard lock(this->ignoresMutex_); - return this->ignores; + return this->ignores_; } void TwitchAccount::loadEmotes(std::function cb) diff --git a/src/providers/twitch/TwitchAccount.hpp b/src/providers/twitch/TwitchAccount.hpp index 2cf16c73f..a92087401 100644 --- a/src/providers/twitch/TwitchAccount.hpp +++ b/src/providers/twitch/TwitchAccount.hpp @@ -33,7 +33,7 @@ enum FollowResult { class TwitchAccount : public Account { public: - TwitchAccount(const QString &username, const QString &oauthToken, const QString &oauthClient, + TwitchAccount(const QString &username, const QString &oauthToken_, const QString &oauthClient_, const QString &_userID); virtual QString toString() const override; @@ -73,14 +73,14 @@ public: QColor color; private: - QString oauthClient; - QString oauthToken; - QString userName; - QString userId; - const bool _isAnon; + QString oauthClient_; + QString oauthToken_; + QString userName_; + QString userId_; + const bool isAnon_; - mutable std::mutex ignoresMutex; - std::set ignores; + mutable std::mutex ignoresMutex_; + std::set ignores_; }; } // namespace chatterino diff --git a/src/providers/twitch/TwitchAccountManager.cpp b/src/providers/twitch/TwitchAccountManager.cpp index 24d75ef31..c2daeddda 100644 --- a/src/providers/twitch/TwitchAccountManager.cpp +++ b/src/providers/twitch/TwitchAccountManager.cpp @@ -7,7 +7,7 @@ namespace chatterino { TwitchAccountManager::TwitchAccountManager() - : anonymousUser(new TwitchAccount(ANONYMOUS_USERNAME, "", "", "")) + : anonymousUser_(new TwitchAccount(ANONYMOUS_USERNAME, "", "", "")) { this->currentUserChanged.connect([this] { auto currentUser = this->getCurrent(); @@ -20,18 +20,18 @@ TwitchAccountManager::TwitchAccountManager() std::shared_ptr TwitchAccountManager::getCurrent() { - if (!this->currentUser) { - return this->anonymousUser; + if (!this->currentUser_) { + return this->anonymousUser_; } - return this->currentUser; + return this->currentUser_; } std::vector TwitchAccountManager::getUsernames() const { std::vector userNames; - std::lock_guard lock(this->mutex); + std::lock_guard lock(this->mutex_); for (const auto &user : this->accounts.getVector()) { userNames.push_back(user->getUserName()); @@ -43,7 +43,7 @@ std::vector TwitchAccountManager::getUsernames() const std::shared_ptr TwitchAccountManager::findUserByUsername( const QString &username) const { - std::lock_guard lock(this->mutex); + std::lock_guard lock(this->mutex_); for (const auto &user : this->accounts.getVector()) { if (username.compare(user->getUserName(), Qt::CaseInsensitive) == 0) { @@ -124,10 +124,10 @@ void TwitchAccountManager::load() if (user) { Log("[AccountManager:currentUsernameChanged] User successfully updated to {}", newUsername); - this->currentUser = user; + this->currentUser_ = user; } else { Log("[AccountManager:currentUsernameChanged] User successfully updated to anonymous"); - this->currentUser = this->anonymousUser; + this->currentUser_ = this->anonymousUser_; } this->currentUserChanged.invoke(); @@ -136,13 +136,13 @@ void TwitchAccountManager::load() bool TwitchAccountManager::isLoggedIn() const { - if (!this->currentUser) { + if (!this->currentUser_) { return false; } // Once `TwitchAccount` class has a way to check, we should also return false if the credentials // are incorrect - return !this->currentUser->isAnon(); + return !this->currentUser_->isAnon(); } bool TwitchAccountManager::removeUser(TwitchAccount *account) diff --git a/src/providers/twitch/TwitchAccountManager.hpp b/src/providers/twitch/TwitchAccountManager.hpp index e9bbfd943..1cb1df1c2 100644 --- a/src/providers/twitch/TwitchAccountManager.hpp +++ b/src/providers/twitch/TwitchAccountManager.hpp @@ -59,10 +59,10 @@ private: AddUserResponse addUser(const UserData &data); bool removeUser(TwitchAccount *account); - std::shared_ptr currentUser; + std::shared_ptr currentUser_; - std::shared_ptr anonymousUser; - mutable std::mutex mutex; + std::shared_ptr anonymousUser_; + mutable std::mutex mutex_; friend class AccountController; }; diff --git a/src/providers/twitch/TwitchChannel.cpp b/src/providers/twitch/TwitchChannel.cpp index cbde1f526..d95834c14 100644 --- a/src/providers/twitch/TwitchChannel.cpp +++ b/src/providers/twitch/TwitchChannel.cpp @@ -4,7 +4,7 @@ #include "common/UrlFetch.hpp" #include "debug/Log.hpp" #include "messages/Message.hpp" -#include "providers/twitch/Pubsub.hpp" +#include "providers/twitch/PubsubClient.hpp" #include "providers/twitch/TwitchMessageBuilder.hpp" #include "singletons/Emotes.hpp" #include "singletons/Settings.hpp" @@ -16,15 +16,15 @@ namespace chatterino { -TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *_readConnection) +TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection *readConnection) : Channel(channelName, Channel::Type::Twitch) , bttvChannelEmotes(new EmoteMap) , ffzChannelEmotes(new EmoteMap) , subscriptionURL("https://www.twitch.tv/subs/" + name) , channelURL("https://twitch.tv/" + name) , popoutPlayerURL("https://player.twitch.tv/?channel=" + name) - , mod(false) - , readConnection(_readConnection) + , mod_(false) + , readConnection_(readConnection) { Log("[TwitchChannel:{}] Opened", this->name); @@ -60,8 +60,8 @@ TwitchChannel::TwitchChannel(const QString &channelName, Communi::IrcConnection this->fetchRecentMessages(); // }); - this->messageSuffix.append(' '); - this->messageSuffix.append(QChar(0x206D)); + this->messageSuffix_.append(' '); + this->messageSuffix_.append(QChar(0x206D)); static QStringList jsonLabels = {"moderators", "staff", "admins", "global_mods", "viewers"}; auto refreshChatters = [=](QJsonObject obj) { @@ -161,8 +161,8 @@ void TwitchChannel::sendMessage(const QString &message) if (!this->hasModRights()) { if (app->settings->allowDuplicateMessages) { - if (parsedMessage == this->lastSentMessage) { - parsedMessage.append(this->messageSuffix); + if (parsedMessage == this->lastSentMessage_) { + parsedMessage.append(this->messageSuffix_); } } } @@ -172,19 +172,19 @@ void TwitchChannel::sendMessage(const QString &message) if (messageSent) { qDebug() << "sent"; - this->lastSentMessage = parsedMessage; + this->lastSentMessage_ = parsedMessage; } } bool TwitchChannel::isMod() const { - return this->mod; + return this->mod_; } void TwitchChannel::setMod(bool value) { - if (this->mod != value) { - this->mod = value; + if (this->mod_ != value) { + this->mod_ = value; this->userStateChanged.invoke(); } @@ -201,9 +201,9 @@ void TwitchChannel::addRecentChatter(const std::shared_ptr &message) { assert(!message->loginName.isEmpty()); - std::lock_guard lock(this->recentChattersMutex); + std::lock_guard lock(this->recentChattersMutex_); - this->recentChatters[message->loginName] = {message->displayName, message->localizedName}; + this->recentChatters_[message->loginName] = {message->displayName, message->localizedName}; this->completionModel.addUser(message->displayName); } @@ -216,22 +216,22 @@ void TwitchChannel::addJoinedUser(const QString &user) return; } - std::lock_guard guard(this->joinedUserMutex); + std::lock_guard guard(this->joinedUserMutex_); - joinedUsers << user; + joinedUsers_ << user; - if (!this->joinedUsersMergeQueued) { - this->joinedUsersMergeQueued = true; + if (!this->joinedUsersMergeQueued_) { + this->joinedUsersMergeQueued_ = true; - QTimer::singleShot(500, &this->object, [this] { - std::lock_guard guard(this->joinedUserMutex); + QTimer::singleShot(500, &this->object_, [this] { + std::lock_guard guard(this->joinedUserMutex_); auto message = - Message::createSystemMessage("Users joined: " + this->joinedUsers.join(", ")); + Message::createSystemMessage("Users joined: " + this->joinedUsers_.join(", ")); message->flags |= Message::Collapsed; this->addMessage(message); - this->joinedUsers.clear(); - this->joinedUsersMergeQueued = false; + this->joinedUsers_.clear(); + this->joinedUsersMergeQueued_ = false; }); } } @@ -245,39 +245,39 @@ void TwitchChannel::addPartedUser(const QString &user) return; } - std::lock_guard guard(this->partedUserMutex); + std::lock_guard guard(this->partedUserMutex_); - partedUsers << user; + partedUsers_ << user; - if (!this->partedUsersMergeQueued) { - this->partedUsersMergeQueued = true; + if (!this->partedUsersMergeQueued_) { + this->partedUsersMergeQueued_ = true; - QTimer::singleShot(500, &this->object, [this] { - std::lock_guard guard(this->partedUserMutex); + QTimer::singleShot(500, &this->object_, [this] { + std::lock_guard guard(this->partedUserMutex_); auto message = - Message::createSystemMessage("Users parted: " + this->partedUsers.join(", ")); + Message::createSystemMessage("Users parted: " + this->partedUsers_.join(", ")); message->flags |= Message::Collapsed; this->addMessage(message); - this->partedUsers.clear(); + this->partedUsers_.clear(); - this->partedUsersMergeQueued = false; + this->partedUsersMergeQueued_ = false; }); } } TwitchChannel::RoomModes TwitchChannel::getRoomModes() { - std::lock_guard lock(this->roomModeMutex); + std::lock_guard lock(this->roomModeMutex_); - return this->roomModes; + return this->roomModes_; } void TwitchChannel::setRoomModes(const RoomModes &_roomModes) { { - std::lock_guard lock(this->roomModeMutex); - this->roomModes = _roomModes; + std::lock_guard lock(this->roomModeMutex_); + this->roomModes_ = _roomModes; } this->roomModesChanged.invoke(); @@ -285,24 +285,24 @@ void TwitchChannel::setRoomModes(const RoomModes &_roomModes) bool TwitchChannel::isLive() const { - std::lock_guard lock(this->streamStatusMutex); - return this->streamStatus.live; + std::lock_guard lock(this->streamStatusMutex_); + return this->streamStatus_.live; } TwitchChannel::StreamStatus TwitchChannel::getStreamStatus() const { - std::lock_guard lock(this->streamStatusMutex); - return this->streamStatus; + std::lock_guard lock(this->streamStatusMutex_); + return this->streamStatus_; } void TwitchChannel::setLive(bool newLiveStatus) { bool gotNewLiveStatus = false; { - std::lock_guard lock(this->streamStatusMutex); - if (this->streamStatus.live != newLiveStatus) { + std::lock_guard lock(this->streamStatusMutex_); + if (this->streamStatus_.live != newLiveStatus) { gotNewLiveStatus = true; - this->streamStatus.live = newLiveStatus; + this->streamStatus_.live = newLiveStatus; } } @@ -369,21 +369,21 @@ void TwitchChannel::refreshLiveStatus() // Stream is live { - std::lock_guard lock(channel->streamStatusMutex); - channel->streamStatus.live = true; - channel->streamStatus.viewerCount = stream["viewers"].GetUint(); - channel->streamStatus.game = stream["game"].GetString(); - channel->streamStatus.title = streamChannel["status"].GetString(); + std::lock_guard lock(channel->streamStatusMutex_); + channel->streamStatus_.live = true; + channel->streamStatus_.viewerCount = stream["viewers"].GetUint(); + channel->streamStatus_.game = stream["game"].GetString(); + channel->streamStatus_.title = streamChannel["status"].GetString(); QDateTime since = QDateTime::fromString(stream["created_at"].GetString(), Qt::ISODate); auto diff = since.secsTo(QDateTime::currentDateTime()); - channel->streamStatus.uptime = + channel->streamStatus_.uptime = QString::number(diff / 3600) + "h " + QString::number(diff % 3600 / 60) + "m"; - channel->streamStatus.rerun = false; + channel->streamStatus_.rerun = false; if (stream.HasMember("stream_type")) { - channel->streamStatus.streamType = stream["stream_type"].GetString(); + channel->streamStatus_.streamType = stream["stream_type"].GetString(); } else { - channel->streamStatus.streamType = QString(); + channel->streamStatus_.streamType = QString(); } if (stream.HasMember("broadcast_platform")) { @@ -392,7 +392,7 @@ void TwitchChannel::refreshLiveStatus() if (broadcastPlatformValue.IsString()) { const char *broadcastPlatform = stream["broadcast_platform"].GetString(); if (strcmp(broadcastPlatform, "rerun") == 0) { - channel->streamStatus.rerun = true; + channel->streamStatus_.rerun = true; } } } @@ -435,7 +435,7 @@ void TwitchChannel::fetchRecentMessages() auto channel = dynamic_cast(shared.get()); assert(channel != nullptr); - static auto readConnection = channel->readConnection; + static auto readConnection = channel->readConnection_; QJsonArray msgArray = obj.value("messages").toArray(); if (msgArray.empty()) { diff --git a/src/providers/twitch/TwitchChannel.hpp b/src/providers/twitch/TwitchChannel.hpp index 595085819..7b4e8a638 100644 --- a/src/providers/twitch/TwitchChannel.hpp +++ b/src/providers/twitch/TwitchChannel.hpp @@ -80,7 +80,7 @@ public: QString roomID; RoomModes getRoomModes(); - void setRoomModes(const RoomModes &roomModes); + void setRoomModes(const RoomModes &roomModes_); StreamStatus getStreamStatus() const; @@ -97,36 +97,35 @@ private: void setLive(bool newLiveStatus); void refreshLiveStatus(); void startRefreshLiveStatusTimer(int intervalMS); - - mutable std::mutex streamStatusMutex; - StreamStatus streamStatus; - - mutable std::mutex userStateMutex; - UserState userState; - void fetchRecentMessages(); - bool mod; - QByteArray messageSuffix; - QString lastSentMessage; - RoomModes roomModes; - std::mutex roomModeMutex; + mutable std::mutex streamStatusMutex_; + StreamStatus streamStatus_; - QObject object; - std::mutex joinedUserMutex; - QStringList joinedUsers; - bool joinedUsersMergeQueued = false; - std::mutex partedUserMutex; - QStringList partedUsers; - bool partedUsersMergeQueued = false; + mutable std::mutex userStateMutex_; + UserState userState_; - Communi::IrcConnection *readConnection; + bool mod_ = false; + QByteArray messageSuffix_; + QString lastSentMessage_; + RoomModes roomModes_; + std::mutex roomModeMutex_; - friend class TwitchServer; + QObject object_; + std::mutex joinedUserMutex_; + QStringList joinedUsers_; + bool joinedUsersMergeQueued_ = false; + std::mutex partedUserMutex_; + QStringList partedUsers_; + bool partedUsersMergeQueued_ = false; + + Communi::IrcConnection *readConnection_ = nullptr; // Key = login name - std::map recentChatters; - std::mutex recentChattersMutex; + std::map recentChatters_; + std::mutex recentChattersMutex_; + + friend class TwitchServer; }; } // namespace chatterino diff --git a/src/providers/twitch/TwitchEmotes.cpp b/src/providers/twitch/TwitchEmotes.cpp index 862d810ad..df1e2e076 100644 --- a/src/providers/twitch/TwitchEmotes.cpp +++ b/src/providers/twitch/TwitchEmotes.cpp @@ -120,7 +120,7 @@ EmoteData TwitchEmotes::getEmoteById(const QString &id, const QString &emoteName _emoteName = it.value(); } - return _twitchEmoteFromCache.getOrAdd(id, [&emoteName, &_emoteName, &id] { + return twitchEmoteFromCache_.getOrAdd(id, [&emoteName, &_emoteName, &id] { EmoteData newEmoteData; auto cleanCode = cleanUpCode(emoteName); newEmoteData.image1x = diff --git a/src/providers/twitch/TwitchEmotes.hpp b/src/providers/twitch/TwitchEmotes.hpp index ef772625a..295fca634 100644 --- a/src/providers/twitch/TwitchEmotes.hpp +++ b/src/providers/twitch/TwitchEmotes.hpp @@ -62,10 +62,10 @@ private: void loadSetData(std::shared_ptr emoteSet); // emote code - ConcurrentMap _twitchEmotes; + ConcurrentMap twitchEmotes_; - // emote id - ConcurrentMap _twitchEmoteFromCache; + // emote id + ConcurrentMap twitchEmoteFromCache_; }; } // namespace chatterino diff --git a/src/providers/twitch/TwitchMessageBuilder.cpp b/src/providers/twitch/TwitchMessageBuilder.cpp index cfae0010e..ace42a4e2 100644 --- a/src/providers/twitch/TwitchMessageBuilder.cpp +++ b/src/providers/twitch/TwitchMessageBuilder.cpp @@ -27,11 +27,11 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, , ircMessage(_ircMessage) , args(_args) , tags(this->ircMessage->tags()) - , originalMessage(_ircMessage->content()) - , action(_ircMessage->isAction()) + , originalMessage_(_ircMessage->content()) + , action_(_ircMessage->isAction()) { auto app = getApp(); - this->usernameColor = app->themes->messages.textColors.system; + this->usernameColor_ = app->themes->messages.textColors.system; } TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, @@ -43,11 +43,11 @@ TwitchMessageBuilder::TwitchMessageBuilder(Channel *_channel, , ircMessage(_ircMessage) , args(_args) , tags(this->ircMessage->tags()) - , originalMessage(content) - , action(isAction) + , originalMessage_(content) + , action_(isAction) { auto app = getApp(); - this->usernameColor = app->themes->messages.textColors.system; + this->usernameColor_ = app->themes->messages.textColors.system; } bool TwitchMessageBuilder::isIgnored() const @@ -56,7 +56,7 @@ bool TwitchMessageBuilder::isIgnored() const // TODO(pajlada): Do we need to check if the phrase is valid first? for (const auto &phrase : app->ignores->phrases.getVector()) { - if (phrase.isMatch(this->originalMessage)) { + if (phrase.isMatch(this->originalMessage_)) { Log("Blocking message because it contains ignored phrase {}", phrase.getPattern()); return true; } @@ -105,7 +105,7 @@ MessagePtr TwitchMessageBuilder::build() // MessageElement::Collapsed); // } //#endif - this->message->flags |= Message::Collapsed; + this->message_->flags |= Message::Collapsed; // PARSING this->parseMessageID(); @@ -181,13 +181,13 @@ MessagePtr TwitchMessageBuilder::build() // words - QStringList splits = this->originalMessage.split(' '); + QStringList splits = this->originalMessage_.split(' '); long int i = 0; for (QString split : splits) { MessageColor textColor = - this->action ? MessageColor(this->usernameColor) : MessageColor(MessageColor::Text); + this->action_ ? MessageColor(this->usernameColor_) : MessageColor(MessageColor::Text); // twitch emote if (currentTwitchEmote != twitchEmotes.end() && currentTwitchEmote->first == i) { @@ -279,7 +279,7 @@ MessagePtr TwitchMessageBuilder::build() i++; } - this->message->searchText = this->userName + ": " + this->originalMessage; + this->message_->searchText = this->userName + ": " + this->originalMessage_; return this->getMessage(); } @@ -302,10 +302,10 @@ void TwitchMessageBuilder::parseRoomID() auto iterator = this->tags.find("room-id"); if (iterator != std::end(this->tags)) { - this->roomID = iterator.value().toString(); + this->roomID_ = iterator.value().toString(); if (this->twitchChannel->roomID.isEmpty()) { - this->twitchChannel->roomID = this->roomID; + this->twitchChannel->roomID = this->roomID_; } } } @@ -323,7 +323,7 @@ void TwitchMessageBuilder::parseUsername() { auto iterator = this->tags.find("color"); if (iterator != this->tags.end()) { - this->usernameColor = QColor(iterator.value().toString()); + this->usernameColor_ = QColor(iterator.value().toString()); } // username @@ -339,7 +339,7 @@ void TwitchMessageBuilder::parseUsername() // this->userName = displayNameVariant.toString() + " (" + this->userName + ")"; // } - this->message->loginName = this->userName; + this->message_->loginName = this->userName; } void TwitchMessageBuilder::appendUsername() @@ -347,7 +347,7 @@ void TwitchMessageBuilder::appendUsername() auto app = getApp(); QString username = this->userName; - this->message->loginName = username; + this->message_->loginName = username; QString localizedName; auto iterator = this->tags.find("display-name"); @@ -357,12 +357,12 @@ void TwitchMessageBuilder::appendUsername() if (QString::compare(displayName, this->userName, Qt::CaseInsensitive) == 0) { username = displayName; - this->message->displayName = displayName; + this->message_->displayName = displayName; } else { localizedName = displayName; - this->message->displayName = username; - this->message->localizedName = displayName; + this->message_->displayName = username; + this->message_->localizedName = displayName; } } @@ -402,7 +402,7 @@ void TwitchMessageBuilder::appendUsername() // userDisplayString += IrcManager::getInstance().getUser().getUserName(); } else if (this->args.isReceivedWhisper) { // Sender username - this->emplace(usernameText, MessageElement::Text, this->usernameColor, + this->emplace(usernameText, MessageElement::Text, this->usernameColor_, FontStyle::ChatMediumBold) ->setLink({Link::UserInfo, this->userName}); @@ -421,11 +421,11 @@ void TwitchMessageBuilder::appendUsername() this->emplace(currentUser->getUserName() + ":", MessageElement::Text, selfColor, FontStyle::ChatMediumBold); } else { - if (!this->action) { + if (!this->action_) { usernameText += ":"; } - this->emplace(usernameText, MessageElement::Text, this->usernameColor, + this->emplace(usernameText, MessageElement::Text, this->usernameColor_, FontStyle::ChatMediumBold) ->setLink({Link::UserInfo, this->userName}); } @@ -443,7 +443,7 @@ void TwitchMessageBuilder::parseHighlights() QString currentUsername = currentUser->getUserName(); if (this->ircMessage->nick() == currentUsername) { - currentUser->color = this->usernameColor; + currentUser->color = this->usernameColor_; // Do nothing. Highlights cannot be triggered by yourself return; } @@ -481,8 +481,8 @@ void TwitchMessageBuilder::parseHighlights() if (!app->highlights->blacklistContains(this->ircMessage->nick())) { for (const HighlightPhrase &highlight : activeHighlights) { - if (highlight.isMatch(this->originalMessage)) { - Log("Highlight because {} matches {}", this->originalMessage, + if (highlight.isMatch(this->originalMessage_)) { + Log("Highlight because {} matches {}", this->originalMessage_, highlight.getPattern()); doHighlight = true; @@ -533,7 +533,7 @@ void TwitchMessageBuilder::parseHighlights() } if (doHighlight) { - this->message->flags |= Message::Highlighted; + this->message_->flags |= Message::Highlighted; } } } @@ -567,11 +567,11 @@ void TwitchMessageBuilder::appendTwitchEmote(const Communi::IrcMessage *ircMessa int start = coords.at(0).toInt(); int end = coords.at(1).toInt(); - if (start >= end || start < 0 || end > this->originalMessage.length()) { + if (start >= end || start < 0 || end > this->originalMessage_.length()) { return; } - QString name = this->originalMessage.mid(start, end - start + 1); + QString name = this->originalMessage_.mid(start, end - start + 1); vec.push_back( std::pair(start, app->emotes->twitch.getEmoteById(id, name))); @@ -613,7 +613,7 @@ void TwitchMessageBuilder::appendTwitchBadges() { auto app = getApp(); - const auto &channelResources = app->resources->channels[this->roomID]; + const auto &channelResources = app->resources->channels[this->roomID_]; auto iterator = this->tags.find("badges"); @@ -791,7 +791,7 @@ bool TwitchMessageBuilder::tryParseCheermote(const QString &string) { auto app = getApp(); // Try to parse custom cheermotes - const auto &channelResources = app->resources->channels[this->roomID]; + const auto &channelResources = app->resources->channels[this->roomID_]; if (channelResources.loaded) { for (const auto &cheermoteSet : channelResources.cheermoteSets) { auto match = cheermoteSet.regex.match(string); diff --git a/src/providers/twitch/TwitchMessageBuilder.hpp b/src/providers/twitch/TwitchMessageBuilder.hpp index 280bdf631..80d80fe7b 100644 --- a/src/providers/twitch/TwitchMessageBuilder.hpp +++ b/src/providers/twitch/TwitchMessageBuilder.hpp @@ -28,8 +28,7 @@ public: explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcPrivateMessage *_ircMessage, const MessageParseArgs &_args); explicit TwitchMessageBuilder(Channel *_channel, const Communi::IrcMessage *_ircMessage, - const MessageParseArgs &_args, QString content, - bool isAction); + const MessageParseArgs &_args, QString content, bool isAction); Channel *channel; TwitchChannel *twitchChannel; @@ -44,14 +43,6 @@ public: MessagePtr build(); private: - QString roomID; - - QColor usernameColor; - const QString originalMessage; - bool senderIsBroadcaster{}; - - const bool action = false; - void parseMessageID(); void parseRoomID(); void appendChannelName(); @@ -66,6 +57,14 @@ private: void appendTwitchBadges(); void appendChatterinoBadges(); bool tryParseCheermote(const QString &string); + + QString roomID_; + + QColor usernameColor_; + const QString originalMessage_; + bool senderIsBroadcaster{}; + + const bool action_ = false; }; } // namespace chatterino diff --git a/src/providers/twitch/TwitchServer.hpp b/src/providers/twitch/TwitchServer.hpp index 56d12c6a4..6ff5c4fe1 100644 --- a/src/providers/twitch/TwitchServer.hpp +++ b/src/providers/twitch/TwitchServer.hpp @@ -42,13 +42,13 @@ protected: QString cleanChannelName(const QString &dirtyChannelName) override; private: + void onMessageSendRequested(TwitchChannel *channel, const QString &message, bool &sent); + std::mutex lastMessageMutex_; std::queue lastMessagePleb_; std::queue lastMessageMod_; std::chrono::steady_clock::time_point lastErrorTimeSpeed_; std::chrono::steady_clock::time_point lastErrorTimeAmount_; - - void onMessageSendRequested(TwitchChannel *channel, const QString &message, bool &sent); }; } // namespace chatterino diff --git a/src/singletons/Fonts.cpp b/src/singletons/Fonts.cpp index 0e5f86fce..e557b40d4 100644 --- a/src/singletons/Fonts.cpp +++ b/src/singletons/Fonts.cpp @@ -35,7 +35,7 @@ Fonts::Fonts() getApp()->windows->incGeneration(); } - for (auto &map : this->fontsByType) { + for (auto &map : this->fontsByType_) { map.clear(); } this->fontChanged.invoke(); @@ -48,13 +48,13 @@ Fonts::Fonts() getApp()->windows->incGeneration(); } - for (auto &map : this->fontsByType) { + for (auto &map : this->fontsByType_) { map.clear(); } this->fontChanged.invoke(); }); - this->fontsByType.resize(size_t(EndType)); + this->fontsByType_.resize(size_t(EndType)); } QFont Fonts::getFont(Fonts::Type type, float scale) @@ -73,7 +73,7 @@ Fonts::FontData &Fonts::getOrCreateFontData(Type type, float scale) assert(type >= 0 && type < EndType); - auto &map = this->fontsByType[size_t(type)]; + auto &map = this->fontsByType_[size_t(type)]; // find element auto it = map.find(scale); diff --git a/src/singletons/Fonts.hpp b/src/singletons/Fonts.hpp index 193640a5e..c3f633c5a 100644 --- a/src/singletons/Fonts.hpp +++ b/src/singletons/Fonts.hpp @@ -74,7 +74,7 @@ private: FontData &getOrCreateFontData(Type type, float scale); FontData createFontData(Type type, float scale); - std::vector> fontsByType; + std::vector> fontsByType_; }; using FontStyle = Fonts::Type; diff --git a/src/singletons/Logging.cpp b/src/singletons/Logging.cpp index e4fbec982..5ef531a3b 100644 --- a/src/singletons/Logging.cpp +++ b/src/singletons/Logging.cpp @@ -25,11 +25,11 @@ void Logging::addMessage(const QString &channelName, MessagePtr message) return; } - auto it = this->loggingChannels.find(channelName); - if (it == this->loggingChannels.end()) { + auto it = this->loggingChannels_.find(channelName); + if (it == this->loggingChannels_.end()) { auto channel = new LoggingChannel(channelName); channel->addMessage(message); - this->loggingChannels.emplace(channelName, + this->loggingChannels_.emplace(channelName, std::unique_ptr(std::move(channel))); } else { it->second->addMessage(message); diff --git a/src/singletons/Logging.hpp b/src/singletons/Logging.hpp index 41286f130..61e261eec 100644 --- a/src/singletons/Logging.hpp +++ b/src/singletons/Logging.hpp @@ -23,7 +23,7 @@ public: void addMessage(const QString &channelName, MessagePtr message); private: - std::map> loggingChannels; + std::map> loggingChannels_; }; } // namespace chatterino diff --git a/src/singletons/Paths.cpp b/src/singletons/Paths.cpp index 4fee851b6..7f6123dcd 100644 --- a/src/singletons/Paths.cpp +++ b/src/singletons/Paths.cpp @@ -42,7 +42,7 @@ bool Paths::createFolder(const QString &folderPath) bool Paths::isPortable() { - return this->portable.get(); + return this->portable_.get(); } void Paths::initAppFilePathHash() @@ -58,13 +58,13 @@ void Paths::initAppFilePathHash() void Paths::initCheckPortable() { - this->portable = + this->portable_ = QFileInfo::exists(combinePath(QCoreApplication::applicationDirPath(), "portable")); } void Paths::initAppDataDirectory() { - assert(this->portable.is_initialized()); + assert(this->portable_.is_initialized()); // Root path = %APPDATA%/Chatterino or the folder that the executable resides in diff --git a/src/singletons/Paths.hpp b/src/singletons/Paths.hpp index 69d30c5ab..53dba36b4 100644 --- a/src/singletons/Paths.hpp +++ b/src/singletons/Paths.hpp @@ -36,13 +36,13 @@ public: bool isPortable(); private: - static Paths *instance; - boost::optional portable; - void initAppFilePathHash(); void initCheckPortable(); void initAppDataDirectory(); void initSubDirectories(); + + static Paths *instance; + boost::optional portable_; }; } // namespace chatterino diff --git a/src/singletons/Settings.cpp b/src/singletons/Settings.cpp index 0ade53a49..16165ec1b 100644 --- a/src/singletons/Settings.cpp +++ b/src/singletons/Settings.cpp @@ -69,18 +69,18 @@ void Settings::saveSnapshot() d->AddMember(key.Move(), val.Move(), a); } - this->snapshot.reset(d); + this->snapshot_.reset(d); Log("hehe: {}", pajlada::Settings::SettingManager::stringify(*d)); } void Settings::restoreSnapshot() { - if (!this->snapshot) { + if (!this->snapshot_) { return; } - const auto &snapshotObject = this->snapshot->GetObject(); + const auto &snapshotObject = this->snapshot_->GetObject(); for (const auto &weakSetting : _settings) { auto setting = weakSetting.lock(); diff --git a/src/singletons/Settings.hpp b/src/singletons/Settings.hpp index bf8406fee..ac0cbf0b8 100644 --- a/src/singletons/Settings.hpp +++ b/src/singletons/Settings.hpp @@ -125,9 +125,9 @@ public: void restoreSnapshot(); private: - std::unique_ptr snapshot; - void updateModerationActions(); + + std::unique_ptr snapshot_; }; Settings *getSettings(); diff --git a/src/singletons/Theme.cpp b/src/singletons/Theme.cpp index d38fc4d00..38c864c36 100644 --- a/src/singletons/Theme.cpp +++ b/src/singletons/Theme.cpp @@ -46,8 +46,8 @@ void Theme::update() // multiplier: 1 = white, 0.8 = light, -0.8 dark, -1 black void Theme::actuallyUpdate(double hue, double multiplier) { - isLight = multiplier > 0; - bool lightWin = isLight; + isLight_ = multiplier > 0; + bool lightWin = isLight_; // QColor themeColor = QColor::fromHslF(hue, 0.43, 0.5); QColor themeColor = QColor::fromHslF(hue, 0.8, 0.5); @@ -82,7 +82,7 @@ void Theme::actuallyUpdate(double hue, double multiplier) // message (referenced later) this->messages.textColors.caret = // - this->messages.textColors.regular = isLight ? "#000" : "#fff"; + this->messages.textColors.regular = isLight_ ? "#000" : "#fff"; QColor highlighted = lightWin ? QColor("#ff0000") : QColor("#ee6166"); @@ -141,14 +141,14 @@ void Theme::actuallyUpdate(double hue, double multiplier) } // Split - bool flat = isLight; + bool flat = isLight_; - this->splits.messageSeperator = isLight ? QColor(127, 127, 127) : QColor(60, 60, 60); + this->splits.messageSeperator = isLight_ ? QColor(127, 127, 127) : QColor(60, 60, 60); this->splits.background = getColor(0, sat, 1); this->splits.dropPreview = QColor(0, 148, 255, 0x30); this->splits.dropPreviewBorder = QColor(0, 148, 255, 0xff); - if (isLight) { + if (isLight_) { this->splits.dropTargetRect = QColor(255, 255, 255, 0x00); this->splits.dropTargetRectBorder = QColor(0, 148, 255, 0x00); @@ -165,7 +165,7 @@ void Theme::actuallyUpdate(double hue, double multiplier) this->splits.header.background = getColor(0, sat, flat ? 1 : 0.9); this->splits.header.border = getColor(0, sat, flat ? 1 : 0.85); this->splits.header.text = this->messages.textColors.regular; - this->splits.header.focusedText = isLight ? QColor("#198CFF") : QColor("#84C1FF"); + this->splits.header.focusedText = isLight_ ? QColor("#198CFF") : QColor("#84C1FF"); this->splits.input.background = getColor(0, sat, flat ? 0.95 : 0.95); this->splits.input.border = getColor(0, sat, flat ? 1 : 1); @@ -175,16 +175,16 @@ void Theme::actuallyUpdate(double hue, double multiplier) "border:" + this->tabs.selected.backgrounds.regular.color().name() + ";" + "color:" + this->messages.textColors.regular.name() + ";" + // "selection-background-color:" + - (isLight ? "#68B1FF" : this->tabs.selected.backgrounds.regular.color().name()); + (isLight_ ? "#68B1FF" : this->tabs.selected.backgrounds.regular.color().name()); // Message - this->messages.textColors.link = isLight ? QColor(66, 134, 244) : QColor(66, 134, 244); + this->messages.textColors.link = isLight_ ? QColor(66, 134, 244) : QColor(66, 134, 244); this->messages.textColors.system = QColor(140, 127, 127); this->messages.backgrounds.regular = splits.background; this->messages.backgrounds.alternate = getColor(0, sat, 0.93); - if (isLight) { + if (isLight_) { this->messages.backgrounds.highlighted = blendColors(themeColor, this->messages.backgrounds.regular, 0.8); } else { @@ -228,7 +228,7 @@ QColor Theme::blendColors(const QColor &color1, const QColor &color2, qreal rati void Theme::normalizeColor(QColor &color) { - if (this->isLight) { + if (this->isLight_) { if (color.lightnessF() > 0.5) { color.setHslF(color.hueF(), color.saturationF(), 0.5); } diff --git a/src/singletons/Theme.hpp b/src/singletons/Theme.hpp index 048af2c2f..973aea862 100644 --- a/src/singletons/Theme.hpp +++ b/src/singletons/Theme.hpp @@ -19,7 +19,7 @@ public: inline bool isLightTheme() const { - return this->isLight; + return this->isLight_; } struct TabColors { @@ -136,16 +136,15 @@ public: private: void actuallyUpdate(double hue, double multiplier); QColor blendColors(const QColor &color1, const QColor &color2, qreal ratio); - - double middleLookupTable[360] = {}; - double minLookupTable[360] = {}; - void fillLookupTableValues(double (&array)[360], double from, double to, double fromValue, double toValue); - bool isLight = false; + double middleLookupTable_[360] = {}; + double minLookupTable_[360] = {}; - pajlada::Signals::NoArgSignal repaintVisibleChatWidgets; + bool isLight_ = false; + + pajlada::Signals::NoArgSignal repaintVisibleChatWidgets_; friend class WindowManager; }; diff --git a/src/singletons/WindowManager.cpp b/src/singletons/WindowManager.cpp index bfd30dc08..1b56b7de2 100644 --- a/src/singletons/WindowManager.cpp +++ b/src/singletons/WindowManager.cpp @@ -62,20 +62,20 @@ WindowManager::WindowManager() auto settings = getSettings(); - this->wordFlagsListener.addSetting(settings->showTimestamps); - this->wordFlagsListener.addSetting(settings->showBadges); - this->wordFlagsListener.addSetting(settings->enableBttvEmotes); - this->wordFlagsListener.addSetting(settings->enableEmojis); - this->wordFlagsListener.addSetting(settings->enableFfzEmotes); - this->wordFlagsListener.addSetting(settings->enableTwitchEmotes); - this->wordFlagsListener.cb = [this](auto) { + this->wordFlagsListener_.addSetting(settings->showTimestamps); + this->wordFlagsListener_.addSetting(settings->showBadges); + this->wordFlagsListener_.addSetting(settings->enableBttvEmotes); + this->wordFlagsListener_.addSetting(settings->enableEmojis); + this->wordFlagsListener_.addSetting(settings->enableFfzEmotes); + this->wordFlagsListener_.addSetting(settings->enableTwitchEmotes); + this->wordFlagsListener_.cb = [this](auto) { this->updateWordTypeMask(); // }; } MessageElement::Flags WindowManager::getWordFlags() { - return this->wordFlags; + return this->wordFlags_; } void WindowManager::updateWordTypeMask() @@ -114,8 +114,8 @@ void WindowManager::updateWordTypeMask() // update flags MessageElement::Flags newFlags = static_cast(flags); - if (newFlags != this->wordFlags) { - this->wordFlags = newFlags; + if (newFlags != this->wordFlags_) { + this->wordFlags_ = newFlags; this->wordFlagsChanged.invoke(); } @@ -134,8 +134,8 @@ void WindowManager::forceLayoutChannelViews() void WindowManager::repaintVisibleChatWidgets(Channel *channel) { - if (this->mainWindow != nullptr) { - this->mainWindow->repaintVisibleChatWidgets(channel); + if (this->mainWindow_ != nullptr) { + this->mainWindow_->repaintVisibleChatWidgets(channel); } } @@ -155,14 +155,14 @@ Window &WindowManager::getMainWindow() { assertInGuiThread(); - return *this->mainWindow; + return *this->mainWindow_; } Window &WindowManager::getSelectedWindow() { assertInGuiThread(); - return *this->selectedWindow; + return *this->selectedWindow_; } Window &WindowManager::createWindow(Window::Type type) @@ -170,16 +170,16 @@ Window &WindowManager::createWindow(Window::Type type) assertInGuiThread(); auto *window = new Window(type); - this->windows.push_back(window); + this->windows_.push_back(window); window->show(); if (type != Window::Type::Main) { window->setAttribute(Qt::WA_DeleteOnClose); QObject::connect(window, &QWidget::destroyed, [this, window] { - for (auto it = this->windows.begin(); it != this->windows.end(); it++) { + for (auto it = this->windows_.begin(); it != this->windows_.end(); it++) { if (*it == window) { - this->windows.erase(it); + this->windows_.erase(it); break; } } @@ -191,19 +191,19 @@ Window &WindowManager::createWindow(Window::Type type) int WindowManager::windowCount() { - return this->windows.size(); + return this->windows_.size(); } Window *WindowManager::windowAt(int index) { assertInGuiThread(); - if (index < 0 || (size_t)index >= this->windows.size()) { + if (index < 0 || (size_t)index >= this->windows_.size()) { return nullptr; } Log("getting window at bad index {}", index); - return this->windows.at(index); + return this->windows_.at(index); } void WindowManager::initialize() @@ -211,9 +211,9 @@ void WindowManager::initialize() assertInGuiThread(); auto app = getApp(); - app->themes->repaintVisibleChatWidgets.connect([this] { this->repaintVisibleChatWidgets(); }); + app->themes->repaintVisibleChatWidgets_.connect([this] { this->repaintVisibleChatWidgets(); }); - assert(!this->initialized); + assert(!this->initialized_); // load file QString settingsPath = app->paths->settingsDirectory + SETTINGS_FILENAME; @@ -231,14 +231,14 @@ void WindowManager::initialize() QString type_val = window_obj.value("type").toString(); Window::Type type = type_val == "main" ? Window::Type::Main : Window::Type::Popup; - if (type == Window::Type::Main && mainWindow != nullptr) { + if (type == Window::Type::Main && mainWindow_ != nullptr) { type = Window::Type::Popup; } Window &window = createWindow(type); if (type == Window::Type::Main) { - mainWindow = &window; + mainWindow_ = &window; } // get geometry @@ -296,12 +296,12 @@ void WindowManager::initialize() } } - if (mainWindow == nullptr) { - mainWindow = &createWindow(Window::Type::Main); - mainWindow->getNotebook().addPage(true); + if (mainWindow_ == nullptr) { + mainWindow_ = &createWindow(Window::Type::Main); + mainWindow_->getNotebook().addPage(true); } - this->initialized = true; + this->initialized_ = true; } void WindowManager::save() @@ -313,7 +313,7 @@ void WindowManager::save() // "serialize" QJsonArray window_arr; - for (Window *window : this->windows) { + for (Window *window : this->windows_) { QJsonObject window_obj; // window type @@ -457,19 +457,19 @@ void WindowManager::closeAll() { assertInGuiThread(); - for (Window *window : windows) { + for (Window *window : windows_) { window->close(); } } int WindowManager::getGeneration() const { - return this->generation; + return this->generation_; } void WindowManager::incGeneration() { - this->generation++; + this->generation_++; } int WindowManager::clampUiScale(int scale) diff --git a/src/singletons/WindowManager.hpp b/src/singletons/WindowManager.hpp index ab1c69dc7..d000349d6 100644 --- a/src/singletons/WindowManager.hpp +++ b/src/singletons/WindowManager.hpp @@ -9,9 +9,18 @@ class WindowManager { public: WindowManager(); - ~WindowManager() = delete; + static void encodeChannel(IndirectChannel channel, QJsonObject &obj); + static IndirectChannel decodeChannel(const QJsonObject &obj); + + static int clampUiScale(int scale); + static float getUiScaleValue(); + static float getUiScaleValue(int scale); + + static const int uiScaleMin; + static const int uiScaleMax; + void showSettingsDialog(); void showAccountSelectPopup(QPoint point); @@ -19,7 +28,6 @@ public: void forceLayoutChannelViews(); void repaintVisibleChatWidgets(Channel *channel = nullptr); void repaintGifEmotes(); - // void updateAll(); Window &getMainWindow(); Window &getSelectedWindow(); @@ -35,38 +43,28 @@ public: int getGeneration() const; void incGeneration(); - pajlada::Signals::NoArgSignal repaintGifs; - pajlada::Signals::Signal layout; - - static const int uiScaleMin; - static const int uiScaleMax; - static int clampUiScale(int scale); - static float getUiScaleValue(); - static float getUiScaleValue(int scale); - MessageElement::Flags getWordFlags(); void updateWordTypeMask(); + pajlada::Signals::NoArgSignal repaintGifs; + pajlada::Signals::Signal layout; + pajlada::Signals::NoArgSignal wordFlagsChanged; private: - bool initialized = false; - - std::atomic generation{0}; - - std::vector windows; - - Window *mainWindow = nullptr; - Window *selectedWindow = nullptr; - void encodeNodeRecusively(SplitContainer::Node *node, QJsonObject &obj); - MessageElement::Flags wordFlags = MessageElement::Default; - pajlada::Settings::SettingListener wordFlagsListener; + bool initialized_ = false; -public: - static void encodeChannel(IndirectChannel channel, QJsonObject &obj); - static IndirectChannel decodeChannel(const QJsonObject &obj); + std::atomic generation_{0}; + + std::vector windows_; + + Window *mainWindow_ = nullptr; + Window *selectedWindow_ = nullptr; + + MessageElement::Flags wordFlags_ = MessageElement::Default; + pajlada::Settings::SettingListener wordFlagsListener_; }; } // namespace chatterino diff --git a/src/util/ConcurrentMap.hpp b/src/util/ConcurrentMap.hpp index 2db2d9f58..84cf98365 100644 --- a/src/util/ConcurrentMap.hpp +++ b/src/util/ConcurrentMap.hpp @@ -18,10 +18,10 @@ public: bool tryGet(const TKey &name, TValue &value) const { - QMutexLocker lock(&this->mutex); + QMutexLocker lock(&this->mutex_); - auto a = this->data.find(name); - if (a == this->data.end()) { + auto a = this->data_.find(name); + if (a == this->data_.end()) { return false; } @@ -32,12 +32,12 @@ public: TValue getOrAdd(const TKey &name, std::function addLambda) { - QMutexLocker lock(&this->mutex); + QMutexLocker lock(&this->mutex_); - auto a = this->data.find(name); - if (a == this->data.end()) { + auto a = this->data_.find(name); + if (a == this->data_.end()) { TValue value = addLambda(); - this->data.insert(name, value); + this->data_.insert(name, value); return value; } @@ -46,30 +46,30 @@ public: TValue &operator[](const TKey &name) { - QMutexLocker lock(&this->mutex); + QMutexLocker lock(&this->mutex_); - return this->data[name]; + return this->data_[name]; } void clear() { - QMutexLocker lock(&this->mutex); + QMutexLocker lock(&this->mutex_); - this->data.clear(); + this->data_.clear(); } void insert(const TKey &name, const TValue &value) { - QMutexLocker lock(&this->mutex); + QMutexLocker lock(&this->mutex_); - this->data.insert(name, value); + this->data_.insert(name, value); } void each(std::function func) const { - QMutexLocker lock(&this->mutex); + QMutexLocker lock(&this->mutex_); - QMapIterator it(this->data); + QMapIterator it(this->data_); while (it.hasNext()) { it.next(); @@ -79,9 +79,9 @@ public: void each(std::function func) { - QMutexLocker lock(&this->mutex); + QMutexLocker lock(&this->mutex_); - QMutableMapIterator it(this->data); + QMutableMapIterator it(this->data_); while (it.hasNext()) { it.next(); @@ -90,8 +90,8 @@ public: } private: - mutable QMutex mutex; - QMap data; + mutable QMutex mutex_; + QMap data_; }; } // namespace chatterino diff --git a/src/util/DebugCount.cpp b/src/util/DebugCount.cpp index f75015eb4..1f6d28a74 100644 --- a/src/util/DebugCount.cpp +++ b/src/util/DebugCount.cpp @@ -2,7 +2,7 @@ namespace chatterino { -QMap DebugCount::counts; -std::mutex DebugCount::mut; +QMap DebugCount::counts_; +std::mutex DebugCount::mut_; } // namespace chatterino diff --git a/src/util/DebugCount.hpp b/src/util/DebugCount.hpp index faea3ebef..7e78641d1 100644 --- a/src/util/DebugCount.hpp +++ b/src/util/DebugCount.hpp @@ -10,17 +10,14 @@ namespace chatterino { class DebugCount { - static QMap counts; - static std::mutex mut; - public: static void increase(const QString &name) { - std::lock_guard lock(mut); + std::lock_guard lock(mut_); - auto it = counts.find(name); - if (it == counts.end()) { - counts.insert(name, 1); + auto it = counts_.find(name); + if (it == counts_.end()) { + counts_.insert(name, 1); } else { reinterpret_cast(it.value())++; } @@ -28,11 +25,11 @@ public: static void decrease(const QString &name) { - std::lock_guard lock(mut); + std::lock_guard lock(mut_); - auto it = counts.find(name); - if (it == counts.end()) { - counts.insert(name, -1); + auto it = counts_.find(name); + if (it == counts_.end()) { + counts_.insert(name, -1); } else { reinterpret_cast(it.value())--; } @@ -40,10 +37,10 @@ public: static QString getDebugText() { - std::lock_guard lock(mut); + std::lock_guard lock(mut_); QString text; - for (auto it = counts.begin(); it != counts.end(); it++) { + for (auto it = counts_.begin(); it != counts_.end(); it++) { text += it.key() + ": " + QString::number(it.value()) + "\n"; } return text; @@ -53,6 +50,10 @@ public: { return ""; } + +private: + static QMap counts_; + static std::mutex mut_; }; } // namespace chatterino diff --git a/src/util/LayoutCreator.hpp b/src/util/LayoutCreator.hpp index 7cdec41b4..af01db373 100644 --- a/src/util/LayoutCreator.hpp +++ b/src/util/LayoutCreator.hpp @@ -15,29 +15,29 @@ class LayoutCreator { public: LayoutCreator(T *_item) - : item(_item) + : item_(_item) { } T *operator->() { - return this->item; + return this->item_; } T &operator*() { - return *this->item; + return *this->item_; } T *getElement() { - return this->item; + return this->item_; } template LayoutCreator append(T2 *_item) { - this->_addItem(this->getOrCreateLayout(), _item); + this->addItem(this->getOrCreateLayout(), _item); return LayoutCreator(_item); } @@ -47,7 +47,7 @@ public: { T2 *t = new T2(std::forward(args)...); - this->_addItem(this->getOrCreateLayout(), t); + this->addItem(this->getOrCreateLayout(), t); return LayoutCreator(t); } @@ -57,7 +57,7 @@ public: LayoutCreator emplaceScrollAreaWidget() { QWidget *widget = new QWidget; - this->item->setWidget(widget); + this->item_->setWidget(widget); return LayoutCreator(widget); } @@ -68,14 +68,14 @@ public: { T2 *layout = new T2; - this->item->setLayout(layout); + this->item_->setLayout(layout); return LayoutCreator(layout); } LayoutCreator assign(T **ptr) { - *ptr = this->item; + *ptr = this->item_; return *this; } @@ -84,7 +84,7 @@ public: typename std::enable_if::value, int>::type = 0> LayoutCreator withoutMargin() { - this->item->setContentsMargins(0, 0, 0, 0); + this->item_->setContentsMargins(0, 0, 0, 0); return *this; } @@ -93,7 +93,7 @@ public: typename std::enable_if::value, int>::type = 0> LayoutCreator hidden() { - this->item->setVisible(false); + this->item_->setVisible(false); return *this; } @@ -107,24 +107,24 @@ public: QWidget *widget = new QWidget; widget->setLayout(item); - this->item->addTab(widget, title); + this->item_->addTab(widget, title); return LayoutCreator(item); } private: - T *item; + T *item_; template ::value, int>::type = 0> - void _addItem(QLayout *layout, T2 *item) + void addItem(QLayout *layout, T2 *item) { layout->addWidget(item); } template ::value, int>::type = 0> - void _addItem(QLayout *layout, T2 *item) + void addItem(QLayout *layout, T2 *item) { QWidget *widget = new QWidget(); widget->setLayout(item); @@ -135,18 +135,18 @@ private: typename std::enable_if::value, int>::type = 0> QLayout *getOrCreateLayout() { - return this->item; + return this->item_; } template ::value, int>::type = 0> QLayout *getOrCreateLayout() { - if (!this->item->layout()) { - this->item->setLayout(new QHBoxLayout()); + if (!this->item_->layout()) { + this->item_->setLayout(new QHBoxLayout()); } - return this->item->layout(); + return this->item_->layout(); } }; diff --git a/src/util/PostToThread.hpp b/src/util/PostToThread.hpp index add2bceac..ddf5caa12 100644 --- a/src/util/PostToThread.hpp +++ b/src/util/PostToThread.hpp @@ -16,16 +16,16 @@ class LambdaRunnable : public QRunnable public: LambdaRunnable(std::function action) { - this->action = action; + this->action_ = action; } void run() { - this->action(); + this->action_(); } private: - std::function action; + std::function action_; }; // Taken from diff --git a/src/util/StreamLink.cpp b/src/util/StreamLink.cpp index 5d1b05c88..312f027d2 100644 --- a/src/util/StreamLink.cpp +++ b/src/util/StreamLink.cpp @@ -15,7 +15,7 @@ namespace chatterino { namespace { -const char *GetBinaryName() +const char *getBinaryName() { #ifdef _WIN32 return "streamlink.exe"; @@ -24,7 +24,7 @@ const char *GetBinaryName() #endif } -const char *GetDefaultBinaryPath() +const char *getDefaultBinaryPath() { #ifdef _WIN32 return "C:\\Program Files (x86)\\Streamlink\\bin\\streamlink.exe"; @@ -38,13 +38,13 @@ QString getStreamlinkProgram() auto app = getApp(); if (app->settings->streamlinkUseCustomPath) { - return app->settings->streamlinkPath + "/" + GetBinaryName(); + return app->settings->streamlinkPath + "/" + getBinaryName(); } else { - return GetBinaryName(); + return getBinaryName(); } } -bool CheckStreamlinkPath(const QString &path) +bool checkStreamlinkPath(const QString &path) { QFileInfo fileinfo(path); @@ -95,7 +95,7 @@ QProcess *createStreamlinkProcess() } // namespace -void GetStreamQualities(const QString &channelURL, std::function cb) +void getStreamQualities(const QString &channelURL, std::function cb) { auto p = createStreamlinkProcess(); @@ -130,7 +130,7 @@ void GetStreamQualities(const QString &channelURL, std::functionstart(); } -void OpenStreamlink(const QString &channelURL, const QString &quality, QStringList extraArguments) +void openStreamlink(const QString &channelURL, const QString &quality, QStringList extraArguments) { auto app = getApp(); @@ -156,7 +156,7 @@ void OpenStreamlink(const QString &channelURL, const QString &quality, QStringLi } } -void Start(const QString &channel) +void openStreamlinkForChannel(const QString &channel) { auto app = getApp(); @@ -166,7 +166,7 @@ void Start(const QString &channel) preferredQuality = preferredQuality.toLower(); if (preferredQuality == "choose") { - GetStreamQualities(channelURL, [=](QStringList qualityOptions) { + getStreamQualities(channelURL, [=](QStringList qualityOptions) { QualityPopup::showDialog(channel, qualityOptions); }); @@ -198,7 +198,7 @@ void Start(const QString &channel) args << "--stream-sorting-excludes" << exclude; } - OpenStreamlink(channelURL, quality, args); + openStreamlink(channelURL, quality, args); } } // namespace chatterino diff --git a/src/util/StreamLink.hpp b/src/util/StreamLink.hpp index fcbdaa003..2c5eebf4a 100644 --- a/src/util/StreamLink.hpp +++ b/src/util/StreamLink.hpp @@ -16,11 +16,11 @@ public: // Open streamlink for given channel, quality and extra arguments // the "Additional arguments" are fetched and added at the beginning of the streamlink call -void OpenStreamlink(const QString &channelURL, const QString &quality, +void openStreamlink(const QString &channelURL, const QString &quality, QStringList extraArguments = QStringList()); // Start opening streamlink for the given channel, reading settings like quality from settings // and opening a quality dialog if the quality is "Choose" -void Start(const QString &channel); +void openStreamlinkForChannel(const QString &channel); } // namespace chatterino diff --git a/src/widgets/AccountSwitchPopupWidget.cpp b/src/widgets/AccountSwitchPopupWidget.cpp index f4abcc4b9..75ac355cb 100644 --- a/src/widgets/AccountSwitchPopupWidget.cpp +++ b/src/widgets/AccountSwitchPopupWidget.cpp @@ -17,10 +17,10 @@ AccountSwitchPopupWidget::AccountSwitchPopupWidget(QWidget *parent) this->setContentsMargins(0, 0, 0, 0); - this->ui.accountSwitchWidget = new AccountSwitchWidget(this); + this->ui_.accountSwitchWidget = new AccountSwitchWidget(this); QVBoxLayout *vbox = new QVBoxLayout(this); - this->ui.accountSwitchWidget->setFocusPolicy(Qt::NoFocus); - vbox->addWidget(this->ui.accountSwitchWidget); + this->ui_.accountSwitchWidget->setFocusPolicy(Qt::NoFocus); + vbox->addWidget(this->ui_.accountSwitchWidget); // vbox->setSizeConstraint(QLayout::SetMinimumSize); @@ -41,7 +41,7 @@ AccountSwitchPopupWidget::AccountSwitchPopupWidget(QWidget *parent) void AccountSwitchPopupWidget::refresh() { - this->ui.accountSwitchWidget->refresh(); + this->ui_.accountSwitchWidget->refresh(); } void AccountSwitchPopupWidget::focusOutEvent(QFocusEvent *) diff --git a/src/widgets/AccountSwitchPopupWidget.hpp b/src/widgets/AccountSwitchPopupWidget.hpp index 7e80b5258..7a8097ced 100644 --- a/src/widgets/AccountSwitchPopupWidget.hpp +++ b/src/widgets/AccountSwitchPopupWidget.hpp @@ -22,7 +22,7 @@ protected: private: struct { AccountSwitchWidget *accountSwitchWidget = nullptr; - } ui; + } ui_; }; } // namespace chatterino diff --git a/src/widgets/AttachedWindow.hpp b/src/widgets/AttachedWindow.hpp index 58f82c3b7..b7a9ad617 100644 --- a/src/widgets/AttachedWindow.hpp +++ b/src/widgets/AttachedWindow.hpp @@ -32,6 +32,21 @@ protected: // override; private: + struct { + Split *split; + } ui_; + + struct Item { + void *hwnd; + AttachedWindow *window; + QString winId; + }; + + static std::vector items; + + void attachToHwnd(void *attached); + void updateWindowRect(void *attached); + void *target_; int yOffset_; int currentYOffset_; @@ -42,21 +57,6 @@ private: bool attached_ = false; #endif QTimer timer_; - - struct { - Split *split; - } ui_; - - void attachToHwnd(void *attached); - void updateWindowRect(void *attached); - - struct Item { - void *hwnd; - AttachedWindow *window; - QString winId; - }; - - static std::vector items; }; } // namespace chatterino diff --git a/src/widgets/BaseWindow.cpp b/src/widgets/BaseWindow.cpp index f67938128..00a841684 100644 --- a/src/widgets/BaseWindow.cpp +++ b/src/widgets/BaseWindow.cpp @@ -160,7 +160,7 @@ void BaseWindow::init() ::SetWindowPos(HWND(this->winId()), topMost ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); }, - this->managedConnections); + this->managedConnections_); }); } #else diff --git a/src/widgets/BaseWindow.hpp b/src/widgets/BaseWindow.hpp index 205b9cff8..d25a1be2e 100644 --- a/src/widgets/BaseWindow.hpp +++ b/src/widgets/BaseWindow.hpp @@ -112,7 +112,7 @@ private: } ui_; pajlada::Signals::SignalHolder connections_; - std::vector managedConnections; + std::vector managedConnections_; }; } // namespace chatterino diff --git a/src/widgets/Label.hpp b/src/widgets/Label.hpp index 0ca8d2dec..96e726b08 100644 --- a/src/widgets/Label.hpp +++ b/src/widgets/Label.hpp @@ -34,7 +34,8 @@ protected: virtual QSize minimumSizeHint() const override; private: - pajlada::Signals::SignalHolder connections_; + void updateSize(); + int getOffset(); QString text_; FontStyle fontStyle_; @@ -42,8 +43,7 @@ private: bool centered_ = false; bool hasOffset_ = true; - void updateSize(); - int getOffset(); + pajlada::Signals::SignalHolder connections_; }; } // namespace chatterino diff --git a/src/widgets/Notebook.cpp b/src/widgets/Notebook.cpp index 5902b7d48..b076cabae 100644 --- a/src/widgets/Notebook.cpp +++ b/src/widgets/Notebook.cpp @@ -27,9 +27,9 @@ namespace chatterino { Notebook::Notebook(QWidget *parent) : BaseWidget(parent) - , addButton(this) + , addButton_(this) { - this->addButton.setHidden(true); + this->addButton_.setHidden(true); auto *shortcut_next = new QShortcut(QKeySequence("Ctrl+Tab"), this); QObject::connect(shortcut_next, &QShortcut::activated, [this] { this->selectNextTab(); }); @@ -49,12 +49,12 @@ NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select) item.page = page; item.tab = tab; - this->items.append(item); + this->items_.append(item); page->hide(); page->setParent(this); - if (select || this->items.count() == 1) { + if (select || this->items_.count() == 1) { this->select(page); } @@ -67,24 +67,24 @@ NotebookTab *Notebook::addPage(QWidget *page, QString title, bool select) void Notebook::removePage(QWidget *page) { - for (int i = 0; i < this->items.count(); i++) { - if (this->items[i].page == page) { - if (this->items.count() == 1) { + for (int i = 0; i < this->items_.count(); i++) { + if (this->items_[i].page == page) { + if (this->items_.count() == 1) { this->select(nullptr); - } else if (i == this->items.count() - 1) { - this->select(this->items[i - 1].page); + } else if (i == this->items_.count() - 1) { + this->select(this->items_[i - 1].page); } else { - this->select(this->items[i + 1].page); + this->select(this->items_[i + 1].page); } - this->items[i].page->deleteLater(); - this->items[i].tab->deleteLater(); + this->items_[i].page->deleteLater(); + this->items_[i].tab->deleteLater(); // if (this->items.empty()) { // this->addNewPage(); // } - this->items.removeAt(i); + this->items_.removeAt(i); break; } } @@ -94,15 +94,15 @@ void Notebook::removePage(QWidget *page) void Notebook::removeCurrentPage() { - if (this->selectedPage != nullptr) { - this->removePage(this->selectedPage); + if (this->selectedPage_ != nullptr) { + this->removePage(this->selectedPage_); } } int Notebook::indexOf(QWidget *page) const { - for (int i = 0; i < this->items.count(); i++) { - if (this->items[i].page == page) { + for (int i = 0; i < this->items_.count(); i++) { + if (this->items_[i].page == page) { return i; } } @@ -112,7 +112,7 @@ int Notebook::indexOf(QWidget *page) const void Notebook::select(QWidget *page) { - if (page == this->selectedPage) { + if (page == this->selectedPage_) { return; } @@ -137,35 +137,35 @@ void Notebook::select(QWidget *page) } } - if (this->selectedPage != nullptr) { - this->selectedPage->setHidden(true); + if (this->selectedPage_ != nullptr) { + this->selectedPage_->setHidden(true); - Item &item = this->findItem(selectedPage); + Item &item = this->findItem(selectedPage_); item.tab->setSelected(false); // for (auto split : this->selectedPage->getSplits()) { // split->updateLastReadMessage(); // } - item.selectedWidget = this->selectedPage->focusWidget(); + item.selectedWidget = this->selectedPage_->focusWidget(); } - this->selectedPage = page; + this->selectedPage_ = page; this->performLayout(); } bool Notebook::containsPage(QWidget *page) { - return std::any_of(this->items.begin(), this->items.end(), + return std::any_of(this->items_.begin(), this->items_.end(), [page](const auto &item) { return item.page == page; }); } Notebook::Item &Notebook::findItem(QWidget *page) { - auto it = std::find_if(this->items.begin(), this->items.end(), + auto it = std::find_if(this->items_.begin(), this->items_.end(), [page](const auto &item) { return page == item.page; }); - assert(it != this->items.end()); + assert(it != this->items_.end()); return *it; } @@ -182,64 +182,64 @@ bool Notebook::containsChild(const QObject *obj, const QObject *child) void Notebook::selectIndex(int index) { - if (index < 0 || this->items.count() <= index) { + if (index < 0 || this->items_.count() <= index) { return; } - this->select(this->items[index].page); + this->select(this->items_[index].page); } void Notebook::selectNextTab() { - if (this->items.size() <= 1) { + if (this->items_.size() <= 1) { return; } - int index = (this->indexOf(this->selectedPage) + 1) % this->items.count(); + int index = (this->indexOf(this->selectedPage_) + 1) % this->items_.count(); - this->select(this->items[index].page); + this->select(this->items_[index].page); } void Notebook::selectPreviousTab() { - if (this->items.size() <= 1) { + if (this->items_.size() <= 1) { return; } - int index = this->indexOf(this->selectedPage) - 1; + int index = this->indexOf(this->selectedPage_) - 1; if (index < 0) { - index += this->items.count(); + index += this->items_.count(); } - this->select(this->items[index].page); + this->select(this->items_[index].page); } int Notebook::getPageCount() const { - return this->items.count(); + return this->items_.count(); } QWidget *Notebook::getPageAt(int index) const { - return this->items[index].page; + return this->items_[index].page; } int Notebook::getSelectedIndex() const { - return this->indexOf(this->selectedPage); + return this->indexOf(this->selectedPage_); } QWidget *Notebook::getSelectedPage() const { - return this->selectedPage; + return this->selectedPage_; } QWidget *Notebook::tabAt(QPoint point, int &index, int maxWidth) { int i = 0; - for (auto &item : this->items) { + for (auto &item : this->items_) { QRect rect = item.tab->getDesiredRect(); rect.setHeight((int)(this->getScale() * 24)); @@ -259,40 +259,40 @@ QWidget *Notebook::tabAt(QPoint point, int &index, int maxWidth) void Notebook::rearrangePage(QWidget *page, int index) { - this->items.move(this->indexOf(page), index); + this->items_.move(this->indexOf(page), index); this->performLayout(true); } bool Notebook::getAllowUserTabManagement() const { - return this->allowUserTabManagement; + return this->allowUserTabManagement_; } void Notebook::setAllowUserTabManagement(bool value) { - this->allowUserTabManagement = value; + this->allowUserTabManagement_ = value; } bool Notebook::getShowAddButton() const { - return this->showAddButton; + return this->showAddButton_; } void Notebook::setShowAddButton(bool value) { - this->showAddButton = 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) { + for (auto &i : this->items_) { i.tab->updateSize(); } } @@ -311,7 +311,7 @@ void Notebook::performLayout(bool animated) int h = int(NOTEBOOK_TAB_HEIGHT * this->getScale()); - for (auto *btn : this->customButtons) { + for (auto *btn : this->customButtons_) { if (!btn->isVisible()) { continue; } @@ -324,9 +324,9 @@ void Notebook::performLayout(bool animated) int tabHeight = static_cast(NOTEBOOK_TAB_HEIGHT * scale); bool first = true; - for (auto i = this->items.begin(); i != this->items.end(); i++) { + for (auto i = this->items_.begin(); i != this->items_.end(); i++) { bool wrap = - !first && (((i + 1 == this->items.end() && this->showAddButton) ? tabHeight : 0) + x + + !first && (((i + 1 == this->items_.end() && this->showAddButton_) ? tabHeight : 0) + x + i->tab->width()) > width(); if (wrap) { @@ -343,29 +343,29 @@ void Notebook::performLayout(bool animated) first = false; } - if (this->showAddButton) { - this->addButton.move(x, y); + if (this->showAddButton_) { + this->addButton_.move(x, y); } - if (this->lineY != y + tabHeight) { - this->lineY = y + tabHeight; + if (this->lineY_ != y + tabHeight) { + this->lineY_ = y + tabHeight; this->update(); } y += int(3 * scale); - for (auto &i : this->items) { + for (auto &i : this->items_) { i.tab->raise(); } - if (this->showAddButton) { - this->addButton.raise(); + if (this->showAddButton_) { + this->addButton_.raise(); } - if (this->selectedPage != nullptr) { - this->selectedPage->move(0, y + tabHeight); - this->selectedPage->resize(width(), height() - y - tabHeight); - this->selectedPage->raise(); + if (this->selectedPage_ != nullptr) { + this->selectedPage_->move(0, y + tabHeight); + this->selectedPage_->resize(width(), height() - y - tabHeight); + this->selectedPage_->raise(); } } @@ -374,20 +374,20 @@ void Notebook::paintEvent(QPaintEvent *event) BaseWidget::paintEvent(event); QPainter painter(this); - painter.fillRect(0, this->lineY, this->width(), (int)(3 * this->getScale()), + painter.fillRect(0, this->lineY_, this->width(), (int)(3 * this->getScale()), this->theme->tabs.bottomLine); } NotebookButton *Notebook::getAddButton() { - return &this->addButton; + return &this->addButton_; } NotebookButton *Notebook::addCustomButton() { NotebookButton *btn = new NotebookButton(this); - this->customButtons.push_back(btn); + this->customButtons_.push_back(btn); this->performLayout(); return btn; @@ -395,7 +395,7 @@ NotebookButton *Notebook::addCustomButton() NotebookTab *Notebook::getTabFromPage(QWidget *page) { - for (auto &it : this->items) { + for (auto &it : this->items_) { if (it.page == page) { return it.tab; } @@ -426,7 +426,7 @@ void SplitNotebook::addCustomButtons() getApp()->settings->hidePreferencesButton.connect( [settingsBtn](bool hide, auto) { settingsBtn->setVisible(!hide); }, - this->uniqueConnections); + this->connections_); settingsBtn->setIcon(NotebookButton::Settings); @@ -437,7 +437,7 @@ void SplitNotebook::addCustomButtons() auto userBtn = this->addCustomButton(); userBtn->setVisible(!getApp()->settings->hideUserButton.getValue()); getApp()->settings->hideUserButton.connect( - [userBtn](bool hide, auto) { userBtn->setVisible(!hide); }, this->uniqueConnections); + [userBtn](bool hide, auto) { userBtn->setVisible(!hide); }, this->connections_); userBtn->setIcon(NotebookButton::User); QObject::connect(userBtn, &NotebookButton::clicked, [this, userBtn] { diff --git a/src/widgets/Notebook.hpp b/src/widgets/Notebook.hpp index a7dd96761..4741fbac1 100644 --- a/src/widgets/Notebook.hpp +++ b/src/widgets/Notebook.hpp @@ -64,22 +64,21 @@ private: QWidget *selectedWidget = nullptr; }; - QList items; - QWidget *selectedPage = nullptr; - bool containsPage(QWidget *page); Item &findItem(QWidget *page); static bool containsChild(const QObject *obj, const QObject *child); - - NotebookButton addButton; - std::vector customButtons; - - bool allowUserTabManagement = false; - bool showAddButton = false; - int lineY = 20; - NotebookTab *getTabFromPage(QWidget *page); + + QList items_; + QWidget *selectedPage_ = nullptr; + + NotebookButton addButton_; + std::vector customButtons_; + + bool allowUserTabManagement_ = false; + bool showAddButton_ = false; + int lineY_ = 20; }; class SplitNotebook : public Notebook, pajlada::Signals::SignalHolder @@ -96,7 +95,7 @@ private: pajlada::Signals::SignalHolder signalHolder_; std::unique_ptr updateDialogHandle_; - std::vector uniqueConnections; + std::vector connections_; }; } // namespace chatterino diff --git a/src/widgets/Scrollbar.hpp b/src/widgets/Scrollbar.hpp index dc9a167cf..8de43d60a 100644 --- a/src/widgets/Scrollbar.hpp +++ b/src/widgets/Scrollbar.hpp @@ -64,6 +64,9 @@ protected: private: Q_PROPERTY(qreal currentValue_ READ getCurrentValue WRITE setCurrentValue) + LimitedQueueSnapshot getHighlightSnapshot(); + void updateScroll(); + QMutex mutex_; QPropertyAnimation currentValueAnimation_; @@ -71,7 +74,6 @@ private: LimitedQueue highlights_; bool highlightsPaused_{false}; LimitedQueueSnapshot highlightSnapshot_; - LimitedQueueSnapshot getHighlightSnapshot(); bool atBottom_{false}; @@ -94,8 +96,6 @@ private: pajlada::Signals::NoArgSignal currentValueChanged_; pajlada::Signals::NoArgSignal desiredValueChanged_; - - void updateScroll(); }; } // namespace chatterino diff --git a/src/widgets/TooltipWidget.cpp b/src/widgets/TooltipWidget.cpp index 1dda62b0e..f703a7c47 100644 --- a/src/widgets/TooltipWidget.cpp +++ b/src/widgets/TooltipWidget.cpp @@ -26,7 +26,7 @@ TooltipWidget *TooltipWidget::getInstance() TooltipWidget::TooltipWidget(BaseWidget *parent) : BaseWindow(parent, BaseWindow::TopMost) - , displayText(new QLabel()) + , displayText_(new QLabel()) { auto app = getApp(); @@ -39,19 +39,19 @@ TooltipWidget::TooltipWidget(BaseWidget *parent) this->setWindowFlags(Qt::Tool | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint | Qt::BypassWindowManagerHint); - displayText->setAlignment(Qt::AlignHCenter); - displayText->setText("tooltip text"); + displayText_->setAlignment(Qt::AlignHCenter); + displayText_->setText("tooltip text"); auto layout = new QVBoxLayout(); layout->setContentsMargins(10, 5, 10, 5); - layout->addWidget(displayText); + layout->addWidget(displayText_); this->setLayout(layout); - this->fontChangedConnection = app->fonts->fontChanged.connect([this] { this->updateFont(); }); + this->fontChangedConnection_ = app->fonts->fontChanged.connect([this] { this->updateFont(); }); } TooltipWidget::~TooltipWidget() { - this->fontChangedConnection.disconnect(); + this->fontChangedConnection_.disconnect(); } #ifdef USEWINSDK @@ -81,7 +81,7 @@ void TooltipWidget::updateFont() void TooltipWidget::setText(QString text) { - this->displayText->setText(text); + this->displayText_->setText(text); } void TooltipWidget::changeEvent(QEvent *) diff --git a/src/widgets/TooltipWidget.hpp b/src/widgets/TooltipWidget.hpp index 410c39139..7d8c95dc2 100644 --- a/src/widgets/TooltipWidget.hpp +++ b/src/widgets/TooltipWidget.hpp @@ -31,10 +31,10 @@ protected: void scaleChangedEvent(float) override; private: - QLabel *displayText; - pajlada::Signals::Connection fontChangedConnection; - void updateFont(); + + QLabel *displayText_; + pajlada::Signals::Connection fontChangedConnection_; }; } // namespace chatterino diff --git a/src/widgets/dialogs/EmotePopup.cpp b/src/widgets/dialogs/EmotePopup.cpp index 3f6d464bd..91a1a2eb4 100644 --- a/src/widgets/dialogs/EmotePopup.cpp +++ b/src/widgets/dialogs/EmotePopup.cpp @@ -15,16 +15,16 @@ namespace chatterino { EmotePopup::EmotePopup() : BaseWindow(nullptr, BaseWindow::EnableCustomFrame) { - this->viewEmotes = new ChannelView(); - this->viewEmojis = new ChannelView(); + this->viewEmotes_ = new ChannelView(); + this->viewEmojis_ = new ChannelView(); - this->viewEmotes->setOverrideFlags(MessageElement::Flags( + this->viewEmotes_->setOverrideFlags(MessageElement::Flags( MessageElement::Default | MessageElement::AlwaysShow | MessageElement::EmoteImages)); - this->viewEmojis->setOverrideFlags(MessageElement::Flags( + this->viewEmojis_->setOverrideFlags(MessageElement::Flags( MessageElement::Default | MessageElement::AlwaysShow | MessageElement::EmoteImages)); - this->viewEmotes->setEnableScrollingToBottom(false); - this->viewEmojis->setEnableScrollingToBottom(false); + this->viewEmotes_->setEnableScrollingToBottom(false); + this->viewEmojis_->setEnableScrollingToBottom(false); auto *layout = new QVBoxLayout(this); this->getLayoutContainer()->setLayout(layout); @@ -33,14 +33,14 @@ EmotePopup::EmotePopup() layout->addWidget(notebook); layout->setMargin(0); - notebook->addPage(this->viewEmotes, "Emotes"); - notebook->addPage(this->viewEmojis, "Emojis"); + notebook->addPage(this->viewEmotes_, "Emotes"); + notebook->addPage(this->viewEmojis_, "Emojis"); this->loadEmojis(); - this->viewEmotes->linkClicked.connect( + this->viewEmotes_->linkClicked.connect( [this](const Link &link) { this->linkClicked.invoke(link); }); - this->viewEmojis->linkClicked.connect( + this->viewEmojis_->linkClicked.connect( [this](const Link &link) { this->linkClicked.invoke(link); }); } @@ -127,7 +127,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel) addEmotes(*channel->ffzChannelEmotes.get(), "FrankerFaceZ Channel Emotes", "FrankerFaceZ Channel Emote"); - this->viewEmotes->setChannel(emoteChannel); + this->viewEmotes_->setChannel(emoteChannel); } void EmotePopup::loadEmojis() @@ -155,7 +155,7 @@ void EmotePopup::loadEmojis() }); emojiChannel->addMessage(builder.getMessage()); - this->viewEmojis->setChannel(emojiChannel); + this->viewEmojis_->setChannel(emojiChannel); } } // namespace chatterino diff --git a/src/widgets/dialogs/EmotePopup.hpp b/src/widgets/dialogs/EmotePopup.hpp index 02b48731f..ad89a37d0 100644 --- a/src/widgets/dialogs/EmotePopup.hpp +++ b/src/widgets/dialogs/EmotePopup.hpp @@ -19,8 +19,8 @@ public: pajlada::Signals::Signal linkClicked; private: - ChannelView *viewEmotes; - ChannelView *viewEmojis; + ChannelView *viewEmotes_; + ChannelView *viewEmojis_; }; } // namespace chatterino diff --git a/src/widgets/dialogs/LoginDialog.cpp b/src/widgets/dialogs/LoginDialog.cpp index 76410b254..c652053b9 100644 --- a/src/widgets/dialogs/LoginDialog.cpp +++ b/src/widgets/dialogs/LoginDialog.cpp @@ -63,22 +63,22 @@ void LogInWithCredentials(const std::string &userID, const std::string &username BasicLoginWidget::BasicLoginWidget() { - this->setLayout(&this->ui.layout); + this->setLayout(&this->ui_.layout); - this->ui.loginButton.setText("Log in (Opens in browser)"); - this->ui.pasteCodeButton.setText("Paste code"); + this->ui_.loginButton.setText("Log in (Opens in browser)"); + this->ui_.pasteCodeButton.setText("Paste code"); - this->ui.horizontalLayout.addWidget(&this->ui.loginButton); - this->ui.horizontalLayout.addWidget(&this->ui.pasteCodeButton); + this->ui_.horizontalLayout.addWidget(&this->ui_.loginButton); + this->ui_.horizontalLayout.addWidget(&this->ui_.pasteCodeButton); - this->ui.layout.addLayout(&this->ui.horizontalLayout); + this->ui_.layout.addLayout(&this->ui_.horizontalLayout); - connect(&this->ui.loginButton, &QPushButton::clicked, []() { + connect(&this->ui_.loginButton, &QPushButton::clicked, []() { printf("open login in browser\n"); QDesktopServices::openUrl(QUrl("https://chatterino.com/client_login")); }); - connect(&this->ui.pasteCodeButton, &QPushButton::clicked, [this]() { + connect(&this->ui_.pasteCodeButton, &QPushButton::clicked, [this]() { QClipboard *clipboard = QGuiApplication::clipboard(); QString clipboardString = clipboard->text(); QStringList parameters = clipboardString.split(';'); @@ -115,78 +115,80 @@ BasicLoginWidget::BasicLoginWidget() AdvancedLoginWidget::AdvancedLoginWidget() { - this->setLayout(&this->ui.layout); + this->setLayout(&this->ui_.layout); - this->ui.instructionsLabel.setText("1. Fill in your username\n2. Fill in your user ID or press " - "the 'Get user ID from username' button\n3. Fill in your " - "Client ID\n4. Fill in your OAuth Token\n5. Press Add User"); - this->ui.instructionsLabel.setWordWrap(true); + this->ui_.instructionsLabel.setText( + "1. Fill in your username\n2. Fill in your user ID or press " + "the 'Get user ID from username' button\n3. Fill in your " + "Client ID\n4. Fill in your OAuth Token\n5. Press Add User"); + this->ui_.instructionsLabel.setWordWrap(true); - this->ui.layout.addWidget(&this->ui.instructionsLabel); - this->ui.layout.addLayout(&this->ui.formLayout); - this->ui.layout.addLayout(&this->ui.buttonUpperRow.layout); - this->ui.layout.addLayout(&this->ui.buttonLowerRow.layout); + this->ui_.layout.addWidget(&this->ui_.instructionsLabel); + this->ui_.layout.addLayout(&this->ui_.formLayout); + this->ui_.layout.addLayout(&this->ui_.buttonUpperRow.layout); + this->ui_.layout.addLayout(&this->ui_.buttonLowerRow.layout); this->refreshButtons(); /// Form - this->ui.formLayout.addRow("Username", &this->ui.usernameInput); - this->ui.formLayout.addRow("User ID", &this->ui.userIDInput); - this->ui.formLayout.addRow("Client ID", &this->ui.clientIDInput); - this->ui.formLayout.addRow("Oauth token", &this->ui.oauthTokenInput); + this->ui_.formLayout.addRow("Username", &this->ui_.usernameInput); + this->ui_.formLayout.addRow("User ID", &this->ui_.userIDInput); + this->ui_.formLayout.addRow("Client ID", &this->ui_.clientIDInput); + this->ui_.formLayout.addRow("Oauth token", &this->ui_.oauthTokenInput); - this->ui.oauthTokenInput.setEchoMode(QLineEdit::Password); + this->ui_.oauthTokenInput.setEchoMode(QLineEdit::Password); - connect(&this->ui.userIDInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); }); - connect(&this->ui.usernameInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); }); - connect(&this->ui.clientIDInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); }); - connect(&this->ui.oauthTokenInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); }); + connect(&this->ui_.userIDInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); }); + connect(&this->ui_.usernameInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); }); + connect(&this->ui_.clientIDInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); }); + connect(&this->ui_.oauthTokenInput, &QLineEdit::textChanged, [=]() { this->refreshButtons(); }); /// Upper button row - this->ui.buttonUpperRow.addUserButton.setText("Add user"); - this->ui.buttonUpperRow.clearFieldsButton.setText("Clear fields"); + this->ui_.buttonUpperRow.addUserButton.setText("Add user"); + this->ui_.buttonUpperRow.clearFieldsButton.setText("Clear fields"); - this->ui.buttonUpperRow.layout.addWidget(&this->ui.buttonUpperRow.addUserButton); - this->ui.buttonUpperRow.layout.addWidget(&this->ui.buttonUpperRow.clearFieldsButton); + this->ui_.buttonUpperRow.layout.addWidget(&this->ui_.buttonUpperRow.addUserButton); + this->ui_.buttonUpperRow.layout.addWidget(&this->ui_.buttonUpperRow.clearFieldsButton); - connect(&this->ui.buttonUpperRow.clearFieldsButton, &QPushButton::clicked, [=]() { - this->ui.userIDInput.clear(); - this->ui.usernameInput.clear(); - this->ui.clientIDInput.clear(); - this->ui.oauthTokenInput.clear(); + connect(&this->ui_.buttonUpperRow.clearFieldsButton, &QPushButton::clicked, [=]() { + this->ui_.userIDInput.clear(); + this->ui_.usernameInput.clear(); + this->ui_.clientIDInput.clear(); + this->ui_.oauthTokenInput.clear(); }); - connect(&this->ui.buttonUpperRow.addUserButton, &QPushButton::clicked, [=]() { - std::string userID = this->ui.userIDInput.text().toStdString(); - std::string username = this->ui.usernameInput.text().toStdString(); - std::string clientID = this->ui.clientIDInput.text().toStdString(); - std::string oauthToken = this->ui.oauthTokenInput.text().toStdString(); + connect(&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked, [=]() { + std::string userID = this->ui_.userIDInput.text().toStdString(); + std::string username = this->ui_.usernameInput.text().toStdString(); + std::string clientID = this->ui_.clientIDInput.text().toStdString(); + std::string oauthToken = this->ui_.oauthTokenInput.text().toStdString(); LogInWithCredentials(userID, username, clientID, oauthToken); }); /// Lower button row - this->ui.buttonLowerRow.fillInUserIDButton.setText("Get user ID from username"); + this->ui_.buttonLowerRow.fillInUserIDButton.setText("Get user ID from username"); - this->ui.buttonLowerRow.layout.addWidget(&this->ui.buttonLowerRow.fillInUserIDButton); + this->ui_.buttonLowerRow.layout.addWidget(&this->ui_.buttonLowerRow.fillInUserIDButton); - connect(&this->ui.buttonLowerRow.fillInUserIDButton, &QPushButton::clicked, [=]() { - twitchApiGetUserID(this->ui.usernameInput.text(), this, [=](const QString &userID) { - this->ui.userIDInput.setText(userID); // + connect(&this->ui_.buttonLowerRow.fillInUserIDButton, &QPushButton::clicked, [=]() { + twitchApiGetUserID(this->ui_.usernameInput.text(), this, [=](const QString &userID) { + this->ui_.userIDInput.setText(userID); // }); }); } void AdvancedLoginWidget::refreshButtons() { - this->ui.buttonLowerRow.fillInUserIDButton.setEnabled(!this->ui.usernameInput.text().isEmpty()); + this->ui_.buttonLowerRow.fillInUserIDButton.setEnabled( + !this->ui_.usernameInput.text().isEmpty()); - if (this->ui.userIDInput.text().isEmpty() || this->ui.usernameInput.text().isEmpty() || - this->ui.clientIDInput.text().isEmpty() || this->ui.oauthTokenInput.text().isEmpty()) { - this->ui.buttonUpperRow.addUserButton.setEnabled(false); + if (this->ui_.userIDInput.text().isEmpty() || this->ui_.usernameInput.text().isEmpty() || + this->ui_.clientIDInput.text().isEmpty() || this->ui_.oauthTokenInput.text().isEmpty()) { + this->ui_.buttonUpperRow.addUserButton.setEnabled(false); } else { - this->ui.buttonUpperRow.addUserButton.setEnabled(true); + this->ui_.buttonUpperRow.addUserButton.setEnabled(true); } } @@ -197,21 +199,21 @@ LoginWidget::LoginWidget() SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); #endif - this->setLayout(&this->ui.mainLayout); + this->setLayout(&this->ui_.mainLayout); - this->ui.mainLayout.addWidget(&this->ui.tabWidget); + this->ui_.mainLayout.addWidget(&this->ui_.tabWidget); - this->ui.tabWidget.addTab(&this->ui.basic, "Basic"); + this->ui_.tabWidget.addTab(&this->ui_.basic, "Basic"); - this->ui.tabWidget.addTab(&this->ui.advanced, "Advanced"); + this->ui_.tabWidget.addTab(&this->ui_.advanced, "Advanced"); - this->ui.buttonBox.setStandardButtons(QDialogButtonBox::Close); + this->ui_.buttonBox.setStandardButtons(QDialogButtonBox::Close); - QObject::connect(&this->ui.buttonBox, &QDialogButtonBox::rejected, [this]() { + QObject::connect(&this->ui_.buttonBox, &QDialogButtonBox::rejected, [this]() { this->close(); // }); - this->ui.mainLayout.addWidget(&this->ui.buttonBox); + this->ui_.mainLayout.addWidget(&this->ui_.buttonBox); } } // namespace chatterino diff --git a/src/widgets/dialogs/LoginDialog.hpp b/src/widgets/dialogs/LoginDialog.hpp index 6394868df..d9363727d 100644 --- a/src/widgets/dialogs/LoginDialog.hpp +++ b/src/widgets/dialogs/LoginDialog.hpp @@ -29,7 +29,7 @@ public: QHBoxLayout horizontalLayout; QPushButton loginButton; QPushButton pasteCodeButton; - } ui; + } ui_; }; class AdvancedLoginWidget : public QWidget @@ -63,7 +63,7 @@ public: QPushButton fillInUserIDButton; } buttonLowerRow; - } ui; + } ui_; }; class LoginWidget : public QDialog @@ -82,7 +82,7 @@ private: BasicLoginWidget basic; AdvancedLoginWidget advanced; - } ui; + } ui_; }; } // namespace chatterino diff --git a/src/widgets/dialogs/LogsPopup.hpp b/src/widgets/dialogs/LogsPopup.hpp index e29441b1e..90c7f9b0c 100644 --- a/src/widgets/dialogs/LogsPopup.hpp +++ b/src/widgets/dialogs/LogsPopup.hpp @@ -16,15 +16,15 @@ public: void setInfo(std::shared_ptr channel, QString userName); private: - ChannelView *channelView_ = nullptr; - ChannelPtr channel_ = Channel::getEmpty(); - - QString userName_; - void initLayout(); void setMessages(std::vector &messages); void getOverrustleLogs(); void getLogviewerLogs(); + + ChannelView *channelView_ = nullptr; + ChannelPtr channel_ = Channel::getEmpty(); + + QString userName_; }; } // namespace chatterino diff --git a/src/widgets/dialogs/NotificationPopup.cpp b/src/widgets/dialogs/NotificationPopup.cpp index ad67dcb8c..cc7a46abf 100644 --- a/src/widgets/dialogs/NotificationPopup.cpp +++ b/src/widgets/dialogs/NotificationPopup.cpp @@ -10,17 +10,17 @@ namespace chatterino { NotificationPopup::NotificationPopup() : BaseWindow((QWidget *)nullptr, BaseWindow::Frameless) - , channel(std::make_shared("notifications", Channel::Type::None)) + , channel_(std::make_shared("notifications", Channel::Type::None)) { - this->channelView = new ChannelView(this); + this->channelView_ = new ChannelView(this); auto *layout = new QVBoxLayout(this); this->setLayout(layout); - layout->addWidget(this->channelView); + layout->addWidget(this->channelView_); - this->channelView->setChannel(this->channel); + this->channelView_->setChannel(this->channel_); this->setScaleIndependantSize(300, 150); } @@ -40,7 +40,7 @@ void NotificationPopup::updatePosition() void NotificationPopup::addMessage(MessagePtr msg) { - this->channel->addMessage(msg); + this->channel_->addMessage(msg); // QTimer::singleShot(5000, this, [this, msg] { this->channel->remove }); } diff --git a/src/widgets/dialogs/NotificationPopup.hpp b/src/widgets/dialogs/NotificationPopup.hpp index dae060bd4..04a35b3a7 100644 --- a/src/widgets/dialogs/NotificationPopup.hpp +++ b/src/widgets/dialogs/NotificationPopup.hpp @@ -18,8 +18,8 @@ public: void updatePosition(); private: - ChannelView *channelView; - ChannelPtr channel; + ChannelView *channelView_; + ChannelPtr channel_; }; } // namespace chatterino diff --git a/src/widgets/dialogs/QualityPopup.cpp b/src/widgets/dialogs/QualityPopup.cpp index 3bc14f98b..faaf95b3f 100644 --- a/src/widgets/dialogs/QualityPopup.cpp +++ b/src/widgets/dialogs/QualityPopup.cpp @@ -5,7 +5,7 @@ namespace chatterino { QualityPopup::QualityPopup(const QString &_channelName, QStringList options) - : channelName(_channelName) + : channelName_(_channelName) { this->ui_.okButton.setText("OK"); this->ui_.cancelButton.setText("Cancel"); @@ -41,10 +41,10 @@ void QualityPopup::showDialog(const QString &channelName, QStringList options) void QualityPopup::okButtonClicked() { - QString channelURL = "twitch.tv/" + this->channelName; + QString channelURL = "twitch.tv/" + this->channelName_; try { - OpenStreamlink(channelURL, this->ui_.selector.currentText()); + openStreamlink(channelURL, this->ui_.selector.currentText()); } catch (const Exception &ex) { Log("Exception caught trying to open streamlink: {}", ex.what()); } diff --git a/src/widgets/dialogs/QualityPopup.hpp b/src/widgets/dialogs/QualityPopup.hpp index 640441e25..0225ae4b3 100644 --- a/src/widgets/dialogs/QualityPopup.hpp +++ b/src/widgets/dialogs/QualityPopup.hpp @@ -16,6 +16,9 @@ public: static void showDialog(const QString &_channelName, QStringList options); private: + void okButtonClicked(); + void cancelButtonClicked(); + struct { QVBoxLayout vbox; QComboBox selector; @@ -24,10 +27,7 @@ private: QPushButton cancelButton; } ui_; - QString channelName; - - void okButtonClicked(); - void cancelButtonClicked(); + QString channelName_; }; } // namespace chatterino diff --git a/src/widgets/dialogs/SelectChannelDialog.cpp b/src/widgets/dialogs/SelectChannelDialog.cpp index 87d85b577..9a9fb99df 100644 --- a/src/widgets/dialogs/SelectChannelDialog.cpp +++ b/src/widgets/dialogs/SelectChannelDialog.cpp @@ -17,11 +17,11 @@ namespace chatterino { SelectChannelDialog::SelectChannelDialog(QWidget *parent) : BaseWindow(parent, BaseWindow::EnableCustomFrame) - , selectedChannel(Channel::getEmpty()) + , selectedChannel_(Channel::getEmpty()) { this->setWindowTitle("Select a channel to join"); - this->tabFilter.dialog = this; + this->tabFilter_.dialog = this; LayoutCreator layoutWidget(this->getLayoutContainer()); auto layout = layoutWidget.setLayoutType().withoutMargin(); @@ -50,8 +50,8 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent) channel_lbl->setVisible(enabled); }); - channel_btn->installEventFilter(&this->tabFilter); - channel_edit->installEventFilter(&this->tabFilter); + channel_btn->installEventFilter(&this->tabFilter_); + channel_edit->installEventFilter(&this->tabFilter_); // whispers_btn auto whispers_btn = @@ -61,7 +61,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent) .hidden(); whispers_lbl->setWordWrap(true); - whispers_btn->installEventFilter(&this->tabFilter); + whispers_btn->installEventFilter(&this->tabFilter_); QObject::connect(whispers_btn.getElement(), &QRadioButton::toggled, [=](bool enabled) mutable { whispers_lbl->setVisible(enabled); }); @@ -74,7 +74,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent) .hidden(); mentions_lbl->setWordWrap(true); - mentions_btn->installEventFilter(&this->tabFilter); + mentions_btn->installEventFilter(&this->tabFilter_); QObject::connect(mentions_btn.getElement(), &QRadioButton::toggled, [=](bool enabled) mutable { mentions_lbl->setVisible(enabled); }); @@ -86,7 +86,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent) vbox.emplace("Requires the chatterino browser extension.").hidden(); watching_lbl->setWordWrap(true); - watching_btn->installEventFilter(&this->tabFilter); + watching_btn->installEventFilter(&this->tabFilter_); QObject::connect(watching_btn.getElement(), &QRadioButton::toggled, [=](bool enabled) mutable { watching_lbl->setVisible(enabled); }); @@ -138,7 +138,7 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent) void SelectChannelDialog::ok() { - this->_hasSelectedChannel = true; + this->hasSelectedChannel_ = true; this->close(); } @@ -148,7 +148,7 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel) assert(channel); - this->selectedChannel = channel; + this->selectedChannel_ = channel; switch (_channel.getType()) { case Channel::Type::Twitch: { @@ -174,13 +174,13 @@ void SelectChannelDialog::setSelectedChannel(IndirectChannel _channel) } } - this->_hasSelectedChannel = false; + this->hasSelectedChannel_ = false; } IndirectChannel SelectChannelDialog::getSelectedChannel() const { - if (!this->_hasSelectedChannel) { - return this->selectedChannel; + if (!this->hasSelectedChannel_) { + return this->selectedChannel_; } auto app = getApp(); @@ -199,12 +199,12 @@ IndirectChannel SelectChannelDialog::getSelectedChannel() const } } - return this->selectedChannel; + return this->selectedChannel_; } bool SelectChannelDialog::hasSeletedChannel() const { - return this->_hasSelectedChannel; + return this->hasSelectedChannel_; } bool SelectChannelDialog::EventFilter::eventFilter(QObject *watched, QEvent *event) diff --git a/src/widgets/dialogs/SelectChannelDialog.hpp b/src/widgets/dialogs/SelectChannelDialog.hpp index eadd7a290..94f21595c 100644 --- a/src/widgets/dialogs/SelectChannelDialog.hpp +++ b/src/widgets/dialogs/SelectChannelDialog.hpp @@ -16,7 +16,7 @@ class SelectChannelDialog : public BaseWindow public: SelectChannelDialog(QWidget *parent = nullptr); - void setSelectedChannel(IndirectChannel selectedChannel); + void setSelectedChannel(IndirectChannel selectedChannel_); IndirectChannel getSelectedChannel() const; bool hasSeletedChannel() const; @@ -47,10 +47,10 @@ private: } twitch; } ui_; - EventFilter tabFilter; + EventFilter tabFilter_; - ChannelPtr selectedChannel; - bool _hasSelectedChannel = false; + ChannelPtr selectedChannel_; + bool hasSelectedChannel_ = false; void ok(); friend class EventFilter; diff --git a/src/widgets/dialogs/SettingsDialog.cpp b/src/widgets/dialogs/SettingsDialog.cpp index 81b421760..72100be2a 100644 --- a/src/widgets/dialogs/SettingsDialog.cpp +++ b/src/widgets/dialogs/SettingsDialog.cpp @@ -28,7 +28,6 @@ SettingsDialog::SettingsDialog() : BaseWindow(nullptr, BaseWindow::DisableCustomScaling) { this->initUi(); - this->addTabs(); this->scaleChangedEvent(this->getScale()); @@ -63,10 +62,9 @@ void SettingsDialog::initUi() this->ui_.tabContainerContainer->setObjectName("tabWidget"); this->ui_.pageStack->setObjectName("pages"); - QObject::connect(this->ui_.okButton, &QPushButton::clicked, this, - &SettingsDialog::okButtonClicked); + QObject::connect(this->ui_.okButton, &QPushButton::clicked, this, &SettingsDialog::onOkClicked); QObject::connect(this->ui_.cancelButton, &QPushButton::clicked, this, - &SettingsDialog::cancelButtonClicked); + &SettingsDialog::onCancelClicked); } SettingsDialog *SettingsDialog::getHandle() @@ -111,25 +109,25 @@ void SettingsDialog::addTab(SettingsPage *page, Qt::Alignment alignment) this->ui_.pageStack->addWidget(page); this->ui_.tabContainer->addWidget(tab, 0, alignment); - this->tabs.push_back(tab); + this->tabs_.push_back(tab); - if (this->tabs.size() == 1) { - this->select(tab); + if (this->tabs_.size() == 1) { + this->selectTab(tab); } } -void SettingsDialog::select(SettingsDialogTab *tab) +void SettingsDialog::selectTab(SettingsDialogTab *tab) { this->ui_.pageStack->setCurrentWidget(tab->getSettingsPage()); - if (this->selectedTab != nullptr) { - this->selectedTab->setSelected(false); - this->selectedTab->setStyleSheet("color: #FFF"); + if (this->selectedTab_ != nullptr) { + this->selectedTab_->setSelected(false); + this->selectedTab_->setStyleSheet("color: #FFF"); } tab->setSelected(true); tab->setStyleSheet("background: #555; color: #FFF"); - this->selectedTab = tab; + this->selectedTab_ = tab; } void SettingsDialog::showDialog(PreferredTab preferredTab) @@ -139,7 +137,7 @@ void SettingsDialog::showDialog(PreferredTab preferredTab) switch (preferredTab) { case SettingsDialog::PreferredTab::Accounts: { - instance->select(instance->tabs.at(0)); + instance->selectTab(instance->tabs_.at(0)); } break; } @@ -153,7 +151,7 @@ void SettingsDialog::refresh() { getApp()->settings->saveSnapshot(); - for (auto *tab : this->tabs) { + for (auto *tab : this->tabs_) { tab->getSettingsPage()->onShow(); } } @@ -166,7 +164,7 @@ void SettingsDialog::scaleChangedEvent(float newDpi) styleSheet.replace("", QString::number(int(14 * newDpi))); styleSheet.replace("", QString::number(int(14 * newDpi))); - for (SettingsDialogTab *tab : this->tabs) { + for (SettingsDialogTab *tab : this->tabs_) { tab->setFixedHeight(int(30 * newDpi)); } @@ -185,14 +183,14 @@ void SettingsDialog::themeChangedEvent() } ///// Widget creation helpers -void SettingsDialog::okButtonClicked() +void SettingsDialog::onOkClicked() { this->close(); } -void SettingsDialog::cancelButtonClicked() +void SettingsDialog::onCancelClicked() { - for (auto &tab : this->tabs) { + for (auto &tab : this->tabs_) { tab->getSettingsPage()->cancel(); } diff --git a/src/widgets/dialogs/SettingsDialog.hpp b/src/widgets/dialogs/SettingsDialog.hpp index 58d50b872..2b6b960af 100644 --- a/src/widgets/dialogs/SettingsDialog.hpp +++ b/src/widgets/dialogs/SettingsDialog.hpp @@ -32,9 +32,18 @@ protected: virtual void themeChangedEvent() override; private: - void refresh(); static SettingsDialog *handle; + void refresh(); + + void initUi(); + void addTabs(); + void addTab(SettingsPage *page, Qt::Alignment alignment = Qt::AlignTop); + void selectTab(SettingsDialogTab *tab); + + void onOkClicked(); + void onCancelClicked(); + struct { QWidget *tabContainerContainer; QVBoxLayout *tabContainer; @@ -42,23 +51,10 @@ private: QPushButton *okButton; QPushButton *cancelButton; } ui_; - - std::vector tabs; - - void initUi(); - void addTabs(); - void addTab(SettingsPage *page, Qt::Alignment alignment = Qt::AlignTop); - - void select(SettingsDialogTab *tab); - - SettingsDialogTab *selectedTab = nullptr; - - void okButtonClicked(); - void cancelButtonClicked(); + std::vector tabs_; + SettingsDialogTab *selectedTab_ = nullptr; friend class SettingsDialogTab; - - // static void setChildrensFont(QLayout *object, QFont &font, int indent = 0); }; } // namespace chatterino diff --git a/src/widgets/dialogs/TextInputDialog.cpp b/src/widgets/dialogs/TextInputDialog.cpp index ddcef0008..7d13a3c46 100644 --- a/src/widgets/dialogs/TextInputDialog.cpp +++ b/src/widgets/dialogs/TextInputDialog.cpp @@ -5,40 +5,50 @@ namespace chatterino { TextInputDialog::TextInputDialog(QWidget *parent) : QDialog(parent) - , _vbox(this) - , _okButton("OK") - , _cancelButton("Cancel") + , vbox_(this) + , okButton_("OK") + , cancelButton_("Cancel") { - _vbox.addWidget(&_lineEdit); - _vbox.addLayout(&_buttonBox); - _buttonBox.addStretch(1); - _buttonBox.addWidget(&_okButton); - _buttonBox.addWidget(&_cancelButton); + this->vbox_.addWidget(&lineEdit_); + this->vbox_.addLayout(&buttonBox_); + this->buttonBox_.addStretch(1); + this->buttonBox_.addWidget(&okButton_); + this->buttonBox_.addWidget(&cancelButton_); - QObject::connect(&_okButton, SIGNAL(clicked()), this, SLOT(okButtonClicked())); - QObject::connect(&_cancelButton, SIGNAL(clicked()), this, SLOT(cancelButtonClicked())); + QObject::connect(&this->okButton_, SIGNAL(clicked()), this, SLOT(okButtonClicked())); + QObject::connect(&this->cancelButton_, SIGNAL(clicked()), this, SLOT(cancelButtonClicked())); - setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); + this->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); - setWindowFlags((windowFlags() & ~(Qt::WindowContextHelpButtonHint)) | Qt::Dialog | - Qt::MSWindowsFixedSizeDialogHint); + this->setWindowFlags((this->windowFlags() & ~(Qt::WindowContextHelpButtonHint)) | Qt::Dialog | + Qt::MSWindowsFixedSizeDialogHint); +} + +QString TextInputDialog::getText() const +{ + return this->lineEdit_.text(); +} + +void TextInputDialog::setText(const QString &text) +{ + this->lineEdit_.setText(text); } void TextInputDialog::okButtonClicked() { - accept(); - close(); + this->accept(); + this->close(); } void TextInputDialog::cancelButtonClicked() { - reject(); - close(); + this->reject(); + this->close(); } void TextInputDialog::highlightText() { - this->_lineEdit.selectAll(); + this->lineEdit_.selectAll(); } } // namespace chatterino diff --git a/src/widgets/dialogs/TextInputDialog.hpp b/src/widgets/dialogs/TextInputDialog.hpp index 698818498..2fa6f7291 100644 --- a/src/widgets/dialogs/TextInputDialog.hpp +++ b/src/widgets/dialogs/TextInputDialog.hpp @@ -16,24 +16,17 @@ class TextInputDialog : public QDialog public: TextInputDialog(QWidget *parent = nullptr); - QString getText() const - { - return _lineEdit.text(); - } - - void setText(const QString &text) - { - _lineEdit.setText(text); - } + QString getText() const; + void setText(const QString &text); void highlightText(); private: - QVBoxLayout _vbox; - QLineEdit _lineEdit; - QHBoxLayout _buttonBox; - QPushButton _okButton; - QPushButton _cancelButton; + QVBoxLayout vbox_; + QLineEdit lineEdit_; + QHBoxLayout buttonBox_; + QPushButton okButton_; + QPushButton cancelButton_; private slots: void okButtonClicked(); diff --git a/src/widgets/dialogs/UserInfoPopup.cpp b/src/widgets/dialogs/UserInfoPopup.cpp index efae603bf..2bf826a20 100644 --- a/src/widgets/dialogs/UserInfoPopup.cpp +++ b/src/widgets/dialogs/UserInfoPopup.cpp @@ -94,7 +94,7 @@ UserInfoPopup::UserInfoPopup() [this] { this->channel_->sendMessage("/unmod " + this->userName_); }); // userstate - this->userStateChanged.connect([this, mod, unmod]() mutable { + this->userStateChanged_.connect([this, mod, unmod]() mutable { TwitchChannel *twitchChannel = dynamic_cast(this->channel_.get()); if (twitchChannel) { @@ -118,7 +118,7 @@ UserInfoPopup::UserInfoPopup() { auto timeout = moderation.emplace(); - this->userStateChanged.connect([this, lineMod, timeout]() mutable { + this->userStateChanged_.connect([this, lineMod, timeout]() mutable { TwitchChannel *twitchChannel = dynamic_cast(this->channel_.get()); if (twitchChannel) { @@ -232,7 +232,7 @@ void UserInfoPopup::setData(const QString &name, const ChannelPtr &channel) this->updateUserData(); - this->userStateChanged.invoke(); + this->userStateChanged_.invoke(); } void UserInfoPopup::updateUserData() diff --git a/src/widgets/dialogs/UserInfoPopup.hpp b/src/widgets/dialogs/UserInfoPopup.hpp index 10909be4a..704d0801d 100644 --- a/src/widgets/dialogs/UserInfoPopup.hpp +++ b/src/widgets/dialogs/UserInfoPopup.hpp @@ -24,6 +24,10 @@ protected: virtual void themeChangedEvent() override; private: + void installEvents(); + void updateUserData(); + + void loadAvatar(const QUrl &url); bool isMod_; bool isBroadcaster_; @@ -31,12 +35,7 @@ private: QString userId_; ChannelPtr channel_; - pajlada::Signals::NoArgSignal userStateChanged; - - void installEvents(); - - void updateUserData(); - void loadAvatar(const QUrl &url); + pajlada::Signals::NoArgSignal userStateChanged_; std::shared_ptr hack_; diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 6a114001b..2b371d8ce 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -70,13 +70,26 @@ protected: void hideEvent(QHideEvent *) override; - void handleLinkClick(QMouseEvent *event, const Link &link, - MessageLayout *layout); + void handleLinkClick(QMouseEvent *event, const Link &link, MessageLayout *layout); - bool tryGetMessageAt(QPoint p, std::shared_ptr &message, - QPoint &relativePos, int &index); + bool tryGetMessageAt(QPoint p, std::shared_ptr &message, QPoint &relativePos, + int &index); private: + void updatePauseStatus(); + void detachChannel(); + void actuallyLayoutMessages(bool causedByScollbar = false); + + void drawMessages(QPainter &painter); + void setSelection(const SelectionItem &start, const SelectionItem &end); + MessageElement::Flags getFlags() const; + bool isPaused(); + + void handleMouseClick(QMouseEvent *event, const MessageLayoutElement *hoverLayoutElement, + MessageLayout *layout); + void addContextMenuItems(const MessageLayoutElement *hoveredElement, MessageLayout *layout); + int getLayoutWidth() const; + QTimer *layoutCooldown_; bool layoutQueued_; @@ -88,7 +101,6 @@ private: bool pausedTemporarily_ = false; bool pausedBySelection_ = false; bool pausedByScrollingUp_ = false; - void updatePauseStatus(); int messagesAddedSinceSelectionPause_ = 0; QTimer pauseTimeout_; @@ -97,23 +109,6 @@ private: LimitedQueueSnapshot snapshot_; - void detachChannel(); - void actuallyLayoutMessages(bool causedByScollbar = false); - - void drawMessages(QPainter &painter); - void setSelection(const SelectionItem &start, const SelectionItem &end); - MessageElement::Flags getFlags() const; - bool isPaused(); - - void handleMouseClick(QMouseEvent *event, - const MessageLayoutElement *hoverLayoutElement, - MessageLayout *layout); - void addContextMenuItems(const MessageLayoutElement *hoveredElement, - MessageLayout *layout); - - // void beginPause(); - // void endPause(); - ChannelPtr channel_; Scrollbar scrollBar_; @@ -149,8 +144,6 @@ private: std::unordered_set> messagesOnScreen_; - int getLayoutWidth() const; - private slots: void wordFlagsChanged() { diff --git a/src/widgets/helper/ComboBoxItemDelegate.hpp b/src/widgets/helper/ComboBoxItemDelegate.hpp index 19433e2cb..2fb026d89 100644 --- a/src/widgets/helper/ComboBoxItemDelegate.hpp +++ b/src/widgets/helper/ComboBoxItemDelegate.hpp @@ -11,7 +11,7 @@ class ComboBoxItemDelegate : public QStyledItemDelegate Q_OBJECT public: - ComboBoxItemDelegate(QObject *parent = 0); + ComboBoxItemDelegate(QObject *parent = nullptr); ~ComboBoxItemDelegate(); virtual QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, diff --git a/src/widgets/helper/DropOverlay.cpp b/src/widgets/helper/DropOverlay.cpp deleted file mode 100644 index 0d49e2141..000000000 --- a/src/widgets/helper/DropOverlay.cpp +++ /dev/null @@ -1,13 +0,0 @@ -//#include "DropOverlay.hpp" - -// namespace chatterino { -// namespace widgets { -// namespace helper { - -// DropOverlay::DropOverlay() -//{ -//} - -//} // namespace helper -//} // namespace widgets -//} // namespace chatterino diff --git a/src/widgets/helper/DropOverlay.hpp b/src/widgets/helper/DropOverlay.hpp deleted file mode 100644 index e9175ff75..000000000 --- a/src/widgets/helper/DropOverlay.hpp +++ /dev/null @@ -1,11 +0,0 @@ -//#pragma once - -//#include "widgets/helper/SplitNode.hpp" - -// namespace chatterino { -// namespace widgets { -// namespace helper { - -//} // namespace helper -//} // namespace widgets -//} // namespace chatterino diff --git a/src/widgets/helper/DropPreview.cpp b/src/widgets/helper/DropPreview.cpp deleted file mode 100644 index 3ec383894..000000000 --- a/src/widgets/helper/DropPreview.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "widgets/helper/DropPreview.hpp" -#include "Application.hpp" -#include "singletons/Theme.hpp" - -#include -#include - -namespace chatterino { - -NotebookPageDropPreview::NotebookPageDropPreview(BaseWidget *parent) - : BaseWidget(parent) -// , positionAnimation(this, "geometry") -{ - // this->positionAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic)); - this->setHidden(true); -} - -void NotebookPageDropPreview::paintEvent(QPaintEvent *) -{ - QPainter painter(this); - - painter.setPen(getApp()->themes->splits.dropPreviewBorder); - painter.setBrush(getApp()->themes->splits.dropPreview); - painter.drawRect(8, 8, this->width() - 17, this->height() - 17); -} - -void NotebookPageDropPreview::hideEvent(QHideEvent *) -{ - // this->animate = false; -} - -void NotebookPageDropPreview::setBounds(const QRect &rect) -{ - // if (rect == this->desiredGeometry) { - // return; - // } - - // if (this->animate) { - // this->positionAnimation.stop(); - // this->positionAnimation.setDuration(50); - // this->positionAnimation.setStartValue(this->geometry()); - // this->positionAnimation.setEndValue(rect); - // this->positionAnimation.start(); - // } else { - this->setGeometry(rect); - // } - - // this->desiredGeometry = rect; - - // this->animate = true; -} - -} // namespace chatterino diff --git a/src/widgets/helper/DropPreview.hpp b/src/widgets/helper/DropPreview.hpp deleted file mode 100644 index 4dc04e7c4..000000000 --- a/src/widgets/helper/DropPreview.hpp +++ /dev/null @@ -1,26 +0,0 @@ -#pragma once - -#include "widgets/BaseWidget.hpp" - -#include -#include - -namespace chatterino { - -class NotebookPageDropPreview : public BaseWidget -{ -public: - NotebookPageDropPreview(BaseWidget *parent); - - void setBounds(const QRect &rect); - -protected: - void paintEvent(QPaintEvent *) override; - void hideEvent(QHideEvent *) override; - - // QPropertyAnimation positionAnimation; - // QRect desiredGeometry; - // bool animate = false; -}; - -} // namespace chatterino diff --git a/src/widgets/helper/EditableModelView.cpp b/src/widgets/helper/EditableModelView.cpp index a62dec22a..fd517f1e5 100644 --- a/src/widgets/helper/EditableModelView.cpp +++ b/src/widgets/helper/EditableModelView.cpp @@ -9,20 +9,20 @@ namespace chatterino { -EditableModelView::EditableModelView(QAbstractTableModel *_model) - : tableView(new QTableView(this)) - , model(_model) +EditableModelView::EditableModelView(QAbstractTableModel *model) + : tableView_(new QTableView(this)) + , model_(model) { - this->model->setParent(this); - this->tableView->setModel(_model); - this->tableView->setSelectionMode(QAbstractItemView::ExtendedSelection); - this->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); - this->tableView->verticalHeader()->hide(); + this->model_->setParent(this); + this->tableView_->setModel(model); + this->tableView_->setSelectionMode(QAbstractItemView::ExtendedSelection); + this->tableView_->setSelectionBehavior(QAbstractItemView::SelectRows); + this->tableView_->verticalHeader()->hide(); // create layout QVBoxLayout *vbox = new QVBoxLayout(this); vbox->setMargin(0); - vbox->addWidget(this->tableView); + vbox->addWidget(this->tableView_); // create button layout QHBoxLayout *buttons = new QHBoxLayout(this); @@ -39,7 +39,7 @@ EditableModelView::EditableModelView(QAbstractTableModel *_model) QObject::connect(remove, &QPushButton::clicked, [this] { QModelIndexList list; while ((list = this->getTableView()->selectionModel()->selectedRows(0)).length() > 0) { - model->removeRow(list[0].row()); + model_->removeRow(list[0].row()); } }); @@ -51,22 +51,22 @@ void EditableModelView::setTitles(std::initializer_list titles) { int i = 0; for (const QString &title : titles) { - if (this->model->columnCount() == i) { + if (this->model_->columnCount() == i) { break; } - this->model->setHeaderData(i++, Qt::Horizontal, title, Qt::DisplayRole); + this->model_->setHeaderData(i++, Qt::Horizontal, title, Qt::DisplayRole); } } QTableView *EditableModelView::getTableView() { - return this->tableView; + return this->tableView_; } QAbstractTableModel *EditableModelView::getModel() { - return this->model; + return this->model_; } } // namespace chatterino diff --git a/src/widgets/helper/EditableModelView.hpp b/src/widgets/helper/EditableModelView.hpp index bd883d784..86a2b1540 100644 --- a/src/widgets/helper/EditableModelView.hpp +++ b/src/widgets/helper/EditableModelView.hpp @@ -22,8 +22,8 @@ public: pajlada::Signals::NoArgSignal addButtonPressed; private: - QTableView *tableView; - QAbstractTableModel *model; + QTableView *tableView_; + QAbstractTableModel *model_; }; } // namespace chatterino diff --git a/src/widgets/helper/NotebookButton.hpp b/src/widgets/helper/NotebookButton.hpp index 01504ad8d..1a8a9cd71 100644 --- a/src/widgets/helper/NotebookButton.hpp +++ b/src/widgets/helper/NotebookButton.hpp @@ -17,7 +17,7 @@ public: explicit NotebookButton(Notebook *parent); - void setIcon(Icon icon_); + void setIcon(Icon icon); Icon getIcon() const; protected: diff --git a/src/widgets/helper/NotebookTab.hpp b/src/widgets/helper/NotebookTab.hpp index ff6249a9c..911e71e4a 100644 --- a/src/widgets/helper/NotebookTab.hpp +++ b/src/widgets/helper/NotebookTab.hpp @@ -22,7 +22,7 @@ class NotebookTab : public RippleEffectButton Q_OBJECT public: - explicit NotebookTab(Notebook *_notebook); + explicit NotebookTab(Notebook *notebook); void updateSize(); @@ -61,7 +61,10 @@ protected: virtual void mouseMoveEvent(QMouseEvent *event) override; private: - std::vector managedConnections_; + bool hasXButton(); + bool shouldDrawXButton(); + QRect getXRect(); + void titleUpdated(); QPropertyAnimation positionChangedAnimation_; bool positionChangedAnimationRunning_ = false; @@ -78,15 +81,11 @@ private: bool mouseOverX_ = false; bool mouseDownX_ = false; - bool hasXButton(); - bool shouldDrawXButton(); - HighlightState highlightState_ = HighlightState::None; QMenu menu_; - QRect getXRect(); - void titleUpdated(); + std::vector managedConnections_; }; } // namespace chatterino diff --git a/src/widgets/helper/ResizingTextEdit.cpp b/src/widgets/helper/ResizingTextEdit.cpp index 2bfc7ff04..abab6dd23 100644 --- a/src/widgets/helper/ResizingTextEdit.cpp +++ b/src/widgets/helper/ResizingTextEdit.cpp @@ -82,7 +82,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event) if (doComplete) { // check if there is a completer - if (!this->completer) { + if (!this->completer_) { return; } @@ -93,32 +93,32 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event) return; } - auto *completionModel = static_cast(this->completer->model()); + auto *completionModel = static_cast(this->completer_->model()); - if (!this->completionInProgress) { + if (!this->completionInProgress_) { // First type pressing tab after modifying a message, we refresh our completion model - this->completer->setModel(completionModel); + this->completer_->setModel(completionModel); completionModel->refresh(); - this->completionInProgress = true; - this->completer->setCompletionPrefix(currentCompletionPrefix); - this->completer->complete(); + this->completionInProgress_ = true; + this->completer_->setCompletionPrefix(currentCompletionPrefix); + this->completer_->complete(); return; } // scrolling through selections if (event->key() == Qt::Key_Tab) { - if (!this->completer->setCurrentRow(this->completer->currentRow() + 1)) { + if (!this->completer_->setCurrentRow(this->completer_->currentRow() + 1)) { // wrap over and start again - this->completer->setCurrentRow(0); + this->completer_->setCurrentRow(0); } } else { - if (!this->completer->setCurrentRow(this->completer->currentRow() - 1)) { + if (!this->completer_->setCurrentRow(this->completer_->currentRow() - 1)) { // wrap over and start again - this->completer->setCurrentRow(this->completer->completionCount() - 1); + this->completer_->setCurrentRow(this->completer_->completionCount() - 1); } } - this->completer->complete(); + this->completer_->complete(); return; } @@ -130,7 +130,7 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event) if (event->key() != Qt::Key_Shift && event->key() != Qt::Key_Control && event->key() != Qt::Key_Alt && event->key() != Qt::Key_Super_L && event->key() != Qt::Key_Super_R) { - this->completionInProgress = false; + this->completionInProgress_ = false; } if (!event->isAccepted()) { @@ -158,27 +158,27 @@ void ResizingTextEdit::focusOutEvent(QFocusEvent *event) void ResizingTextEdit::setCompleter(QCompleter *c) { - if (this->completer) { - QObject::disconnect(this->completer, nullptr, this, nullptr); + if (this->completer_) { + QObject::disconnect(this->completer_, nullptr, this, nullptr); } - this->completer = c; + this->completer_ = c; - if (!this->completer) { + if (!this->completer_) { return; } - this->completer->setWidget(this); - this->completer->setCompletionMode(QCompleter::InlineCompletion); - this->completer->setCaseSensitivity(Qt::CaseInsensitive); - QObject::connect(completer, + this->completer_->setWidget(this); + this->completer_->setCompletionMode(QCompleter::InlineCompletion); + this->completer_->setCaseSensitivity(Qt::CaseInsensitive); + QObject::connect(completer_, static_cast(&QCompleter::highlighted), this, &ResizingTextEdit::insertCompletion); } void ResizingTextEdit::insertCompletion(const QString &completion) { - if (this->completer->widget() != this) { + if (this->completer_->widget() != this) { return; } @@ -199,7 +199,7 @@ void ResizingTextEdit::insertCompletion(const QString &completion) QCompleter *ResizingTextEdit::getCompleter() const { - return this->completer; + return this->completer_; } } // namespace chatterino diff --git a/src/widgets/helper/ResizingTextEdit.hpp b/src/widgets/helper/ResizingTextEdit.hpp index 0e633cdc4..9006cca25 100644 --- a/src/widgets/helper/ResizingTextEdit.hpp +++ b/src/widgets/helper/ResizingTextEdit.hpp @@ -31,12 +31,12 @@ protected: void focusOutEvent(QFocusEvent *event) override; private: - QCompleter *completer = nullptr; - bool completionInProgress = false; - // hadSpace is set to true in case the "textUnderCursor" word was after a space QString textUnderCursor(bool *hadSpace = nullptr) const; + QCompleter *completer_ = nullptr; + bool completionInProgress_ = false; + private slots: void insertCompletion(const QString &completion); }; diff --git a/src/widgets/helper/RippleEffectButton.hpp b/src/widgets/helper/RippleEffectButton.hpp index 583ea52a1..1211cddf0 100644 --- a/src/widgets/helper/RippleEffectButton.hpp +++ b/src/widgets/helper/RippleEffectButton.hpp @@ -48,11 +48,6 @@ signals: void leftMousePress(); protected: - bool enabled_ = true; - bool selected_ = false; - bool mouseOver_ = false; - bool mouseDown_ = false; - virtual void paintEvent(QPaintEvent *) override; virtual void enterEvent(QEvent *) override; virtual void leaveEvent(QEvent *) override; @@ -62,7 +57,14 @@ protected: void fancyPaint(QPainter &painter); + bool enabled_ = true; + bool selected_ = false; + bool mouseOver_ = false; + bool mouseDown_ = false; + private: + void onMouseEffectTimeout(); + QColor borderColor_; QPixmap pixmap_; bool dimPixmap_ = true; @@ -71,8 +73,6 @@ private: QTimer effectTimer_; std::vector clickEffects_; boost::optional mouseEffectColor_ = boost::none; - - void onMouseEffectTimeout(); }; } // namespace chatterino diff --git a/src/widgets/helper/RippleEffectLabel.cpp b/src/widgets/helper/RippleEffectLabel.cpp index 40c9c876a..a4a8180c1 100644 --- a/src/widgets/helper/RippleEffectLabel.cpp +++ b/src/widgets/helper/RippleEffectLabel.cpp @@ -9,16 +9,16 @@ namespace chatterino { RippleEffectLabel::RippleEffectLabel(BaseWidget *parent, int spacing) : RippleEffectButton(parent) - , label(this) + , label_(this) { - setLayout(&this->hbox); + setLayout(&this->hbox_); - this->label.setAlignment(Qt::AlignCenter); + this->label_.setAlignment(Qt::AlignCenter); - this->hbox.setMargin(0); - this->hbox.addSpacing(spacing); - this->hbox.addWidget(&this->label); - this->hbox.addSpacing(spacing); + this->hbox_.setMargin(0); + this->hbox_.addSpacing(spacing); + this->hbox_.addWidget(&this->label_); + this->hbox_.addSpacing(spacing); } RippleEffectLabel2::RippleEffectLabel2(BaseWidget *parent, int padding) diff --git a/src/widgets/helper/RippleEffectLabel.hpp b/src/widgets/helper/RippleEffectLabel.hpp index a18119905..b8ada5518 100644 --- a/src/widgets/helper/RippleEffectLabel.hpp +++ b/src/widgets/helper/RippleEffectLabel.hpp @@ -19,12 +19,12 @@ public: SignalLabel &getLabel() { - return this->label; + return this->label_; } private: - QHBoxLayout hbox; - SignalLabel label; + QHBoxLayout hbox_; + SignalLabel label_; }; class RippleEffectLabel2 : public RippleEffectButton diff --git a/src/widgets/helper/ScrollbarHighlight.cpp b/src/widgets/helper/ScrollbarHighlight.cpp index a9892d067..addfffafe 100644 --- a/src/widgets/helper/ScrollbarHighlight.cpp +++ b/src/widgets/helper/ScrollbarHighlight.cpp @@ -5,30 +5,30 @@ namespace chatterino { ScrollbarHighlight::ScrollbarHighlight() - : color(Color::Highlight) - , style(Style::None) + : color_(Color::Highlight) + , style_(Style::None) { } -ScrollbarHighlight::ScrollbarHighlight(Color _color, Style _style) - : color(_color) - , style(_style) +ScrollbarHighlight::ScrollbarHighlight(Color color, Style style) + : color_(color) + , style_(style) { } ScrollbarHighlight::Color ScrollbarHighlight::getColor() const { - return this->color; + return this->color_; } ScrollbarHighlight::Style ScrollbarHighlight::getStyle() const { - return this->style; + return this->style_; } bool ScrollbarHighlight::isNull() const { - return this->style == None; + return this->style_ == None; } } // namespace chatterino diff --git a/src/widgets/helper/ScrollbarHighlight.hpp b/src/widgets/helper/ScrollbarHighlight.hpp index 16b9a08fd..b88cdae09 100644 --- a/src/widgets/helper/ScrollbarHighlight.hpp +++ b/src/widgets/helper/ScrollbarHighlight.hpp @@ -11,15 +11,15 @@ public: enum Color : char { Highlight, Subscription }; ScrollbarHighlight(); - ScrollbarHighlight(Color _color, Style _style = Default); + ScrollbarHighlight(Color color, Style style = Default); Color getColor() const; Style getStyle() const; bool isNull() const; private: - Color color; - Style style; + Color color_; + Style style_; }; } // namespace chatterino diff --git a/src/widgets/helper/SearchPopup.cpp b/src/widgets/helper/SearchPopup.cpp index facf2796d..52d20b337 100644 --- a/src/widgets/helper/SearchPopup.cpp +++ b/src/widgets/helper/SearchPopup.cpp @@ -30,9 +30,9 @@ void SearchPopup::initLayout() // SEARCH INPUT { - this->searchInput = new QLineEdit(this); - layout2->addWidget(this->searchInput); - QObject::connect(this->searchInput, &QLineEdit::returnPressed, + this->searchInput_ = new QLineEdit(this); + layout2->addWidget(this->searchInput_); + QObject::connect(this->searchInput_, &QLineEdit::returnPressed, [this] { this->performSearch(); }); } @@ -50,9 +50,9 @@ void SearchPopup::initLayout() // CHANNELVIEW { - this->channelView = new ChannelView(this); + this->channelView_ = new ChannelView(this); - layout1->addWidget(this->channelView); + layout1->addWidget(this->channelView_); } this->setLayout(layout1); @@ -61,7 +61,7 @@ void SearchPopup::initLayout() void SearchPopup::setChannel(ChannelPtr channel) { - this->snapshot = channel->getMessageSnapshot(); + this->snapshot_ = channel->getMessageSnapshot(); this->performSearch(); this->setWindowTitle("Searching in " + channel->name + "s history"); @@ -69,20 +69,20 @@ void SearchPopup::setChannel(ChannelPtr channel) void SearchPopup::performSearch() { - QString text = searchInput->text(); + QString text = searchInput_->text(); ChannelPtr channel(new Channel("search", Channel::Type::None)); - for (size_t i = 0; i < this->snapshot.getLength(); i++) { - MessagePtr message = this->snapshot[i]; + for (size_t i = 0; i < this->snapshot_.getLength(); i++) { + MessagePtr message = this->snapshot_[i]; if (text.isEmpty() || - message->searchText.indexOf(this->searchInput->text(), 0, Qt::CaseInsensitive) != -1) { + message->searchText.indexOf(this->searchInput_->text(), 0, Qt::CaseInsensitive) != -1) { channel->addMessage(message); } } - this->channelView->setChannel(channel); + this->channelView_->setChannel(channel); } } // namespace chatterino diff --git a/src/widgets/helper/SearchPopup.hpp b/src/widgets/helper/SearchPopup.hpp index 509cc6e56..0a7065c55 100644 --- a/src/widgets/helper/SearchPopup.hpp +++ b/src/widgets/helper/SearchPopup.hpp @@ -21,12 +21,12 @@ public: void setChannel(std::shared_ptr channel); private: - LimitedQueueSnapshot snapshot; - QLineEdit *searchInput; - ChannelView *channelView; - void initLayout(); void performSearch(); + + LimitedQueueSnapshot snapshot_; + QLineEdit *searchInput_; + ChannelView *channelView_; }; } // namespace chatterino diff --git a/src/widgets/helper/SettingsDialogTab.cpp b/src/widgets/helper/SettingsDialogTab.cpp index e84734666..480f54dc4 100644 --- a/src/widgets/helper/SettingsDialogTab.cpp +++ b/src/widgets/helper/SettingsDialogTab.cpp @@ -10,11 +10,11 @@ namespace chatterino { SettingsDialogTab::SettingsDialogTab(SettingsDialog *_dialog, SettingsPage *_page, QString imageFileName) : BaseWidget(_dialog) - , dialog(_dialog) - , page(_page) + , dialog_(_dialog) + , page_(_page) { - this->ui.labelText = page->getName(); - this->ui.icon.addFile(imageFileName); + this->ui_.labelText = page_->getName(); + this->ui_.icon.addFile(imageFileName); this->setCursor(QCursor(Qt::PointingHandCursor)); @@ -23,19 +23,19 @@ SettingsDialogTab::SettingsDialogTab(SettingsDialog *_dialog, SettingsPage *_pag void SettingsDialogTab::setSelected(bool _selected) { - if (this->selected == _selected) { + if (this->selected_ == _selected) { return; } // height: px; - this->selected = _selected; - emit selectedChanged(selected); + this->selected_ = _selected; + emit selectedChanged(selected_); } SettingsPage *SettingsDialogTab::getSettingsPage() { - return this->page; + return this->page_; } void SettingsDialogTab::paintEvent(QPaintEvent *) @@ -48,13 +48,13 @@ void SettingsDialogTab::paintEvent(QPaintEvent *) this->style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); int a = (this->height() - (20 * this->getScale())) / 2; - QPixmap pixmap = this->ui.icon.pixmap(QSize(this->height() - a * 2, this->height() - a * 2)); + QPixmap pixmap = this->ui_.icon.pixmap(QSize(this->height() - a * 2, this->height() - a * 2)); painter.drawPixmap(a, a, pixmap); a = a + a + 20 + a; - painter.drawText(QRect(a, 0, width() - a, height()), this->ui.labelText, + painter.drawText(QRect(a, 0, width() - a, height()), this->ui_.labelText, QTextOption(Qt::AlignLeft | Qt::AlignVCenter)); } @@ -64,7 +64,7 @@ void SettingsDialogTab::mousePressEvent(QMouseEvent *event) return; } - this->dialog->select(this); + this->dialog_->selectTab(this); } } // namespace chatterino diff --git a/src/widgets/helper/SettingsDialogTab.hpp b/src/widgets/helper/SettingsDialogTab.hpp index 8b608bcd6..5cb922819 100644 --- a/src/widgets/helper/SettingsDialogTab.hpp +++ b/src/widgets/helper/SettingsDialogTab.hpp @@ -16,9 +16,9 @@ class SettingsDialogTab : public BaseWidget Q_OBJECT public: - SettingsDialogTab(SettingsDialog *dialog, SettingsPage *page, QString imageFileName); + SettingsDialogTab(SettingsDialog *dialog_, SettingsPage *page_, QString imageFileName); - void setSelected(bool selected); + void setSelected(bool selected_); SettingsPage *getSettingsPage(); signals: @@ -31,13 +31,13 @@ private: struct { QString labelText; QIcon icon; - } ui; + } ui_; // Parent settings dialog - SettingsDialog *dialog; - SettingsPage *page; + SettingsDialog *dialog_; + SettingsPage *page_; - bool selected = false; + bool selected_ = false; }; } // namespace chatterino diff --git a/src/widgets/helper/TitlebarButton.cpp b/src/widgets/helper/TitlebarButton.cpp index 820d33e14..09fb5903b 100644 --- a/src/widgets/helper/TitlebarButton.cpp +++ b/src/widgets/helper/TitlebarButton.cpp @@ -11,12 +11,12 @@ TitleBarButton::TitleBarButton() TitleBarButton::Style TitleBarButton::getButtonStyle() const { - return this->style; + return this->style_; } void TitleBarButton::setButtonStyle(Style _style) { - this->style = _style; + this->style_ = _style; this->update(); } @@ -34,7 +34,7 @@ void TitleBarButton::paintEvent(QPaintEvent *event) painter.setRenderHint(QPainter::Antialiasing, false); - switch (this->style) { + switch (this->style_) { case Minimize: { painter.fillRect(centerX - xD / 2, xD * 3 / 2, xD, 1, color); break; diff --git a/src/widgets/helper/TitlebarButton.hpp b/src/widgets/helper/TitlebarButton.hpp index b77995be5..2ca354bcb 100644 --- a/src/widgets/helper/TitlebarButton.hpp +++ b/src/widgets/helper/TitlebarButton.hpp @@ -20,13 +20,13 @@ public: TitleBarButton(); Style getButtonStyle() const; - void setButtonStyle(Style style); + void setButtonStyle(Style style_); protected: void paintEvent(QPaintEvent *) override; private: - Style style; + Style style_; }; } // namespace chatterino diff --git a/src/widgets/settingspages/AboutPage.cpp b/src/widgets/settingspages/AboutPage.cpp index f6ecd33c6..8cf9059a3 100644 --- a/src/widgets/settingspages/AboutPage.cpp +++ b/src/widgets/settingspages/AboutPage.cpp @@ -30,7 +30,7 @@ AboutPage::AboutPage() QPixmap pixmap; pixmap.load(":/images/aboutlogo.png"); - auto logo = layout.emplace().assign(&this->logo); + auto logo = layout.emplace().assign(&this->logo_); logo->setPixmap(pixmap); logo->setFixedSize(PIXMAP_WIDTH, PIXMAP_WIDTH * pixmap.height() / pixmap.width()); logo->setScaledContents(true); diff --git a/src/widgets/settingspages/AboutPage.hpp b/src/widgets/settingspages/AboutPage.hpp index e9b936709..bbb3588ce 100644 --- a/src/widgets/settingspages/AboutPage.hpp +++ b/src/widgets/settingspages/AboutPage.hpp @@ -13,10 +13,10 @@ public: AboutPage(); private: - QLabel *logo; - - void addLicense(QFormLayout *form, const QString &name, const QString &website, + void addLicense(QFormLayout *form, const QString &name_, const QString &website, const QString &licenseLink); + + QLabel *logo_; }; } // namespace chatterino diff --git a/src/widgets/settingspages/AccountsPage.hpp b/src/widgets/settingspages/AccountsPage.hpp index e905bd697..ce6bb7d3a 100644 --- a/src/widgets/settingspages/AccountsPage.hpp +++ b/src/widgets/settingspages/AccountsPage.hpp @@ -13,9 +13,9 @@ public: AccountsPage(); private: - QPushButton *addButton; - QPushButton *removeButton; - AccountSwitchWidget *accSwitchWidget; + QPushButton *addButton_; + QPushButton *removeButton_; + AccountSwitchWidget *accountSwitchWidget_; }; } // namespace chatterino diff --git a/src/widgets/settingspages/CommandPage.cpp b/src/widgets/settingspages/CommandPage.cpp index 905ed8c81..9b418181a 100644 --- a/src/widgets/settingspages/CommandPage.cpp +++ b/src/widgets/settingspages/CommandPage.cpp @@ -51,7 +51,7 @@ CommandPage::CommandPage() text->setStyleSheet("color: #bbb"); // ---- end of layout - this->commandsEditTimer.setSingleShot(true); + this->commandsEditTimer_.setSingleShot(true); } } // namespace chatterino diff --git a/src/widgets/settingspages/CommandPage.hpp b/src/widgets/settingspages/CommandPage.hpp index 6407eb211..60ba9175b 100644 --- a/src/widgets/settingspages/CommandPage.hpp +++ b/src/widgets/settingspages/CommandPage.hpp @@ -13,7 +13,7 @@ public: CommandPage(); private: - QTimer commandsEditTimer; + QTimer commandsEditTimer_; }; } // namespace chatterino diff --git a/src/widgets/settingspages/ExternalToolsPage.cpp b/src/widgets/settingspages/ExternalToolsPage.cpp index 7f355af60..3b77fc035 100644 --- a/src/widgets/settingspages/ExternalToolsPage.cpp +++ b/src/widgets/settingspages/ExternalToolsPage.cpp @@ -66,7 +66,7 @@ ExternalToolsPage::ExternalToolsPage() [=](const auto &value, auto) { customPath->setEnabled(value); // }, - this->managedConnections); + this->managedConnections_); } layout->addStretch(1); diff --git a/src/widgets/settingspages/HighlightingPage.cpp b/src/widgets/settingspages/HighlightingPage.cpp index 045ab5644..45a0876f3 100644 --- a/src/widgets/settingspages/HighlightingPage.cpp +++ b/src/widgets/settingspages/HighlightingPage.cpp @@ -131,7 +131,7 @@ HighlightingPage::HighlightingPage() } // ---- misc - this->disabledUsersChangedTimer.setSingleShot(true); + this->disabledUsersChangedTimer_.setSingleShot(true); } } // namespace chatterino diff --git a/src/widgets/settingspages/HighlightingPage.hpp b/src/widgets/settingspages/HighlightingPage.hpp index 80152db9e..327cef33a 100644 --- a/src/widgets/settingspages/HighlightingPage.hpp +++ b/src/widgets/settingspages/HighlightingPage.hpp @@ -16,7 +16,7 @@ public: HighlightingPage(); private: - QTimer disabledUsersChangedTimer; + QTimer disabledUsersChangedTimer_; }; } // namespace chatterino diff --git a/src/widgets/settingspages/IgnoresPage.cpp b/src/widgets/settingspages/IgnoresPage.cpp index 5d6131d29..fe7b86d0e 100644 --- a/src/widgets/settingspages/IgnoresPage.cpp +++ b/src/widgets/settingspages/IgnoresPage.cpp @@ -34,7 +34,7 @@ IgnoresPage::IgnoresPage() auto tabs = layout.emplace(); addPhrasesTab(tabs.appendTab(new QVBoxLayout, "Phrases")); - addUsersTab(*this, tabs.appendTab(new QVBoxLayout, "Users"), this->userListModel); + addUsersTab(*this, tabs.appendTab(new QVBoxLayout, "Users"), this->userListModel_); auto label = layout.emplace(INFO); label->setWordWrap(true); @@ -95,7 +95,7 @@ void IgnoresPage::onShow() for (const auto &ignoredUser : user->getIgnores()) { users << ignoredUser.name; } - this->userListModel.setStringList(users); + this->userListModel_.setStringList(users); } } // namespace chatterino diff --git a/src/widgets/settingspages/IgnoresPage.hpp b/src/widgets/settingspages/IgnoresPage.hpp index 5a966fcbb..a3b82089f 100644 --- a/src/widgets/settingspages/IgnoresPage.hpp +++ b/src/widgets/settingspages/IgnoresPage.hpp @@ -16,7 +16,7 @@ public: void onShow() final; private: - QStringListModel userListModel; + QStringListModel userListModel_; }; } // namespace chatterino diff --git a/src/widgets/settingspages/LookPage.cpp b/src/widgets/settingspages/LookPage.cpp index bcdeb0ad7..b0d9baaf2 100644 --- a/src/widgets/settingspages/LookPage.cpp +++ b/src/widgets/settingspages/LookPage.cpp @@ -355,8 +355,8 @@ QLayout *LookPage::createFontChanger() ", " + QString::number(app->fonts->chatFontSize) + "pt)"); }; - app->fonts->chatFontFamily.connectSimple(updateFontFamilyLabel, this->managedConnections); - app->fonts->chatFontSize.connectSimple(updateFontFamilyLabel, this->managedConnections); + app->fonts->chatFontFamily.connectSimple(updateFontFamilyLabel, this->managedConnections_); + app->fonts->chatFontSize.connectSimple(updateFontFamilyLabel, this->managedConnections_); // BUTTON QPushButton *button = new QPushButton("Select"); diff --git a/src/widgets/settingspages/ModerationPage.cpp b/src/widgets/settingspages/ModerationPage.cpp index 9e61bd3d4..fd07cf5b9 100644 --- a/src/widgets/settingspages/ModerationPage.cpp +++ b/src/widgets/settingspages/ModerationPage.cpp @@ -146,7 +146,7 @@ ModerationPage::ModerationPage() } // ---- misc - this->itemsChangedTimer.setSingleShot(true); + this->itemsChangedTimer_.setSingleShot(true); } } // namespace chatterino diff --git a/src/widgets/settingspages/ModerationPage.hpp b/src/widgets/settingspages/ModerationPage.hpp index 954c20cde..cd879625f 100644 --- a/src/widgets/settingspages/ModerationPage.hpp +++ b/src/widgets/settingspages/ModerationPage.hpp @@ -14,7 +14,7 @@ public: ModerationPage(); private: - QTimer itemsChangedTimer; + QTimer itemsChangedTimer_; }; } // namespace chatterino diff --git a/src/widgets/settingspages/SettingsPage.cpp b/src/widgets/settingspages/SettingsPage.cpp index 081c1172a..7ba8f7e37 100644 --- a/src/widgets/settingspages/SettingsPage.cpp +++ b/src/widgets/settingspages/SettingsPage.cpp @@ -4,25 +4,25 @@ namespace chatterino { -SettingsPage::SettingsPage(const QString &_name, const QString &_iconResource) - : name(_name) - , iconResource(_iconResource) +SettingsPage::SettingsPage(const QString &name, const QString &iconResource) + : name_(name) + , iconResource_(iconResource) { } const QString &SettingsPage::getName() { - return this->name; + return this->name_; } const QString &SettingsPage::getIconResource() { - return this->iconResource; + return this->iconResource_; } void SettingsPage::cancel() { - this->onCancel.invoke(); + this->onCancel_.invoke(); } QCheckBox *SettingsPage::createCheckBox(const QString &text, @@ -35,7 +35,7 @@ QCheckBox *SettingsPage::createCheckBox(const QString &text, [checkbox](const bool &value, auto) { checkbox->setChecked(value); // }, - this->managedConnections); + this->managedConnections_); // update setting on toggle QObject::connect(checkbox, &QCheckBox::toggled, this, [&setting](bool state) { @@ -56,7 +56,7 @@ QComboBox *SettingsPage::createComboBox(const QStringList &items, // update when setting changes setting.connect([combo](const QString &value, auto) { combo->setCurrentText(value); }, - this->managedConnections); + this->managedConnections_); QObject::connect(combo, &QComboBox::currentTextChanged, [&setting](const QString &newValue) { setting = newValue; }); diff --git a/src/widgets/settingspages/SettingsPage.hpp b/src/widgets/settingspages/SettingsPage.hpp index 15fed970a..da8743624 100644 --- a/src/widgets/settingspages/SettingsPage.hpp +++ b/src/widgets/settingspages/SettingsPage.hpp @@ -31,11 +31,11 @@ public: } protected: - QString name; - QString iconResource; + QString name_; + QString iconResource_; - pajlada::Signals::NoArgSignal onCancel; - std::vector managedConnections; + pajlada::Signals::NoArgSignal onCancel_; + std::vector managedConnections_; }; } // namespace chatterino diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index 2262ff096..2eaf132c2 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -43,29 +43,29 @@ Qt::KeyboardModifiers Split::modifierStatus = Qt::NoModifier; Split::Split(SplitContainer *parent) : Split(static_cast(parent)) { - this->container = parent; + this->container_ = parent; } Split::Split(QWidget *parent) : BaseWidget(parent) - , container(nullptr) - , channel(Channel::getEmpty()) - , vbox(this) - , header(this) - , view(this) - , input(this) - , overlay(new SplitOverlay(this)) + , container_(nullptr) + , channel_(Channel::getEmpty()) + , vbox_(this) + , header_(this) + , view_(this) + , input_(this) + , overlay_(new SplitOverlay(this)) { auto app = getApp(); 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 @@ -90,148 +90,148 @@ 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 (app->settings->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(); } }); app->settings->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->managedConnections_); - this->header.updateModerationModeIcon(); - this->overlay->hide(); + this->header_.updateModerationModeIcon(); + this->overlay_->hide(); this->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); this->managedConnect(modifierStatusChanged, [this](Qt::KeyboardModifiers status) { if ((status == showSplitOverlayModifiers /*|| status == showAddSplitRegions*/) && - this->isMouseOver) { - this->overlay->show(); + this->isMouseOver_) { + this->overlay_->show(); } else { - this->overlay->hide(); + this->overlay_->hide(); } }); - this->input.ui_.textEdit->focused.connect([this] { this->focused.invoke(); }); - this->input.ui_.textEdit->focusLost.connect([this] { this->focusLost.invoke(); }); + this->input_.ui_.textEdit->focused.connect([this] { this->focused.invoke(); }); + this->input_.ui_.textEdit->focusLost.connect([this] { this->focusLost.invoke(); }); } Split::~Split() { - this->usermodeChangedConnection.disconnect(); - this->roomModeChangedConnection.disconnect(); - this->channelIDChangedConnection.disconnect(); - this->indirectChannelChangedConnection.disconnect(); + this->usermodeChangedConnection_.disconnect(); + this->roomModeChangedConnection_.disconnect(); + this->channelIDChangedConnection_.disconnect(); + this->indirectChannelChangedConnection_.disconnect(); } ChannelView &Split::getChannelView() { - return this->view; + return this->view_; } SplitContainer *Split::getContainer() { - return this->container; + return this->container_; } bool Split::isInContainer() const { - return this->container != nullptr; + return this->container_ != nullptr; } -void Split::setContainer(SplitContainer *_container) +void Split::setContainer(SplitContainer *container) { - this->container = _container; + this->container_ = container; } IndirectChannel Split::getIndirectChannel() { - return this->channel; + return this->channel_; } ChannelPtr Split::getChannel() { - return this->channel.get(); + return this->channel_.get(); } void Split::setChannel(IndirectChannel newChannel) { - this->channel = newChannel; + this->channel_ = newChannel; - this->view.setChannel(newChannel.get()); + this->view_.setChannel(newChannel.get()); - this->usermodeChangedConnection.disconnect(); - this->roomModeChangedConnection.disconnect(); - this->indirectChannelChangedConnection.disconnect(); + this->usermodeChangedConnection_.disconnect(); + this->roomModeChangedConnection_.disconnect(); + this->indirectChannelChangedConnection_.disconnect(); TwitchChannel *tc = dynamic_cast(newChannel.get().get()); if (tc != nullptr) { - this->usermodeChangedConnection = tc->userStateChanged.connect([this] { - this->header.updateModerationModeIcon(); - this->header.updateRoomModes(); + this->usermodeChangedConnection_ = tc->userStateChanged.connect([this] { + this->header_.updateModerationModeIcon(); + this->header_.updateRoomModes(); }); - this->roomModeChangedConnection = - tc->roomModesChanged.connect([this] { this->header.updateRoomModes(); }); + this->roomModeChangedConnection_ = + tc->roomModesChanged.connect([this] { this->header_.updateRoomModes(); }); } - this->indirectChannelChangedConnection = newChannel.getChannelChanged().connect([this] { // - QTimer::singleShot(0, [this] { this->setChannel(this->channel); }); + this->indirectChannelChangedConnection_ = newChannel.getChannelChanged().connect([this] { // + 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(); } void Split::setModerationMode(bool value) { - if (value != this->moderationMode) { - this->moderationMode = value; - this->header.updateModerationModeIcon(); - this->view.layoutMessages(); + if (value != this->moderationMode_) { + this->moderationMode_ = value; + this->header_.updateModerationModeIcon(); + this->view_.layoutMessages(); } } bool Split::getModerationMode() const { - return this->moderationMode; + return this->moderationMode_; } void Split::showChangeChannelPopup(const char *dialogTitle, bool empty, std::function callback) { - if (this->selectChannelDialog.hasElement()) { - this->selectChannelDialog->raise(); + if (this->selectChannelDialog_.hasElement()) { + this->selectChannelDialog_->raise(); return; } @@ -246,39 +246,39 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty, if (dialog->hasSeletedChannel()) { this->setChannel(dialog->getSelectedChannel()); if (this->isInContainer()) { - this->container->refreshTabTitle(); + this->container_->refreshTabTitle(); } } callback(dialog->hasSeletedChannel()); - this->selectChannelDialog = nullptr; + this->selectChannelDialog_ = nullptr; }); - this->selectChannelDialog = dialog; + this->selectChannelDialog_ = dialog; } 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 *) @@ -296,13 +296,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()); } @@ -310,29 +310,29 @@ void Split::resizeEvent(QResizeEvent *event) { BaseWidget::resizeEvent(event); - this->overlay->setGeometry(this->rect()); + this->overlay_->setGeometry(this->rect()); } void Split::enterEvent(QEvent *event) { - this->isMouseOver = true; + this->isMouseOver_ = true; this->handleModifiers(QGuiApplication::queryKeyboardModifiers()); if (modifierStatus == showSplitOverlayModifiers /*|| modifierStatus == showAddSplitRegions*/) { - this->overlay->show(); + this->overlay_->show(); } - if (this->container != nullptr) { - this->container->resetMouseStatus(); + if (this->container_ != nullptr) { + this->container_->resetMouseStatus(); } } void Split::leaveEvent(QEvent *event) { - this->isMouseOver = false; + this->isMouseOver_ = false; - this->overlay->hide(); + this->overlay_->hide(); this->handleModifiers(QGuiApplication::queryKeyboardModifiers()); } @@ -353,15 +353,15 @@ void Split::handleModifiers(Qt::KeyboardModifiers modifiers) /// Slots void Split::doAddSplit() { - if (this->container) { - this->container->appendNewSplit(true); + if (this->container_) { + this->container_->appendNewSplit(true); } } void Split::doCloseSplit() { - if (this->container) { - this->container->deleteSplit(this); + if (this->container_) { + this->container_->deleteSplit(this); } } @@ -392,7 +392,7 @@ void Split::doPopup() void Split::doClearChat() { - this->view.clearMessages(); + this->view_.clearMessages(); } void Split::doOpenChannel() @@ -418,7 +418,7 @@ void Split::doOpenPopupPlayer() void Split::doOpenStreamlink() { try { - Start(this->getChannel()->name); + openStreamlinkForChannel(this->getChannel()->name); } catch (const Exception &ex) { Log("Error in doOpenStreamlink: {}", ex.what()); } @@ -431,8 +431,8 @@ void Split::doOpenViewerList() viewerDock->setFeatures(QDockWidget::DockWidgetVerticalTitleBar | QDockWidget::DockWidgetClosable | 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); @@ -521,7 +521,7 @@ void Split::doOpenUserInfoPopup(const QString &user) void Split::doCopy() { - QApplication::clipboard()->setText(this->view.getSelectedText()); + QApplication::clipboard()->setText(this->view_.getSelectedText()); } void Split::doSearch() diff --git a/src/widgets/splits/Split.hpp b/src/widgets/splits/Split.hpp index 3f5142bd3..c22b324f4 100644 --- a/src/widgets/splits/Split.hpp +++ b/src/widgets/splits/Split.hpp @@ -88,34 +88,34 @@ protected: void focusInEvent(QFocusEvent *event) override; private: - SplitContainer *container; - IndirectChannel channel; - - QVBoxLayout vbox; - SplitHeader header; - ChannelView view; - SplitInput input; - SplitOverlay *overlay; - - NullablePtr selectChannelDialog; - - bool moderationMode = false; - - bool isMouseOver = false; - bool isDragging = false; - - pajlada::Signals::Connection channelIDChangedConnection; - pajlada::Signals::Connection usermodeChangedConnection; - pajlada::Signals::Connection roomModeChangedConnection; - - pajlada::Signals::Connection indirectChannelChangedConnection; - - std::vector managedConnections; - void doOpenUserInfoPopup(const QString &user); void channelNameUpdated(const QString &newChannelName); void handleModifiers(Qt::KeyboardModifiers modifiers); + SplitContainer *container_; + IndirectChannel channel_; + + QVBoxLayout vbox_; + SplitHeader header_; + ChannelView view_; + SplitInput input_; + SplitOverlay *overlay_; + + NullablePtr selectChannelDialog_; + + bool moderationMode_ = false; + + bool isMouseOver_ = false; + bool isDragging_ = false; + + pajlada::Signals::Connection channelIDChangedConnection_; + pajlada::Signals::Connection usermodeChangedConnection_; + pajlada::Signals::Connection roomModeChangedConnection_; + + pajlada::Signals::Connection indirectChannelChangedConnection_; + + std::vector managedConnections_; + public slots: // Add new split to the notebook page that this chat widget is in // This is only activated from the menu now. Hotkey is handled in Notebook diff --git a/src/widgets/splits/SplitContainer.cpp b/src/widgets/splits/SplitContainer.cpp index 5073ac066..4a8e6da7c 100644 --- a/src/widgets/splits/SplitContainer.cpp +++ b/src/widgets/splits/SplitContainer.cpp @@ -31,10 +31,9 @@ Split *SplitContainer::draggingSplit = nullptr; SplitContainer::SplitContainer(Notebook *parent) : BaseWidget(parent) - , dropPreview(this) - , overlay(this) - , mouseOverPoint(-10000, -10000) - , tab(nullptr) + , overlay_(this) + , mouseOverPoint_(-10000, -10000) + , tab_(nullptr) { this->refreshTabTitle(); @@ -42,12 +41,12 @@ SplitContainer::SplitContainer(Notebook *parent) this->layout(); if (modifiers == showResizeHandlesModifiers) { - for (std::unique_ptr &handle : this->resizeHandles) { + for (std::unique_ptr &handle : this->resizeHandles_) { handle->show(); handle->raise(); } } else { - for (std::unique_ptr &handle : this->resizeHandles) { + for (std::unique_ptr &handle : this->resizeHandles_) { handle->hide(); } } @@ -62,12 +61,12 @@ SplitContainer::SplitContainer(Notebook *parent) this->setCursor(Qt::PointingHandCursor); this->setAcceptDrops(true); - this->managedConnect(this->overlay.dragEnded, [this]() { - this->isDragging = false; + this->managedConnect(this->overlay_.dragEnded, [this]() { + this->isDragging_ = false; this->layout(); }); - this->overlay.hide(); + this->overlay_.hide(); this->setMouseTracking(true); this->setAcceptDrops(true); @@ -75,30 +74,30 @@ SplitContainer::SplitContainer(Notebook *parent) NotebookTab *SplitContainer::getTab() const { - return this->tab; + return this->tab_; } void SplitContainer::setTab(NotebookTab *_tab) { - this->tab = _tab; + this->tab_ = _tab; - this->tab->page = this; + this->tab_->page = this; this->refreshTabTitle(); } void SplitContainer::hideResizeHandles() { - this->overlay.hide(); + this->overlay_.hide(); - for (std::unique_ptr &handle : this->resizeHandles) { + for (std::unique_ptr &handle : this->resizeHandles_) { handle->hide(); } } void SplitContainer::resetMouseStatus() { - this->mouseOverPoint = QPoint(-10000, -10000); + this->mouseOverPoint_ = QPoint(-10000, -10000); this->update(); } @@ -125,12 +124,12 @@ void SplitContainer::appendSplit(Split *split) void SplitContainer::insertSplit(Split *split, const Position &position) { - this->insertSplit(split, position.direction, reinterpret_cast(position.relativeNode)); + this->insertSplit(split, position.direction_, reinterpret_cast(position.relativeNode_)); } void SplitContainer::insertSplit(Split *split, Direction direction, Split *relativeTo) { - Node *node = this->baseNode.findNodeContainingSplit(relativeTo); + Node *node = this->baseNode_.findNodeContainingSplit(relativeTo); assert(node != nullptr); this->insertSplit(split, direction, node); @@ -143,15 +142,15 @@ void SplitContainer::insertSplit(Split *split, Direction direction, Node *relati split->setContainer(this); if (relativeTo == nullptr) { - if (this->baseNode.type == Node::EmptyRoot) { - this->baseNode.setSplit(split); - } else if (this->baseNode.type == Node::_Split) { - this->baseNode.nestSplitIntoCollection(split, direction); + if (this->baseNode_.type_ == Node::EmptyRoot) { + this->baseNode_.setSplit(split); + } else if (this->baseNode_.type_ == Node::_Split) { + this->baseNode_.nestSplitIntoCollection(split, direction); } else { - this->baseNode.insertSplitRelative(split, direction); + this->baseNode_.insertSplitRelative(split, direction); } } else { - assert(this->baseNode.isOrContainsNode(relativeTo)); + assert(this->baseNode_.isOrContainsNode(relativeTo)); relativeTo->insertSplitRelative(split, direction); } @@ -167,13 +166,13 @@ void SplitContainer::addSplit(Split *split) split->show(); split->giveFocus(Qt::MouseFocusReason); this->unsetCursor(); - this->splits.push_back(split); + this->splits_.push_back(split); this->refreshTabTitle(); split->getChannelView().tabHighlightRequested.connect([this](HighlightState state) { - if (this->tab != nullptr) { - this->tab->setHighlightState(state); + if (this->tab_ != nullptr) { + this->tab_->setHighlightState(state); } }); @@ -184,19 +183,19 @@ void SplitContainer::addSplit(Split *split) void SplitContainer::setSelected(Split *split) { - this->selected = split; + this->selected_ = split; - if (Node *node = this->baseNode.findNodeContainingSplit(split)) { + if (Node *node = this->baseNode_.findNodeContainingSplit(split)) { this->setPreferedTargetRecursive(node); } } void SplitContainer::setPreferedTargetRecursive(Node *node) { - if (node->parent != nullptr) { - node->parent->preferedFocusTarget = node; + if (node->parent_ != nullptr) { + node->parent_->preferedFocusTarget_ = node; - this->setPreferedTargetRecursive(node->parent); + this->setPreferedTargetRecursive(node->parent_); } } @@ -204,18 +203,18 @@ SplitContainer::Position SplitContainer::releaseSplit(Split *split) { assertInGuiThread(); - Node *node = this->baseNode.findNodeContainingSplit(split); + Node *node = this->baseNode_.findNodeContainingSplit(split); assert(node != nullptr); - this->splits.erase(std::find(this->splits.begin(), this->splits.end(), split)); + this->splits_.erase(std::find(this->splits_.begin(), this->splits_.end(), split)); split->setParent(nullptr); Position position = node->releaseSplit(); this->layout(); - if (splits.size() == 0) { + if (splits_.size() == 0) { this->setSelected(nullptr); this->setCursor(Qt::PointingHandCursor); } else { - this->splits.front()->giveFocus(Qt::MouseFocusReason); + this->splits_.front()->giveFocus(Qt::MouseFocusReason); } this->refreshTabTitle(); @@ -241,16 +240,16 @@ void SplitContainer::selectNextSplit(Direction direction) { assertInGuiThread(); - if (Node *node = this->baseNode.findNodeContainingSplit(this->selected)) { + if (Node *node = this->baseNode_.findNodeContainingSplit(this->selected_)) { this->selectSplitRecursive(node, direction); } } void SplitContainer::selectSplitRecursive(Node *node, Direction direction) { - if (node->parent != nullptr) { - if (node->parent->type == Node::toContainerType(direction)) { - auto &siblings = node->parent->children; + if (node->parent_ != nullptr) { + if (node->parent_->type_ == Node::toContainerType(direction)) { + auto &siblings = node->parent_->children_; auto it = std::find_if(siblings.begin(), siblings.end(), [node](const auto &other) { return other.get() == node; }); @@ -258,42 +257,42 @@ void SplitContainer::selectSplitRecursive(Node *node, Direction direction) if (direction == Direction::Left || direction == Direction::Above) { if (it == siblings.begin()) { - this->selectSplitRecursive(node->parent, direction); + this->selectSplitRecursive(node->parent_, direction); } else { this->focusSplitRecursive(siblings[it - siblings.begin() - 1].get(), direction); } } else { if (it->get() == siblings.back().get()) { - this->selectSplitRecursive(node->parent, direction); + this->selectSplitRecursive(node->parent_, direction); } else { this->focusSplitRecursive(siblings[it - siblings.begin() + 1].get(), direction); } } } else { - this->selectSplitRecursive(node->parent, direction); + this->selectSplitRecursive(node->parent_, direction); } } } void SplitContainer::focusSplitRecursive(Node *node, Direction direction) { - switch (node->type) { + switch (node->type_) { case Node::_Split: { - node->split->giveFocus(Qt::OtherFocusReason); + node->split_->giveFocus(Qt::OtherFocusReason); } break; case Node::HorizontalContainer: case Node::VerticalContainer: { - auto &children = node->children; + auto &children = node->children_; auto it = std::find_if(children.begin(), children.end(), [node](const auto &other) { - return node->preferedFocusTarget == other.get(); + return node->preferedFocusTarget_ == other.get(); }); if (it != children.end()) { this->focusSplitRecursive(it->get(), direction); } else { - this->focusSplitRecursive(node->children.front().get(), direction); + this->focusSplitRecursive(node->children_.front().get(), direction); } } break; @@ -303,19 +302,19 @@ void SplitContainer::focusSplitRecursive(Node *node, Direction direction) void SplitContainer::layout() { - this->baseNode.geometry = this->rect(); + this->baseNode_.geometry_ = this->rect(); std::vector _dropRects; std::vector _resizeRects; - this->baseNode.layout(Split::modifierStatus == showAddSplitRegions || this->isDragging, - this->getScale(), _dropRects, _resizeRects); + this->baseNode_.layout(Split::modifierStatus == showAddSplitRegions || this->isDragging_, + this->getScale(), _dropRects, _resizeRects); - this->dropRects = _dropRects; + this->dropRects_ = _dropRects; - for (Split *split : this->splits) { + for (Split *split : this->splits_) { const QRect &g = split->geometry(); - Node *node = this->baseNode.findNodeContainingSplit(split); + Node *node = this->baseNode_.findNodeContainingSplit(split); _dropRects.push_back(DropRect(QRect(g.left(), g.top(), g.width() / 4, g.height()), Position(node, Direction::Left))); @@ -330,27 +329,27 @@ void SplitContainer::layout() Position(node, Direction::Below))); } - if (this->splits.empty()) { + if (this->splits_.empty()) { QRect g = this->rect(); _dropRects.push_back(DropRect(QRect(g.left(), g.top(), g.width(), g.height()), Position(nullptr, Direction::Below))); } - this->overlay.setRects(std::move(_dropRects)); + this->overlay_.setRects(std::move(_dropRects)); // handle resizeHandles - if (this->resizeHandles.size() < _resizeRects.size()) { - while (this->resizeHandles.size() < _resizeRects.size()) { - this->resizeHandles.push_back(std::make_unique(this)); + if (this->resizeHandles_.size() < _resizeRects.size()) { + while (this->resizeHandles_.size() < _resizeRects.size()) { + this->resizeHandles_.push_back(std::make_unique(this)); } - } else if (this->resizeHandles.size() > _resizeRects.size()) { - this->resizeHandles.resize(_resizeRects.size()); + } else if (this->resizeHandles_.size() > _resizeRects.size()) { + this->resizeHandles_.resize(_resizeRects.size()); } { size_t i = 0; for (ResizeRect &resizeRect : _resizeRects) { - ResizeHandle *handle = this->resizeHandles[i].get(); + ResizeHandle *handle = this->resizeHandles_[i].get(); handle->setGeometry(resizeRect.rect); handle->setVertical(resizeRect.vertical); handle->node = resizeRect.node; @@ -378,17 +377,17 @@ void SplitContainer::resizeEvent(QResizeEvent *event) void SplitContainer::mouseReleaseEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - if (this->splits.size() == 0) { + if (this->splits_.size() == 0) { // "Add Chat" was clicked this->appendNewSplit(true); - this->mouseOverPoint = QPoint(-10000, -10000); + this->mouseOverPoint_ = QPoint(-10000, -10000); // this->setCursor(QCursor(Qt::ArrowCursor)); } else { auto it = - std::find_if(this->dropRects.begin(), this->dropRects.end(), + std::find_if(this->dropRects_.begin(), this->dropRects_.end(), [event](DropRect &rect) { return rect.rect.contains(event->pos()); }); - if (it != this->dropRects.end()) { + if (it != this->dropRects_.end()) { this->insertSplit(new Split(this), it->position); } } @@ -399,7 +398,7 @@ void SplitContainer::paintEvent(QPaintEvent *) { QPainter painter(this); - if (this->splits.size() == 0) { + if (this->splits_.size() == 0) { painter.fillRect(rect(), this->theme->splits.background); painter.setPen(this->theme->splits.header.text); @@ -424,11 +423,11 @@ void SplitContainer::paintEvent(QPaintEvent *) } } - for (DropRect &dropRect : this->dropRects) { + for (DropRect &dropRect : this->dropRects_) { QColor border = getApp()->themes->splits.dropTargetRectBorder; QColor background = getApp()->themes->splits.dropTargetRect; - if (!dropRect.rect.contains(this->mouseOverPoint)) { + if (!dropRect.rect.contains(this->mouseOverPoint_)) { // border.setAlphaF(0.1); // background.setAlphaF(0.1); } else { @@ -471,12 +470,12 @@ void SplitContainer::dragEnterEvent(QDragEnterEvent *event) if (!SplitContainer::isDraggingSplit) return; - this->isDragging = true; + this->isDragging_ = true; this->layout(); - this->overlay.setGeometry(this->rect()); - this->overlay.show(); - this->overlay.raise(); + this->overlay_.setGeometry(this->rect()); + this->overlay_.show(); + this->overlay_.raise(); } void SplitContainer::mouseMoveEvent(QMouseEvent *event) @@ -485,38 +484,38 @@ void SplitContainer::mouseMoveEvent(QMouseEvent *event) this->setCursor(Qt::PointingHandCursor); } - this->mouseOverPoint = event->pos(); + this->mouseOverPoint_ = event->pos(); this->update(); } void SplitContainer::leaveEvent(QEvent *) { - this->mouseOverPoint = QPoint(-10000, -10000); + this->mouseOverPoint_ = QPoint(-10000, -10000); this->update(); } void SplitContainer::focusInEvent(QFocusEvent *) { - if (this->baseNode.findNodeContainingSplit(this->selected) != nullptr) { - this->selected->setFocus(); + if (this->baseNode_.findNodeContainingSplit(this->selected_) != nullptr) { + this->selected_->setFocus(); return; } - if (this->splits.size() != 0) { - this->splits.front()->setFocus(); + if (this->splits_.size() != 0) { + this->splits_.front()->setFocus(); } } void SplitContainer::refreshTabTitle() { - if (this->tab == nullptr) { + if (this->tab_ == nullptr) { return; } QString newTitle = ""; bool first = true; - for (const auto &chatWidget : this->splits) { + for (const auto &chatWidget : this->splits_) { auto channelName = chatWidget->getChannel()->name; if (channelName.isEmpty()) { continue; @@ -534,7 +533,7 @@ void SplitContainer::refreshTabTitle() newTitle = "empty"; } - this->tab->setDefaultTitle(newTitle); + this->tab_->setDefaultTitle(newTitle); } int SplitContainer::getSplitCount() @@ -544,19 +543,19 @@ int SplitContainer::getSplitCount() const std::vector SplitContainer::getSplits() const { - return this->splits; + return this->splits_; } SplitContainer::Node *SplitContainer::getBaseNode() { - return &this->baseNode; + return &this->baseNode_; } void SplitContainer::decodeFromJson(QJsonObject &obj) { - assert(this->baseNode.type == Node::EmptyRoot); + assert(this->baseNode_.type_ == Node::EmptyRoot); - this->decodeNodeRecusively(obj, &this->baseNode); + this->decodeNodeRecusively(obj, &this->baseNode_); } void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node) @@ -573,7 +572,7 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node) Direction direction = vertical ? Direction::Below : Direction::Right; - node->type = vertical ? Node::VerticalContainer : Node::HorizontalContainer; + node->type_ = vertical ? Node::VerticalContainer : Node::HorizontalContainer; for (QJsonValue _val : obj.value("items").toArray()) { auto _obj = _val.toObject(); @@ -584,19 +583,19 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node) split->setChannel(WindowManager::decodeChannel(_obj.value("data").toObject())); Node *_node = new Node(); - _node->parent = node; - _node->split = split; - _node->type = Node::_Split; + _node->parent_ = node; + _node->split_ = split; + _node->type_ = Node::_Split; - _node->flexH = _obj.value("flexh").toDouble(1.0); - _node->flexV = _obj.value("flexv").toDouble(1.0); - node->children.emplace_back(_node); + _node->flexH_ = _obj.value("flexh").toDouble(1.0); + _node->flexV_ = _obj.value("flexv").toDouble(1.0); + node->children_.emplace_back(_node); this->addSplit(split); } else { Node *_node = new Node(); - _node->parent = node; - node->children.emplace_back(_node); + _node->parent_ = node; + node->children_.emplace_back(_node); this->decodeNodeRecusively(_obj, _node); } } @@ -618,44 +617,44 @@ void SplitContainer::decodeNodeRecusively(QJsonObject &obj, Node *node) SplitContainer::Node::Type SplitContainer::Node::getType() { - return this->type; + return this->type_; } Split *SplitContainer::Node::getSplit() { - return this->split; + return this->split_; } SplitContainer::Node *SplitContainer::Node::getParent() { - return this->parent; + return this->parent_; } qreal SplitContainer::Node::getHorizontalFlex() { - return this->flexH; + return this->flexH_; } qreal SplitContainer::Node::getVerticalFlex() { - return this->flexV; + return this->flexV_; } const std::vector> &SplitContainer::Node::getChildren() { - return this->children; + return this->children_; } SplitContainer::Node::Node() - : type(SplitContainer::Node::Type::EmptyRoot) - , split(nullptr) - , parent(nullptr) + : type_(SplitContainer::Node::Type::EmptyRoot) + , split_(nullptr) + , parent_(nullptr) { } SplitContainer::Node::Node(Split *_split, Node *_parent) - : type(Type::_Split) - , split(_split) - , parent(_parent) + : type_(Type::_Split) + , split_(_split) + , parent_(_parent) { } @@ -665,17 +664,17 @@ bool SplitContainer::Node::isOrContainsNode(SplitContainer::Node *_node) return true; } - return std::any_of(this->children.begin(), this->children.end(), + return std::any_of(this->children_.begin(), this->children_.end(), [_node](std::unique_ptr &n) { return n->isOrContainsNode(_node); }); } SplitContainer::Node *SplitContainer::Node::findNodeContainingSplit(Split *_split) { - if (this->type == Type::_Split && this->split == _split) { + if (this->type_ == Type::_Split && this->split_ == _split) { return this; } - for (std::unique_ptr &node : this->children) { + for (std::unique_ptr &node : this->children_) { Node *a = node->findNodeContainingSplit(_split); if (a != nullptr) { @@ -687,8 +686,8 @@ SplitContainer::Node *SplitContainer::Node::findNodeContainingSplit(Split *_spli void SplitContainer::Node::insertSplitRelative(Split *_split, Direction _direction) { - if (this->parent == nullptr) { - switch (this->type) { + if (this->parent_ == nullptr) { + switch (this->type_) { case Node::EmptyRoot: { this->setSplit(_split); } break; @@ -706,9 +705,9 @@ void SplitContainer::Node::insertSplitRelative(Split *_split, Direction _directi } // parent != nullptr - if (parent->type == toContainerType(_direction)) { + if (parent_->type_ == toContainerType(_direction)) { // hell yeah we'll just insert it next to outselves - this->_insertNextToThis(_split, _direction); + this->insertNextToThis(_split, _direction); } else { this->nestSplitIntoCollection(_split, _direction); } @@ -716,38 +715,38 @@ void SplitContainer::Node::insertSplitRelative(Split *_split, Direction _directi void SplitContainer::Node::nestSplitIntoCollection(Split *_split, Direction _direction) { - if (toContainerType(_direction) == this->type) { - this->children.emplace_back(new Node(_split, this)); + if (toContainerType(_direction) == this->type_) { + this->children_.emplace_back(new Node(_split, this)); } else { // we'll need to nest outselves // move all our data into a new node Node *clone = new Node(); - clone->type = this->type; - clone->children = std::move(this->children); - for (std::unique_ptr &node : clone->children) { - node->parent = clone; + clone->type_ = this->type_; + clone->children_ = std::move(this->children_); + for (std::unique_ptr &node : clone->children_) { + node->parent_ = clone; } - clone->split = this->split; - clone->parent = this; + clone->split_ = this->split_; + clone->parent_ = this; // add the node to our children and change our type - this->children.push_back(std::unique_ptr(clone)); - this->type = toContainerType(_direction); - this->split = nullptr; + this->children_.push_back(std::unique_ptr(clone)); + this->type_ = toContainerType(_direction); + this->split_ = nullptr; - clone->_insertNextToThis(_split, _direction); + clone->insertNextToThis(_split, _direction); } } -void SplitContainer::Node::_insertNextToThis(Split *_split, Direction _direction) +void SplitContainer::Node::insertNextToThis(Split *_split, Direction _direction) { - auto &siblings = this->parent->children; + auto &siblings = this->parent_->children_; - qreal width = this->parent->geometry.width() / siblings.size(); - qreal height = this->parent->geometry.height() / siblings.size(); + qreal width = this->parent_->geometry_.width() / siblings.size(); + qreal height = this->parent_->geometry_.height() / siblings.size(); if (siblings.size() == 1) { - this->geometry = QRect(0, 0, int(width), int(height)); + this->geometry_ = QRect(0, 0, int(width), int(height)); } auto it = std::find_if(siblings.begin(), siblings.end(), @@ -758,34 +757,34 @@ void SplitContainer::Node::_insertNextToThis(Split *_split, Direction _direction it++; } - Node *node = new Node(_split, this->parent); - node->geometry = QRectF(0, 0, width, height); + Node *node = new Node(_split, this->parent_); + node->geometry_ = QRectF(0, 0, width, height); siblings.insert(it, std::unique_ptr(node)); } void SplitContainer::Node::setSplit(Split *_split) { - assert(this->split == nullptr); - assert(this->children.size() == 0); + assert(this->split_ == nullptr); + assert(this->children_.size() == 0); - this->split = _split; - this->type = Type::_Split; + this->split_ = _split; + this->type_ = Type::_Split; } SplitContainer::Position SplitContainer::Node::releaseSplit() { - assert(this->type == Type::_Split); + assert(this->type_ == Type::_Split); - if (parent == nullptr) { - this->type = Type::EmptyRoot; - this->split = nullptr; + if (parent_ == nullptr) { + this->type_ = Type::EmptyRoot; + this->split_ = nullptr; Position pos; - pos.relativeNode = nullptr; - pos.direction = Direction::Right; + pos.relativeNode_ = nullptr; + pos.direction_ = Direction::Right; return pos; } else { - auto &siblings = this->parent->children; + auto &siblings = this->parent_->children_; auto it = std::find_if(begin(siblings), end(siblings), [this](auto &node) { return this == node.get(); }); @@ -794,35 +793,35 @@ SplitContainer::Position SplitContainer::Node::releaseSplit() Position position; if (siblings.size() == 2) { // delete this and move split to parent - position.relativeNode = this->parent; - if (this->parent->type == Type::VerticalContainer) { - position.direction = siblings.begin() == it ? Direction::Above : Direction::Below; + position.relativeNode_ = this->parent_; + if (this->parent_->type_ == Type::VerticalContainer) { + position.direction_ = siblings.begin() == it ? Direction::Above : Direction::Below; } else { - position.direction = siblings.begin() == it ? Direction::Left : Direction::Right; + position.direction_ = siblings.begin() == it ? Direction::Left : Direction::Right; } - Node *_parent = this->parent; + Node *_parent = this->parent_; siblings.erase(it); std::unique_ptr &sibling = siblings.front(); - _parent->type = sibling->type; - _parent->split = sibling->split; - std::vector> nodes = std::move(sibling->children); + _parent->type_ = sibling->type_; + _parent->split_ = sibling->split_; + std::vector> nodes = std::move(sibling->children_); for (auto &node : nodes) { - node->parent = _parent; + node->parent_ = _parent; } - _parent->children = std::move(nodes); + _parent->children_ = std::move(nodes); } else { if (this == siblings.back().get()) { - position.direction = this->parent->type == Type::VerticalContainer - ? Direction::Below - : Direction::Right; + position.direction_ = this->parent_->type_ == Type::VerticalContainer + ? Direction::Below + : Direction::Right; siblings.erase(it); - position.relativeNode = siblings.back().get(); + position.relativeNode_ = siblings.back().get(); } else { - position.relativeNode = (it + 1)->get(); - position.direction = this->parent->type == Type::VerticalContainer - ? Direction::Above - : Direction::Left; + position.relativeNode_ = (it + 1)->get(); + position.direction_ = this->parent_->type_ == Type::VerticalContainer + ? Direction::Above + : Direction::Left; siblings.erase(it); } } @@ -833,46 +832,46 @@ SplitContainer::Position SplitContainer::Node::releaseSplit() qreal SplitContainer::Node::getFlex(bool isVertical) { - return isVertical ? this->flexV : this->flexH; + return isVertical ? this->flexV_ : this->flexH_; } qreal SplitContainer::Node::getSize(bool isVertical) { - return isVertical ? this->geometry.height() : this->geometry.width(); + return isVertical ? this->geometry_.height() : this->geometry_.width(); } qreal SplitContainer::Node::getChildrensTotalFlex(bool isVertical) { return std::accumulate( - this->children.begin(), this->children.end(), qreal(0), + this->children_.begin(), this->children_.end(), qreal(0), [=](qreal val, std::unique_ptr &node) { return val + node->getFlex(isVertical); }); } void SplitContainer::Node::layout(bool addSpacing, float _scale, std::vector &dropRects, std::vector &resizeRects) { - for (std::unique_ptr &node : this->children) { - if (node->flexH <= 0) - node->flexH = 0; - if (node->flexV <= 0) - node->flexV = 0; + for (std::unique_ptr &node : this->children_) { + if (node->flexH_ <= 0) + node->flexH_ = 0; + if (node->flexV_ <= 0) + node->flexV_ = 0; } - switch (this->type) { + switch (this->type_) { case Node::_Split: { - QRect rect = this->geometry.toRect(); - this->split->setGeometry(rect.marginsRemoved(QMargins(1, 1, 1, 1))); + QRect rect = this->geometry_.toRect(); + this->split_->setGeometry(rect.marginsRemoved(QMargins(1, 1, 1, 1))); } break; case Node::VerticalContainer: case Node::HorizontalContainer: { - bool isVertical = this->type == Node::VerticalContainer; + bool isVertical = this->type_ == Node::VerticalContainer; // vars qreal minSize = qreal(48 * _scale); qreal totalFlex = this->getChildrensTotalFlex(isVertical); qreal totalSize = std::accumulate( - this->children.begin(), this->children.end(), qreal(0), + this->children_.begin(), this->children_.end(), qreal(0), [=](int val, std::unique_ptr &node) { return val + std::max(this->getSize(isVertical) / totalFlex * node->getFlex(isVertical), @@ -880,7 +879,7 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, std::vectorgetSize(isVertical) / totalSize; - QRectF childRect = this->geometry; + QRectF childRect = this->geometry_; // add spacing if reqested if (addSpacing) { @@ -889,23 +888,23 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, std::vectorgeometry.left(), this->geometry.top(), - isVertical ? offset : this->geometry.width(), - isVertical ? this->geometry.height() : offset) + QRectF(this->geometry_.left(), this->geometry_.top(), + isVertical ? offset : this->geometry_.width(), + isVertical ? this->geometry_.height() : offset) .toRect(), Position(this, isVertical ? Direction::Left : Direction::Above)); // droprect right / below if (isVertical) { dropRects.emplace_back( - QRectF(this->geometry.right() - offset, this->geometry.top(), offset, - this->geometry.height()) + QRectF(this->geometry_.right() - offset, this->geometry_.top(), offset, + this->geometry_.height()) .toRect(), Position(this, Direction::Right)); } else { dropRects.emplace_back( - QRectF(this->geometry.left(), this->geometry.bottom() - offset, - this->geometry.width(), offset) + QRectF(this->geometry_.left(), this->geometry_.bottom() - offset, + this->geometry_.width(), offset) .toRect(), Position(this, Direction::Below)); } @@ -922,43 +921,45 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale, std::vector &child : this->children) { + for (std::unique_ptr &child : this->children_) { // set rect QRectF rect = childRect; if (isVertical) { rect.setTop(pos); rect.setHeight( - std::max(this->geometry.height() / totalFlex * child->flexV, + std::max(this->geometry_.height() / totalFlex * child->flexV_, minSize) * sizeMultiplier); } else { rect.setLeft(pos); - rect.setWidth(std::max(this->geometry.width() / totalFlex * child->flexH, - minSize) * - sizeMultiplier); + rect.setWidth( + std::max(this->geometry_.width() / totalFlex * child->flexH_, + minSize) * + sizeMultiplier); } - child->geometry = rect; + child->geometry_ = rect; child->layout(addSpacing, _scale, dropRects, resizeRects); pos += child->getSize(isVertical); // add resize rect - if (child != this->children.front()) { - QRectF r = isVertical ? QRectF(this->geometry.left(), child->geometry.top() - 4, - this->geometry.width(), 8) - : QRectF(child->geometry.left() - 4, this->geometry.top(), - 8, this->geometry.height()); + if (child != this->children_.front()) { + QRectF r = isVertical + ? QRectF(this->geometry_.left(), child->geometry_.top() - 4, + this->geometry_.width(), 8) + : QRectF(child->geometry_.left() - 4, this->geometry_.top(), 8, + this->geometry_.height()); resizeRects.push_back(ResizeRect(r.toRect(), child.get(), isVertical)); } // normalize flex if (isVertical) { - child->flexV = child->flexV / totalFlex * this->children.size(); - child->flexH = 1; + child->flexV_ = child->flexV_ / totalFlex * this->children_.size(); + child->flexH_ = 1; } else { - child->flexH = child->flexH / totalFlex * this->children.size(); - child->flexV = 1; + child->flexH_ = child->flexH_ / totalFlex * this->children_.size(); + child->flexV_ = 1; } } } break; @@ -977,8 +978,8 @@ SplitContainer::Node::Type SplitContainer::Node::toContainerType(Direction _dir) SplitContainer::DropOverlay::DropOverlay(SplitContainer *_parent) : QWidget(_parent) - , mouseOverPoint(-10000, -10000) - , parent(_parent) + , mouseOverPoint_(-10000, -10000) + , parent_(_parent) { this->setMouseTracking(true); this->setAcceptDrops(true); @@ -986,7 +987,7 @@ SplitContainer::DropOverlay::DropOverlay(SplitContainer *_parent) void SplitContainer::DropOverlay::setRects(std::vector _rects) { - this->rects = std::move(_rects); + this->rects_ = std::move(_rects); } // pajlada::Signals::NoArgSignal dragEnded; @@ -999,8 +1000,8 @@ void SplitContainer::DropOverlay::paintEvent(QPaintEvent *) bool foundMover = false; - for (DropRect &rect : this->rects) { - if (!foundMover && rect.rect.contains(this->mouseOverPoint)) { + for (DropRect &rect : this->rects_) { + if (!foundMover && rect.rect.contains(this->mouseOverPoint_)) { painter.setBrush(getApp()->themes->splits.dropPreview); painter.setPen(getApp()->themes->splits.dropPreviewBorder); foundMover = true; @@ -1023,13 +1024,13 @@ void SplitContainer::DropOverlay::dragMoveEvent(QDragMoveEvent *event) { event->acceptProposedAction(); - this->mouseOverPoint = event->pos(); + this->mouseOverPoint_ = event->pos(); this->update(); } void SplitContainer::DropOverlay::dragLeaveEvent(QDragLeaveEvent *) { - this->mouseOverPoint = QPoint(-10000, -10000); + this->mouseOverPoint_ = QPoint(-10000, -10000); this->close(); this->dragEnded.invoke(); } @@ -1037,19 +1038,19 @@ void SplitContainer::DropOverlay::dragLeaveEvent(QDragLeaveEvent *) void SplitContainer::DropOverlay::dropEvent(QDropEvent *event) { Position *position = nullptr; - for (DropRect &rect : this->rects) { - if (rect.rect.contains(this->mouseOverPoint)) { + for (DropRect &rect : this->rects_) { + if (rect.rect.contains(this->mouseOverPoint_)) { position = &rect.position; break; } } if (position != nullptr) { - this->parent->insertSplit(SplitContainer::draggingSplit, *position); + this->parent_->insertSplit(SplitContainer::draggingSplit, *position); event->acceptProposedAction(); } - this->mouseOverPoint = QPoint(-10000, -10000); + this->mouseOverPoint_ = QPoint(-10000, -10000); this->close(); this->dragEnded.invoke(); } @@ -1061,7 +1062,7 @@ void SplitContainer::DropOverlay::dropEvent(QDropEvent *event) void SplitContainer::ResizeHandle::setVertical(bool isVertical) { this->setCursor(isVertical ? Qt::SplitVCursor : Qt::SplitHCursor); - this->vertical = isVertical; + this->vertical_ = isVertical; } SplitContainer::ResizeHandle::ResizeHandle(SplitContainer *_parent) @@ -1079,7 +1080,7 @@ void SplitContainer::ResizeHandle::paintEvent(QPaintEvent *) painter.fillRect(this->rect(), getApp()->themes->splits.resizeHandleBackground); - if (this->vertical) { + if (this->vertical_) { painter.drawLine(0, this->height() / 2, this->width(), this->height() / 2); } else { painter.drawLine(this->width() / 2, 0, this->width() / 2, this->height()); @@ -1088,24 +1089,24 @@ void SplitContainer::ResizeHandle::paintEvent(QPaintEvent *) void SplitContainer::ResizeHandle::mousePressEvent(QMouseEvent *) { - this->isMouseDown = true; + this->isMouseDown_ = true; } void SplitContainer::ResizeHandle::mouseReleaseEvent(QMouseEvent *) { - this->isMouseDown = false; + this->isMouseDown_ = false; } void SplitContainer::ResizeHandle::mouseMoveEvent(QMouseEvent *event) { - if (!this->isMouseDown) { + if (!this->isMouseDown_) { return; } assert(node != nullptr); - assert(node->parent != nullptr); + assert(node->parent_ != nullptr); - auto &siblings = node->parent->getChildren(); + auto &siblings = node->parent_->getChildren(); auto it = std::find_if(siblings.begin(), siblings.end(), [this](const std::unique_ptr &n) { return n.get() == this->node; }); @@ -1113,8 +1114,8 @@ void SplitContainer::ResizeHandle::mouseMoveEvent(QMouseEvent *event) assert(it != siblings.end()); Node *before = siblings[it - siblings.begin() - 1].get(); - QPoint topLeft = this->parent->mapToGlobal(before->geometry.topLeft().toPoint()); - QPoint bottomRight = this->parent->mapToGlobal(this->node->geometry.bottomRight().toPoint()); + QPoint topLeft = this->parent->mapToGlobal(before->geometry_.topLeft().toPoint()); + QPoint bottomRight = this->parent->mapToGlobal(this->node->geometry_.bottomRight().toPoint()); int globalX = topLeft.x() > event->globalX() ? topLeft.x() @@ -1125,26 +1126,26 @@ void SplitContainer::ResizeHandle::mouseMoveEvent(QMouseEvent *event) QPoint mousePoint(globalX, globalY); - if (this->vertical) { - qreal totalFlexV = this->node->flexV + before->flexV; - before->flexV = + if (this->vertical_) { + qreal totalFlexV = this->node->flexV_ + before->flexV_; + before->flexV_ = totalFlexV * (mousePoint.y() - topLeft.y()) / (bottomRight.y() - topLeft.y()); - this->node->flexV = totalFlexV - before->flexV; + this->node->flexV_ = totalFlexV - before->flexV_; this->parent->layout(); // move handle - this->move(this->x(), int(before->geometry.bottom() - 4)); + this->move(this->x(), int(before->geometry_.bottom() - 4)); } else { - qreal totalFlexH = this->node->flexH + before->flexH; - before->flexH = + qreal totalFlexH = this->node->flexH_ + before->flexH_; + before->flexH_ = totalFlexH * (mousePoint.x() - topLeft.x()) / (bottomRight.x() - topLeft.x()); - this->node->flexH = totalFlexH - before->flexH; + this->node->flexH_ = totalFlexH - before->flexH_; this->parent->layout(); // move handle - this->move(int(before->geometry.right() - 4), this->y()); + this->move(int(before->geometry_.right() - 4), this->y()); } } @@ -1153,8 +1154,8 @@ void SplitContainer::ResizeHandle::mouseDoubleClickEvent(QMouseEvent *event) event->accept(); for (auto &sibling : this->node->getParent()->getChildren()) { - sibling->flexH = 1; - sibling->flexV = 1; + sibling->flexH_ = 1; + sibling->flexV_ = 1; } this->parent->layout(); diff --git a/src/widgets/splits/SplitContainer.hpp b/src/widgets/splits/SplitContainer.hpp index 5a80d1b0f..566503b61 100644 --- a/src/widgets/splits/SplitContainer.hpp +++ b/src/widgets/splits/SplitContainer.hpp @@ -1,7 +1,6 @@ #pragma once #include "widgets/BaseWidget.hpp" -#include "widgets/helper/DropPreview.hpp" #include "widgets/helper/NotebookTab.hpp" #include "widgets/splits/Split.hpp" @@ -41,14 +40,14 @@ public: struct Position final { private: Position() = default; - Position(Node *_relativeNode, Direction _direcion) - : relativeNode(_relativeNode) - , direction(_direcion) + Position(Node *relativeNode, Direction direcion) + : relativeNode_(relativeNode) + , direction_(direcion) { } - Node *relativeNode; - Direction direction; + Node *relativeNode_; + Direction direction_; friend struct Node; friend class SplitContainer; @@ -91,15 +90,6 @@ public: const std::vector> &getChildren(); private: - Type type; - Split *split; - Node *preferedFocusTarget; - Node *parent; - QRectF geometry; - qreal flexH = 1; - qreal flexV = 1; - std::vector> children; - Node(); Node(Split *_split, Node *_parent); @@ -107,17 +97,26 @@ public: Node *findNodeContainingSplit(Split *_split); void insertSplitRelative(Split *_split, Direction _direction); void nestSplitIntoCollection(Split *_split, Direction _direction); - void _insertNextToThis(Split *_split, Direction _direction); + void insertNextToThis(Split *_split, Direction _direction); void setSplit(Split *_split); Position releaseSplit(); qreal getFlex(bool isVertical); qreal getSize(bool isVertical); qreal getChildrensTotalFlex(bool isVertical); - void layout(bool addSpacing, float _scale, std::vector &dropRects, + void layout(bool addSpacing, float _scale, std::vector &dropRects_, std::vector &resizeRects); static Type toContainerType(Direction _dir); + Type type_; + Split *split_; + Node *preferedFocusTarget_; + Node *parent_; + QRectF geometry_; + qreal flexH_ = 1; + qreal flexV_ = 1; + std::vector> children_; + friend class SplitContainer; }; @@ -139,9 +138,9 @@ private: void dropEvent(QDropEvent *event) override; private: - std::vector rects; - QPoint mouseOverPoint; - SplitContainer *parent; + std::vector rects_; + QPoint mouseOverPoint_; + SplitContainer *parent_; }; class ResizeHandle final : public QWidget @@ -161,8 +160,8 @@ private: friend class SplitContainer; private: - bool vertical; - bool isMouseDown = false; + bool vertical_; + bool isMouseDown_ = false; }; public: @@ -186,7 +185,7 @@ public: NotebookTab *getTab() const; Node *getBaseNode(); - void setTab(NotebookTab *tab); + void setTab(NotebookTab *tab_); void hideResizeHandles(); void resetMouseStatus(); @@ -206,6 +205,16 @@ protected: void resizeEvent(QResizeEvent *event) override; private: + void layout(); + void setSelected(Split *selected_); + void selectSplitRecursive(Node *node, Direction direction); + void focusSplitRecursive(Node *node, Direction direction); + void setPreferedTargetRecursive(Node *node); + + void addSplit(Split *split); + + void decodeNodeRecusively(QJsonObject &obj, Node *node); + struct DropRegion { QRect rect; std::pair position; @@ -217,30 +226,19 @@ private: } }; - void addSplit(Split *split); + std::vector dropRects_; + std::vector dropRegions_; + DropOverlay overlay_; + std::vector> resizeHandles_; + QPoint mouseOverPoint_; - std::vector dropRects; - std::vector dropRegions; - NotebookPageDropPreview dropPreview; - DropOverlay overlay; - std::vector> resizeHandles; - QPoint mouseOverPoint; + Node baseNode_; + Split *selected_; - void layout(); + NotebookTab *tab_; + std::vector splits_; - Node baseNode; - Split *selected; - void setSelected(Split *selected); - void selectSplitRecursive(Node *node, Direction direction); - void focusSplitRecursive(Node *node, Direction direction); - void setPreferedTargetRecursive(Node *node); - - NotebookTab *tab; - std::vector splits; - - bool isDragging = false; - - void decodeNodeRecusively(QJsonObject &obj, Node *node); + bool isDragging_ = false; }; } // namespace chatterino diff --git a/src/widgets/splits/SplitHeader.cpp b/src/widgets/splits/SplitHeader.cpp index 044362cc9..adfb318a9 100644 --- a/src/widgets/splits/SplitHeader.cpp +++ b/src/widgets/splits/SplitHeader.cpp @@ -26,10 +26,10 @@ namespace chatterino { SplitHeader::SplitHeader(Split *_split) : BaseWidget(_split) - , split(_split) + , split_(_split) { - this->split->focused.connect([this]() { this->themeChangedEvent(); }); - this->split->focusLost.connect([this]() { this->themeChangedEvent(); }); + this->split_->focused.connect([this]() { this->themeChangedEvent(); }); + this->split_->focusLost.connect([this]() { this->themeChangedEvent(); }); auto app = getApp(); @@ -44,7 +44,7 @@ SplitHeader::SplitHeader(Split *_split) title->setHasOffset(false); // mode button - auto mode = layout.emplace(nullptr).assign(&this->modeButton); + auto mode = layout.emplace(nullptr).assign(&this->modeButton_); mode->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); mode->hide(); @@ -53,38 +53,38 @@ SplitHeader::SplitHeader(Split *_split) QObject::connect(mode.getElement(), &RippleEffectLabel::clicked, this, [this] { QTimer::singleShot(80, this, [&, this] { - ChannelPtr _channel = this->split->getChannel(); + ChannelPtr _channel = this->split_->getChannel(); if (_channel->hasModRights()) { - this->modeMenu.move( - this->modeButton->mapToGlobal(QPoint(0, this->modeButton->height()))); - this->modeMenu.show(); + this->modeMenu_.move( + this->modeButton_->mapToGlobal(QPoint(0, this->modeButton_->height()))); + this->modeMenu_.show(); } }); }); // moderation mode - auto moderator = layout.emplace(this).assign(&this->moderationButton); + auto moderator = layout.emplace(this).assign(&this->moderationButton_); QObject::connect(moderator.getElement(), &RippleEffectButton::clicked, this, [this, moderator]() mutable { - this->split->setModerationMode(!this->split->getModerationMode()); + this->split_->setModerationMode(!this->split_->getModerationMode()); - moderator->setDim(!this->split->getModerationMode()); + moderator->setDim(!this->split_->getModerationMode()); }); this->updateModerationModeIcon(); // dropdown label - auto dropdown = layout.emplace(this).assign(&this->dropdownButton); + auto dropdown = layout.emplace(this).assign(&this->dropdownButton_); dropdown->setMouseTracking(true); // dropdown->setPixmap(*app->resources->splitHeaderContext->getPixmap()); // dropdown->setScaleIndependantSize(23, 23); this->addDropdownItems(dropdown.getElement()); QObject::connect(dropdown.getElement(), &RippleEffectButton::leftMousePress, this, [this] { QTimer::singleShot(80, [&, this] { - this->dropdownMenu.move( - this->dropdownButton->mapToGlobal(QPoint(0, this->dropdownButton->height()))); - this->dropdownMenu.show(); + this->dropdownMenu_.move( + this->dropdownButton_->mapToGlobal(QPoint(0, this->dropdownButton_->height()))); + this->dropdownMenu_.show(); }); }); } @@ -97,34 +97,34 @@ SplitHeader::SplitHeader(Split *_split) this->initializeChannelSignals(); - this->split->channelChanged.connect([this]() { + this->split_->channelChanged.connect([this]() { this->initializeChannelSignals(); // }); this->managedConnect(app->accounts->twitch.currentUserChanged, [this] { this->updateModerationModeIcon(); }); - this->addModeActions(this->modeMenu); + this->addModeActions(this->modeMenu_); this->setMouseTracking(true); } SplitHeader::~SplitHeader() { - this->onlineStatusChangedConnection.disconnect(); + this->onlineStatusChangedConnection_.disconnect(); } void SplitHeader::addDropdownItems(RippleEffectButton *) { // clang-format off - this->dropdownMenu.addAction("New split", this->split, &Split::doAddSplit, QKeySequence(tr("Ctrl+T"))); - this->dropdownMenu.addAction("Close split", this->split, &Split::doCloseSplit, QKeySequence(tr("Ctrl+W"))); - this->dropdownMenu.addAction("Change channel", this->split, &Split::doChangeChannel, QKeySequence(tr("Ctrl+R"))); - this->dropdownMenu.addSeparator(); - this->dropdownMenu.addAction("Viewer list", this->split, &Split::doOpenViewerList); - this->dropdownMenu.addAction("Search", this->split, &Split::doSearch, QKeySequence(tr("Ctrl+F"))); - this->dropdownMenu.addSeparator(); - this->dropdownMenu.addAction("Popup", this->split, &Split::doPopup); + this->dropdownMenu_.addAction("New split", this->split_, &Split::doAddSplit, QKeySequence(tr("Ctrl+T"))); + this->dropdownMenu_.addAction("Close split", this->split_, &Split::doCloseSplit, QKeySequence(tr("Ctrl+W"))); + this->dropdownMenu_.addAction("Change channel", this->split_, &Split::doChangeChannel, QKeySequence(tr("Ctrl+R"))); + this->dropdownMenu_.addSeparator(); + this->dropdownMenu_.addAction("Viewer list", this->split_, &Split::doOpenViewerList); + this->dropdownMenu_.addAction("Search", this->split_, &Split::doSearch, QKeySequence(tr("Ctrl+F"))); + this->dropdownMenu_.addSeparator(); + this->dropdownMenu_.addAction("Popup", this->split_, &Split::doPopup); #ifdef USEWEBENGINE this->dropdownMenu.addAction("Start watching", this, [this]{ ChannelPtr _channel = this->split->getChannel(); @@ -137,15 +137,15 @@ void SplitHeader::addDropdownItems(RippleEffectButton *) } }); #endif - this->dropdownMenu.addAction("Open browser", this->split, &Split::doOpenChannel); + this->dropdownMenu_.addAction("Open browser", this->split_, &Split::doOpenChannel); #ifndef USEWEBENGINE - this->dropdownMenu.addAction("Open browser popup", this->split, &Split::doOpenPopupPlayer); + this->dropdownMenu_.addAction("Open browser popup", this->split_, &Split::doOpenPopupPlayer); #endif - this->dropdownMenu.addAction("Open streamlink", this->split, &Split::doOpenStreamlink); - this->dropdownMenu.addSeparator(); - this->dropdownMenu.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes())); - this->dropdownMenu.addAction("Reconnect", this, SLOT(menuManualReconnect())); - this->dropdownMenu.addAction("Clear messages", this->split, &Split::doClearChat); + this->dropdownMenu_.addAction("Open streamlink", this->split_, &Split::doOpenStreamlink); + this->dropdownMenu_.addSeparator(); + this->dropdownMenu_.addAction("Reload channel emotes", this, SLOT(menuReloadChannelEmotes())); + this->dropdownMenu_.addAction("Reconnect", this, SLOT(menuManualReconnect())); + this->dropdownMenu_.addAction("Clear messages", this->split_, &Split::doClearChat); // this->dropdownMenu.addSeparator(); // this->dropdownMenu.addAction("Show changelog", this, SLOT(menuShowChangelog())); // clang-format on @@ -158,8 +158,8 @@ void SplitHeader::updateRoomModes() void SplitHeader::setupModeLabel(RippleEffectLabel &label) { - this->managedConnections.push_back(this->modeUpdateRequested_.connect([this, &label] { - auto twitchChannel = dynamic_cast(this->split->getChannel().get()); + this->managedConnections_.push_back(this->modeUpdateRequested_.connect([this, &label] { + auto twitchChannel = dynamic_cast(this->split_->getChannel().get()); // return if the channel is not a twitch channel if (twitchChannel == nullptr) { @@ -224,11 +224,11 @@ void SplitHeader::addModeActions(QMenu &menu) menu.addAction(setSlow); menu.addAction(setR9k); - this->managedConnections.push_back(this->modeUpdateRequested_.connect( // + this->managedConnections_.push_back(this->modeUpdateRequested_.connect( // [this, setSub, setEmote, setSlow, setR9k]() { - auto twitchChannel = dynamic_cast(this->split->getChannel().get()); + auto twitchChannel = dynamic_cast(this->split_->getChannel().get()); if (twitchChannel == nullptr) { - this->modeButton->hide(); + this->modeButton_->hide(); return; } @@ -249,7 +249,7 @@ void SplitHeader::addModeActions(QMenu &menu) action->setChecked(!action->isChecked()); qDebug() << command; - this->split->getChannel().get()->sendMessage(command); + this->split_->getChannel().get()->sendMessage(command); }; QObject::connect(setSub, &QAction::triggered, this, @@ -260,7 +260,7 @@ void SplitHeader::addModeActions(QMenu &menu) QObject::connect(setSlow, &QAction::triggered, this, [setSlow, this]() { if (!setSlow->isChecked()) { - this->split->getChannel().get()->sendMessage("/slowoff"); + this->split_->getChannel().get()->sendMessage("/slowoff"); setSlow->setChecked(false); return; }; @@ -268,7 +268,7 @@ void SplitHeader::addModeActions(QMenu &menu) int slowSec = QInputDialog::getInt(this, "", "Seconds:", 10, 0, 500, 1, &ok, Qt::FramelessWindowHint); if (ok) { - this->split->getChannel().get()->sendMessage(QString("/slow %1").arg(slowSec)); + this->split_->getChannel().get()->sendMessage(QString("/slow %1").arg(slowSec)); } else { setSlow->setChecked(false); } @@ -281,13 +281,13 @@ void SplitHeader::addModeActions(QMenu &menu) void SplitHeader::initializeChannelSignals() { // Disconnect any previous signal first - this->onlineStatusChangedConnection.disconnect(); + this->onlineStatusChangedConnection_.disconnect(); - auto channel = this->split->getChannel(); + auto channel = this->split_->getChannel(); TwitchChannel *twitchChannel = dynamic_cast(channel.get()); if (twitchChannel) { - this->managedConnections.emplace_back(twitchChannel->updateLiveInfo.connect([this]() { + this->managedConnections_.emplace_back(twitchChannel->updateLiveInfo.connect([this]() { this->updateChannelText(); // })); } @@ -298,16 +298,16 @@ void SplitHeader::scaleChangedEvent(float scale) int w = int(28 * scale); this->setFixedHeight(w); - this->dropdownButton->setFixedWidth(w); - this->moderationButton->setFixedWidth(w); + this->dropdownButton_->setFixedWidth(w); + this->moderationButton_->setFixedWidth(w); // this->titleLabel->setFont( // FontManager::getInstance().getFont(FontStyle::Medium, scale)); } void SplitHeader::updateChannelText() { - auto indirectChannel = this->split->getIndirectChannel(); - auto channel = this->split->getChannel(); + auto indirectChannel = this->split_->getIndirectChannel(); + auto channel = this->split_->getChannel(); QString title = channel->name; @@ -321,8 +321,8 @@ void SplitHeader::updateChannelText() const auto streamStatus = twitchChannel->getStreamStatus(); if (streamStatus.live) { - this->isLive = true; - this->tooltip = "" + this->isLive_ = true; + this->tooltip_ = "" "

" + streamStatus.title + "

" + streamStatus.game + "
" + (streamStatus.rerun ? "Vod-casting" : "Live") + " for " + @@ -338,7 +338,7 @@ void SplitHeader::updateChannelText() title += " (live)"; } } else { - this->tooltip = QString(); + this->tooltip_ = QString(); } } @@ -346,7 +346,7 @@ void SplitHeader::updateChannelText() title = ""; } - this->isLive = false; + this->isLive_ = false; this->titleLabel->setText(title); } @@ -354,12 +354,12 @@ void SplitHeader::updateModerationModeIcon() { auto app = getApp(); - this->moderationButton->setPixmap(this->split->getModerationMode() + this->moderationButton_->setPixmap(this->split_->getModerationMode() ? *app->resources->moderationmode_enabled->getPixmap() : *app->resources->moderationmode_disabled->getPixmap()); bool modButtonVisible = false; - ChannelPtr channel = this->split->getChannel(); + ChannelPtr channel = this->split_->getChannel(); TwitchChannel *tc = dynamic_cast(channel.get()); @@ -367,7 +367,7 @@ void SplitHeader::updateModerationModeIcon() modButtonVisible = true; } - this->moderationButton->setVisible(modButtonVisible); + this->moderationButton_->setVisible(modButtonVisible); } void SplitHeader::paintEvent(QPaintEvent *) @@ -382,26 +382,26 @@ void SplitHeader::paintEvent(QPaintEvent *) void SplitHeader::mousePressEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - this->dragging = true; + this->dragging_ = true; - this->dragStart = event->pos(); + this->dragStart_ = event->pos(); } - this->doubleClicked = false; + this->doubleClicked_ = false; } void SplitHeader::mouseReleaseEvent(QMouseEvent *event) { - if (this->dragging && event->button() == Qt::LeftButton) { + if (this->dragging_ && event->button() == Qt::LeftButton) { QPoint pos = event->globalPos(); - if (!showingHelpTooltip) { - this->showingHelpTooltip = true; + if (!showingHelpTooltip_) { + this->showingHelpTooltip_ = true; QTimer::singleShot(400, this, [this, pos] { - if (this->doubleClicked) { - this->doubleClicked = false; - this->showingHelpTooltip = false; + if (this->doubleClicked_) { + this->doubleClicked_ = false; + this->showingHelpTooltip_ = false; return; } @@ -416,22 +416,22 @@ void SplitHeader::mouseReleaseEvent(QMouseEvent *event) QTimer::singleShot(3000, widget, [this, widget] { widget->close(); - this->showingHelpTooltip = false; + this->showingHelpTooltip_ = false; }); }); } } - this->dragging = false; + this->dragging_ = false; } void SplitHeader::mouseMoveEvent(QMouseEvent *event) { - if (this->dragging) { - if (std::abs(this->dragStart.x() - event->pos().x()) > int(12 * this->getScale()) || - std::abs(this->dragStart.y() - event->pos().y()) > int(12 * this->getScale())) { - this->split->drag(); - this->dragging = false; + if (this->dragging_) { + if (std::abs(this->dragStart_.x() - event->pos().x()) > int(12 * this->getScale()) || + std::abs(this->dragStart_.y() - event->pos().y()) > int(12 * this->getScale())) { + this->split_->drag(); + this->dragging_ = false; } } } @@ -439,17 +439,17 @@ void SplitHeader::mouseMoveEvent(QMouseEvent *event) void SplitHeader::mouseDoubleClickEvent(QMouseEvent *event) { if (event->button() == Qt::LeftButton) { - this->split->doChangeChannel(); + this->split_->doChangeChannel(); } - this->doubleClicked = true; + this->doubleClicked_ = true; } void SplitHeader::enterEvent(QEvent *event) { - if (!this->tooltip.isEmpty()) { + if (!this->tooltip_.isEmpty()) { auto tooltipWidget = TooltipWidget::getInstance(); tooltipWidget->moveTo(this, this->mapToGlobal(this->rect().bottomLeft()), false); - tooltipWidget->setText(this->tooltip); + tooltipWidget->setText(this->tooltip_); tooltipWidget->show(); tooltipWidget->raise(); } @@ -472,16 +472,16 @@ void SplitHeader::themeChangedEvent() { QPalette palette; - if (this->split->hasFocus()) { + if (this->split_->hasFocus()) { palette.setColor(QPalette::Foreground, this->theme->splits.header.focusedText); } else { palette.setColor(QPalette::Foreground, this->theme->splits.header.text); } if (this->theme->isLightTheme()) { - this->dropdownButton->setPixmap(QPixmap(":/images/menu_black.png")); + this->dropdownButton_->setPixmap(QPixmap(":/images/menu_black.png")); } else { - this->dropdownButton->setPixmap(QPixmap(":/images/menu_white.png")); + this->dropdownButton_->setPixmap(QPixmap(":/images/menu_white.png")); } this->titleLabel->setPalette(palette); @@ -493,7 +493,7 @@ void SplitHeader::menuMoveSplit() void SplitHeader::menuReloadChannelEmotes() { - auto channel = this->split->getChannel(); + auto channel = this->split_->getChannel(); TwitchChannel *twitchChannel = dynamic_cast(channel.get()); if (twitchChannel) { diff --git a/src/widgets/splits/SplitHeader.hpp b/src/widgets/splits/SplitHeader.hpp index 2c6907d32..9b3d75283 100644 --- a/src/widgets/splits/SplitHeader.hpp +++ b/src/widgets/splits/SplitHeader.hpp @@ -55,33 +55,32 @@ private: void setupModeLabel(RippleEffectLabel &label); void addDropdownItems(RippleEffectButton *label); - Split *const split; + Split *const split_; - QPoint dragStart; - bool dragging = false; - bool doubleClicked = false; - bool showingHelpTooltip = false; + QPoint dragStart_; + bool dragging_ = false; + bool doubleClicked_ = false; + bool showingHelpTooltip_ = false; - pajlada::Signals::Connection onlineStatusChangedConnection; + pajlada::Signals::Connection onlineStatusChangedConnection_; - RippleEffectButton *dropdownButton = nullptr; + RippleEffectButton *dropdownButton_ = nullptr; // Label *titleLabel; Label *titleLabel = nullptr; - RippleEffectLabel *modeButton = nullptr; - RippleEffectButton *moderationButton = nullptr; + RippleEffectLabel *modeButton_ = nullptr; + RippleEffectButton *moderationButton_ = nullptr; - QMenu dropdownMenu; - QMenu modeMenu; + QMenu dropdownMenu_; + QMenu modeMenu_; pajlada::Signals::NoArgSignal modeUpdateRequested_; - QString tooltip; - bool isLive; + QString tooltip_; + bool isLive_; - std::vector managedConnections; + std::vector managedConnections_; public slots: - void menuMoveSplit(); void menuReloadChannelEmotes(); void menuManualReconnect(); diff --git a/src/widgets/splits/SplitInput.cpp b/src/widgets/splits/SplitInput.cpp index 426244f8c..70efdd77b 100644 --- a/src/widgets/splits/SplitInput.cpp +++ b/src/widgets/splits/SplitInput.cpp @@ -91,7 +91,7 @@ void SplitInput::initLayout() // clear channelview selection when selecting in the input QObject::connect(this->ui_.textEdit, &QTextEdit::copyAvailable, [this](bool available) { if (available) { - this->split_->view.clearSelection(); + this->split_->view_.clearSelection(); } }); @@ -254,7 +254,7 @@ void SplitInput::installKeyPressedEvent() notebook->selectPreviousTab(); } } else if (event->key() == Qt::Key_C && event->modifiers() == Qt::ControlModifier) { - if (this->split_->view.hasSelection()) { + if (this->split_->view_.hasSelection()) { this->split_->doCopy(); event->accept(); } diff --git a/src/widgets/splits/SplitInput.hpp b/src/widgets/splits/SplitInput.hpp index 491841d44..42a8f082b 100644 --- a/src/widgets/splits/SplitInput.hpp +++ b/src/widgets/splits/SplitInput.hpp @@ -40,6 +40,10 @@ protected: virtual void mousePressEvent(QMouseEvent *event) override; private: + void initLayout(); + void installKeyPressedEvent(); + void updateEmoteButton(); + Split *const split_; std::unique_ptr emotePopup_; @@ -56,11 +60,6 @@ private: QString currMsg_; int prevIndex_ = 0; - void initLayout(); - void installKeyPressedEvent(); - - void updateEmoteButton(); - private slots: void editTextChanged(); diff --git a/src/widgets/splits/SplitOverlay.cpp b/src/widgets/splits/SplitOverlay.cpp index 4f3ced959..d6b504c6f 100644 --- a/src/widgets/splits/SplitOverlay.cpp +++ b/src/widgets/splits/SplitOverlay.cpp @@ -17,10 +17,10 @@ namespace chatterino { SplitOverlay::SplitOverlay(Split *parent) : BaseWidget(parent) - , split(parent) + , split_(parent) { QGridLayout *layout = new QGridLayout(this); - this->_layout = layout; + this->layout_ = layout; layout->setMargin(1); layout->setSpacing(1); @@ -30,11 +30,11 @@ SplitOverlay::SplitOverlay(Split *parent) layout->setColumnStretch(3, 1); QPushButton *move = new QPushButton(getApp()->resources->split.move, QString()); - QPushButton *left = this->_left = new QPushButton(getApp()->resources->split.left, QString()); - QPushButton *right = this->_right = + QPushButton *left = this->left_ = new QPushButton(getApp()->resources->split.left, QString()); + QPushButton *right = this->right_ = new QPushButton(getApp()->resources->split.right, QString()); - QPushButton *up = this->_up = new QPushButton(getApp()->resources->split.up, QString()); - QPushButton *down = this->_down = new QPushButton(getApp()->resources->split.down, QString()); + QPushButton *up = this->up_ = new QPushButton(getApp()->resources->split.up, QString()); + QPushButton *down = this->down_ = new QPushButton(getApp()->resources->split.down, QString()); move->setGraphicsEffect(new QGraphicsOpacityEffect(this)); left->setGraphicsEffect(new QGraphicsOpacityEffect(this)); @@ -98,7 +98,7 @@ void SplitOverlay::paintEvent(QPaintEvent *) } QRect rect; - switch (this->hoveredElement) { + switch (this->hoveredElement_) { case SplitLeft: { rect = QRect(0, 0, this->width() / 2, this->height()); } break; @@ -134,10 +134,10 @@ void SplitOverlay::resizeEvent(QResizeEvent *event) bool wideEnough = event->size().width() > 150 * _scale; bool highEnough = event->size().height() > 150 * _scale; - this->_left->setVisible(wideEnough); - this->_right->setVisible(wideEnough); - this->_up->setVisible(highEnough); - this->_down->setVisible(highEnough); + this->left_->setVisible(wideEnough); + this->right_->setVisible(wideEnough); + this->up_->setVisible(highEnough); + this->down_->setVisible(highEnough); } void SplitOverlay::mouseMoveEvent(QMouseEvent *event) @@ -169,7 +169,7 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched, QEvent *even effect->setOpacity(0.99); } - this->parent->hoveredElement = this->hoveredElement; + this->parent->hoveredElement_ = this->hoveredElement; this->parent->update(); } break; case QEvent::Leave: { @@ -180,27 +180,27 @@ bool SplitOverlay::ButtonEventFilter::eventFilter(QObject *watched, QEvent *even effect->setOpacity(0.7); } - this->parent->hoveredElement = HoveredElement::None; + this->parent->hoveredElement_ = HoveredElement::None; this->parent->update(); } break; case QEvent::MouseButtonPress: { if (this->hoveredElement == HoveredElement::SplitMove) { QMouseEvent *mouseEvent = static_cast(event); if (mouseEvent->button() == Qt::LeftButton) { - this->parent->split->drag(); + this->parent->split_->drag(); } return true; } } break; case QEvent::MouseButtonRelease: { if (this->hoveredElement != HoveredElement::SplitMove) { - SplitContainer *container = this->parent->split->getContainer(); + SplitContainer *container = this->parent->split_->getContainer(); if (container != nullptr) { auto *_split = new Split(container); auto dir = SplitContainer::Direction(this->hoveredElement + SplitContainer::Left - SplitLeft); - container->insertSplit(_split, dir, this->parent->split); + container->insertSplit(_split, dir, this->parent->split_); this->parent->hide(); } } diff --git a/src/widgets/splits/SplitOverlay.hpp b/src/widgets/splits/SplitOverlay.hpp index 1601a86c9..6709639b5 100644 --- a/src/widgets/splits/SplitOverlay.hpp +++ b/src/widgets/splits/SplitOverlay.hpp @@ -24,13 +24,6 @@ protected: private: // fourtf: !!! preserve the order of left, up, right and down enum HoveredElement { None, SplitMove, SplitLeft, SplitUp, SplitRight, SplitDown }; - HoveredElement hoveredElement = None; - Split *split; - QGridLayout *_layout; - QPushButton *_left; - QPushButton *_up; - QPushButton *_right; - QPushButton *_down; class ButtonEventFilter : public QObject { @@ -44,6 +37,14 @@ private: bool eventFilter(QObject *watched, QEvent *event) override; }; + HoveredElement hoveredElement_ = None; + Split *split_; + QGridLayout *layout_; + QPushButton *left_; + QPushButton *up_; + QPushButton *right_; + QPushButton *down_; + friend class ButtonEventFilter; };