make the list of ignored usernames into a set instead, making it more maintanable
change "open twitch channel in new split" menu action text
This commit is contained in:
@@ -9,8 +9,8 @@
|
|||||||
#include "messages/Message.hpp"
|
#include "messages/Message.hpp"
|
||||||
#include "messages/MessageElement.hpp"
|
#include "messages/MessageElement.hpp"
|
||||||
#include "messages/layouts/MessageLayout.hpp"
|
#include "messages/layouts/MessageLayout.hpp"
|
||||||
#include "providers/twitch/TwitchChannel.hpp"
|
|
||||||
#include "messages/layouts/MessageLayoutElement.hpp"
|
#include "messages/layouts/MessageLayoutElement.hpp"
|
||||||
|
#include "providers/twitch/TwitchChannel.hpp"
|
||||||
#include "providers/twitch/TwitchServer.hpp"
|
#include "providers/twitch/TwitchServer.hpp"
|
||||||
#include "singletons/Settings.hpp"
|
#include "singletons/Settings.hpp"
|
||||||
#include "singletons/Theme.hpp"
|
#include "singletons/Theme.hpp"
|
||||||
@@ -438,7 +438,8 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this->channel_->getType() != Channel::Type::TwitchMentions) {
|
if (this->channel_->getType() != Channel::Type::TwitchMentions) {
|
||||||
this->scrollBar_->addHighlight(message->getScrollBarHighlight());
|
this->scrollBar_->addHighlight(
|
||||||
|
message->getScrollBarHighlight());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->messageWasAdded_ = true;
|
this->messageWasAdded_ = true;
|
||||||
@@ -1049,7 +1050,6 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case Qt::RightButton: {
|
case Qt::RightButton: {
|
||||||
|
|
||||||
auto insertText = [=](QString text) {
|
auto insertText = [=](QString text) {
|
||||||
if (auto split = dynamic_cast<Split *>(this->parentWidget())) {
|
if (auto split = dynamic_cast<Split *>(this->parentWidget())) {
|
||||||
split->insertTextToInput(text);
|
split->insertTextToInput(text);
|
||||||
@@ -1131,15 +1131,18 @@ void ChannelView::addContextMenuItems(
|
|||||||
static QRegularExpression twitchChannelRegex(
|
static QRegularExpression twitchChannelRegex(
|
||||||
R"(^(?:https?:\/\/)?(?:www\.|go\.)?twitch\.tv\/(?<username>[a-z0-9_]+))",
|
R"(^(?:https?:\/\/)?(?:www\.|go\.)?twitch\.tv\/(?<username>[a-z0-9_]+))",
|
||||||
QRegularExpression::CaseInsensitiveOption);
|
QRegularExpression::CaseInsensitiveOption);
|
||||||
|
static QSet<QString> ignoredUsernames{
|
||||||
|
"videos",
|
||||||
|
"settings",
|
||||||
|
};
|
||||||
|
|
||||||
auto twitchMatch = twitchChannelRegex.match(
|
auto twitchMatch =
|
||||||
hoveredElement->getLink().value);
|
twitchChannelRegex.match(hoveredElement->getLink().value);
|
||||||
auto twitchUsername = twitchMatch.captured("username");
|
auto twitchUsername = twitchMatch.captured("username");
|
||||||
if (!twitchUsername.isEmpty() &&
|
if (!twitchUsername.isEmpty() &&
|
||||||
twitchUsername != "settings" &&
|
!ignoredUsernames.contains(twitchUsername)) {
|
||||||
twitchUsername != "videos") {
|
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
menu->addAction("Join to channel", [twitchUsername, this] {
|
menu->addAction("Open in new split", [twitchUsername, this] {
|
||||||
this->joinToChannel.invoke(twitchUsername);
|
this->joinToChannel.invoke(twitchUsername);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user