Qt Utilities 6.14.4
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Loading...
Searching...
No Matches
qtconfigarguments.h
Go to the documentation of this file.
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
38namespace CppUtilities {
39
41public:
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
54private:
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
72{
73 return m_qtWidgetsGuiArg;
74}
75
80{
81 return m_qtQuickGuiArg;
82}
83
88{
89 return m_lngArg;
90}
91
96{
97 return m_qtWidgetsGuiArg.isPresent() || m_qtQuickGuiArg.isPresent();
98}
99
100#ifdef QT_UTILITIES_GUI_QTQUICK
104inline 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
Argument & qtWidgetsGuiArg()
Returns the argument for the Qt Widgets GUI.
Argument & qtQuickGuiArg()
Returns the argument for the Qt Quick GUI.
Argument & languageArg()
Returns the language argument.
bool areQtGuiArgsPresent() const
Returns whether at least one of the GUI arguments is present.
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition global.h:14
The CppUtilities namespace contains addons to the c++utilities library provided by the qtutilities li...