7#include <QtCore/qdir.h>
8#include <QtCore/qfile.h>
9#include <QtCore/qdebug.h>
10#if QT_CONFIG(settings)
11#include <QtCore/qsettings.h>
13#include <QtCore/qfileselector.h>
14#include <QtCore/qlibraryinfo.h>
15#include <QtCore/qloggingcategory.h>
16#include <QtCore/qmetaobject.h>
17#include <QtGui/qcolor.h>
18#include <QtGui/qfont.h>
19#include <QtGui/qpalette.h>
20#include <QtGui/private/qguiapplication_p.h>
21#include <QtGui/qpa/qplatformtheme.h>
22#include <QtQml/private/qqmlmetatype_p.h>
23#include <QtQml/qqmlengine.h>
24#include <QtQml/qqmlfile.h>
88 return style.mid(style.lastIndexOf(
QLatin1Char(
'/')) + 1);
103 qCDebug(lcQtQuickControlsStyle) <<
"style" <<
s <<
"set on QQuickStyleSpec";
105 qWarning() <<
"Style names must not contain paths; see the \"Definition of a Style\" documentation for more information";
109 qCDebug(lcQtQuickControlsStyle) <<
"clearing resolved flag and resolving";
118 qCDebug(lcQtQuickControlsStyle) <<
"fallback style" << fallback <<
"set on QQuickStyleSpec via" <<
method;
120 fallbackStyle = fallback;
126 qCDebug(lcQtQuickControlsStyle) <<
"resolving style";
132 if (fallbackStyle.isEmpty())
134#if QT_CONFIG(settings)
135 if (style.isEmpty() || fallbackStyle.isEmpty()) {
140 if (fallbackStyle.isEmpty())
147 if (!fallbackStyle.isEmpty() && !builtInStyleList.contains(fallbackStyle)) {
148 qWarning().nospace().noquote() << fallbackMethod <<
": the specified fallback style \"" <<
149 fallbackStyle <<
"\" is not one of the built-in Qt Quick Controls 2 styles";
150 fallbackStyle.clear();
154 resolveConfigFilePath();
156 usingDefaultStyle =
false;
158 if (style.isEmpty() || style.toLower() ==
QStringLiteral(
"default")) {
159 usingDefaultStyle =
true;
162 qCDebug(lcQtQuickControlsStyle) <<
"no style (or Default) was specified;"
163 <<
"checking if we have an appropriate style for this platform";
167#if defined(Q_OS_MACOS)
169#elif defined(Q_OS_WINDOWS)
171#elif defined(Q_OS_ANDROID)
173#elif defined(Q_OS_LINUX)
175#elif defined(Q_OS_IOS)
178 if (!style.isEmpty())
179 qCDebug(lcQtQuickControlsStyle) <<
"using" << style <<
"as a default";
181 qCDebug(lcQtQuickControlsStyle) <<
"no appropriate style found; using Basic as a default";
191 qCDebug(lcQtQuickControlsStyle).nospace() <<
"done resolving:"
192 <<
"\n style=" << style
193 <<
"\n custom=" << custom
194 <<
"\n resolved=" << resolved
195 <<
"\n fallbackStyle=" << fallbackStyle
196 <<
"\n fallbackMethod=" << fallbackMethod
197 <<
"\n configFilePath=" << configFilePath;
202 qCDebug(lcQtQuickControlsStyle) <<
"resetting values to their defaults";
206 usingDefaultStyle =
false;
208 fallbackStyle.clear();
209 fallbackMethod.clear();
210 configFilePath.clear();
215 if (configFilePath.isEmpty()) {
217 if (configFilePath.isEmpty() || !
QFile::exists(configFilePath)) {
218 if (!configFilePath.isEmpty())
224 return configFilePath;
230 bool resolved =
false;
232 bool usingDefaultStyle =
false;
252 return styleSpec()->
style;
262 return styleSpec()->fallbackStyle;
267 return styleSpec()->custom;
272 return styleSpec()->resolved;
277 return styleSpec()->usingDefaultStyle;
289 styleSpec()->reset();
294 return styleSpec()->resolveConfigFilePath();
299#ifndef QT_NO_SETTINGS
304 if (!
group.isEmpty())
312#if QT_CONFIG(settings)
320template <
typename Enum>
331 return static_cast<Enum
>(
var.
toInt());
358 static const int index = QPalette::staticMetaObject.indexOfEnumerator(
"ColorRole");
360 QMetaEnum metaEnum = QPalette::staticMetaObject.enumerator(
index);
389 const bool dark = [](){
427 return styleSpec()->name();
440 qCDebug(lcQtQuickControlsStyle) <<
"setStyle called with" << style;
444 qWarning() <<
"ERROR: QQuickStyle::setStyle() must be called before loading QML that imports Qt Quick Controls 2.";
448 styleSpec()->setStyle(style);
469 qWarning() <<
"ERROR: QQuickStyle::setFallbackStyle() must be called before loading QML that imports Qt Quick Controls 2.";
473 styleSpec()->setFallbackStyle(style,
"QQuickStyle::setFallbackStyle()");
The QColor class provides colors based on RGB, HSV or CMYK values.
QString select(const QString &filePath) const
This function returns the selected version of the path, based on the conditions at runtime.
static QString decodeName(const QByteArray &localFileName)
This does the reverse of QFile::encodeName() using localFileName.
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static QString styleOverride
static QPlatformTheme * platformTheme()
The QPalette class contains color groups for each widget state.
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
static bool isLocalFile(const QString &url)
Returns true if url is a local file that can be opened with QFile.
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to QFile.
static QString effectiveStyleName(const QString &styleName)
static QStringList builtInStyles()
static bool isCustomStyle()
static const QFont * readFont(const QSharedPointer< QSettings > &settings)
static QSharedPointer< QSettings > settings(const QString &group=QString())
static bool isDarkSystemTheme()
static const QPalette * readPalette(const QSharedPointer< QSettings > &settings)
static QString fallbackStyle()
static bool isUsingDefaultStyle()
static QString configFilePath()
static void setFallbackStyle(const QString &style)
static void setStyle(const QString &style)
Sets the application style to style.
static QString name()
Returns the name of the application style.
void endGroup()
Resets the group to what it was before the corresponding beginGroup() call.
QVariant value(QAnyStringView key, const QVariant &defaultValue) const
Returns the value for setting key.
QStringList childKeys() const
Returns a list of all top-level keys that can be read using the QSettings object.
void beginGroup(QAnyStringView prefix)
Appends prefix to the current group.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
static constexpr QTypeRevision fromVersion(Major majorVersion, Minor minorVersion)
Produces a QTypeRevision from the given majorVersion and minorVersion, both of which need to be a val...
qreal toReal(bool *ok=nullptr) const
Returns the variant as a qreal if the variant has userType() \l QMetaType::Double,...
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
int toInt(bool *ok=nullptr) const
Returns the variant as an int if the variant has userType() \l QMetaType::Int, \l QMetaType::Bool,...
QString toString() const
Returns the variant as a QString if the variant has a userType() including, but not limited to:
Combined button and popup list for selecting options.
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
static quint32 readValue(QDataStream &s, quint32 size)
#define Q_GLOBAL_STATIC(TYPE, NAME,...)
#define Q_LOGGING_CATEGORY(name,...)
#define qCDebug(category,...)
static Enum toEnumValue(const QByteArray &value, bool *ok)
#define qPrintable(string)
QLatin1StringView QLatin1String
#define QStringLiteral(str)
Q_CORE_EXPORT QByteArray qgetenv(const char *varName)
QFileSelector selector
[1]
QSettings settings("MySoft", "Star Runner")
[0]
settings setValue("DataPump/bgcolor", color)
char * toString(const MyType &t)
[31]
\inmodule QtCore \reentrant
QByteArray fallbackMethod
void setFallbackStyle(const QString &fallback, const QByteArray &method)
QString resolveConfigFilePath()
void setStyle(const QString &s)