From 1d272c399b805f75284bbf6db0511243cd5ccc88 Mon Sep 17 00:00:00 2001 From: Infinitay Date: Sun, 16 Jan 2022 08:35:00 -0500 Subject: [PATCH] Added ability to copy message ID with `Shift + Right Click` (#3481) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Paweł Co-authored-by: Felanbird <41973452+Felanbird@users.noreply.github.com> Co-authored-by: Rasmus Karlsson --- CHANGELOG.md | 1 + src/widgets/helper/ChannelView.cpp | 14 ++++++++++++-- src/widgets/helper/ChannelView.hpp | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d40b10579..3749d52e1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ - Minor: Add feedback when writing a non-command message in the `/whispers` split. (#3439) - Minor: Opening streamlink through hotkeys and/or split header menu matches `/streamlink` command and shows feedback in chat as well. (#3510) - Minor: Removed timestamp from AutoMod messages. (#3503) +- Minor: Added ability to copy message ID with `Shift + Right Click`. (#3481) - Bugfix: Fix Split Input hotkeys not being available when input is hidden (#3362) - Bugfix: Fixed colored usernames sometimes not working. (#3170) - Bugfix: Restored ability to send duplicate `/me` messages. (#3166) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index 653177fc3..85f215a3c 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -1828,7 +1828,7 @@ void ChannelView::handleMouseClick(QMouseEvent *event, } else { - this->addContextMenuItems(hoveredElement, layout); + this->addContextMenuItems(hoveredElement, layout, event); } } break; @@ -1845,7 +1845,8 @@ void ChannelView::handleMouseClick(QMouseEvent *event, } void ChannelView::addContextMenuItems( - const MessageLayoutElement *hoveredElement, MessageLayoutPtr layout) + const MessageLayoutElement *hoveredElement, MessageLayoutPtr layout, + QMouseEvent *event) { const auto &creator = hoveredElement->getCreator(); auto creatorFlags = creator.getFlags(); @@ -1983,6 +1984,15 @@ void ChannelView::addContextMenuItems( } } + if (event->modifiers() == Qt::ShiftModifier && + !layout->getMessage()->id.isEmpty()) + { + menu->addAction("Copy message ID", + [messageID = layout->getMessage()->id] { + crossPlatformCopy(messageID); + }); + } + menu->popup(QCursor::pos()); menu->raise(); diff --git a/src/widgets/helper/ChannelView.hpp b/src/widgets/helper/ChannelView.hpp index 43534981a..4b4c7afe9 100644 --- a/src/widgets/helper/ChannelView.hpp +++ b/src/widgets/helper/ChannelView.hpp @@ -160,7 +160,7 @@ private: const MessageLayoutElement *hoverLayoutElement, MessageLayoutPtr layout); void addContextMenuItems(const MessageLayoutElement *hoveredElement, - MessageLayoutPtr layout); + MessageLayoutPtr layout, QMouseEvent *event); int getLayoutWidth() const; void updatePauses(); void unpaused();