Add accelerators to the right click menu for messages (#4705)

This commit is contained in:
Mm2PL
2023-07-22 12:54:48 +02:00
committed by GitHub
parent 7fd01ac575
commit ae8b2adcdd
2 changed files with 23 additions and 22 deletions
+1
View File
@@ -10,6 +10,7 @@
- Minor: Added setting to only show tabs with live channels (default toggle hotkey: Ctrl+Shift+L). (#4358) - Minor: Added setting to only show tabs with live channels (default toggle hotkey: Ctrl+Shift+L). (#4358)
- Minor: Added option to subscribe to and unsubscribe from reply threads. (#4680) - Minor: Added option to subscribe to and unsubscribe from reply threads. (#4680)
- Minor: Added a message for when Chatterino joins a channel (#4616) - Minor: Added a message for when Chatterino joins a channel (#4616)
- Minor: Add accelerators to the right click menu for messages (#4705)
- Minor: Add pin action to usercards and reply threads. (#4692) - Minor: Add pin action to usercards and reply threads. (#4692)
- Minor: Stream status requests are now batched. (#4713) - Minor: Stream status requests are now batched. (#4713)
- Bugfix: Fixed generation of crashdumps by the browser-extension process when the browser was closed. (#4667) - Bugfix: Fixed generation of crashdumps by the browser-extension process when the browser was closed. (#4667)
+22 -22
View File
@@ -71,11 +71,11 @@ namespace {
void addEmoteContextMenuItems(const Emote &emote, void addEmoteContextMenuItems(const Emote &emote,
MessageElementFlags creatorFlags, QMenu &menu) MessageElementFlags creatorFlags, QMenu &menu)
{ {
auto openAction = menu.addAction("Open"); auto *openAction = menu.addAction("&Open");
auto openMenu = new QMenu; auto openMenu = new QMenu;
openAction->setMenu(openMenu); openAction->setMenu(openMenu);
auto copyAction = menu.addAction("Copy"); auto *copyAction = menu.addAction("&Copy");
auto copyMenu = new QMenu; auto copyMenu = new QMenu;
copyAction->setMenu(copyMenu); copyAction->setMenu(copyMenu);
@@ -89,12 +89,12 @@ namespace {
auto addImageLink = [&](const ImagePtr &image, char scale) { auto addImageLink = [&](const ImagePtr &image, char scale) {
if (!image->isEmpty()) if (!image->isEmpty())
{ {
copyMenu->addAction(QString(scale) + "x link", copyMenu->addAction("&" + QString(scale) + "x link",
[url = image->url()] { [url = image->url()] {
crossPlatformCopy(url.string); crossPlatformCopy(url.string);
}); });
openMenu->addAction( openMenu->addAction(
QString(scale) + "x link", [url = image->url()] { "&" + QString(scale) + "x link", [url = image->url()] {
QDesktopServices::openUrl(QUrl(url.string)); QDesktopServices::openUrl(QUrl(url.string));
}); });
} }
@@ -109,11 +109,11 @@ namespace {
copyMenu->addSeparator(); copyMenu->addSeparator();
openMenu->addSeparator(); openMenu->addSeparator();
copyMenu->addAction("Copy " + name + " emote link", copyMenu->addAction("Copy " + name + " &emote link",
[url = emote.homePage] { [url = emote.homePage] {
crossPlatformCopy(url.string); crossPlatformCopy(url.string);
}); });
openMenu->addAction("Open " + name + " emote link", openMenu->addAction("Open " + name + " &emote link",
[url = emote.homePage] { [url = emote.homePage] {
QDesktopServices::openUrl(QUrl(url.string)); QDesktopServices::openUrl(QUrl(url.string));
}); });
@@ -2292,17 +2292,17 @@ void ChannelView::addLinkContextMenuItems(
QString url = link.value; QString url = link.value;
// open link // open link
menu.addAction("Open link", [url] { menu.addAction("&Open link", [url] {
QDesktopServices::openUrl(QUrl(url)); QDesktopServices::openUrl(QUrl(url));
}); });
// open link default // open link default
if (supportsIncognitoLinks()) if (supportsIncognitoLinks())
{ {
menu.addAction("Open link incognito", [url] { menu.addAction("Open link &incognito", [url] {
openLinkIncognito(url); openLinkIncognito(url);
}); });
} }
menu.addAction("Copy link", [url] { menu.addAction("&Copy link", [url] {
crossPlatformCopy(url); crossPlatformCopy(url);
}); });
@@ -2315,12 +2315,12 @@ void ChannelView::addMessageContextMenuItems(
// Copy actions // Copy actions
if (!this->selection_.isEmpty()) if (!this->selection_.isEmpty())
{ {
menu.addAction("Copy selection", [this] { menu.addAction("&Copy selection", [this] {
crossPlatformCopy(this->getSelectedText()); crossPlatformCopy(this->getSelectedText());
}); });
} }
menu.addAction("Copy message", [layout] { menu.addAction("Copy &message", [layout] {
QString copyString; QString copyString;
layout->addSelectionText(copyString, 0, INT_MAX, layout->addSelectionText(copyString, 0, INT_MAX,
CopyMode::OnlyTextAndEmotes); CopyMode::OnlyTextAndEmotes);
@@ -2328,7 +2328,7 @@ void ChannelView::addMessageContextMenuItems(
crossPlatformCopy(copyString); crossPlatformCopy(copyString);
}); });
menu.addAction("Copy full message", [layout] { menu.addAction("Copy &full message", [layout] {
QString copyString; QString copyString;
layout->addSelectionText(copyString, 0, INT_MAX, layout->addSelectionText(copyString, 0, INT_MAX,
CopyMode::EverythingButReplies); CopyMode::EverythingButReplies);
@@ -2340,13 +2340,13 @@ void ChannelView::addMessageContextMenuItems(
if (this->canReplyToMessages() && layout->isReplyable()) if (this->canReplyToMessages() && layout->isReplyable())
{ {
const auto &messagePtr = layout->getMessagePtr(); const auto &messagePtr = layout->getMessagePtr();
menu.addAction("Reply to message", [this, &messagePtr] { menu.addAction("&Reply to message", [this, &messagePtr] {
this->setInputReply(messagePtr); this->setInputReply(messagePtr);
}); });
if (messagePtr->replyThread != nullptr) if (messagePtr->replyThread != nullptr)
{ {
menu.addAction("View thread", [this, &messagePtr] { menu.addAction("View &thread", [this, &messagePtr] {
this->showReplyThreadPopup(messagePtr); this->showReplyThreadPopup(messagePtr);
}); });
} }
@@ -2361,8 +2361,8 @@ void ChannelView::addMessageContextMenuItems(
if (isSearch || isMentions || isReplyOrUserCard) if (isSearch || isMentions || isReplyOrUserCard)
{ {
const auto &messagePtr = layout->getMessagePtr(); const auto &messagePtr = layout->getMessagePtr();
menu.addAction("Go to message", [this, &messagePtr, isSearch, menu.addAction("&Go to message", [this, &messagePtr, isSearch,
isMentions, isReplyOrUserCard] { isMentions, isReplyOrUserCard] {
if (isSearch) if (isSearch)
{ {
if (const auto &search = if (const auto &search =
@@ -2437,21 +2437,21 @@ void ChannelView::addTwitchLinkContextMenuItems(
if (!twitchUsername.isEmpty() && !ignoredUsernames.contains(twitchUsername)) if (!twitchUsername.isEmpty() && !ignoredUsernames.contains(twitchUsername))
{ {
menu.addSeparator(); menu.addSeparator();
menu.addAction("Open in new split", [twitchUsername, this] { menu.addAction("&Open in new split", [twitchUsername, this] {
this->openChannelIn.invoke(twitchUsername, this->openChannelIn.invoke(twitchUsername,
FromTwitchLinkOpenChannelIn::Split); FromTwitchLinkOpenChannelIn::Split);
}); });
menu.addAction("Open in new tab", [twitchUsername, this] { menu.addAction("Open in new &tab", [twitchUsername, this] {
this->openChannelIn.invoke(twitchUsername, this->openChannelIn.invoke(twitchUsername,
FromTwitchLinkOpenChannelIn::Tab); FromTwitchLinkOpenChannelIn::Tab);
}); });
menu.addSeparator(); menu.addSeparator();
menu.addAction("Open player in browser", [twitchUsername, this] { menu.addAction("Open player in &browser", [twitchUsername, this] {
this->openChannelIn.invoke( this->openChannelIn.invoke(
twitchUsername, FromTwitchLinkOpenChannelIn::BrowserPlayer); twitchUsername, FromTwitchLinkOpenChannelIn::BrowserPlayer);
}); });
menu.addAction("Open in streamlink", [twitchUsername, this] { menu.addAction("Open in &streamlink", [twitchUsername, this] {
this->openChannelIn.invoke(twitchUsername, this->openChannelIn.invoke(twitchUsername,
FromTwitchLinkOpenChannelIn::Streamlink); FromTwitchLinkOpenChannelIn::Streamlink);
}); });
@@ -2475,7 +2475,7 @@ void ChannelView::addHiddenContextMenuItems(
if (!layout->getMessage()->id.isEmpty()) if (!layout->getMessage()->id.isEmpty())
{ {
menu.addAction("Copy message ID", menu.addAction("Copy message &ID",
[messageID = layout->getMessage()->id] { [messageID = layout->getMessage()->id] {
crossPlatformCopy(messageID); crossPlatformCopy(messageID);
}); });
@@ -2503,7 +2503,7 @@ void ChannelView::addCommandExecutionContextMenuItems(
} }
menu.addSeparator(); menu.addSeparator();
auto executeAction = menu.addAction("Execute command"); auto *executeAction = menu.addAction("&Execute command");
auto cmdMenu = new QMenu; auto cmdMenu = new QMenu;
executeAction->setMenu(cmdMenu); executeAction->setMenu(cmdMenu);