Added button in menu to join to channel. (#724)

This commit is contained in:
23rd
2018-09-21 21:35:14 +03:00
committed by pajlada
parent a3a7317e62
commit 9a6650b56c
5 changed files with 29 additions and 2 deletions
+19
View File
@@ -1126,6 +1126,25 @@ void ChannelView::addContextMenuItems(
QGuiApplication::clipboard()->setText(copyString);
});
// Join to channel
if (hoveredElement->getLink().type == Link::Url) {
static QRegularExpression twitchChannelRegex(
R"(^(?:https?:\/\/)?(?:www\.|go\.)?twitch\.tv\/(?<username>[a-z0-9_]+))",
QRegularExpression::CaseInsensitiveOption);
auto twitchMatch = twitchChannelRegex.match(
hoveredElement->getLink().value);
auto twitchUsername = twitchMatch.captured("username");
if (!twitchUsername.isEmpty() &&
twitchUsername != "settings" &&
twitchUsername != "videos") {
menu->addSeparator();
menu->addAction("Join to channel", [twitchUsername, this] {
this->joinToChannel.invoke(twitchUsername);
});
}
}
menu->popup(QCursor::pos());
menu->raise();