From db8842a0d480d36b568336889a06e623f0c1685e Mon Sep 17 00:00:00 2001 From: Cristian Adam Date: Wed, 14 Jun 2023 14:20:19 +0200 Subject: [PATCH] App: Allow usage of "windows" style if enforced Currently the code checks if qFuzzyCompare(qApp->devicePixelRatio(), 1.0) and if the condition is true it will always set the "fusion" style. If the user sets a "-style" option we shouldn't override it. Change-Id: If9a20a1b38f4a5aa3c2ccaf53cb01aafb45077f9 Reviewed-by: Alessandro Portale Reviewed-by: --- src/app/main.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 9e1e7458803..08d45e3544e 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -495,6 +495,10 @@ int main(int argc, char **argv) Options options = parseCommandLine(argc, argv); applicationDirPath(argv[0]); + const bool hasStyleOption = Utils::findOrDefault(options.appArguments, [](char *arg) { + return strcmp(arg, "-style") == 0; + }); + if (qEnvironmentVariableIsSet("QTC_DO_NOT_PROPAGATE_LD_PRELOAD")) { Utils::Environment::modifySystemEnvironment( {{"LD_PRELOAD", "", Utils::EnvironmentItem::Unset}}); @@ -607,10 +611,8 @@ int main(int argc, char **argv) setPixmapCacheLimit(); loadFonts(); - if (Utils::HostOsInfo::isWindowsHost() - && !qFuzzyCompare(qApp->devicePixelRatio(), 1.0) - && QApplication::style()->objectName().startsWith( - QLatin1String("windows"), Qt::CaseInsensitive)) { + if (Utils::HostOsInfo::isWindowsHost() && !qFuzzyCompare(qApp->devicePixelRatio(), 1.0) + && !hasStyleOption) { QApplication::setStyle(QLatin1String("fusion")); } const int threadCount = QThreadPool::globalInstance()->maxThreadCount();