From f7c0efb42bd7f8b331525b42ec16536c1b4862f9 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 21 Mar 2017 16:42:51 +0100 Subject: Move settings from QQuickStyleAttached to QQuickStylePrivate The settings were added before QQuickStyle(Private) existed. Now QQuickStyle(Private) is a lot more logical place for the settings that are not specific to the attached style attributes only, but can be also determine which style is used etc. Change-Id: I7bc432c330d58ab501b51b0ee8eaf24697155324 Reviewed-by: Mitch Curtis --- src/quickcontrols2/qquickstyle.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/quickcontrols2/qquickstyle.cpp') diff --git a/src/quickcontrols2/qquickstyle.cpp b/src/quickcontrols2/qquickstyle.cpp index 184cbfc7..d4e72efb 100644 --- a/src/quickcontrols2/qquickstyle.cpp +++ b/src/quickcontrols2/qquickstyle.cpp @@ -36,11 +36,12 @@ #include "qquickstyle.h" #include "qquickstyle_p.h" -#include "qquickstyleattached_p.h" #include +#include #include #include +#include #include #include #include @@ -176,7 +177,7 @@ struct QQuickStyleSpec setFallbackStyle(QString::fromLatin1(qgetenv("QT_QUICK_CONTROLS_FALLBACK_STYLE")), "QT_QUICK_CONTROLS_FALLBACK_STYLE"); #if QT_CONFIG(settings) if (style.isEmpty() || fallbackStyle.isEmpty()) { - QSharedPointer settings = QQuickStyleAttached::settings(QStringLiteral("Controls")); + QSharedPointer settings = QQuickStylePrivate::settings(QStringLiteral("Controls")); if (settings) { if (style.isEmpty()) style = settings->value(QStringLiteral("Style")).toString(); @@ -313,6 +314,21 @@ QString QQuickStylePrivate::configFilePath() return styleSpec()->resolveConfigFilePath(); } +QSharedPointer QQuickStylePrivate::settings(const QString &group) +{ +#ifndef QT_NO_SETTINGS + const QString filePath = QQuickStylePrivate::configFilePath(); + if (QFile::exists(filePath)) { + QFileSelector selector; + QSettings *settings = new QSettings(selector.select(filePath), QSettings::IniFormat); + if (!group.isEmpty()) + settings->beginGroup(group); + return QSharedPointer(settings); + } +#endif // QT_NO_SETTINGS + return QSharedPointer(); +} + /*! Returns the name of the application style. -- cgit v1.2.3