-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
FIX(client, ui): fix text selection in chat log #6289
Conversation
Thanks for picking this up again! Given that I don't have a Mumble development environment anymore, I picked up the artifacts from Azure from this job and tried it out. From a first glance, it seems to work exactly as intended, so thank you @dexgs! TestsTest Environment:
Check after PRLooks fine. I've posted an image to verify that images still work as expected, and it seems all is working as intended. Pre-Check on current stableFor comparison, this is how it looks on the current stable: Don't worry about the screenshot, it's actually a different one. ConcernsThere is one minor concern I have with the The Windows high-contrast setting does not yield any change though (except for a hight contrast title bar). |
I hadn't already thought about themes, but I think the call to I don't know how screen readers interact with the blank line, but I suspect they won't cause problems since they don't have any text in them. |
I updated the commit to set the top and bottom margins to zero to hopefully address any problems with themes. I also switched to setting the QTextBlockFormat before and after each message instead of using setVisible to deal with the initial gap at the top of the text log because the latter strategy still leaves a gap at the top of the chat log after it is cleared, i.e. it only deals with the gap when the log is first initialized. |
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.
Have you tested whether your changes also play nicely with the [Date changed to xy]
message that inserts a new block instead of a new frame?
@Krzmbrzl you're right and I hadn't thought about this. I'm checking on this now. |
@Krzmbrzl The simplest fix seems to be setting the "date changed" notification to use a text frame as well. Here's how it looks (for testing, I modified the "date changed" notification to appear before every log entry) Is this acceptable? EDIT: I've updated the PR to include this change |
Sure. So I take it that it is indeed essential that new text is always added as a new frame, correct? What happens to the date message when adding it as a block? Is it simply invisible due to the line height being zero? |
without putting the date message into a frame, the text ends up overlapping the next log entry because the line height is zero |
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.
I have compiled this PR and the result is decent. It fixes the selection bug for me. I can not comment on whether or not this works on Windows.
However one small thing I noticed is that if you select an entire line by triple-clicking, two line breaks (one at the start and one at the end) will also be selected. No idea if there is an easy fix for this, but I could live with it either way.
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.
I tested these changes on Linux, Windows and macOS and it seems to work as expected on all of them. Nice work! 👍
In v1.4, the logic surrounding when entries in the chat log are put in their own text frame was changed, introducing a bug where elements such as lists would not be terminated correctly (mumble-voip#4491). The fix for this issue was to put every chat log entry into its own text frame, but Qt inserts a blank line between adjacent frames resulting in too much space between subsequent chat entries. There is no convenient Qt API (as far as I know) to disable this behaviour, so my second attempt to resolve this (PR mumble-voip#5820) set the font size to near zero for the blank lines between entries. This worked on Linux, but broke on (at least) Windows (mumble-voip#5886). PR mumble-voip#5927 fixed the issue by calling `setVisible(false)` on the blank lines instead of changing the font size, but this introduced a regression to text selection in the chat log (mumble-voip#6045). This PR deals with the empty lines between entries by setting their *line height* to zero using a call to `setLineHeight(0, QTextBlockFormat::FixedHeight)`. https://doc.qt.io/qt-5/qtextblockformat.html#LineHeightTypes-enum According to the Qt documentation, this method allows setting a fixed line height in pixels. Based on my testing on Linux, this solves the problem without introducing any new regressions. This should still be tested on Windows before v1.5, just in case. Fixes mumble-voip#6045
Thank you very much for looking at this again 👍 |
In v1.4, the logic surrounding when entries in the chat log are put in their own text frame was changed, introducing a bug where elements such as lists would not be terminated correctly (#4491).
The fix for this issue was to put every chat log entry into its own text frame, but Qt inserts a blank line between adjacent frames resulting in too much space between subsequent chat entries.
There is no convenient Qt API (as far as I know) to disable this behaviour, so my second attempt to resolve this (PR #5820) set the font size to near zero for the blank lines between entries.
This worked on Linux, but broke on (at least) Windows (#5886).
PR #5927 fixed the issue by calling
setVisible(false)
on the blank lines instead of changing the font size, but this introduced a regression to text selection in the chat log (#6045).This PR
retains thedeals with the empty lines between entries by setting their line height to zero using a call tosetVisible(false)
strategy by @bkaestner to remove the initial "gap" at the top of the chat log, butsetLineHeight(0, QTextBlockFormat::FixedHeight)
https://doc.qt.io/qt-5/qtextblockformat.html#LineHeightTypes-enum
According to the Qt documentation, this method allows setting a fixed line height in pixels. Based on my testing on Linux, this solves the problem without introducing any new regressions.
This should still be tested on Windows before v1.5, just in case.
Fixes #6045
Checks