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

FIX(ui): resolve text/icon scaling issues #5820

Merged
merged 1 commit into from
Aug 27, 2022
Merged

Conversation

dexgs
Copy link
Contributor

@dexgs dexgs commented Aug 22, 2022

Fixed chat log scaling issue introduced by PR #5619 (my fault, whoops)
The bug fixed by that commit is still fixed after this PR, but the
regression introduced has been resolved.

Added minimum icon size for channel status icons which now scale since PR #5772
Initially, icons were too small at 100% scale.

Checks

@dexgs
Copy link
Contributor Author

dexgs commented Aug 22, 2022

This is an attempt to fix the issues reported since release v1.4.274. Specifically: #5817 and #5818.
However, I can only confirm that these changes resolved the issues on Linux.

@dexgs dexgs force-pushed the master branch 2 times, most recently from a813744 to 369d963 Compare August 22, 2022 05:29
@Krzmbrzl
Copy link
Member

These are two separate fixes. Therefore, I would ask you to split the changes into two separate commits as well. You don't have to create a separate PR though

@Hartmnt
Copy link
Member

Hartmnt commented Aug 22, 2022

The minimum Icon size might be a good idea, but I wonder why this broke in the first place? Also, do the TalkingUI icons work as expected as they are created in the same way IIRC.

Edit: I would recommend to first find the discrepancy in the logic rather than using a hard-coded minimum size. If e.g. the "make font size configurable" is implemented, the minimum size will also break. Is the icon scaling problem a Windows thing?

@Krzmbrzl
Copy link
Member

The minimum Icon size might be a good idea

I'm not so sure about that. The icon size should equal the font size. Always.

but I wonder why this broke in the first place?

This could be another case of Qt stupidity. I fought very long and hard against such issues in the TalkingUI as well. As it turns out, the font of widgets is not initialized when the widget is initialized but some time later. Thus, when taking the font from a freshly constructed widget to measure the font height, then what is returned is some sort of default font size instead of the actual font size.
In order to get the actual font size, it was necessary to delay the query for the font-size at least to the event loop iteration after the one in which the widget got created.

My best guess would be that we are seeing a similar issue here.

@Hartmnt
Copy link
Member

Hartmnt commented Aug 22, 2022

My best guess would be that we are seeing a similar issue here.

Interesting. This would be curious, as it did never happen while testing so I wonder if this is a platform/qt-version thing. I am currently trying to create a build environment, in which I can build the 1.4 branch (because 1.4 fails to compile with OpenSSL 3.0)

@Hartmnt
Copy link
Member

Hartmnt commented Aug 22, 2022

@Krzmbrzl I think I found the logic issue regarding the icon size and will try to prepare a merge request

@dexgs
Copy link
Contributor Author

dexgs commented Aug 22, 2022

@Krzmbrzl I think I found the logic issue regarding the icon size and will try to prepare a merge request

Great, I'll remove my change to the icon sizing from this PR.

@dexgs
Copy link
Contributor Author

dexgs commented Aug 22, 2022

Okay, done. This PR is now just the fix for the log. I've also changed the commit message to reflect this (although the pr message is unchanged)

@Krzmbrzl
Copy link
Member

Krzmbrzl commented Aug 22, 2022

Could you give a quick summary as to what was the underlying problem? Aka: why do your changes affect the font size?
Also, when I look at the diff of this PR and the diff in #5619, it seems that this PR mostly undoes the changes from the previous PR. So which are the changes that are left of #5619 that do fix the issue and why did you originally make more changes than that in the first place? 👀

