Skip to content

Set some Qt settings to play nicer on High DPI displays #96

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

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

chrisjbillington
Copy link
Member

labscript_utils.splash is the first place a QApplication gets created for all of our apps. So setting these settings there applies them to all our applications, although they are also needed for the splash screen itself to be scaled better on High DPI displays.

AA_EnableHighDpiScaling scales all pixel metrics to the device pixel ratio - so this means curved edges and padding and whatnot get scaled up, as well as the size of some pixmaps.

AA_UseHighDpiPixmaps means to use high DPI pixmaps for icons etc, directly, rather than rendering them at the lower resolution and then scaling them up (not sure why anyone would want the latter behaviour). Strangely, high resolution pixmaps are used when AA_EnableHighDpiScaling is off. It's only when it is turned on that they get downscaled and then upscaled again and end up blocky.

Before:

image

After:

image

There are some other places where is it maybe more obvious like this tiny icon in BLACS:

image

Which is full-sized after these changes:

image

With higher resolution icons in qtutils now, things should be pretty good on High DPI displays.

`labscript_utils.splash` is the first place a `QApplication` gets
created for all of our apps. So setting these settings there applies
them to all our applications, although they are also needed for the
splash screen itself to be scaled better on High DPI displays.

`AA_EnableHighDpiScaling` scales all pixel metrics to the device pixel
ratio - so this means curved edges and padding and whatnot get scaled
up, as well as the size of some pixmaps.

`AA_UseHighDpiPixmaps` means to use high DPI pixmaps for icons etc,
directly, rather than rendering them at the lower resolution and then
scaling them up (not sure why anyone would want the latter behaviour).
Strangely, high resolution pixmaps *are* used when
`AA_EnableHighDpiScaling` is *off*. It's only when it is turned on that
they get downscaled and then upscaled again and end up blocky.
@chrisjbillington
Copy link
Member Author

I haven't actually tested this on Windows yet. I'll do so at some point, or anyone should feel free to beat me to it.

@dihm
Copy link
Contributor

dihm commented Apr 12, 2023

I can confirm this works on Windows. For me, it appears this also scales up the font sizes of most things, meaning that the minimum sizes of some widgets are different. The digital buttons are the most notable for me.

Before:
image

After:
image

Relative scales in these screen clips appear to be accurate. Probably not a fundamental issue, but I can imagine some users with a ton of tabs and a big screen may get annoyed when their layout options change.

As a fun note, it appears the restored windows size (ie you ran BLACS before implementing this PR) scales up as well. People may be in for a fun surprise when updating when everything is suddenly huge.

Overall, I like this change. We like using giant screens with high resolution. This definitely makes it easier to see things.

@dihm
Copy link
Contributor

dihm commented Apr 17, 2023

@chrisjbillington Do you think this is ready to merge? I'm hoping to include it in the next release (which will let me push labscript-suite v3.2.0 with full Python 3.10 & 3.11 support).

@chrisjbillington
Copy link
Member Author

Yep, I'm happy let's do it.

Thanks for all the work getting the latest releases happening!

@chrisjbillington chrisjbillington merged commit d14cb74 into master Apr 18, 2023
@chrisjbillington chrisjbillington deleted the high-dipi branch April 18, 2023 03:14
dihm added a commit that referenced this pull request Apr 18, 2023
commit d14cb74
Merge: fb122b3 d07618a
Author: Chris Billington <chrisjbillington@gmail.com>
Date:   Tue Apr 18 13:14:45 2023 +1000

    Merge pull request #96 from labscript-suite/high-dipi

    Set some Qt settings to play nicer on High DPI displays

commit fb122b3
Merge: 87de9cd 1568793
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Wed Apr 12 21:19:24 2023 -0400

    Merge pull request #94 from dihm/shot_utils

    Moving `get_shot_globals` function from runmanager to labscript_utils.

commit 87de9cd
Merge: 29ac288 835bbe8
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Wed Apr 12 20:22:57 2023 -0400

    Merge pull request #97 from labscript-suite/dragdroptab-fix

    Fix issue with dragdroptab - convert float coords to int

commit 29ac288
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Wed Apr 12 19:45:40 2023 -0400

    Update python version support

commit 5f2775e
Merge: c38b661 90f486d
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Wed Apr 12 17:10:05 2023 -0400

    Merge pull request #98 from dihm/update-workflow

    Sync workflow

commit 90f486d
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Wed Apr 12 17:06:41 2023 -0400

    Sync workflow

commit 835bbe8
Author: chrisjbillington <chrisjbillington@gmail.com>
Date:   Sat Apr 8 21:00:52 2023 +1000

    Fix issue with dragdroptab - convert float coords to int

    QPoint no longer auto converts float arguments, resulting in an error

commit d07618a
Author: chrisjbillington <chrisjbillington@gmail.com>
Date:   Sat Apr 8 20:37:17 2023 +1000

    Set some Qt settings to play nicer on High DPI displays

    `labscript_utils.splash` is the first place a `QApplication` gets
    created for all of our apps. So setting these settings there applies
    them to all our applications, although they are also needed for the
    splash screen itself to be scaled better on High DPI displays.

    `AA_EnableHighDpiScaling` scales all pixel metrics to the device pixel
    ratio - so this means curved edges and padding and whatnot get scaled
    up, as well as the size of some pixmaps.

    `AA_UseHighDpiPixmaps` means to use high DPI pixmaps for icons etc,
    directly, rather than rendering them at the lower resolution and then
    scaling them up (not sure why anyone would want the latter behaviour).
    Strangely, high resolution pixmaps *are* used when
    `AA_EnableHighDpiScaling` is *off*. It's only when it is turned on that
    they get downscaled and then upscaled again and end up blocky.

commit 1568793
Author: David Meyer <dihm@users.noreply.github.com>
Date:   Mon Mar 13 10:21:39 2023 -0400

    Moving `get_shot_globals` function from runmanager to labscript_utils.

    This will allow us to break lyse's dependency on runmanager.
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