Qt Utilities
6.22.1
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
Toggle main menu visibility
Loading...
Searching...
No Matches
resources
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
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
71
inline
Argument &
QtConfigArguments::qtWidgetsGuiArg
()
72
{
73
return
m_qtWidgetsGuiArg;
74
}
75
79
inline
Argument &
QtConfigArguments::qtQuickGuiArg
()
80
{
81
return
m_qtQuickGuiArg;
82
}
83
87
inline
Argument &
QtConfigArguments::languageArg
()
88
{
89
return
m_lngArg;
90
}
91
95
inline
bool
QtConfigArguments::areQtGuiArgsPresent
()
const
96
{
97
return
m_qtWidgetsGuiArg.isPresent() || m_qtQuickGuiArg.isPresent();
98
}
99
100
#ifdef QT_UTILITIES_GUI_QTQUICK
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
CppUtilities::QtConfigArguments::qtWidgetsGuiArg
Argument & qtWidgetsGuiArg()
Returns the argument for the Qt Widgets GUI.
Definition
qtconfigarguments.h:71
CppUtilities::QtConfigArguments::QtConfigArguments
QtConfigArguments()
Constructs new Qt config arguments.
Definition
qtconfigarguments.cpp:40
CppUtilities::QtConfigArguments::qtQuickGuiArg
Argument & qtQuickGuiArg()
Returns the argument for the Qt Quick GUI.
Definition
qtconfigarguments.h:79
CppUtilities::QtConfigArguments::languageArg
Argument & languageArg()
Returns the language argument.
Definition
qtconfigarguments.h:87
CppUtilities::QtConfigArguments::applySettings
void applySettings(bool preventApplyingDefaultFont=false) const
Applies the settings from the arguments.
Definition
qtconfigarguments.cpp:123
CppUtilities::QtConfigArguments::areQtGuiArgsPresent
bool areQtGuiArgsPresent() const
Returns whether at least one of the GUI arguments is present.
Definition
qtconfigarguments.h:95
global.h
QT_UTILITIES_EXPORT
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Definition
global.h:14
CppUtilities
The CppUtilities namespace contains addons to the c++utilities library provided by the qtutilities li...
Definition
qtconfigarguments.h:38
Generated on
for Qt Utilities by
1.18.0