(Note: This is not an attempt of blaming you for this! I'm simply hoping to get a better understanding of the situation)

@Krzmbrzl Krzmbrzl linked an issue Aug 22, 2022 that may be closed by this pull request
@Krzmbrzl Krzmbrzl added client bug A bug (error) in the software labels Aug 22, 2022
@dexgs
Copy link
Contributor Author

dexgs commented Aug 22, 2022

Could you give a quick summary as to what was the underlying problem?

@Krzmbrzl Sure:

The scaling problem

The issue with the font size has to do with the previous deletion of ae097d6#diff-368234adaec42dd85fef69ff070b7ba375dbedc09a42b0b17f5f41c95f4eb846L645-L647

It's some Qt magic, but i think removing this messed up the styles which get passed on to the inserted log entry. Re-introducing that snippet is what fixed the scaling during my testing.

The selecting problem

The initial assessment of the log pollution from my first PR is correct: the problem is caused by inserting block elements such as lists into QTextBlock.

The solution from that PR is also correct (putting all messages into QTextFrame instead of QTextBlock).

However, QTextEdit will always insert a blank line before each QTextFrame which disrupts the spacing of the chat window.

Initially, I resolved this by setting a negative top margin on each frame equal to the height of each frame. This works visually, but it causes mouse events to be blocked because there are now overlapping elements. The change in this PR is to instead set the frame's position to float which simply displaces the blank line without creating any overlap.

@dexgs
Copy link
Contributor Author

dexgs commented Aug 22, 2022

Actually, even setting the position to float seems to cause some weird behaviour with text selection.

I think a better solution is that since each message is in a QTextFrame instead of a QTextBlock, we can set the font size for QTextBlocks to 0 for the chat log without messing up the font size of log entries. This seems to resolve the blank lines between log entries when using QTextFrame without introducing any regression.

I've updated this PR with the above changes. I'm confident this solution fixes the previous issues without introducing new problems, but please take a look to make sure I didn't miss anything.

src/mumble/Log.cpp Outdated Show resolved Hide resolved
@Krzmbrzl
Copy link
Member

Also one small detail: Could you turn your commit message into a FIX(client, ui) instead of only FIX(ui)? That way when auto-generating the changelog, the change will appear in the correct section :)

@dexgs
Copy link
Contributor Author

dexgs commented Aug 25, 2022

I've removed the static annotation and updated the commit message as requested.

@Krzmbrzl
Copy link
Member

Could you add a line Fixes #5818 to the end of your commit message?

FIX(client, ui): resolve log text scaling issues

Fixed chat log scaling issue introduced by PR #5619 (my fault, whoops)
The bug fixed by that commit is still fixed after this PR, but the
regression introduced has been resolved.

Fixes #5818

Fixed chat log scaling issue introduced by PR mumble-voip#5619 (my fault, whoops)
The bug fixed by that commit is still fixed after this PR, but the
regression introduced has been resolved.

Fixes mumble-voip#5818
@Krzmbrzl Krzmbrzl merged commit 6067c4a into mumble-voip:master Aug 27, 2022
@Krzmbrzl
Copy link
Member

Thanks for fixing this 👍

@Krzmbrzl
Copy link
Member

Krzmbrzl commented Sep 8, 2022

💚 All backports created successfully

Status Branch Result
1.4.x

Questions ?

Please refer to the Backport tool documentation

@Krzmbrzl
Copy link
Member

@dexgs please have a look at #5886

@dexgs
Copy link
Contributor Author

dexgs commented Sep 15, 2022

@dexgs please have a look at #5886

Yeah, I'm aware of this. The problem doesn't affect linux, but I observed it on windows. I suspect the problem is with setting font sizes on windows. Qt docs say anything > 0 is valid, but I'm thinking that the windows implementation is more picky.

https://doc.qt.io/qt-5/qtextedit.html#setFontPointSize

dexgs added a commit to dexgs/mumble that referenced this pull request Dec 27, 2023
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 retains the `setVisible(false)` strategy by @bkaestner to remove
the initial "gap" at the top of the chat log, but 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
dexgs added a commit to dexgs/mumble that referenced this pull request Dec 28, 2023
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
dexgs added a commit to dexgs/mumble that referenced this pull request Dec 29, 2023
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
dexgs added a commit to dexgs/mumble that referenced this pull request Dec 31, 2023
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
dexgs added a commit to dexgs/mumble that referenced this pull request Jan 2, 2024
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
Krzmbrzl added a commit that referenced this pull request Jan 2, 2024
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 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 #6045
Hartmnt pushed a commit to Hartmnt/mumble that referenced this pull request Jan 22, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug (error) in the software client
Projects
None yet
Development

Successfully merging this pull request may close these issues.

First lines of messages are uninteractable
3 participants