Browse Source

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.
adaptive-webui-19844
Chocobo1 7 years ago
parent
commit
f934042a98
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 7
      src/gui/utils.cpp

7
src/gui/utils.cpp

@ -45,16 +45,21 @@ void Utils::Gui::resize(QWidget *widget, const QSize &newSize) @@ -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)

Loading…
Cancel
Save