aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorMitch Curtis <mitch.curtis@qt.io>2019-01-25 14:04:28 +0100
committerMitch Curtis <mitch.curtis@qt.io>2019-02-04 11:03:30 +0000
commit32f05c5f5f5a580af0e0fe0964d71cf498ce391b (patch)
tree1e06cc9118a57c62f6ac77f6f654b3a943ae0fe2 /tests/auto
parentec8952cec9b44e7ab77c5450d8d6fb6579c21555 (diff)
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 <nils.jeisecke@saltation.com> Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/qquickstyle/data/custom.conf4
-rw-r--r--tests/auto/qquickstyle/data/default.conf4
-rw-r--r--tests/auto/qquickstyle/data/fusion.conf4
-rw-r--r--tests/auto/qquickstyle/data/imagine.conf4
-rw-r--r--tests/auto/qquickstyle/data/material.conf4
-rw-r--r--tests/auto/qquickstyle/data/universal.conf4
-rw-r--r--tests/auto/qquickstyle/tst_qquickstyle.cpp17
7 files changed, 40 insertions, 1 deletions
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()