diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2016-04-16 18:37:09 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-04-18 14:11:31 +0000 |
commit | b9c3f6b95e116354acc3f70c0811f4d2f4c68afe (patch) | |
tree | 3331ce65de4436f0f4ff98a7ae514efc18bc17eb /tests/auto/universal/data/tst_universal.qml | |
parent | 392d520ade77e6fb941e54fdaa8b23d34c745a8b (diff) |
Universal: add foreground and background attached properties
Same as b51e520f for Material.
This has been a common request on the mailing lists and forums. Users
want to customize the text color of various controls without having to
replace whole delegates. This change makes it possible to specify both
foreground (eg. Button text) and background (eg. ApplicationWindow,
Page and Pane background) colors so that they propagate to children in
the same way than accent and theme do.
Change-Id: I55084c58f0c62e8088b270ed98437241e382ca15
Reviewed-by: Mitch Curtis <mitch.curtis@theqtcompany.com>
Diffstat (limited to 'tests/auto/universal/data/tst_universal.qml')
-rw-r--r-- | tests/auto/universal/data/tst_universal.qml | 66 |
1 files changed, 45 insertions, 21 deletions
diff --git a/tests/auto/universal/data/tst_universal.qml b/tests/auto/universal/data/tst_universal.qml index d54a2fff..352a7b11 100644 --- a/tests/auto/universal/data/tst_universal.qml +++ b/tests/auto/universal/data/tst_universal.qml @@ -62,6 +62,8 @@ TestCase { Button { Universal.theme: Universal.Dark Universal.accent: Universal.Violet + Universal.foreground: Universal.Brown + Universal.background: Universal.Yellow } } @@ -139,6 +141,8 @@ TestCase { verify(control) verify(control.Universal) compare(control.Universal.accent, "#3e65ff") // Universal.Cobalt + compare(control.Universal.foreground, "#000000") // SystemBaseHighColor + compare(control.Universal.background, "#ffffff") // SystemAltHighColor compare(control.Universal.theme, Universal.Light) control.destroy() } @@ -147,8 +151,12 @@ TestCase { var control = button.createObject(testCase) verify(control) control.Universal.accent = Universal.Steel + control.Universal.foreground = Universal.Red + control.Universal.background = Universal.Green control.Universal.theme = Universal.Dark compare(control.Universal.accent, "#647687") // Universal.Steel + compare(control.Universal.foreground, "#e51400") // Universal.Red + compare(control.Universal.background, "#60a917") // Universal.Green compare(control.Universal.theme, Universal.Dark) control.destroy() } @@ -157,10 +165,16 @@ TestCase { var control = styledButton.createObject(testCase) verify(control) compare(control.Universal.accent, "#aa00ff") // Universal.Violet + compare(control.Universal.foreground, "#825a2c") // Universal.Brown + compare(control.Universal.background, "#e3c800") // Universal.Yellow compare(control.Universal.theme, Universal.Dark) control.Universal.accent = undefined + control.Universal.foreground = undefined + control.Universal.background = undefined control.Universal.theme = undefined compare(control.Universal.accent, testCase.Universal.accent) + compare(control.Universal.foreground, testCase.Universal.foreground) + compare(control.Universal.background, testCase.Universal.background) compare(control.Universal.theme, testCase.Universal.theme) control.destroy() } @@ -168,6 +182,8 @@ TestCase { function test_inheritance_data() { return [ { tag: "accent", value1: "#a20025" /*Universal.Crimson*/, value2: "#6a00ff" /*Universal.Indigo*/ }, + { tag: "foreground", value1: "#a20025" /*Universal.Crimson*/, value2: "#6a00ff" /*Universal.Indigo*/ }, + { tag: "background", value1: "#a20025" /*Universal.Crimson*/, value2: "#6a00ff" /*Universal.Indigo*/ }, { tag: "theme", value1: Universal.Dark, value2: Universal.Light }, ] } @@ -302,45 +318,53 @@ TestCase { window.destroy() } - function test_colors() { + function test_colors_data() { + return [ + { tag: "accent" }, { tag: "background" }, { tag: "foreground" } + ] + } + + function test_colors(data) { var control = button.createObject(testCase) verify(control) + var prop = data.tag + // Universal.Color - enum - control.Universal.accent = Universal.Red - compare(control.Universal.accent, "#e51400") + control.Universal[prop] = Universal.Red + compare(control.Universal[prop], "#e51400") // Universal.Color - string - control.Universal.accent = "Emerald" - compare(control.Universal.accent, "#008a00") + control.Universal[prop] = "Emerald" + compare(control.Universal[prop], "#008a00") // SVG named color - control.Universal.accent = "tomato" - compare(control.Universal.accent, "#ff6347") + control.Universal[prop] = "tomato" + compare(control.Universal[prop], "#ff6347") // #rrggbb - control.Universal.accent = "#123456" - compare(control.Universal.accent, "#123456") + control.Universal[prop] = "#123456" + compare(control.Universal[prop], "#123456") // #aarrggbb - control.Universal.accent = "#12345678" - compare(control.Universal.accent, "#12345678") + control.Universal[prop] = "#12345678" + compare(control.Universal[prop], "#12345678") // Qt.rgba() - no alpha - control.Universal.accent = Qt.rgba(0.5, 0.5, 0.5) - compare(control.Universal.accent, "#808080") + control.Universal[prop] = Qt.rgba(0.5, 0.5, 0.5) + compare(control.Universal[prop], "#808080") // Qt.rgba() - with alpha - control.Universal.accent = Qt.rgba(0.5, 0.5, 0.5, 0.5) - compare(control.Universal.accent, "#80808080") + control.Universal[prop] = Qt.rgba(0.5, 0.5, 0.5, 0.5) + compare(control.Universal[prop], "#80808080") // unknown - ignoreWarning(Qt.resolvedUrl("tst_universal.qml") + ":57:9: QML Button: unknown Universal.accent value: 123") - control.Universal.accent = 123 - ignoreWarning(Qt.resolvedUrl("tst_universal.qml") + ":57:9: QML Button: unknown Universal.accent value: foo") - control.Universal.accent = "foo" - ignoreWarning(Qt.resolvedUrl("tst_universal.qml") + ":57:9: QML Button: unknown Universal.accent value: #1") - control.Universal.accent = "#1" + ignoreWarning(Qt.resolvedUrl("tst_universal.qml") + ":57:9: QML Button: unknown Universal." + prop + " value: 123") + control.Universal[prop] = 123 + ignoreWarning(Qt.resolvedUrl("tst_universal.qml") + ":57:9: QML Button: unknown Universal." + prop + " value: foo") + control.Universal[prop] = "foo" + ignoreWarning(Qt.resolvedUrl("tst_universal.qml") + ":57:9: QML Button: unknown Universal." + prop + " value: #1") + control.Universal[prop] = "#1" control.destroy() } |