Main: Move option into options

Change-Id: Ibcba302ce959347588c1f1d0d4d9fcff8f99ec25
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
This commit is contained in:
Marcus Tillmanns
2024-08-01 07:09:07 +02:00
parent 523b4045cc
commit 54333873f4

View File

@@ -84,6 +84,7 @@ const char CLIENT_OPTION[] = "-client";
const char SETTINGS_OPTION[] = "-settingspath"; const char SETTINGS_OPTION[] = "-settingspath";
const char INSTALL_SETTINGS_OPTION[] = "-installsettingspath"; const char INSTALL_SETTINGS_OPTION[] = "-installsettingspath";
const char TEST_OPTION[] = "-test"; const char TEST_OPTION[] = "-test";
const char STYLE_OPTION[] = "-style";
const char TEMPORARY_CLEAN_SETTINGS1[] = "-temporarycleansettings"; const char TEMPORARY_CLEAN_SETTINGS1[] = "-temporarycleansettings";
const char TEMPORARY_CLEAN_SETTINGS2[] = "-tcs"; const char TEMPORARY_CLEAN_SETTINGS2[] = "-tcs";
const char PID_OPTION[] = "-pid"; const char PID_OPTION[] = "-pid";
@@ -317,6 +318,7 @@ struct Options
std::optional<QString> userLibraryPath; std::optional<QString> userLibraryPath;
bool hasTestOption = false; bool hasTestOption = false;
bool wantsCleanSettings = false; bool wantsCleanSettings = false;
bool hasStyleOption = false;
}; };
Options parseCommandLine(int argc, char *argv[]) Options parseCommandLine(int argc, char *argv[])
@@ -353,12 +355,15 @@ Options parseCommandLine(int argc, char *argv[])
options.wantsCleanSettings = true; options.wantsCleanSettings = true;
options.preAppArguments << arg; options.preAppArguments << arg;
} else { // arguments that are still passed on to the application } else { // arguments that are still passed on to the application
if (arg == STYLE_OPTION)
options.hasStyleOption = true;
if (arg == TEST_OPTION) if (arg == TEST_OPTION)
options.hasTestOption = true; options.hasTestOption = true;
options.appArguments.push_back(*it); options.appArguments.push_back(*it);
} }
++it; ++it;
} }
return options; return options;
} }
@@ -697,22 +702,17 @@ int main(int argc, char **argv)
setPixmapCacheLimit(); setPixmapCacheLimit();
loadFonts(); loadFonts();
if (HostOsInfo::isWindowsHost()) { if (Utils::HostOsInfo::isWindowsHost() && !options.hasStyleOption) {
const bool hasStyleOption = Utils::findOrDefault(options.appArguments, [](char *arg) { // The Windows 11 default style (Qt 6.7) has major issues, therefore
return arg && strcmp(arg, "-style") == 0; // set the previous default style: "windowsvista"
}); // FIXME: check newer Qt Versions
if (!hasStyleOption) { QApplication::setStyle(QLatin1String("windowsvista"));
// 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 // On scaling different than 100% or 200% use the "fusion" style
qreal tmp; qreal tmp;
const bool fractionalDpi = !qFuzzyIsNull(std::modf(qApp->devicePixelRatio(), &tmp)); const bool fractionalDpi = !qFuzzyIsNull(std::modf(qApp->devicePixelRatio(), &tmp));
if (fractionalDpi) if (fractionalDpi)
QApplication::setStyle(QLatin1String("fusion")); QApplication::setStyle(QLatin1String("fusion"));
}
} }
const int threadCount = QThreadPool::globalInstance()->maxThreadCount(); const int threadCount = QThreadPool::globalInstance()->maxThreadCount();