diff options
-rw-r--r-- | examples/quick/extras/flat/main.cpp | 4 | ||||
-rw-r--r-- | src/controls/Private/qquickcontrolsettings.cpp | 14 | ||||
-rw-r--r-- | src/controls/doc/src/qtquickcontrolsstyles-index.qdoc | 6 | ||||
-rw-r--r-- | tests/auto/customcontrolsstyle/tst_customcontrolsstyle.cpp | 2 |
4 files changed, 17 insertions, 9 deletions
diff --git a/examples/quick/extras/flat/main.cpp b/examples/quick/extras/flat/main.cpp index a061d90b..dd90f807 100644 --- a/examples/quick/extras/flat/main.cpp +++ b/examples/quick/extras/flat/main.cpp @@ -56,8 +56,8 @@ int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); - if (qgetenv("QT_QUICK_CONTROLS_STYLE").isEmpty()) { - qputenv("QT_QUICK_CONTROLS_STYLE", "Flat"); + if (qgetenv("QT_QUICK_CONTROLS_1_STYLE").isEmpty()) { + qputenv("QT_QUICK_CONTROLS_1_STYLE", "Flat"); } QQmlApplicationEngine engine; engine.load(QUrl("qrc:/main.qml")); diff --git a/src/controls/Private/qquickcontrolsettings.cpp b/src/controls/Private/qquickcontrolsettings.cpp index 32efd332..8861296d 100644 --- a/src/controls/Private/qquickcontrolsettings.cpp +++ b/src/controls/Private/qquickcontrolsettings.cpp @@ -70,9 +70,17 @@ static QString defaultStyleName() return QLatin1String("Base"); } +static QString styleEnvironmentVariable() +{ + QString style = qgetenv("QT_QUICK_CONTROLS_1_STYLE"); + if (style.isEmpty()) + style = qgetenv("QT_QUICK_CONTROLS_STYLE"); + return style; +} + static QString styleImportName() { - QString name = qgetenv("QT_QUICK_CONTROLS_STYLE"); + QString name = styleEnvironmentVariable(); if (name.isEmpty()) name = defaultStyleName(); return QFileInfo(name).fileName(); @@ -174,7 +182,7 @@ static QString relativeStyleImportPath(QQmlEngine *engine, const QString &styleN static QString styleImportPath(QQmlEngine *engine, const QString &styleName) { - QString path = qgetenv("QT_QUICK_CONTROLS_STYLE"); + QString path = styleEnvironmentVariable(); QFileInfo info(path); if (fromResource(path)) { path = info.path(); @@ -209,7 +217,7 @@ QQuickControlSettings1::QQuickControlSettings1(QQmlEngine *engine) m_name = styleImportName(); // If the style name is a path.. - const QString styleNameFromEnvVar = qgetenv("QT_QUICK_CONTROLS_STYLE"); + const QString styleNameFromEnvVar = styleEnvironmentVariable(); if (QFile::exists(styleNameFromEnvVar)) { StyleData styleData; styleData.m_styleDirPath = styleNameFromEnvVar; diff --git a/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc b/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc index 956096d1..8a1c2ab0 100644 --- a/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc +++ b/src/controls/doc/src/qtquickcontrolsstyles-index.qdoc @@ -92,17 +92,17 @@ \section2 Selecting Styles You can apply a different style to the controls by setting the - \e QT_QUICK_CONTROLS_STYLE environment variable to the name of the style. + \e QT_QUICK_CONTROLS_1_STYLE environment variable to the name of the style. For example, to use the Flat style, you can do the following: \code - QT_QUICK_CONTROLS_STYLE=Flat ./app + QT_QUICK_CONTROLS_1_STYLE=Flat ./app \endcode This can also be done in C++, using qputenv(): \code - qputenv("QT_QUICK_CONTROLS_STYLE", "Flat"); + qputenv("QT_QUICK_CONTROLS_1_STYLE", "Flat"); \endcode \section1 Styling Views diff --git a/tests/auto/customcontrolsstyle/tst_customcontrolsstyle.cpp b/tests/auto/customcontrolsstyle/tst_customcontrolsstyle.cpp index 1df21391..ebd60d1e 100644 --- a/tests/auto/customcontrolsstyle/tst_customcontrolsstyle.cpp +++ b/tests/auto/customcontrolsstyle/tst_customcontrolsstyle.cpp @@ -69,7 +69,7 @@ void tst_customcontrolsstyle::style() QFETCH(QString, specifiedStyle); QFETCH(QString, expectedStyleName); - qputenv("QT_QUICK_CONTROLS_STYLE", specifiedStyle.toLocal8Bit()); + qputenv("QT_QUICK_CONTROLS_1_STYLE", specifiedStyle.toLocal8Bit()); const bool expectBase = expectedStyleName == QLatin1String("Base"); |