on xenial help sign in
Add support for background color in StyleTool.
983e075Michał Sawicz
plugins/Dash/StyleTool.qml+3
@@ -35,4 +35,7 @@ QtObject {
35 /// Color used for text and symbolic icons
35 /// Color used for text and symbolic icons
36 // FIXME: should be taken from the theme
36 // FIXME: should be taken from the theme
37 readonly property color foreground: style && "foreground-color" in style ? style["foreground-color"] : "grey"
37 readonly property color foreground: style && "foreground-color" in style ? style["foreground-color"] : "grey"
38+
39+ /// Color used for text and symbolic icons
40+ readonly property color background: style && "background-color" in style ? style["background-color"] : "transparent"
38}
41}
tests/plugins/Dash/tst_StyleTool.qml+19−3
@@ -35,9 +35,9 @@ Rectangle {
35 property color color
35 property color color
36 property var styles: [
36 property var styles: [
37 {},
37 {},
38− { "foreground-color": "red" },
38+ { "foreground-color": "red", "background-color": "black" },
39− { "foreground-color": "green" },
39+ { "foreground-color": "green", "background-color": "white" },
40− { "foreground-color": "blue" },
40+ { "foreground-color": "blue", "background-color": "darkgrey" },
41 ]
41 ]
42
42
43 function cleanup() {
43 function cleanup() {
@@ -76,5 +76,21 @@ Rectangle {
76 verify(Qt.colorEqual(tool.foreground, data.foreground),
76 verify(Qt.colorEqual(tool.foreground, data.foreground),
77 "Foreground color not equal: %1 != %2".arg(tool.foreground).arg(data.foreground));
77 "Foreground color not equal: %1 != %2".arg(tool.foreground).arg(data.foreground));
78 }
78 }
79+
80+ function test_background_data() {
81+ return [
82+ { tag: "default", index: 0, background: "transparent" },
83+ { tag: "black", index: 1, background: "black" },
84+ { tag: "white", index: 2, background: "white" },
85+ { tag: "darkgrey", index: 3, background: "darkgrey" },
86+ ];
87+ }
88+
89+ function test_background(data) {
90+ tool.style = testCase.styles[data.index];
91+ verify(Qt.colorEqual(tool.background, data.background),
92+ "Background color not equal: %1 != %2".arg(tool.background).arg(data.background));
93+ }
94+
79 }
95 }
80}
96}