From 0b36f43611a33b88229ed4596694b0c5c2a1a2f5 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Fri, 21 Sep 2018 22:46:00 +0200 Subject: [PATCH] make the list of ignored usernames into a set instead, making it more maintanable change "open twitch channel in new split" menu action text --- src/widgets/helper/ChannelView.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 05462a59e..d180448ff 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -9,8 +9,8 @@ #include "messages/Message.hpp" #include "messages/MessageElement.hpp" #include "messages/layouts/MessageLayout.hpp" -#include "providers/twitch/TwitchChannel.hpp" #include "messages/layouts/MessageLayoutElement.hpp" +#include "providers/twitch/TwitchChannel.hpp" #include "providers/twitch/TwitchServer.hpp" #include "singletons/Settings.hpp" #include "singletons/Theme.hpp" @@ -438,7 +438,8 @@ void ChannelView::setChannel(ChannelPtr newChannel) } if (this->channel_->getType() != Channel::Type::TwitchMentions) { - this->scrollBar_->addHighlight(message->getScrollBarHighlight()); + this->scrollBar_->addHighlight( + message->getScrollBarHighlight()); } this->messageWasAdded_ = true; @@ -1049,7 +1050,6 @@ void ChannelView::handleMouseClick(QMouseEvent *event, } } break; case Qt::RightButton: { - auto insertText = [=](QString text) { if (auto split = dynamic_cast(this->parentWidget())) { split->insertTextToInput(text); @@ -1131,15 +1131,18 @@ void ChannelView::addContextMenuItems( static QRegularExpression twitchChannelRegex( R"(^(?:https?:\/\/)?(?:www\.|go\.)?twitch\.tv\/(?[a-z0-9_]+))", QRegularExpression::CaseInsensitiveOption); + static QSet ignoredUsernames{ + "videos", + "settings", + }; - auto twitchMatch = twitchChannelRegex.match( - hoveredElement->getLink().value); + auto twitchMatch = + twitchChannelRegex.match(hoveredElement->getLink().value); auto twitchUsername = twitchMatch.captured("username"); if (!twitchUsername.isEmpty() && - twitchUsername != "settings" && - twitchUsername != "videos") { + !ignoredUsernames.contains(twitchUsername)) { menu->addSeparator(); - menu->addAction("Join to channel", [twitchUsername, this] { + menu->addAction("Open in new split", [twitchUsername, this] { this->joinToChannel.invoke(twitchUsername); }); }