diff options
Diffstat (limited to 'src/quickcontrols2')
-rw-r--r-- | src/quickcontrols2/qquickstyle.cpp | 27 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin.cpp | 10 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyleplugin_p.h | 1 | ||||
-rw-r--r-- | src/quickcontrols2/qquickstyleselector.cpp | 12 | ||||
-rw-r--r-- | src/quickcontrols2/qquicktumblerview.cpp | 2 |
5 files changed, 46 insertions, 6 deletions
diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index 0d7b44c6..e1cf4bfe 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -43,6 +43,7 @@ #include <QtCore/qsettings.h> #include <QtCore/qfileselector.h> #include <QtCore/qlibraryinfo.h> +#include <QtCore/qloggingcategory.h> #include <QtCore/qmetaobject.h> #include <QtGui/qcolor.h> #include <QtGui/qfont.h> @@ -57,6 +58,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcQtQuickControlsStyle, "qt.quick.controls.style") + /*! \class QQuickStyle \brief The QQuickStyle class allows configuring the application style. @@ -188,6 +191,8 @@ struct QQuickStyleSpec void resolve(const QUrl &baseUrl = QUrl()) { + qCDebug(lcQtQuickControlsStyle) << "resolving style with baseUrl" << baseUrl; + if (style.isEmpty()) style = QGuiApplicationPrivate::styleOverride; if (style.isEmpty()) @@ -240,6 +245,15 @@ struct QQuickStyleSpec } resolved = true; } + + qCDebug(lcQtQuickControlsStyle).nospace() << "done resolving:" + << "\n custom=" << custom + << "\n resolved=" << resolved + << "\n style=" << style + << "\n fallbackStyle=" << fallbackStyle + << "\n fallbackMethod=" << fallbackMethod + << "\n configFilePath=" << configFilePath + << "\n customStylePaths=" << customStylePaths; } void reset() @@ -266,12 +280,19 @@ struct QQuickStyleSpec return configFilePath; } + // Is this a custom style defined by the user and not "built-in" style? bool custom; + // Did we manage to find a valid style path? bool resolved; + // The full path to the style. QString style; + // The built-in style to use if the requested style cannot be found. QString fallbackStyle; + // A description of the way in which fallbackStyle was set, used in e.g. warning messages shown to the user. QByteArray fallbackMethod; + // The path to the qtquickcontrols2.conf file. QString configFilePath; + // An extra list of directories where we search for available styles before any other directories. QStringList customStylePaths; }; @@ -555,7 +576,9 @@ QString QQuickStyle::path() */ void QQuickStyle::setStyle(const QString &style) { - if (QQmlMetaType::isModule(QStringLiteral("QtQuick.Controls"), 2, 0)) { + qCDebug(lcQtQuickControlsStyle) << "setStyle called with" << style; + + if (QQmlMetaType::isModule(QStringLiteral("QtQuick.Controls"), QTypeRevision::fromVersion(2, 0))) { qWarning() << "ERROR: QQuickStyle::setStyle() must be called before loading QML that imports Qt Quick Controls 2."; return; } @@ -579,7 +602,7 @@ void QQuickStyle::setStyle(const QString &style) */ void QQuickStyle::setFallbackStyle(const QString &style) { - if (QQmlMetaType::isModule(QStringLiteral("QtQuick.Controls"), 2, 0)) { + if (QQmlMetaType::isModule(QStringLiteral("QtQuick.Controls"), QTypeRevision::fromVersion(2, 0))) { qWarning() << "ERROR: QQuickStyle::setFallbackStyle() must be called before loading QML that imports Qt Quick Controls 2."; return; } diff --git a/src/quickcontrols2/qquickstyleplugin.cpp b/src/quickcontrols2/qquickstyleplugin.cpp index 553a6cad..c35c8735 100644 --- a/src/quickcontrols2/qquickstyleplugin.cpp +++ b/src/quickcontrols2/qquickstyleplugin.cpp @@ -63,7 +63,15 @@ QString QQuickStylePlugin::name() const void QQuickStylePlugin::initializeTheme(QQuickTheme *theme) { - Q_UNUSED(theme); + Q_UNUSED(theme) +} + +void QQuickStylePlugin::unregisterTypes() +{ + Q_D(QQuickStylePlugin); + // Destroy the selector so that it is recreated in resolvedUrl() and + // any new style that has been set at runtime will be accounted for when selecting QML files. + d->selector.reset(); } QUrl QQuickStylePlugin::resolvedUrl(const QString &fileName) const diff --git a/src/quickcontrols2/qquickstyleplugin_p.h b/src/quickcontrols2/qquickstyleplugin_p.h index 6b89926c..67103e12 100644 --- a/src/quickcontrols2/qquickstyleplugin_p.h +++ b/src/quickcontrols2/qquickstyleplugin_p.h @@ -66,6 +66,7 @@ public: virtual QString name() const; virtual void initializeTheme(QQuickTheme *theme); + virtual void unregisterTypes() override; QUrl resolvedUrl(const QString &fileName) const; diff --git a/src/quickcontrols2/qquickstyleselector.cpp b/src/quickcontrols2/qquickstyleselector.cpp index d11a95bd..72e7af66 100644 --- a/src/quickcontrols2/qquickstyleselector.cpp +++ b/src/quickcontrols2/qquickstyleselector.cpp @@ -48,7 +48,9 @@ QT_BEGIN_NAMESPACE -Q_LOGGING_CATEGORY(lcQtQuickControlsStyle, "qt.quick.controls.style") +Q_LOGGING_CATEGORY(lcStyleSelectorSelect, "qt.quick.controls.styleSelector.select") +Q_LOGGING_CATEGORY(lcStyleSelectorSetPaths, "qt.quick.controls.styleSelector.setPaths") +Q_LOGGING_CATEGORY(lcStyleSelectorAddSelector, "qt.quick.controls.styleSelector.addSelector") static QString ensureSlash(const QString &path) { @@ -112,6 +114,9 @@ void QQuickStyleSelector::addSelector(const QString &selector) return; d->selectors += selector; + + qCDebug(lcStyleSelectorSetPaths).nospace() << "added selector " << selector + << "; full list is now: " << d->selectors; } QStringList QQuickStyleSelector::paths() const @@ -123,6 +128,7 @@ QStringList QQuickStyleSelector::paths() const void QQuickStyleSelector::setPaths(const QStringList &paths) { Q_D(QQuickStyleSelector); + qCDebug(lcStyleSelectorSetPaths) << "setting paths to" << paths; d->paths = paths; } @@ -133,7 +139,7 @@ QUrl QQuickStyleSelector::select(const QString &fileName) const // 1) requested style (e.g. "MyStyle", included in d->selectors) // 2) fallback style (e.g. "Material", included in d->selectors) // 3) default style (empty selector, not in d->selectors) - qCDebug(lcQtQuickControlsStyle) << "selecting" << fileName << "from" << d->paths << "with selectors" << d->selectors; + qCDebug(lcStyleSelectorSelect) << "selecting" << fileName << "from" << d->paths << "with selectors" << d->selectors; int to = d->selectors.count() - 1; if (d->selectors.isEmpty() || !d->selectors.first().isEmpty()) @@ -145,7 +151,7 @@ QUrl QQuickStyleSelector::select(const QString &fileName) const for (const QString &path : d->paths) { const QUrl selectedUrl = d->select(ensureSlash(path) + selector + QLatin1Char('/') + fileName); if (selectedUrl.isValid()) { - qCDebug(lcQtQuickControlsStyle) << "==>" << selectedUrl << "from" << path << "with selector" << selector; + qCDebug(lcStyleSelectorSelect) << "==>" << selectedUrl << "from" << path << "with selector" << selector; return selectedUrl; } } diff --git a/src/quickcontrols2/qquicktumblerview.cpp b/src/quickcontrols2/qquicktumblerview.cpp index 4a64ad7f..eaa58032 100644 --- a/src/quickcontrols2/qquicktumblerview.cpp +++ b/src/quickcontrols2/qquicktumblerview.cpp @@ -316,3 +316,5 @@ QQuickItem *QQuickTumblerView::view() } QT_END_NAMESPACE + +#include "moc_qquicktumblerview_p.cpp" |