Debian Codegraph @

resources/qtconfigarguments.h

raw symbols SCIP
1 #ifndef APPLICATION_UTILITIES_QTCONFIGARGUMENTS_H
2 #define APPLICATION_UTILITIES_QTCONFIGARGUMENTS_H
3
4 #include "../global.h"
5
6 #include <c++utilities/application/argumentparser.h>
7
8 #ifdef QT_UTILITIES_GUI_QTQUICK
9 #include <QQuickStyle>
10 #include <QString>
11
12 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
13 #if defined(PLATFORM_ANDROID)
14 #define QT_UTILITIES_DEFAULT_QQC2_STYLE "Material"
15 #elif defined(PLATFORM_WINDOWS)
16 #include <QLibraryInfo>
17 #include <QOperatingSystemVersion>
18 #define QT_UTILITIES_DEFAULT_QQC2_STYLE "Universal"
19 #define QT_UTILITIES_DEFAULT_QQC2_STYLE_QSTRING \
20 (QLibraryInfo::version() >= QVersionNumber(6, 8, 0) \
21 && QOperatingSystemVersion::current() >= QOperatingSystemVersion(QOperatingSystemVersion::Windows11) \
22 ? QStringLiteral("FluentWinUI3") \
23 : QStringLiteral("Universal"))
24 #endif
25 #else
26 #if defined(PLATFORM_ANDROID)
27 #define QT_UTILITIES_DEFAULT_QQC2_STYLE "material"
28 #elif defined(PLATFORM_WINDOWS)
29 #define QT_UTILITIES_DEFAULT_QQC2_STYLE "universal"
30 #endif
31 #endif
32 #if defined(QT_UTILITIES_DEFAULT_QQC2_STYLE) && !defined(QT_UTILITIES_DEFAULT_QQC2_STYLE_QSTRING)
33 #define QT_UTILITIES_DEFAULT_QQC2_STYLE_QSTRING QStringLiteral(QT_UTILITIES_DEFAULT_QQC2_STYLE)
34 #endif
35
36 #endif
37
38 namespace CppUtilities {
39
40 class QT_UTILITIES_EXPORT QtConfigArguments {
41 public:
42 QtConfigArguments();
43
44 Argument &qtWidgetsGuiArg();
45 Argument &qtQuickGuiArg();
46 Argument &languageArg();
47
48 bool areQtGuiArgsPresent() const;
49 void applySettings(bool preventApplyingDefaultFont = false) const;
50 #ifdef QT_UTILITIES_GUI_QTQUICK
51 void applySettingsForQuickGui() const;
52 #endif
53
54 private:
55 Argument m_qtWidgetsGuiArg;
56 Argument m_qtQuickGuiArg;
57 Argument m_lngArg;
58 Argument m_qmlDebuggerArg;
59 Argument m_widgetsStyleArg;
60 Argument m_quickControls2StyleArg;
61 Argument m_iconThemeArg;
62 Argument m_fontArg;
63 Argument m_libraryPathsArg;
64 Argument m_platformThemeArg;
65 Argument m_sceneGraphRenderLoopArg;
66 };
67
68 /*!
69 * \brief Returns the argument for the Qt Widgets GUI.
70 */
71 inline Argument &QtConfigArguments::qtWidgetsGuiArg()
72 {
73 return m_qtWidgetsGuiArg;
74 }
75
76 /*!
77 * \brief Returns the argument for the Qt Quick GUI.
78 */
79 inline Argument &QtConfigArguments::qtQuickGuiArg()
80 {
81 return m_qtQuickGuiArg;
82 }
83
84 /*!
85 * \brief Returns the language argument.
86 */
87 inline Argument &QtConfigArguments::languageArg()
88 {
89 return m_lngArg;
90 }
91
92 /*!
93 * \brief Returns whether at least one of the GUI arguments is present.
94 */
95 inline bool QtConfigArguments::areQtGuiArgsPresent() const
96 {
97 return m_qtWidgetsGuiArg.isPresent() || m_qtQuickGuiArg.isPresent();
98 }
99
100 #ifdef QT_UTILITIES_GUI_QTQUICK
101 /*!
102 * \brief Applies settings the for Qt Quick GUI.
103 */
104 inline void QtConfigArguments::applySettingsForQuickGui() const
105 {
106 if (m_quickControls2StyleArg.isPresent()) {
107 QQuickStyle::setStyle(QString::fromLocal8Bit(m_quickControls2StyleArg.values().front()));
108 }
109 #ifdef QT_UTILITIES_DEFAULT_QQC2_STYLE
110 else if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
111 if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_MATERIAL_THEME")) {
112 qputenv("QT_QUICK_CONTROLS_MATERIAL_THEME", "System");
113 }
114 if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_UNIVERSAL_THEME")) {
115 qputenv("QT_QUICK_CONTROLS_UNIVERSAL_THEME", "System");
116 }
117 QQuickStyle::setStyle(QT_UTILITIES_DEFAULT_QQC2_STYLE_QSTRING);
118 }
119 #endif // QT_UTILITIES_DEFAULT_QQC2_STYLE
120 }
121 #endif // QT_UTILITIES_GUI_QTQUICK
122
123 } // namespace CppUtilities
124
125 #endif // APPLICATION_UTILITIES_QTCONFIGARGUMENTS_H
126
127 #ifdef QT_CONFIG_ARGUMENTS
128 #undef QT_CONFIG_ARGUMENTS
129 #endif
130 #define QT_CONFIG_ARGUMENTS CppUtilities::QtConfigArguments