From c3793121cb916be50c82f77f7048c620818ed2d7 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Tue, 10 Jul 2018 19:27:42 +0300 Subject: [PATCH] Added mention of user by right-clicking on his nickname. (#589) * Added mention of user by right-clicking on his nickname. * Removed possibility of choice. Always add @ to username. --- src/widgets/helper/ChannelView.cpp | 10 +++++++++- src/widgets/splits/Split.cpp | 5 +++++ src/widgets/splits/Split.hpp | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/widgets/helper/ChannelView.cpp b/src/widgets/helper/ChannelView.cpp index ef377300e..bb6ec30a0 100644 --- a/src/widgets/helper/ChannelView.cpp +++ b/src/widgets/helper/ChannelView.cpp @@ -963,7 +963,15 @@ void ChannelView::handleMouseClick(QMouseEvent *event, const MessageLayoutElemen } } break; case Qt::RightButton: { - this->addContextMenuItems(hoveredElement, layout); + auto &link = hoveredElement->getLink(); + if (link.type == Link::UserInfo) { + Split *split = dynamic_cast(this->parentWidget()); + if (split != nullptr) { + split->insertTextToInput("@" + link.value + ", "); + } + } else { + this->addContextMenuItems(hoveredElement, layout); + } } break; default:; } diff --git a/src/widgets/splits/Split.cpp b/src/widgets/splits/Split.cpp index a00cf5085..efa6fbc77 100644 --- a/src/widgets/splits/Split.cpp +++ b/src/widgets/splits/Split.cpp @@ -227,6 +227,11 @@ bool Split::getModerationMode() const return this->moderationMode_; } +void Split::insertTextToInput(const QString &text) +{ + this->input_.insertText(text); +} + void Split::showChangeChannelPopup(const char *dialogTitle, bool empty, std::function callback) { diff --git a/src/widgets/splits/Split.hpp b/src/widgets/splits/Split.hpp index c22b324f4..dc525462a 100644 --- a/src/widgets/splits/Split.hpp +++ b/src/widgets/splits/Split.hpp @@ -60,6 +60,8 @@ public: void setModerationMode(bool value); bool getModerationMode() const; + void insertTextToInput(const QString &text); + void showChangeChannelPopup(const char *dialogTitle, bool empty, std::function callback); void giveFocus(Qt::FocusReason reason);