From 54333873f45a6935ef12ddea4961bbf56113b4e2 Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 1 Aug 2024 07:09:07 +0200 Subject: [PATCH] Main: Move option into options Change-Id: Ibcba302ce959347588c1f1d0d4d9fcff8f99ec25 Reviewed-by: Alessandro Portale --- src/app/main.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/app/main.cpp b/src/app/main.cpp index 1c8a47ae2e5..caa780f1206 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -84,6 +84,7 @@ const char CLIENT_OPTION[] = "-client"; const char SETTINGS_OPTION[] = "-settingspath"; const char INSTALL_SETTINGS_OPTION[] = "-installsettingspath"; const char TEST_OPTION[] = "-test"; +const char STYLE_OPTION[] = "-style"; const char TEMPORARY_CLEAN_SETTINGS1[] = "-temporarycleansettings"; const char TEMPORARY_CLEAN_SETTINGS2[] = "-tcs"; const char PID_OPTION[] = "-pid"; @@ -317,6 +318,7 @@ struct Options std::optional userLibraryPath; bool hasTestOption = false; bool wantsCleanSettings = false; + bool hasStyleOption = false; }; Options parseCommandLine(int argc, char *argv[]) @@ -353,12 +355,15 @@ Options parseCommandLine(int argc, char *argv[]) options.wantsCleanSettings = true; options.preAppArguments << arg; } else { // arguments that are still passed on to the application + if (arg == STYLE_OPTION) + options.hasStyleOption = true; if (arg == TEST_OPTION) options.hasTestOption = true; options.appArguments.push_back(*it); } ++it; } + return options; } @@ -697,22 +702,17 @@ int main(int argc, char **argv) setPixmapCacheLimit(); loadFonts(); - if (HostOsInfo::isWindowsHost()) { - const bool hasStyleOption = Utils::findOrDefault(options.appArguments, [](char *arg) { - return arg && strcmp(arg, "-style") == 0; - }); - if (!hasStyleOption) { - // The Windows 11 default style (Qt 6.7) has major issues, therefore - // set the previous default style: "windowsvista" - // FIXME: check newer Qt Versions - QApplication::setStyle(QLatin1String("windowsvista")); + if (Utils::HostOsInfo::isWindowsHost() && !options.hasStyleOption) { + // The Windows 11 default style (Qt 6.7) has major issues, therefore + // set the previous default style: "windowsvista" + // FIXME: check newer Qt Versions + QApplication::setStyle(QLatin1String("windowsvista")); - // On scaling different than 100% or 200% use the "fusion" style - qreal tmp; - const bool fractionalDpi = !qFuzzyIsNull(std::modf(qApp->devicePixelRatio(), &tmp)); - if (fractionalDpi) - QApplication::setStyle(QLatin1String("fusion")); - } + // On scaling different than 100% or 200% use the "fusion" style + qreal tmp; + const bool fractionalDpi = !qFuzzyIsNull(std::modf(qApp->devicePixelRatio(), &tmp)); + if (fractionalDpi) + QApplication::setStyle(QLatin1String("fusion")); } const int threadCount = QThreadPool::globalInstance()->maxThreadCount();