diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2017-05-09 15:40:45 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2017-05-31 09:07:01 +0000 |
commit | f2264e2684ebc5ff775515e6fcc358c68298ef3e (patch) | |
tree | 1e476570219c4fef7e3c6e1c15759ae7b4fc7d66 /tests/auto/qquickmaterialstyleconf | |
parent | 7d592bcbfb604b1179004e311aa6a972fab6707c (diff) |
Add support for configurable fonts
A style's default font is specified in qtquickcontrols2.conf in
a "Font" group under the style's section. QSettings supports the
following two alternative syntaxes:
[Default]
Font\Family=Open Sans
Font\PixelSize=20
or
[Default\Font]
Family=Open Sans
PixelSize=20
[ChangeLog][Controls] Added support for specifying the default
font for different styles in qtquickcontrols2.conf.
Change-Id: I54e1efb79a2913eab35174dbf09b6956fe740e28
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'tests/auto/qquickmaterialstyleconf')
-rw-r--r-- | tests/auto/qquickmaterialstyleconf/qtquickcontrols2.conf | 4 | ||||
-rw-r--r-- | tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp | 10 |
2 files changed, 12 insertions, 2 deletions
diff --git a/tests/auto/qquickmaterialstyleconf/qtquickcontrols2.conf b/tests/auto/qquickmaterialstyleconf/qtquickcontrols2.conf index 78634834..30cee878 100644 --- a/tests/auto/qquickmaterialstyleconf/qtquickcontrols2.conf +++ b/tests/auto/qquickmaterialstyleconf/qtquickcontrols2.conf @@ -4,3 +4,7 @@ Style=Material [Material] Background=#444444 Foreground=Red +Font\PixelSize=22 + +[Material\Font] +Family=Courier diff --git a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp index cc81afea..17d1ea6d 100644 --- a/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp +++ b/tests/auto/qquickmaterialstyleconf/tst_qquickmaterialstyleconf.cpp @@ -55,16 +55,22 @@ void tst_qquickmaterialstyleconf::conf() { QQuickApplicationHelper helper(this, QLatin1String("applicationwindow.qml")); + QFont customFont; + customFont.setFamily("Courier"); + customFont.setPixelSize(22); + QQuickApplicationWindow *window = helper.appWindow; window->show(); QVERIFY(QTest::qWaitForWindowExposed(window)); - // We specified a custom background color, so the window should have it. + // We specified a custom background color and font, so the window should have them. QCOMPARE(window->property("color").value<QColor>(), QColor("#444444")); + QCOMPARE(window->property("font").value<QFont>(), customFont); - // We specified a custom foreground color, so the label should have it. + // We specified a custom foreground color and font, so the label should have them. QQuickItem *label = window->property("label").value<QQuickItem*>(); QVERIFY(label); QCOMPARE(label->property("color").value<QColor>(), QColor("#F44336")); + QCOMPARE(label->property("font").value<QFont>(), customFont); } QTEST_MAIN(tst_qquickmaterialstyleconf) |