diff --git a/src/channel.hpp b/src/channel.hpp index ac06a2a04..be3564979 100644 --- a/src/channel.hpp +++ b/src/channel.hpp @@ -64,6 +64,6 @@ private: // std::shared_ptr loggingChannel; }; -typedef std::shared_ptr SharedChannel; +typedef std::shared_ptr ChannelPtr; } // namespace chatterino diff --git a/src/singletons/channelmanager.cpp b/src/singletons/channelmanager.cpp index 893d788cc..b18a56ff7 100644 --- a/src/singletons/channelmanager.cpp +++ b/src/singletons/channelmanager.cpp @@ -19,11 +19,11 @@ ChannelManager::ChannelManager() { } -const std::vector ChannelManager::getItems() +const std::vector ChannelManager::getItems() { QMutexLocker locker(&this->channelsMutex); - std::vector items; + std::vector items; for (auto &item : this->twitchChannels.values()) { items.push_back(std::get<0>(item)); @@ -32,7 +32,7 @@ const std::vector ChannelManager::getItems() return items; } -SharedChannel ChannelManager::addTwitchChannel(const QString &rawChannelName) +ChannelPtr ChannelManager::addTwitchChannel(const QString &rawChannelName) { QString channelName = rawChannelName.toLower(); @@ -63,7 +63,7 @@ SharedChannel ChannelManager::addTwitchChannel(const QString &rawChannelName) return std::get<0>(it.value()); } -SharedChannel ChannelManager::getTwitchChannel(const QString &channel) +ChannelPtr ChannelManager::getTwitchChannel(const QString &channel) { QMutexLocker locker(&this->channelsMutex); @@ -128,7 +128,7 @@ const std::string &ChannelManager::getUserID(const std::string &username) return temporary; } -void ChannelManager::doOnAll(std::function func) +void ChannelManager::doOnAll(std::function func) { for (const auto &channel : this->twitchChannels) { func(std::get<0>(channel)); diff --git a/src/singletons/channelmanager.hpp b/src/singletons/channelmanager.hpp index 3fcf6b41c..89e3d257e 100644 --- a/src/singletons/channelmanager.hpp +++ b/src/singletons/channelmanager.hpp @@ -17,20 +17,20 @@ class ChannelManager public: static ChannelManager &getInstance(); - const std::vector getItems(); + const std::vector getItems(); - SharedChannel addTwitchChannel(const QString &channel); - SharedChannel getTwitchChannel(const QString &channel); + ChannelPtr addTwitchChannel(const QString &channel); + ChannelPtr getTwitchChannel(const QString &channel); void removeTwitchChannel(const QString &channel); const std::string &getUserID(const std::string &username); - void doOnAll(std::function func); + void doOnAll(std::function func); // Special channels - const SharedChannel whispersChannel; - const SharedChannel mentionsChannel; - const SharedChannel emptyChannel; + const ChannelPtr whispersChannel; + const ChannelPtr mentionsChannel; + const ChannelPtr emptyChannel; private: std::map usernameToID; diff --git a/src/singletons/commandmanager.cpp b/src/singletons/commandmanager.cpp index 40b070fab..a19060f3b 100644 --- a/src/singletons/commandmanager.cpp +++ b/src/singletons/commandmanager.cpp @@ -88,7 +88,7 @@ QStringList CommandManager::getCommands() return this->commandsStringList; } -QString CommandManager::execCommand(const QString &text, SharedChannel channel, +QString CommandManager::execCommand(const QString &text, ChannelPtr channel, bool dryRun) { QStringList words = text.split(' ', QString::SkipEmptyParts); diff --git a/src/singletons/ircmanager.cpp b/src/singletons/ircmanager.cpp index 43f615632..59f829ec9 100644 --- a/src/singletons/ircmanager.cpp +++ b/src/singletons/ircmanager.cpp @@ -391,7 +391,7 @@ void IrcManager::onConnected() MessagePtr msg = Message::createSystemMessage("connected to chat"); MessagePtr remsg = Message::createSystemMessage("reconnected to chat"); - this->channelManager.doOnAll([msg, remsg](SharedChannel channel) { + this->channelManager.doOnAll([msg, remsg](ChannelPtr channel) { assert(channel); LimitedQueueSnapshot snapshot = channel->getMessageSnapshot(); @@ -412,7 +412,7 @@ void IrcManager::onDisconnected() MessagePtr msg = Message::createSystemMessage("disconnected from chat"); msg->addFlags(Message::DisconnectedMessage); - this->channelManager.doOnAll([msg](SharedChannel channel) { + this->channelManager.doOnAll([msg](ChannelPtr channel) { assert(channel); channel->addMessage(msg); }); diff --git a/src/twitch/twitchchannel.cpp b/src/twitch/twitchchannel.cpp index 4377ed5d4..e308a1e22 100644 --- a/src/twitch/twitchchannel.cpp +++ b/src/twitch/twitchchannel.cpp @@ -159,7 +159,7 @@ void TwitchChannel::refreshLiveStatus() std::weak_ptr weak = this->shared_from_this(); util::twitch::get2(url, QThread::currentThread(), false, [weak](const rapidjson::Document &d) { - SharedChannel shared = weak.lock(); + ChannelPtr shared = weak.lock(); if (!shared) { return; @@ -220,7 +220,7 @@ void TwitchChannel::fetchRecentMessages() std::weak_ptr weak = this->shared_from_this(); util::twitch::get(genericURL.arg(roomID), QThread::currentThread(), [weak](QJsonObject obj) { - SharedChannel shared = weak.lock(); + ChannelPtr shared = weak.lock(); if (!shared) { return; diff --git a/src/widgets/accountpopup.cpp b/src/widgets/accountpopup.cpp index 1c053653d..e1a84d732 100644 --- a/src/widgets/accountpopup.cpp +++ b/src/widgets/accountpopup.cpp @@ -18,7 +18,7 @@ namespace chatterino { namespace widgets { -AccountPopupWidget::AccountPopupWidget(SharedChannel _channel) +AccountPopupWidget::AccountPopupWidget(ChannelPtr _channel) : BaseWindow() , ui(new Ui::AccountPopup) , channel(_channel) @@ -172,7 +172,7 @@ void AccountPopupWidget::setName(const QString &name) this->popupWidgetUser.refreshUserType(this->channel, false); } -void AccountPopupWidget::User::refreshUserType(const SharedChannel &channel, bool loggedInUser) +void AccountPopupWidget::User::refreshUserType(const ChannelPtr &channel, bool loggedInUser) { if (channel->name == this->username) { this->userType = UserType::Owner; @@ -183,7 +183,7 @@ void AccountPopupWidget::User::refreshUserType(const SharedChannel &channel, boo } } -void AccountPopupWidget::setChannel(SharedChannel _channel) +void AccountPopupWidget::setChannel(ChannelPtr _channel) { this->channel = _channel; } diff --git a/src/widgets/accountpopup.hpp b/src/widgets/accountpopup.hpp index e5bae7d1a..aeac473b4 100644 --- a/src/widgets/accountpopup.hpp +++ b/src/widgets/accountpopup.hpp @@ -23,10 +23,10 @@ class AccountPopupWidget : public BaseWindow { Q_OBJECT public: - AccountPopupWidget(SharedChannel _channel); + AccountPopupWidget(ChannelPtr _channel); void setName(const QString &name); - void setChannel(SharedChannel _channel); + void setChannel(ChannelPtr _channel); public slots: void actuallyRefreshButtons(); @@ -52,7 +52,7 @@ private: enum class UserType { User, Mod, Owner }; - SharedChannel channel; + ChannelPtr channel; QPixmap avatar; @@ -63,7 +63,7 @@ private: QString userID; UserType userType = UserType::User; - void refreshUserType(const SharedChannel &channel, bool loggedInUser); + void refreshUserType(const ChannelPtr &channel, bool loggedInUser); }; User loggedInUser; diff --git a/src/widgets/emotepopup.cpp b/src/widgets/emotepopup.cpp index 8e8ee1118..1fce82c50 100644 --- a/src/widgets/emotepopup.cpp +++ b/src/widgets/emotepopup.cpp @@ -32,7 +32,7 @@ EmotePopup::EmotePopup(singletons::ThemeManager &themeManager) this->loadEmojis(); } -void EmotePopup::loadChannel(SharedChannel _channel) +void EmotePopup::loadChannel(ChannelPtr _channel) { TwitchChannel *channel = dynamic_cast(_channel.get()); @@ -40,7 +40,7 @@ void EmotePopup::loadChannel(SharedChannel _channel) return; } - SharedChannel emoteChannel(new Channel("")); + ChannelPtr emoteChannel(new Channel("")); auto addEmotes = [&](util::EmoteMap &map, const QString &title, const QString &emoteDesc) { // TITLE @@ -81,7 +81,7 @@ void EmotePopup::loadEmojis() { util::EmoteMap &emojis = singletons::EmoteManager::getInstance().getEmojis(); - SharedChannel emojiChannel(new Channel("")); + ChannelPtr emojiChannel(new Channel("")); // title messages::MessageBuilder builder1; diff --git a/src/widgets/emotepopup.hpp b/src/widgets/emotepopup.hpp index d64f979d6..e6727dd74 100644 --- a/src/widgets/emotepopup.hpp +++ b/src/widgets/emotepopup.hpp @@ -12,7 +12,7 @@ class EmotePopup : public BaseWindow public: explicit EmotePopup(singletons::ThemeManager &); - void loadChannel(SharedChannel channel); + void loadChannel(ChannelPtr channel); void loadEmojis(); private: diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index 866c2a51c..e5296c88d 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -293,7 +293,7 @@ messages::LimitedQueueSnapshot ChannelView::getMessagesSnapsho return this->snapshot; } -void ChannelView::setChannel(SharedChannel newChannel) +void ChannelView::setChannel(ChannelPtr newChannel) { if (this->channel) { this->detachChannel(); diff --git a/src/widgets/helper/channelview.hpp b/src/widgets/helper/channelview.hpp index 2397cabe6..edc43c7cf 100644 --- a/src/widgets/helper/channelview.hpp +++ b/src/widgets/helper/channelview.hpp @@ -41,7 +41,7 @@ public: void pause(int msecTimeout); void updateLastReadMessage(); - void setChannel(SharedChannel channel); + void setChannel(ChannelPtr channel); messages::LimitedQueueSnapshot getMessagesSnapshot(); void layoutMessages(); @@ -84,7 +84,7 @@ private: void setSelection(const messages::SelectionItem &start, const messages::SelectionItem &end); messages::MessageElement::Flags getFlags() const; - SharedChannel channel; + ChannelPtr channel; Scrollbar scrollBar; RippleEffectLabel *goToBottom; diff --git a/src/widgets/helper/searchpopup.cpp b/src/widgets/helper/searchpopup.cpp index 048f00a5a..db1f7a65a 100644 --- a/src/widgets/helper/searchpopup.cpp +++ b/src/widgets/helper/searchpopup.cpp @@ -58,7 +58,7 @@ void SearchPopup::initLayout() } } -void SearchPopup::setChannel(SharedChannel channel) +void SearchPopup::setChannel(ChannelPtr channel) { this->snapshot = channel->getMessageSnapshot(); this->performSearch(); @@ -70,7 +70,7 @@ void SearchPopup::performSearch() { QString text = searchInput->text(); - SharedChannel channel(new Channel("search")); + ChannelPtr channel(new Channel("search")); for (size_t i = 0; i < this->snapshot.getLength(); i++) { messages::MessagePtr message = this->snapshot[i]; diff --git a/src/widgets/helper/splitheader.cpp b/src/widgets/helper/splitheader.cpp index 67c0ee355..1390845c0 100644 --- a/src/widgets/helper/splitheader.cpp +++ b/src/widgets/helper/splitheader.cpp @@ -93,7 +93,7 @@ void SplitHeader::addDropdownItems(RippleEffectButton *label) this->dropdownMenu.addSeparator(); #ifdef USEWEBENGINE this->dropdownMenu.addAction("Start watching", this, [this]{ - SharedChannel _channel = this->split->getChannel(); + ChannelPtr _channel = this->split->getChannel(); twitch::TwitchChannel *tc = dynamic_cast(_channel.get()); if (tc != nullptr) { @@ -180,7 +180,7 @@ void SplitHeader::updateModerationModeIcon() : resourceManager.moderationmode_disabled->getPixmap()); bool modButtonVisible = false; - SharedChannel channel = this->split->getChannel(); + ChannelPtr channel = this->split->getChannel(); twitch::TwitchChannel *tc = dynamic_cast(channel.get()); diff --git a/src/widgets/split.cpp b/src/widgets/split.cpp index 19ac3fa5e..d61fcebc2 100644 --- a/src/widgets/split.cpp +++ b/src/widgets/split.cpp @@ -132,17 +132,17 @@ const std::string &Split::getUUID() const return this->uuid; } -SharedChannel Split::getChannel() const +ChannelPtr Split::getChannel() const { return this->channel; } -SharedChannel &Split::getChannelRef() +ChannelPtr &Split::getChannelRef() { return this->channel; } -void Split::setChannel(SharedChannel _newChannel) +void Split::setChannel(ChannelPtr _newChannel) { this->view.setChannel(_newChannel); @@ -355,7 +355,7 @@ void Split::doClearChat() void Split::doOpenChannel() { - SharedChannel _channel = this->channel; + ChannelPtr _channel = this->channel; twitch::TwitchChannel *tc = dynamic_cast(_channel.get()); if (tc != nullptr) { @@ -365,7 +365,7 @@ void Split::doOpenChannel() void Split::doOpenPopupPlayer() { - SharedChannel _channel = this->channel; + ChannelPtr _channel = this->channel; twitch::TwitchChannel *tc = dynamic_cast(_channel.get()); if (tc != nullptr) { diff --git a/src/widgets/split.hpp b/src/widgets/split.hpp index 5e5e12e31..42ec4c69b 100644 --- a/src/widgets/split.hpp +++ b/src/widgets/split.hpp @@ -55,8 +55,8 @@ public: } const std::string &getUUID() const; - SharedChannel getChannel() const; - SharedChannel &getChannelRef(); + ChannelPtr getChannel() const; + ChannelPtr &getChannelRef(); void setFlexSizeX(double x); double getFlexSizeX(); void setFlexSizeY(double y); @@ -83,7 +83,7 @@ protected: private: SplitContainer &parentPage; - SharedChannel channel; + ChannelPtr channel; QVBoxLayout vbox; SplitHeader header; @@ -97,7 +97,7 @@ private: boost::signals2::connection channelIDChangedConnection; boost::signals2::connection usermodeChangedConnection; - void setChannel(SharedChannel newChannel); + void setChannel(ChannelPtr newChannel); void doOpenAccountPopupWidget(AccountPopupWidget *widget, QString user); void channelNameUpdated(const std::string &newChannelName); void handleModifiers(QEvent *event, Qt::KeyboardModifiers modifiers); diff --git a/src/widgets/streamview.cpp b/src/widgets/streamview.cpp index d3ffd0416..7ad017d6d 100644 --- a/src/widgets/streamview.cpp +++ b/src/widgets/streamview.cpp @@ -11,7 +11,7 @@ namespace chatterino { namespace widgets { -StreamView::StreamView(SharedChannel channel, QUrl url) +StreamView::StreamView(ChannelPtr channel, QUrl url) { util::LayoutCreator layoutCreator(this);