Qt Utilities  5.12.2
Common Qt related C++ classes and routines used by my applications such as dialogs, widgets and models
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 defined(PLATFORM_ANDROID)
13 #define QT_UTILITIES_DEFAULT_QQC2_STYLE "material"
14 #elif defined(PLATFORM_WINDOWS)
15 #define QT_UTILITIES_DEFAULT_QQC2_STYLE "universal"
16 #endif
17 #endif
18 
20 
22 public:
24 
25  Argument &qtWidgetsGuiArg();
26  Argument &qtQuickGuiArg();
27  Argument &languageArg();
28 
29  bool areQtGuiArgsPresent() const;
30  void applySettings(bool preventApplyingDefaultFont = false) const;
31 #ifdef QT_UTILITIES_GUI_QTQUICK
32  void applySettingsForQuickGui() const;
33 #endif
34 
35 private:
36  Argument m_qtWidgetsGuiArg;
37  Argument m_qtQuickGuiArg;
38  Argument m_lngArg;
39  Argument m_qmlDebuggerArg;
40  Argument m_styleArg;
41  Argument m_iconThemeArg;
42  Argument m_fontArg;
43  Argument m_libraryPathsArg;
44  Argument m_platformThemeArg;
45 };
46 
51 {
52  return m_qtWidgetsGuiArg;
53 }
54 
59 {
60  return m_qtQuickGuiArg;
61 }
62 
67 {
68  return m_lngArg;
69 }
70 
75 {
76  return m_qtWidgetsGuiArg.isPresent() || m_qtQuickGuiArg.isPresent();
77 }
78 
79 #ifdef QT_UTILITIES_GUI_QTQUICK
80 
83 inline void QtConfigArguments::applySettingsForQuickGui() const
84 {
85  if (m_qtQuickGuiArg.isPresent() && m_styleArg.isPresent()) {
86  QQuickStyle::setStyle(QString::fromLocal8Bit(m_styleArg.values().front()));
87  }
88 #ifdef QT_UTILITIES_DEFAULT_QQC2_STYLE
89  else if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) {
90  QQuickStyle::setStyle(QStringLiteral(QT_UTILITIES_DEFAULT_QQC2_STYLE));
91  }
92 #endif // QT_UTILITIES_DEFAULT_QQC2_STYLE
93 }
94 #endif // QT_UTILITIES_GUI_QTQUICK
95 
96 } // namespace ApplicationUtilities
97 
98 #endif // APPLICATION_UTILITIES_QTCONFIGARGUMENTS_H
99 
100 #ifdef QT_CONFIG_ARGUMENTS
101 #undef QT_CONFIG_ARGUMENTS
102 #endif
103 #define QT_CONFIG_ARGUMENTS ApplicationUtilities::QtConfigArguments
Argument & qtWidgetsGuiArg()
Returns the argument for the Qt Widgets GUI.
Argument & languageArg()
Returns the language argument.
#define QT_UTILITIES_EXPORT
Marks the symbol to be exported by the qtutilities library.
Argument & qtQuickGuiArg()
Returns the argument for the Qt Quick GUI.
bool areQtGuiArgsPresent() const
Returns whether at least one of the GUI arguments is present.