Fix GUI scaling factor on macOS

macOS seems have an unique way to handle widget size, that is, it doesn't require
application to resize widgets manually, Qt will handle the resize job
automatically.

Closes #8841.
This commit is contained in:
Chocobo1 2018-05-09 15:46:17 +08:00 committed by sledgehammer999
parent 4168772904
commit 17c0463906
No known key found for this signature in database
GPG key ID: 6E4A2D025B7CC9A2

View file

@ -45,16 +45,21 @@ void Utils::Gui::resize(QWidget *widget, const QSize &newSize)
qreal Utils::Gui::screenScalingFactor(const QWidget *widget)
{
if (!widget)
return 1;
#ifdef Q_OS_WIN
const int screen = qApp->desktop()->screenNumber(widget);
return (QApplication::screens()[screen]->logicalDotsPerInch() / 96);
#elif defined(Q_OS_MAC)
return 1;
#else
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
return widget->devicePixelRatioF();
#else
return widget->devicePixelRatio();
#endif
#endif // Q_OS_WIN
#endif
}
QPixmap Utils::Gui::scaledPixmap(const QString &path, const QWidget *widget, const int height)