notes icon indicating copy to clipboard operation
notes copied to clipboard

Support for High DPI Displays

Open nuttyartist opened this issue 8 years ago • 9 comments

I got this email from someone:

Hi guys,

Loving notes. I was wondering whether you were gonna support scaling for 4k? At the moment on my Dell XPS 15 (4k) the interface is tiny :-(

The best way to support High DPI Displays is to follow these guidelines:

  • Always use the qreal versions of the QPainter drawing API.
  • Size windows and dialogs in relation to the screen size.
  • Replace hard-coded sizes in layouts and drawing code by values calculated from font metrics or screen size.

There are quick things we can do like setting some environment variables and attributes. But we should really aspire to quality support are users with High DPI Displays.

More info can be found here: http://doc.qt.io/qt-5/highdpi.html

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

nuttyartist avatar Apr 07 '16 07:04 nuttyartist

As you already mentioned, Qt 5.6 onwards supports high DPI screens. However, not everyone will have Qt 5.6 installed (especially Linux users). Here is the code that I use to obtain the scale factor of the screen:

    /* Avoid UI scaling issues with Qt 5.6 */
#if QT_VERSION >= QT_VERSION_CHECK (5, 6, 0)
#if defined Q_OS_MAC
    QApplication::setAttribute (Qt::AA_EnableHighDpiScaling);
#else
    QApplication::setAttribute (Qt::AA_DisableHighDpiScaling);
#endif
#endif

    /* Calculate the scale factor of the screen */
    qreal ratio = (qApp->primaryScreen()->physicalDotsPerInch() / 100) * 0.9;

    /* Scale factor is too small */
    if (ratio < 1.2)
        ratio = 1;

    /* Mac already scales things */
#if defined Q_OS_MAC
    ratio = 1;
#endif

This code will output 1 for normal density screens. On higher-density screens it will output the most appropriate value. The downside of this approach is that you need to manually multiply every pixel/UI related value by this obtained factor (which should be set as a static global variable).

I hope that this can help you!

alex-spataru avatar Jun 18 '16 06:06 alex-spataru

@alex-spataru does Qt 5.6 onwards support high DPI screens out-of-the-box? Does someone has high screen display to test?

nuttyartist avatar Aug 18 '16 12:08 nuttyartist

I got a linux mint cinnamon 18.2 running with a 3k display, and i'd be happy to test any update of the app.

julientaq avatar Aug 12 '17 12:08 julientaq

@julientaq That's great, we will contact you when we'll work on this for our future release. Thanks :+1:

nuttyartist avatar Aug 12 '17 14:08 nuttyartist

I am not sure if it is the right place, currently the layout has issue when set Xft.dpi to larger values (than 96, 144 in screenshot) in Xresources on Linux: Screenshot_2021-03-15_23-54-06 If I set qt scaling globally with QT_SCALE_FACTOR=2 it works well, while Xft.dpi only changes font size I think.

xlucn avatar Mar 15 '21 15:03 xlucn

@OliverLew Yeah, this issue was also reported at #164 when larger fonts are used on Windows. The widget or delegate used there should probably calculate its size depending on the font size, whereas it currently appears to have a fixed height.

bjorn avatar Mar 16 '21 10:03 bjorn

@bjorn Exactly! That (plus upgrading the icons to suit bigger resolutions) would be the main objective of this issue.

nuttyartist avatar Mar 20 '21 14:03 nuttyartist

Guess it's the same bug, but I've noticed a lot of cut-off or strangely placed icons, as well as a glitch in the secondary settings dropdown (on right) (primary settings dropdown on left is ok)

Notes_bGu2FMTr0G

Darthagnon avatar Jul 30 '23 23:07 Darthagnon

First of all, I see you're using the Qt5 version, is that intentional? If so, why?

Second, I'm curious if in Kanban mode (which is supoprted in Qt 6+) you'll also have scaling issues. So if you could report back I'd appreciate it.

Theird, I think I understand why the Glitch with the Edtior Settings happen (Although I'll need to investigate more). Can you please open a new issue for that?

The rest, is probably an issue with scaling. Can you test to see what happens if you change your scaling in your OS settings? People that had this problem told me it fixed the issue. But of course we still need to find a way to make it work right out of the box. That's why I'm curious if there's also a scaling issue in the Kanban view - sicne it's written in QML and we're planning to migrate our entire UI to QML

nuttyartist avatar Jul 31 '23 05:07 nuttyartist