From 56bddc7fa4b0222d38fcc5e083b9588c3d2f8b93 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Thu, 22 Sep 2016 13:57:42 +0200 Subject: Let QT_QUICK_CONTROLS_CONF override :/qtquickcontrols2.conf This is an undocumented feature mainly for tooling purposes. This way tooling can make sure that qmlpuppet uses the same configuration as the application when displaying a form in the Qt Quick Designer. Change-Id: If46055f09049118f1f49c350c74d5aab501a0378 Reviewed-by: Thomas Hartmann --- src/quickcontrols2/qquickstyleattached.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/quickcontrols2/qquickstyleattached.cpp b/src/quickcontrols2/qquickstyleattached.cpp index d0df79c5..cdfa902e 100644 --- a/src/quickcontrols2/qquickstyleattached.cpp +++ b/src/quickcontrols2/qquickstyleattached.cpp @@ -146,6 +146,18 @@ static QList findChildStyles(const QMetaObject *type, QOb return children; } +static QString resolveConfigFile() +{ + QString filePath = QFile::decodeName(qgetenv("QT_QUICK_CONTROLS_CONF")); + if (!QFile::exists(filePath)) { + if (!filePath.isEmpty()) + qWarning("QT_QUICK_CONTROLS_CONF=%s: No such file", qPrintable(filePath)); + + filePath = QStringLiteral(":/qtquickcontrols2.conf"); + } + return filePath; +} + QQuickStyleAttached::QQuickStyleAttached(QObject *parent) : QObject(parent) { QQuickItem *item = qobject_cast(parent); @@ -175,7 +187,7 @@ QQuickStyleAttached::~QQuickStyleAttached() QSharedPointer QQuickStyleAttached::settings(const QString &group) { #ifndef QT_NO_SETTINGS - const QString filePath = QStringLiteral(":/qtquickcontrols2.conf"); + static const QString filePath = resolveConfigFile(); if (QFile::exists(filePath)) { QFileSelector selector; QSettings *settings = new QSettings(selector.select(filePath), QSettings::IniFormat); -- cgit v1.2.3