on xenial help sign in
Add support for header logo in StyleTool.
b127c93Michał Sawicz
plugins/Dash/StyleTool.qml+5
@@ -67,6 +67,9 @@ QtObject {
67 return d.foregroundLuminance < d.backgroundLuminance ? foreground : background;
67 return d.foregroundLuminance < d.backgroundLuminance ? foreground : background;
68 }
68 }
69
69
70+ /// Source of the logo image for the header
71+ readonly property url headerLogo: "logo" in d.headerStyle ? d.headerStyle["logo"] : ""
72+
70 //! @cond
73 //! @cond
71 property var d: QtObject {
74 property var d: QtObject {
72 readonly property real foregroundLuminance: luminance(foreground)
75 readonly property real foregroundLuminance: luminance(foreground)
@@ -77,6 +80,8 @@ QtObject {
77 readonly property color defaultDark: "grey"
80 readonly property color defaultDark: "grey"
78 readonly property real defaultLightLuminance: luminance(defaultLight)
81 readonly property real defaultLightLuminance: luminance(defaultLight)
79 readonly property real defaultDarkLuminance: luminance(defaultDark)
82 readonly property real defaultDarkLuminance: luminance(defaultDark)
83+
84+ readonly property var headerStyle: "page-header" in style ? style["page-header"] : { }
80 }
85 }
81 //! @endcond
86 //! @endcond
82}
87}
tests/plugins/Dash/tst_StyleTool.qml+12−1
@@ -35,7 +35,7 @@ Rectangle {
35 property color color
35 property color color
36 property var styles: [
36 property var styles: [
37 {},
37 {},
38− { "foreground-color": "red", "background-color": "black" },
38+ { "foreground-color": "red", "background-color": "black", "page-header": { "logo": "/foo/bar" } },
39 { "foreground-color": "green", "background-color": "white" },
39 { "foreground-color": "green", "background-color": "white" },
40 { "foreground-color": "blue", "background-color": "darkgrey" },
40 { "foreground-color": "blue", "background-color": "darkgrey" },
41 ]
41 ]
@@ -136,5 +136,16 @@ Rectangle {
136 "Dark color not equal: %1 != %2".arg(tool.dark).arg(data.dark));
136 "Dark color not equal: %1 != %2".arg(tool.dark).arg(data.dark));
137 }
137 }
138
138
139+ function test_headerLogo_data() {
140+ return [
141+ { tag: "default", index: 0, headerLogo: "" },
142+ { tag: "with logo", index: 1, headerLogo: "file:///foo/bar" },
143+ ];
144+ }
145+
146+ function test_headerLogo(data) {
147+ tool.style = testCase.styles[data.index];
148+ compare(tool.headerLogo, data.headerLogo, "Header logo was incorrect.");
149+ }
139 }
150 }
140}
151}