on xenial help sign in
Add support for header logo in StyleTool.
commitb127c9345450cc20677cbde417dec004a87fa51b authorMichał Sawicz <michal.sawicz@canonical.com> dateMon 7 Jul 2014, 00:05 (12 years ago) parent8431052
2 files changed+17−1
plugins/Dash/StyleTool.qml+5 tests/plugins/Dash/tst_StyleTool.qml+12−1
plugins/Dash/StyleTool.qml+5
@@ -67,6 +67,9 @@ QtObject {
6767 return d.foregroundLuminance < d.backgroundLuminance ? foreground : background;
6868 }
6969
70+ /// Source of the logo image for the header
71+ readonly property url headerLogo: "logo" in d.headerStyle ? d.headerStyle["logo"] : ""
72+
7073 //! @cond
7174 property var d: QtObject {
7275 readonly property real foregroundLuminance: luminance(foreground)
@@ -77,6 +80,8 @@ QtObject {
7780 readonly property color defaultDark: "grey"
7881 readonly property real defaultLightLuminance: luminance(defaultLight)
7982 readonly property real defaultDarkLuminance: luminance(defaultDark)
83+
84+ readonly property var headerStyle: "page-header" in style ? style["page-header"] : { }
8085 }
8186 //! @endcond
8287}
tests/plugins/Dash/tst_StyleTool.qml+12−1
@@ -35,7 +35,7 @@ Rectangle {
3535 property color color
3636 property var styles: [
3737 {},
38− { "foreground-color": "red", "background-color": "black" },
38+ { "foreground-color": "red", "background-color": "black", "page-header": { "logo": "/foo/bar" } },
3939 { "foreground-color": "green", "background-color": "white" },
4040 { "foreground-color": "blue", "background-color": "darkgrey" },
4141 ]
@@ -136,5 +136,16 @@ Rectangle {
136136 "Dark color not equal: %1 != %2".arg(tool.dark).arg(data.dark));
137137 }
138138
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+ }
139150 }
140151}