Skip to content

Commit

Permalink
优化setHighDpiEnvironmentVariable函数;
Browse files Browse the repository at this point in the history
  • Loading branch information
RealChuan committed Sep 20, 2023
1 parent d2d9cc8 commit 18da551
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
5 changes: 2 additions & 3 deletions apps/app/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,11 @@ void setQss()
auto main(int argc, char *argv[]) -> int
{
#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!qEnvironmentVariableIsSet("QT_OPENGL"))
if (!qEnvironmentVariableIsSet("QT_OPENGL")) {
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
}
#else
qputenv("QSG_RHI_BACKEND", "opengl");
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
Qt::HighDpiScaleFactorRoundingPolicy::Round);
#endif
Utils::setHighDpiEnvironmentVariable();
SharedTools::QtSingleApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
Expand Down
5 changes: 2 additions & 3 deletions apps/crashreport/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ void setQss()
auto main(int argc, char *argv[]) -> int
{
#if defined(Q_OS_WIN) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
if (!qEnvironmentVariableIsSet("QT_OPENGL"))
if (!qEnvironmentVariableIsSet("QT_OPENGL")) {
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
}
#else
qputenv("QSG_RHI_BACKEND", "opengl");
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(
Qt::HighDpiScaleFactorRoundingPolicy::Round);
#endif
Utils::setHighDpiEnvironmentVariable();
SharedTools::QtSingleApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
Expand Down
6 changes: 0 additions & 6 deletions utils/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,6 @@ void Utils::setHighDpiEnvironmentVariable()
if (Utils::HostOsInfo::isMacHost()) {
return;
}
if (Utils::HostOsInfo::isWindowsHost() && !qEnvironmentVariableIsSet("QT_OPENGL")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_UseOpenGLES);
#endif
}

if (Utils::HostOsInfo::isWindowsHost()
&& !qEnvironmentVariableIsSet("QT_DEVICE_PIXEL_RATIO") // legacy in 5.6, but still functional
Expand All @@ -113,7 +108,6 @@ void Utils::setHighDpiEnvironmentVariable()
&& !qEnvironmentVariableIsSet("QT_SCREEN_SCALE_FACTORS")) {
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
#endif
}

Expand Down

0 comments on commit 18da551

Please sign in to comment.