Skip to content
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

Right-click tap handler for replies #696

Merged
merged 1 commit into from
Sep 3, 2021

Conversation

resolritter
Copy link
Contributor

This is an attempt at fixing #695, but it doesn't actually work fully. I was unable to make more progress than this because I don't know anything about QML.

The intention for this PR is to support only "copy" and "copy link" actions, but there are problems with this code:

  • The context menu gets open in a weird position
  • reply.child.hoveredLink does not actually work, apparently; reply.child.copyText does

Feel free to disregard any part of the code which looks nonsensical, as aforementioned I don't know anything about QML. Also feel free to take over this PR and push the remaining code to this branch.

@deepbluev7
Copy link
Member

The hoveredLink does not work, because the MessageDelegate::enabled is set to false, so any input event isn't forwarded to it including the mouse hover. (That's also why clicking links, text selection and the normal context menu doesn't work).

@resolritter
Copy link
Contributor Author

resolritter commented Aug 26, 2021

The hoveredLink does not work, because the MessageDelegate::enabled is set to false, so any input event isn't forwarded to it including the mouse hover

Thank you! I set it to true. I'm still noticing the context menu appearing at a really weird position but it's also happening for normal messages (#698), so I suppose it's not related to this PR.

Copy link
Member

@deepbluev7 deepbluev7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Welp, I never clicked the submit button on the review...

@@ -41,6 +42,40 @@ Item {
gesturePolicy: TapHandler.ReleaseWithinBounds
}

Platform.Menu {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move this somewhere global, like into the MessageView where the other menu is? Menus have been a performance issue in the past, although I don't know, if the Platform.Menu would still trigger that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to do that (no idea about how QT/QML works). Feel free to push code wherever you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You just put that menu into a different file (the MessageView.qml, where the other Menu should be). That is all. It should just work, since that is a parent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to MessageView.qml

@@ -99,11 +134,10 @@ Item {
callType: r.callType
relatedEventCacheBuster: r.relatedEventCacheBuster
encryptionError: r.encryptionError
enabled: false
enabled: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was done, so that tapping the reply would scroll to the correct position instead of selecting some text. Does that not happen anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was not working as you described. I reverted it back to enabled: false, added a comment and moved the TapHandler to column. I think now it achieves the interaction you mentioned.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah wait, setting enabled: false breaks links within the message :-|

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found a way of making it work even with enabled: false by using linkAt in the text message and subtracting the username's height from the point's Y (since TapHandler is installed in the column which has both the username and the text).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds like a horrible hack, but might be the best option for now :D

}

TapHandler {
acceptedButtons: Qt.RightButton
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you also make this trigger on long press?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@deepbluev7
Copy link
Member

Seems to work correctly and the Got to Reply is a nice addition to the menu! Thanks!

@deepbluev7 deepbluev7 merged commit 5d6c26c into Nheko-Reborn:master Sep 3, 2021
@resolritter resolritter deleted the reply branch September 3, 2021 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants