41 : m_qtWidgetsGuiArg(
"qt-widgets-gui",
'g',
"shows a Qt widgets based graphical user interface")
42 , m_qtQuickGuiArg(
"qt-quick-gui",
'q',
"shows a Qt quick based graphical user interface")
43 , m_lngArg(
"lang",
'l',
"sets the language for the Qt GUI")
44 , m_qmlDebuggerArg(
"qmljsdebugger",
'q',
45 "enables QML debugging (see "
46 "http://doc.qt.io/qt-5/"
47 "qtquick-debugging.html)")
48 , m_widgetsStyleArg(
"widgets-style",
'\0',
"sets the Qt Widgets style")
49 , m_quickControls2StyleArg(
"qqc2-style",
'\0',
"sets the Qt Quick Controls 2 style")
50 , m_iconThemeArg(
"icon-theme",
'\0',
51 "sets the icon theme and additional "
52 "theme search paths for the Qt GUI")
53 , m_fontArg(
"font",
'\0',
"sets the font family and size (point) for the Qt GUI")
54 , m_libraryPathsArg(
"library-paths",
'\0',
55 "sets the list of directories to search when loading "
56 "libraries (all existing paths will be deleted)")
57 , m_platformThemeArg(
"platformtheme",
'\0',
"specifies the Qt platform theme to be used")
58 , m_sceneGraphRenderLoopArg(
"scene-graph-render-loop",
'\0',
"sets the loop for the Qt Quick Scene Graph OpenGL Renderer")
61 m_lngArg.setValueNames({
"language" });
62 m_lngArg.setRequiredValueCount(1);
63 m_lngArg.setRequired(
false);
64 m_lngArg.setCombinable(
true);
66 m_qmlDebuggerArg.setValueNames({
"port:<port_from>[,port_to][,host:<ip address>][,block]" });
67 m_qmlDebuggerArg.setRequiredValueCount(1);
68 m_qmlDebuggerArg.setCombinable(
true);
70 m_widgetsStyleArg.setValueNames({
"breeze/cleanlooks/fusion/kvantum/oxygen/adwaita/windows/..." });
71 m_widgetsStyleArg.setRequiredValueCount(1);
72 m_widgetsStyleArg.setCombinable(
true);
73 m_widgetsStyleArg.setEnvironmentVariable(
"QT_STYLE_OVERRIDE");
74 m_quickControls2StyleArg.setValueNames({
"default/material/universal/org.kde.desktop/..." });
75 m_quickControls2StyleArg.setRequiredValueCount(1);
76 m_quickControls2StyleArg.setCombinable(
true);
77 m_quickControls2StyleArg.setEnvironmentVariable(
"QT_QUICK_CONTROLS_STYLE");
78 m_iconThemeArg.setValueNames({
"theme name",
"search path 1",
"search path 2" });
79 m_iconThemeArg.setRequiredValueCount(Argument::varValueCount);
80 m_iconThemeArg.setCombinable(
true);
81 m_iconThemeArg.setEnvironmentVariable(
"ICON_THEME_SEARCH_PATH and ICON_THEME");
82 m_fontArg.setValueNames({
"name",
"size" });
83 m_fontArg.setRequiredValueCount(2);
84 m_fontArg.setCombinable(
true);
85 m_libraryPathsArg.setValueNames({
"path 1",
"path 2" });
86 m_libraryPathsArg.setRequiredValueCount(Argument::varValueCount);
87 m_libraryPathsArg.setCombinable(
true);
88 m_platformThemeArg.setRequiredValueCount(1);
89 m_platformThemeArg.setCombinable(
true);
90 m_platformThemeArg.setValueNames({
"qt5ct/kde/..." });
91 m_platformThemeArg.setPreDefinedCompletionValues(
"kde gnome "
92#
if QT_VERSION_MAJOR == 5
94#elif QT_VERSION_MAJOR == 6
98 m_platformThemeArg.setEnvironmentVariable(
"QT_QPA_PLATFORMTHEME");
99 m_sceneGraphRenderLoopArg.setRequiredValueCount(1);
100 m_sceneGraphRenderLoopArg.setCombinable(
true);
101 m_sceneGraphRenderLoopArg.setValueNames({
"basic/windows/threaded" });
102 m_sceneGraphRenderLoopArg.setPreDefinedCompletionValues(
"basic windows threaded");
103 m_sceneGraphRenderLoopArg.setEnvironmentVariable(
"QSG_RENDER_LOOP");
104 m_qtWidgetsGuiArg.setSubArguments(
105 { &m_lngArg, &m_qmlDebuggerArg, &m_widgetsStyleArg, &m_iconThemeArg, &m_fontArg, &m_libraryPathsArg, &m_platformThemeArg });
106 m_qtQuickGuiArg.setSubArguments({ &m_lngArg, &m_qmlDebuggerArg, &m_quickControls2StyleArg, &m_iconThemeArg, &m_fontArg, &m_libraryPathsArg,
107 &m_platformThemeArg, &m_sceneGraphRenderLoopArg });
108 m_qtWidgetsGuiArg.setDenotesOperation(
true);
109 m_qtQuickGuiArg.setDenotesOperation(
true);
110#if defined(QT_UTILITIES_GUI_QTWIDGETS)
111 m_qtWidgetsGuiArg.setImplicit(
true);
112#elif defined(QT_UTILITIES_GUI_QTQUICK)
113 m_qtQuickGuiArg.setImplicit(
true);
125 if (m_lngArg.isPresent()) {
126 QLocale::setDefault(QLocale(QString::fromLocal8Bit(m_lngArg.values().front())));
128#ifdef QT_UTILITIES_GUI_QTWIDGETS
129 if (m_widgetsStyleArg.isPresent()) {
130 if (QStyle *
const style = QStyleFactory::create(QString::fromLocal8Bit(m_widgetsStyleArg.values().front()))) {
131 QApplication::setStyle(style);
133 cerr << Phrases::Warning <<
"Can not find the specified Qt Widgets style." << Phrases::EndFlush;
137 if (m_iconThemeArg.isPresent()) {
139 if (
auto i = m_iconThemeArg.values().cbegin(), end = m_iconThemeArg.values().cend(); i != end) {
140 QIcon::setThemeName(QString::fromUtf8(*i));
142 auto searchPaths = QStringList();
143 searchPaths.reserve(
static_cast<QStringList::size_type
>(m_iconThemeArg.values().size()));
144 for (; i != end; ++i) {
145 searchPaths << QString::fromUtf8(*i);
147 searchPaths << QStringLiteral(
":/icons");
148 QIcon::setThemeSearchPaths(searchPaths);
152 if (qEnvironmentVariableIsSet(
"ICON_THEME_SEARCH_PATH")) {
153 QIcon::setThemeSearchPaths(QStringList({ qEnvironmentVariable(
"ICON_THEME_SEARCH_PATH"), QStringLiteral(
":/icons") }));
155 QIcon::setThemeSearchPaths(QIcon::themeSearchPaths() << QStringLiteral(
"../share/icons") << QStringLiteral(
":/icons"));
157 if (qEnvironmentVariableIsSet(
"ICON_THEME")) {
158 QIcon::setThemeName(qEnvironmentVariable(
"ICON_THEME"));
161 if (m_fontArg.isPresent()) {
163 font.setFamily(QString::fromLocal8Bit(m_fontArg.values().front()));
165 font.setPointSize(stringToNumber<int>(m_fontArg.values().back()));
166 }
catch (
const ConversionException &) {
167 cerr << Phrases::Warning <<
"The specified font size is no number and will be ignored." << Phrases::EndFlush;
169 QGuiApplication::setFont(font);
172 else if (!preventApplyingDefaultFont) {
173 QGuiApplication::setFont(QFont(QStringLiteral(
"Segoe UI"), 9));
176 CPP_UTILITIES_UNUSED(preventApplyingDefaultFont)
178 if (m_libraryPathsArg.isPresent()) {
179 QStringList libraryPaths;
180 libraryPaths.reserve(
static_cast<QStringList::size_type
>(m_libraryPathsArg.values().size()));
181 for (
const auto &path : m_libraryPathsArg.values()) {
182 libraryPaths << QString::fromLocal8Bit(path);
184 QCoreApplication::setLibraryPaths(libraryPaths);
186 if (m_sceneGraphRenderLoopArg.isPresent()) {
187 qputenv(m_sceneGraphRenderLoopArg.environmentVariable(), QByteArray(m_sceneGraphRenderLoopArg.firstValue()));
190#ifdef QT_UTILITIES_CHECK_WINDOWS_VERSION
191 if (QOperatingSystemVersion::current() < QOperatingSystemVersion::Windows10_1809) {
192 QMessageBox::warning(
nullptr, QCoreApplication::applicationName(),
193 QCoreApplication::translate(
"QtConfigArguments",
194 "This application requires Windows 10, version 1809 or newer. The current Windows version is older so the application might not work "