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
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 44 additions and 39 deletions

View file

@ -19,6 +19,7 @@
- Minor: Stream status requests are now batched. (#4713)
- Minor: Added `/c2-theme-autoreload` command to automatically reload a custom theme. This is useful for when you're developing your own theme. (#4718)
- Minor: Show channel point redemptions without messages in usercard. (#4557)
- Minor: Allow for customizing the behavior of `Right Click`ing of usernames. (#4622, #4751)
- Bugfix: Increased amount of blocked users loaded from 100 to 1,000. (#4721)
- Bugfix: Fixed generation of crashdumps by the browser-extension process when the browser was closed. (#4667)
- Bugfix: Fix spacing issue with mentions inside RTL text. (#4677)
@ -54,7 +55,6 @@
- Minor: Added a Send button in the input box so you can click to send a message. This is disabled by default and can be enabled with the "Show send message button" setting. (#4607)
- Minor: Improved error messages when the updater fails a download. (#4594)
- Minor: Added `/shield` and `/shieldoff` commands to toggle shield mode. (#4580)
- Minor: Allow for customizing the behavior of `Right Click`ing of usernames. (#4622)
- Bugfix: Fixed the menu warping on macOS on Qt6. (#4595)
- Bugfix: Fixed link tooltips not showing unless the thumbnail setting was enabled. (#4597)
- Bugfix: Domains starting with `http` are now parsed as links again. (#4598)

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;