From 32f05c5f5f5a580af0e0fe0964d71cf498ce391b Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Fri, 25 Jan 2019 14:04:28 +0100 Subject: Fix font and palette settings in .conf files not being respected In 5.11, the font palette read from the qtquickcontrols2.conf file was respected. After some large architectural changes (around the time of 94780538) required to fix a crash, 5.12 stopped respecting these settings. This patch fixes the issue by setting the default font as the System scope font, 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 for each control. The same fix is used for palettes. Change-Id: I706a9f109c9959b8ea6b91f842146dbfc876cb2b Fixes: QTBUG-72023 Reviewed-by: Nils Jeisecke Reviewed-by: Frederik Gladhorn --- tests/auto/qquickstyle/data/custom.conf | 4 ++++ tests/auto/qquickstyle/data/default.conf | 4 ++++ tests/auto/qquickstyle/data/fusion.conf | 4 ++++ tests/auto/qquickstyle/data/imagine.conf | 4 ++++ tests/auto/qquickstyle/data/material.conf | 4 ++++ tests/auto/qquickstyle/data/universal.conf | 4 ++++ tests/auto/qquickstyle/tst_qquickstyle.cpp | 17 ++++++++++++++++- 7 files changed, 40 insertions(+), 1 deletion(-) (limited to 'tests/auto') 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 #include #include +#include #include #include @@ -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 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(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() -- cgit v1.2.3