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

Qt: AA_EnableHighDpiScaling flags #4850

Merged
merged 2 commits into from
Apr 10, 2020

Conversation

elgiano
Copy link
Contributor

@elgiano elgiano commented Apr 3, 2020

Purpose and Motivation

Maybe helps with #2442, badly needs testing on Windows though. @dyfer tested it, and it works, with his addition (see below).

Enables Qt's auto-detection for devicePixelRatio (HiDPI scaling), for both sclang and scide.
Qt provides ways to override this feature by setting environment variables, if the user prefers so.
For example:

  • it's possible to turn auto-detection off by setting QT_AUTO_SCREEN_SCALE_FACTOR or QT_ENABLE_HIGHDPI_SCALING to 0

  • it's possible to combine auto-detection with a user-supplied scale factor, for either GUIs, fonts or both, by setting QT_SCALE_FACTOR and QT_FONT_DPI

What I've found on my system, is that without any env var set, scide's and sclang's GUIs look very small, especially the help browser text and sclang-generated GUIs ( this resembles the situation in #2442 ). By setting the env vars, OR just by setting the flags I'm setting in this PR, the automatic scaling renders GUIs and text of a reasonable size.

After a commit from @dyfer we are also setting HighDpiScaleFactorRoundingPolicy to PassThrough, so that fractional scale factors are not rounded to the nearest integer. This flag is available and set only for Qt version >= 5.14.
Since in previous versions of Qt was not possible to change the default policy (Round), for fractional scaling to work out of the box on Windows it is required to build with at least Qt 5.14.

More general info at doc.qt.io

Types of changes

  • New feature

To-do list

  • Code is tested on Windows, Linux, and Mac
    meaning that we tried different scaling settings, and both UIs and text scale appropriately
    (for QcCanvas based UIs, see HiDPI fractional scaling: remove rounding to int #4846)
  • All tests are passing
  • Updated documentation (not needed IMO)
  • This PR is ready for review

@elgiano elgiano changed the title AA_EnableHighDpiScaling flags Qt: AA_EnableHighDpiScaling flags Apr 3, 2020
@mossheim mossheim added os: Windows comp: Qt GUI sclang Qt components -- for IDE tickets, use "env: SCIDE" instead env: SCIDE labels Apr 4, 2020
@dyfer
Copy link
Member

dyfer commented Apr 5, 2020

Thanks @elgiano !
To further clarify I wanted to point out that this PR fixes sclang gui for highdpi/4k screens on Windows (200% scaling) even without QT update, so I'd mark it as a fix for #2442.

Without updated QT, 125% and 150% will be the same as 100%, and 175% will be the same as 200%; after updating QT to 5.14, the scale factors will be properly set for all values.

Updating QT is probably something for another PR and I wouldn't want to suggest that before discussing with other devs first.

EDIT: In addition to Windows, I tested this on macOS as well and it works fine - there are no regressions/side effects, as far as I can tell.

@dyfer
Copy link
Member

dyfer commented Apr 7, 2020

@brianlheim I tested this and this works fine and I think it's ready to be merged. Since I have limited experience with C++ PRs I wanted to check if it's OK for me to approve this?

@mossheim
Copy link
Contributor

@dyfer 'approve' also means the code looks good in your opinion, so if you have no issue with it go ahead! i gave it a quick look and it seems fine to me.

our mac builds use qt 5.13.2 right now, and windows builds use qt 5.9 (32-bit builds) and qt 5.11 (64-bit builds). i can't update the 5.9 32-bit build because that was when Qt dropped a key component from distribution, but i can update the others!

@mossheim
Copy link
Contributor

@elgiano what are the downsides of using this change on windows with qt < 5.14? it was difficult for me to tell from your OP.

@dyfer
Copy link
Member

dyfer commented Apr 10, 2020

thanks @brianlheim
since I was also involved in this I can respond the the qt < 5.14 question:

  • without this PR, scaling of SC GUI (and help browser) does not work/does not follow system settings, i.e. GUI is always scaled at 100% (so on a 4k HiDPI display it is tiny)
  • with this PR and qt < 5.14, integer scaling works properly (100%, 200%), so on 4k screen the interface will look good (200% scaling)
    • non-integer scaling factors are "rounded" (according to QT rounding policy): 125% and 150% becomes 100% (effectively making SC GUI smaller than system setting), 175% becomes 200% (effectively making SC GUI larger than system setting)
  • with this PR and qt 5.14, all scaling factors behave properly and reflect system interface (including 125%, 150% etc)

@mossheim
Copy link
Contributor

okay! thanks for the explanation. i've updated our CI builds to use qt 5.14 when possible in #4862

@mossheim mossheim merged commit a0ab24f into supercollider:develop Apr 10, 2020
@dyfer dyfer mentioned this pull request Apr 10, 2020
@elgiano elgiano deleted the autoHiDPIScaling branch April 10, 2020 21:00
@mossheim mossheim mentioned this pull request Apr 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp: Qt GUI sclang Qt components -- for IDE tickets, use "env: SCIDE" instead env: SCIDE os: Windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants