Fixed right-clicking mentions no longer working. (#4751)

* fix up rightclicking mentions

* changelog

* Merge changelog entries other PR was merged after 2.4.4
This commit is contained in:
Mm2PL
2023-08-05 13:17:34 +02:00
committed by GitHub
parent 222b3da79e
commit b98be3b0f3
2 changed files with 44 additions and 39 deletions
+43 -38
View File
@@ -2104,8 +2104,15 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
if (link.type == Link::UserInfo)
{
if (hoveredElement->getFlags().has(
MessageElementFlag::Username))
// This is terrible because it FPs on messages where the
// user mentions themselves
bool canReply =
QString::compare(link.value,
layout->getMessage()->loginName,
Qt::CaseInsensitive) == 0;
UsernameRightClickBehavior action =
UsernameRightClickBehavior::Mention;
if (canReply)
{
Qt::KeyboardModifier userSpecifiedModifier =
getSettings()->usernameRightClickModifier;
@@ -2124,7 +2131,6 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
Qt::KeyboardModifiers modifiers{userSpecifiedModifier};
auto isModifierHeld = event->modifiers() == modifiers;
UsernameRightClickBehavior action{};
if (isModifierHeld)
{
action = getSettings()
@@ -2134,44 +2140,43 @@ void ChannelView::handleMouseClick(QMouseEvent *event,
{
action = getSettings()->usernameRightClickBehavior;
}
switch (action)
{
case UsernameRightClickBehavior::Mention: {
if (split == nullptr)
{
return;
}
// Insert @username into split input
const bool commaMention =
getSettings()->mentionUsersWithComma;
const bool isFirstWord =
split->getInput().isEditFirstWord();
auto userMention = formatUserMention(
link.value, isFirstWord, commaMention);
insertText("@" + userMention + " ");
}
switch (action)
{
case UsernameRightClickBehavior::Mention: {
if (split == nullptr)
{
return;
}
break;
case UsernameRightClickBehavior::Reply: {
// Start a new reply if matching user's settings
this->setInputReply(layout->getMessagePtr());
}
break;
case UsernameRightClickBehavior::Ignore:
break;
default: {
qCWarning(chatterinoCommon)
<< "unhandled or corrupted "
"UsernameRightClickBehavior value in "
"ChannelView::handleMouseClick:"
<< action;
}
break; // unreachable
// Insert @username into split input
const bool commaMention =
getSettings()->mentionUsersWithComma;
const bool isFirstWord =
split->getInput().isEditFirstWord();
auto userMention = formatUserMention(
link.value, isFirstWord, commaMention);
insertText("@" + userMention + " ");
}
break;
case UsernameRightClickBehavior::Reply: {
// Start a new reply if matching user's settings
this->setInputReply(layout->getMessagePtr());
}
break;
case UsernameRightClickBehavior::Ignore:
break;
default: {
qCWarning(chatterinoCommon)
<< "unhandled or corrupted "
"UsernameRightClickBehavior value in "
"ChannelView::handleMouseClick:"
<< action;
}
break; // unreachable
}
return;