-
-
Notifications
You must be signed in to change notification settings - Fork 449
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for customizing the behavior of Right Click
ing of usernames.
#4622
Merged
pajlada
merged 11 commits into
master
from
feature/lidl_hotkeys_for_username_right_click
Jul 1, 2023
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
723d2f4
Add username right-click customization
Mm2PL ba70500
i forgor
Mm2PL 57f8c3f
Shorten setting display text MORE
Mm2PL 2b7bfad
changelog
Mm2PL 3bf8fb8
fuck you msvc
Mm2PL 7615f13
Merge branch 'master' of github.com:Chatterino/chatterino2 into featu…
Mm2PL ce15b49
Apply suggestions from @pajlada's review :)
Mm2PL 3bfcbaa
Add a NoModifier sanity check
Mm2PL 399d3d6
Reformat setting definitions
pajlada 0e15758
Use Warning instead of Critical log levels
pajlada bdcf830
Slight code restructure
pajlada File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2084,22 +2084,73 @@ void ChannelView::handleMouseClick(QMouseEvent *event, | |||||
if (link.type == Link::UserInfo) | ||||||
{ | ||||||
if (hoveredElement->getFlags().has( | ||||||
MessageElementFlag::Username) && | ||||||
event->modifiers() == Qt::ShiftModifier) | ||||||
MessageElementFlag::Username)) | ||||||
{ | ||||||
// Start a new reply if Shift+Right-clicking the message username | ||||||
this->setInputReply(layout->getMessagePtr()); | ||||||
} | ||||||
else | ||||||
{ | ||||||
// Insert @username into split input | ||||||
const bool commaMention = | ||||||
getSettings()->mentionUsersWithComma; | ||||||
const bool isFirstWord = | ||||||
split && split->getInput().isEditFirstWord(); | ||||||
auto userMention = formatUserMention( | ||||||
link.value, isFirstWord, commaMention); | ||||||
insertText("@" + userMention + " "); | ||||||
Qt::KeyboardModifier userSpecifiedModifier = | ||||||
getSettings()->usernameRightClickModifier; | ||||||
|
||||||
if (userSpecifiedModifier == | ||||||
Qt::KeyboardModifier::NoModifier) | ||||||
{ | ||||||
qCWarning(chatterinoCommon) | ||||||
<< "sanity check failed: " | ||||||
"invalid settings detected " | ||||||
"Settings::usernameRightClickModifier is " | ||||||
"NoModifier, which should never happen"; | ||||||
return; | ||||||
} | ||||||
|
||||||
Qt::KeyboardModifiers modifiers{userSpecifiedModifier}; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: variable 'modifiers' of type 'Qt::KeyboardModifiers' (aka 'QFlagsQt::KeyboardModifier') can be declared 'const' [misc-const-correctness]
Suggested change
|
||||||
auto isModifierHeld = event->modifiers() == modifiers; | ||||||
|
||||||
UsernameRightClickBehavior action{}; | ||||||
if (isModifierHeld) | ||||||
{ | ||||||
action = getSettings() | ||||||
->usernameRightClickModifierBehavior; | ||||||
} | ||||||
else | ||||||
{ | ||||||
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 + " "); | ||||||
} | ||||||
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; | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: variable 'userSpecifiedModifier' of type 'Qt::KeyboardModifier' can be declared 'const' [misc-const-correctness]