Delegate GUI scaling work to Qt

Set Qt::AA_EnableHighDpiScaling application attribute when Qt 5.14.x or
newer is used. This fixes a lot of scaling issues on HiDPI displays.

Unfortunately, this flag must be set only before QApllication object
creation, so the only one place where it can be done is main().
This commit is contained in:
Nick Korotysh 2020-03-03 23:39:17 +03:00
parent b519ece18b
commit d49d7c1d82
No known key found for this signature in database
GPG key ID: 7D0D4117C97CCC46
2 changed files with 11 additions and 0 deletions

View file

@ -62,6 +62,10 @@ void Utils::Gui::resize(QWidget *widget, const QSize &newSize)
qreal Utils::Gui::screenScalingFactor(const QWidget *widget)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
Q_UNUSED(widget);
return 1;
#else
if (!widget)
return 1;
@ -77,6 +81,7 @@ qreal Utils::Gui::screenScalingFactor(const QWidget *widget)
#else
return widget->devicePixelRatioF();
#endif // Q_OS_WIN
#endif // QT_VERSION
}
QPixmap Utils::Gui::scaledPixmap(const QIcon &icon, const QWidget *widget, const int height)