diff options
-rw-r--r-- | src/imports/controls/qtquickcontrols2plugin.cpp | 8 | ||||
-rw-r--r-- | tests/auto/qquickstyle/data/custom.conf | 4 | ||||
-rw-r--r-- | tests/auto/qquickstyle/data/default.conf | 4 | ||||
-rw-r--r-- | tests/auto/qquickstyle/data/fusion.conf | 4 | ||||
-rw-r--r-- | tests/auto/qquickstyle/data/imagine.conf | 4 | ||||
-rw-r--r-- | tests/auto/qquickstyle/data/material.conf | 4 | ||||
-rw-r--r-- | tests/auto/qquickstyle/data/universal.conf | 4 | ||||
-rw-r--r-- | tests/auto/qquickstyle/tst_qquickstyle.cpp | 17 |
8 files changed, 48 insertions, 1 deletions
diff --git a/src/imports/controls/qtquickcontrols2plugin.cpp b/src/imports/controls/qtquickcontrols2plugin.cpp index a03cbd06..5e9f253d 100644 --- a/src/imports/controls/qtquickcontrols2plugin.cpp +++ b/src/imports/controls/qtquickcontrols2plugin.cpp @@ -302,7 +302,15 @@ QQuickTheme *QtQuickControls2Plugin::createTheme(const QString &name) QSharedPointer<QSettings> settings = QQuickStylePrivate::settings(name); if (settings) { p->defaultFont.reset(QQuickStylePrivate::readFont(settings)); + // Set the default font as the System scope, because that's what + // QQuickControlPrivate::parentFont() uses as its fallback if no + // parent item has a font explicitly set. QQuickControlPrivate::parentFont() + // is used as the starting point for font inheritance/resolution. + // The same goes for palettes below. + theme->setFont(QQuickTheme::System, *p->defaultFont); + p->defaultPalette.reset(QQuickStylePrivate::readPalette(settings)); + theme->setPalette(QQuickTheme::System, *p->defaultPalette); } #endif QQuickThemePrivate::instance.reset(theme); diff --git a/tests/auto/qquickstyle/data/custom.conf b/tests/auto/qquickstyle/data/custom.conf index 4e17d1dc..2230b452 100644 --- a/tests/auto/qquickstyle/data/custom.conf +++ b/tests/auto/qquickstyle/data/custom.conf @@ -1,2 +1,6 @@ [Controls] Style=:/Custom + +[Custom] +Font\PixelSize=3 +Palette\WindowText=#ff0000 diff --git a/tests/auto/qquickstyle/data/default.conf b/tests/auto/qquickstyle/data/default.conf index caace6db..12ca5d8f 100644 --- a/tests/auto/qquickstyle/data/default.conf +++ b/tests/auto/qquickstyle/data/default.conf @@ -1,2 +1,6 @@ [Controls] Style=Default + +[Default] +Font\PixelSize=3 +Palette\WindowText=#ff0000 diff --git a/tests/auto/qquickstyle/data/fusion.conf b/tests/auto/qquickstyle/data/fusion.conf index 9cd14111..1f343e65 100644 --- a/tests/auto/qquickstyle/data/fusion.conf +++ b/tests/auto/qquickstyle/data/fusion.conf @@ -1,2 +1,6 @@ [Controls] Style=Fusion + +[Fusion] +Font\PixelSize=3 +Palette\WindowText=#ff0000 diff --git a/tests/auto/qquickstyle/data/imagine.conf b/tests/auto/qquickstyle/data/imagine.conf index add378d4..919bbcf0 100644 --- a/tests/auto/qquickstyle/data/imagine.conf +++ b/tests/auto/qquickstyle/data/imagine.conf @@ -1,2 +1,6 @@ [Controls] Style=Imagine + +[Imagine] +Font\PixelSize=3 +Palette\WindowText=#ff0000 diff --git a/tests/auto/qquickstyle/data/material.conf b/tests/auto/qquickstyle/data/material.conf index b6c7c87e..27c7931a 100644 --- a/tests/auto/qquickstyle/data/material.conf +++ b/tests/auto/qquickstyle/data/material.conf @@ -1,2 +1,6 @@ [Controls] Style=Material + +[Material] +Font\PixelSize=3 +Palette\WindowText=#ff0000 diff --git a/tests/auto/qquickstyle/data/universal.conf b/tests/auto/qquickstyle/data/universal.conf index 8c6dd807..a5ac3ca3 100644 --- a/tests/auto/qquickstyle/data/universal.conf +++ b/tests/auto/qquickstyle/data/universal.conf @@ -1,2 +1,6 @@ [Controls] Style=Universal + +[Universal] +Font\PixelSize=3 +Palette\WindowText=#ff0000 diff --git a/tests/auto/qquickstyle/tst_qquickstyle.cpp b/tests/auto/qquickstyle/tst_qquickstyle.cpp index 3f55bcfb..e99dad62 100644 --- a/tests/auto/qquickstyle/tst_qquickstyle.cpp +++ b/tests/auto/qquickstyle/tst_qquickstyle.cpp @@ -39,6 +39,7 @@ #include <QtQml/qqmlcomponent.h> #include <QtQuickControls2/qquickstyle.h> #include <QtQuickControls2/private/qquickstyle_p.h> +#include <QtQuickTemplates2/private/qquicklabel_p.h> #include <QtQuickTemplates2/private/qquicktheme_p.h> #include <QtGui/private/qguiapplication_p.h> @@ -133,11 +134,25 @@ void tst_QQuickStyle::configurationFile() qputenv("QT_QUICK_CONTROLS_CONF", testFile(fileName).toLocal8Bit()); - loadControls(); + // Load a control. The import causes the configuration file to be read. + QQmlEngine engine; + QQmlComponent labelComponent(&engine); + labelComponent.setData("import QtQuick 2.0; import QtQuick.Controls 2.12; Label {}", QUrl()); + + QScopedPointer<QObject> object(labelComponent.create()); + QVERIFY2(!object.isNull(), qPrintable(labelComponent.errorString())); QCOMPARE(QQuickStyle::name(), expectedStyle); if (!expectedPath.isEmpty()) QCOMPARE(QQuickStyle::path(), expectedPath); + + // Test that fonts and palettes specified in configuration files are respected. + QQuickLabel *label = qobject_cast<QQuickLabel *>(object.data()); + QVERIFY(label); + // Make it small so that there's less possibility for the default/system + // pixel size to match it and give us false positives. + QCOMPARE(label->font().pixelSize(), 3); + QCOMPARE(label->palette().windowText(), Qt::red); } void tst_QQuickStyle::commandLineArgument() |