on xenial help sign in
Transition from fore/backgroundColor to StyleTool.
6c03f35Michał Sawicz
plugins/Dash/CardCreator.js+4−4
@@ -289,7 +289,7 @@ function cardString(template, components) {
289 property var cardData; \n\
289 property var cardData; \n\
290 property var artShapeBorderSource: undefined; \n\
290 property var artShapeBorderSource: undefined; \n\
291 property real fontScale: 1.0; \n\
291 property real fontScale: 1.0; \n\
292− property color foregroundColor: "grey"; \n\
292+ property var styleTool: Object({ foreground: "grey" }) \n\
293 property int headerAlignment: Text.AlignLeft; \n\
293 property int headerAlignment: Text.AlignLeft; \n\
294 property int fixedHeaderHeight: -1; \n\
294 property int fixedHeaderHeight: -1; \n\
295 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
295 property size fixedArtShapeSize: Qt.size(-1, -1); \n\
@@ -408,7 +408,7 @@ function cardString(template, components) {
408 mascotCode = kMascotImageCode.arg(anchors).arg(mascotImageVisible);
408 mascotCode = kMascotImageCode.arg(anchors).arg(mascotImageVisible);
409 }
409 }
410
410
411− var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : root.foregroundColor';
411+ var summaryColorWithBackground = 'backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : root.styleTool.foreground';
412
412
413 var titleSubtitleCode = "";
413 var titleSubtitleCode = "";
414 if (hasTitle) {
414 if (hasTitle) {
@@ -420,7 +420,7 @@ function cardString(template, components) {
420 } else if (hasBackground) {
420 } else if (hasBackground) {
421 color = summaryColorWithBackground;
421 color = summaryColorWithBackground;
422 } else {
422 } else {
423− color = 'root.foregroundColor';
423+ color = 'root.styleTool.foreground';
424 }
424 }
425
425
426 var titleAnchors;
426 var titleAnchors;
@@ -496,7 +496,7 @@ function cardString(template, components) {
496 if (hasBackground) {
496 if (hasBackground) {
497 color = summaryColorWithBackground;
497 color = summaryColorWithBackground;
498 } else {
498 } else {
499− color = 'root.foregroundColor';
499+ color = 'root.styleTool.foreground';
500 }
500 }
501
501
502 var summaryTopMargin = (hasMascot || hasSubtitle ? 'anchors.margins' : '0');
502 var summaryTopMargin = (hasMascot || hasSubtitle ? 'anchors.margins' : '0');
qml/Components/PageHeader.qml+20−13
@@ -27,7 +27,6 @@ Item {
27
27
28 property bool showBackButton: false
28 property bool showBackButton: false
29 property string title
29 property string title
30− property string imageSource
31
30
32 property bool searchEntryEnabled: false
31 property bool searchEntryEnabled: false
33 property ListModel searchHistory: SearchHistoryModel
32 property ListModel searchHistory: SearchHistoryModel
@@ -35,13 +34,19 @@ Item {
35 property bool searchInProgress: false
34 property bool searchInProgress: false
36
35
37 property alias bottomItem: bottomContainer.children
36 property alias bottomItem: bottomContainer.children
37+
38− // TODO We should use foregroundColor for the icons
38+ // TODO We should use foreground for the icons
39 // of the toolbar but unfortunately Action does not have
39 // of the toolbar but unfortunately Action does not have
40 // the keyColor property as Icon does :-/
40 // the keyColor property as Icon does :-/
41− property color foregroundColor: "gray"
41+ property var styleTool: QtObject {
42+ readonly property color foreground: "grey"
43+ readonly property url headerLogo: ""
44+ }
42
45
43 signal backClicked()
46 signal backClicked()
44
47
48+ onStyleToolChanged: refreshLogo()
49+
45 function triggerSearch() {
50 function triggerSearch() {
46 if (searchEntryEnabled) {
51 if (searchEntryEnabled) {
47 headerContainer.showSearch = true;
52 headerContainer.showSearch = true;
@@ -82,15 +87,20 @@ Item {
82 }
87 }
83 }
88 }
84
89
85− onImageSourceChanged: {
90+ function refreshLogo() {
86− if (imageSource) {
91+ if (styleTool.headerLogo != "") {
87 header.contents = imageComponent.createObject();
92 header.contents = imageComponent.createObject();
88− } else {
93+ } else if (header.contents) {
89 header.contents.destroy();
94 header.contents.destroy();
90 header.contents = null;
95 header.contents = null;
91 }
96 }
92 }
97 }
93
98
99+ Connections {
100+ target: styleTool
101+ onHeaderLogoChanged: root.refreshLogo()
102+ }
103+
94 InverseMouseArea {
104 InverseMouseArea {
95 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
105 anchors { fill: parent; margins: units.gu(1); bottomMargin: units.gu(3) + bottomContainer.height }
96 visible: headerContainer.showSearch
106 visible: headerContainer.showSearch
@@ -216,7 +226,7 @@ Item {
216 height: headerContainer.height
226 height: headerContainer.height
217 contentHeight: height
227 contentHeight: height
218 separatorSource: ""
228 separatorSource: ""
219− textColor: root.foregroundColor
229+ textColor: root.styleTool.foreground
220 property var styledItem: header
230 property var styledItem: header
221 property string title: root.title
231 property string title: root.title
222 property var config: PageHeadConfiguration {
232 property var config: PageHeadConfiguration {
@@ -241,11 +251,8 @@ Item {
241 }
251 }
242
252
243 property var contents: null
253 property var contents: null
244− Component.onCompleted: {
254+ Component.onCompleted: root.refreshLogo()
245− if (root.imageSource) {
255+
246− header.contents = imageComponent.createObject();
247− }
248− }
249 Component {
256 Component {
250 id: imageComponent
257 id: imageComponent
251
258
@@ -255,7 +262,7 @@ Item {
255 Image {
262 Image {
256 objectName: "titleImage"
263 objectName: "titleImage"
257 anchors.fill: parent
264 anchors.fill: parent
258− source: root.imageSource
265+ source: root.styleTool.headerLogo
259 fillMode: Image.PreserveAspectFit
266 fillMode: Image.PreserveAspectFit
260 horizontalAlignment: Image.AlignLeft
267 horizontalAlignment: Image.AlignLeft
261 sourceSize.height: height
268 sourceSize.height: height
qml/Dash/CardCarousel.qml+1−1
@@ -64,7 +64,7 @@ DashRenderer {
64 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
64 item.fontScale = Qt.binding(function() { return carousel.fontScale; });
65 item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
65 item.showHeader = Qt.binding(function() { return loader.explicitlyScaled; });
66 item.artShapeBorderSource = "none";
66 item.artShapeBorderSource = "none";
67− item.foregroundColor = Qt.binding(function() { return cardCarousel.foregroundColor; });
67+ item.styleTool = cardCarousel.styleTool;
68 }
68 }
69
69
70 BorderImage {
70 BorderImage {
qml/Dash/CardFilterGrid.qml+1−1
@@ -58,7 +58,7 @@ DashRenderer {
58 item.template = Qt.binding(function() { return cardTool.template; });
58 item.template = Qt.binding(function() { return cardTool.template; });
59 item.components = Qt.binding(function() { return cardTool.components; });
59 item.components = Qt.binding(function() { return cardTool.components; });
60 item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
60 item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
61− item.foregroundColor = Qt.binding(function() { return genericFilterGrid.foregroundColor; });
61+ item.styleTool = genericFilterGrid.styleTool;
62 }
62 }
63 Connections {
63 Connections {
64 target: loader.item
64 target: loader.item
qml/Dash/CardVerticalJournal.qml+1−1
@@ -75,7 +75,7 @@ DashRenderer {
75 item.template = Qt.binding(function() { return cardTool.template; });
75 item.template = Qt.binding(function() { return cardTool.template; });
76 item.components = Qt.binding(function() { return cardTool.components; });
76 item.components = Qt.binding(function() { return cardTool.components; });
77 item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
77 item.headerAlignment = Qt.binding(function() { return cardTool.headerAlignment; });
78− item.foregroundColor = Qt.binding(function() { return root.foregroundColor; });
78+ item.styleTool = root.styleTool;
79 }
79 }
80 Connections {
80 Connections {
81 target: loader.item
81 target: loader.item
qml/Dash/DashDepartments.qml+4−6
@@ -29,8 +29,7 @@ AbstractButton {
29
29
30 property alias windowWidth: blackRect.width
30 property alias windowWidth: blackRect.width
31 property alias windowHeight: blackRect.height
31 property alias windowHeight: blackRect.height
32− property color backgroundColor: "white"
32+ property var styleTool: { foreground: "grey" }
33− property color foregroundColor: "gray"
34
33
35 // Are we drilling down the tree or up?
34 // Are we drilling down the tree or up?
36 property bool isGoingBack: false
35 property bool isGoingBack: false
@@ -80,7 +79,7 @@ AbstractButton {
80 anchors.margins: units.gu(2)
79 anchors.margins: units.gu(2)
81 verticalAlignment: Text.AlignVCenter
80 verticalAlignment: Text.AlignVCenter
82 text: root.currentDepartment ? root.currentDepartment.label : ""
81 text: root.currentDepartment ? root.currentDepartment.label : ""
83− color: root.foregroundColor
82+ color: root.styleTool.foreground
84 }
83 }
85
84
86 Icon {
85 Icon {
@@ -90,7 +89,7 @@ AbstractButton {
90 name: showList ? "up" : "down"
89 name: showList ? "up" : "down"
91 height: units.gu(2)
90 height: units.gu(2)
92 width: height
91 width: height
93− color: root.foregroundColor
92+ color: root.styleTool.foreground
94 }
93 }
95
94
96 // departmentListView is outside root
95 // departmentListView is outside root
@@ -125,8 +124,7 @@ AbstractButton {
125 objectName: "department" + index
124 objectName: "department" + index
126 visible: height != 0
125 visible: height != 0
127 width: departmentListView.width
126 width: departmentListView.width
128− backgroundColor: root.backgroundColor
127+ styleTool: root.styleTool
129− foregroundColor: root.foregroundColor
130 property real desiredHeight: {
128 property real desiredHeight: {
131 if (root.showList) {
129 if (root.showList) {
132 if (department && department.loaded && x == departmentListView.contentX)
130 if (department && department.loaded && x == departmentListView.contentX)
qml/Dash/DashDepartmentsList.qml+10−11
@@ -21,8 +21,7 @@ Item {
21 id: root
21 id: root
22 property var department: null
22 property var department: null
23 property var currentDepartment: null
23 property var currentDepartment: null
24− property color foregroundColor: "gray"
24+ property var styleTool: Object({ foreground: "grey", background: "transparent" })
25− property color backgroundColor: "white"
26 signal enterDepartment(var newDepartmentId, bool hasChildren)
25 signal enterDepartment(var newDepartmentId, bool hasChildren)
27 signal goBackToParentClicked()
26 signal goBackToParentClicked()
28 signal allDepartmentClicked()
27 signal allDepartmentClicked()
@@ -31,7 +30,7 @@ Item {
31 implicitHeight: flickable.contentHeight
30 implicitHeight: flickable.contentHeight
32
31
33 Rectangle {
32 Rectangle {
34− color: root.backgroundColor
33+ color: Qt.colorEqual(root.styleTool.background, "transparent") ? "white" : root.styleTool.background
35 anchors.fill: parent
34 anchors.fill: parent
36 }
35 }
37
36
@@ -83,7 +82,7 @@ Item {
83 name: "back"
82 name: "back"
84 height: units.gu(2)
83 height: units.gu(2)
85 width: height
84 width: height
86− color: root.foregroundColor
85+ color: root.styleTool.foreground
87 }
86 }
88
87
89 Label {
88 Label {
@@ -93,7 +92,7 @@ Item {
93 leftMargin: units.gu(0.5)
92 leftMargin: units.gu(0.5)
94 }
93 }
95 text: department ? department.parentLabel : ""
94 text: department ? department.parentLabel : ""
96− color: root.foregroundColor
95+ color: root.styleTool.foreground
97 }
96 }
98
97
99 Rectangle {
98 Rectangle {
@@ -104,7 +103,7 @@ Item {
104 leftMargin: units.gu(2)
103 leftMargin: units.gu(2)
105 rightMargin: units.gu(2)
104 rightMargin: units.gu(2)
106 }
105 }
107− color: root.foregroundColor
106+ color: root.styleTool.foreground
108 opacity: 0.2
107 opacity: 0.2
109 height: units.dp(1)
108 height: units.dp(1)
110 }
109 }
@@ -125,7 +124,7 @@ Item {
125 }
124 }
126 text: department ? (department.allLabel != "" ? department.allLabel : department.label) : ""
125 text: department ? (department.allLabel != "" ? department.allLabel : department.label) : ""
127 font.bold: true
126 font.bold: true
128− color: root.foregroundColor
127+ color: root.styleTool.foreground
129 }
128 }
130
129
131 Rectangle {
130 Rectangle {
@@ -136,7 +135,7 @@ Item {
136 leftMargin: units.gu(2)
135 leftMargin: units.gu(2)
137 rightMargin: units.gu(2)
136 rightMargin: units.gu(2)
138 }
137 }
139− color: root.foregroundColor
138+ color: root.styleTool.foreground
140 opacity: 0.2
139 opacity: 0.2
141 height: units.dp(1)
140 height: units.dp(1)
142 }
141 }
@@ -161,7 +160,7 @@ Item {
161 leftMargin: units.gu(2)
160 leftMargin: units.gu(2)
162 }
161 }
163 text: label
162 text: label
164− color: root.foregroundColor
163+ color: root.styleTool.foreground
165 }
164 }
166
165
167 Icon {
166 Icon {
@@ -173,7 +172,7 @@ Item {
173 height: units.gu(2)
172 height: units.gu(2)
174 width: height
173 width: height
175 name: hasChildren ? "go-next" : "tick"
174 name: hasChildren ? "go-next" : "tick"
176− color: root.foregroundColor
175+ color: root.styleTool.foreground
177 visible: hasChildren || isActive
176 visible: hasChildren || isActive
178 }
177 }
179
178
@@ -185,7 +184,7 @@ Item {
185 leftMargin: units.gu(2)
184 leftMargin: units.gu(2)
186 rightMargin: units.gu(2)
185 rightMargin: units.gu(2)
187 }
186 }
188− color: root.foregroundColor
187+ color: root.styleTool.foreground
189 opacity: 0.1
188 opacity: 0.1
190 height: units.dp(1)
189 height: units.dp(1)
191 visible: index != department.count - 1
190 visible: index != department.count - 1
qml/Dash/DashRenderer.qml+5−6
@@ -33,15 +33,14 @@ Item {
33
33
34 property real originY: 0
34 property real originY: 0
35
35
36− property color foregroundColor: "gray"
37−
38 // The model to renderer
36 // The model to renderer
39 property var model
37 property var model
40
38
41− /*!
42− \brief CardTool component.
39+ /// CardTool component.
43− */
44− property var cardTool: undefined
40+ property var cardTool: null
41+
42+ /// StyleTool component.
43+ property var styleTool: null
45
44
46 /// Emitted when the user clicked on an item
45 /// Emitted when the user clicked on an item
47 /// @param index is the index of the clicked item
46 /// @param index is the index of the clicked item
qml/Dash/GenericScopeView.qml+11−10
@@ -19,6 +19,7 @@ import Ubuntu.Components 0.1
19import Utils 0.1
19import Utils 0.1
20import Unity 0.2
20import Unity 0.2
21import Unity.Application 0.1
21import Unity.Application 0.1
22+import Dash 0.1
22import "../Components"
23import "../Components"
23import "../Components/ListItems" as ListItems
24import "../Components/ListItems" as ListItems
24
25
@@ -33,9 +34,10 @@ FocusScope {
33 property bool hasBackAction: false
34 property bool hasBackAction: false
34 property bool enableHeightBehaviorOnNextCreation: false
35 property bool enableHeightBehaviorOnNextCreation: false
35 property var categoryView: categoryView
36 property var categoryView: categoryView
36− // TODO Should be taken from the theme
37+
37− property color foregroundColor: scope && scope.customizations["foreground-color"] || "grey"
38+ property var styleTool: StyleTool {
38− property color backgroundColor: scope && scope.customizations["background-color"] || "transparent"
39+ style: scope ? scope.customizations : {}
40+ }
39
41
40 signal backClicked()
42 signal backClicked()
41
43
@@ -103,7 +105,7 @@ FocusScope {
103
105
104 Rectangle {
106 Rectangle {
105 anchors.fill: parent
107 anchors.fill: parent
106− color: scopeView.backgroundColor
108+ color: scopeView.styleTool.background
107 visible: color != "transparent"
109 visible: color != "transparent"
108 }
110 }
109
111
@@ -174,7 +176,7 @@ FocusScope {
174 item.model = Qt.binding(function() { return results })
176 item.model = Qt.binding(function() { return results })
175 }
177 }
176 item.objectName = Qt.binding(function() { return categoryId })
178 item.objectName = Qt.binding(function() { return categoryId })
177− item.foregroundColor = Qt.binding(function() { return scopeView.foregroundColor })
179+ item.styleTool = scopeView.styleTool;
178 if (item.expandable) {
180 if (item.expandable) {
179 var shouldFilter = categoryId != categoryView.expandedCategoryId;
181 var shouldFilter = categoryId != categoryView.expandedCategoryId;
180 item.setFilter(shouldFilter, false /*animate*/);
182 item.setFilter(shouldFilter, false /*animate*/);
@@ -314,7 +316,7 @@ FocusScope {
314 property var delegate: categoryView.item(delegateIndex)
316 property var delegate: categoryView.item(delegateIndex)
315 width: categoryView.width
317 width: categoryView.width
316 text: section
318 text: section
317− textColor: foregroundColor
319+ textColor: styleTool.foreground
318 image: {
320 image: {
319 if (delegate && delegate.expandable)
321 if (delegate && delegate.expandable)
320 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
322 return delegate.filtered ? "graphics/header_handlearrow.png" : "graphics/header_handlearrow2.png"
@@ -335,8 +337,7 @@ FocusScope {
335 showBackButton: scopeView.hasBackAction
337 showBackButton: scopeView.hasBackAction
336 searchEntryEnabled: true
338 searchEntryEnabled: true
337 searchInProgress: scopeView.scope ? scopeView.scope.searchInProgress : false
339 searchInProgress: scopeView.scope ? scopeView.scope.searchInProgress : false
338− foregroundColor: scopeView.foregroundColor
340+ styleTool: scopeView.styleTool
339− imageSource: scopeView.scope && scopeView.scope.customizations["page-header"] && scopeView.scope.customizations["page-header"]["logo"] || ""
340
341
341 bottomItem: DashDepartments {
342 bottomItem: DashDepartments {
342 scope: scopeView.scope
343 scope: scopeView.scope
@@ -344,8 +345,7 @@ FocusScope {
344 anchors.right: parent.right
345 anchors.right: parent.right
345 windowHeight: scopeView.height
346 windowHeight: scopeView.height
346 windowWidth: scopeView.width
347 windowWidth: scopeView.width
347− foregroundColor: scopeView.foregroundColor
348+ styleTool: scopeView.styleTool
348− backgroundColor: scopeView.backgroundColor === Qt.rgba(0, 0, 0, 0) ? "white" : scopeView.backgroundColor
349 }
349 }
350
350
351 onBackClicked: scopeView.backClicked()
351 onBackClicked: scopeView.backClicked()
@@ -357,6 +357,7 @@ FocusScope {
357 objectName: "previewListView"
357 objectName: "previewListView"
358 visible: x != width
358 visible: x != width
359 scope: scopeView.scope
359 scope: scopeView.scope
360+ styleTool: scopeView.styleTool
360 width: parent.width
361 width: parent.width
361 height: parent.height
362 height: parent.height
362 anchors.left: categoryView.right
363 anchors.left: categoryView.right
qml/Dash/PreviewListView.qml+3
@@ -24,6 +24,7 @@ Item {
24 id: root
24 id: root
25
25
26 property var scope: null
26 property var scope: null
27+ property var styleTool: null
27
28
28 property alias open: previewListView.open
29 property alias open: previewListView.open
29 property alias model: previewListView.model
30 property alias model: previewListView.model
@@ -38,6 +39,7 @@ Item {
38 title: scope ? scope.name : ""
39 title: scope ? scope.name : ""
39 showBackButton: true
40 showBackButton: true
40 searchEntryEnabled: false
41 searchEntryEnabled: false
42+ styleTool: root.styleTool
41
43
42 onBackClicked: root.open = false
44 onBackClicked: root.open = false
43 }
45 }
@@ -101,6 +103,7 @@ Item {
101 var previewStack = root.scope.preview(result);
103 var previewStack = root.scope.preview(result);
102 return previewStack.getPreviewModel(0);
104 return previewStack.getPreviewModel(0);
103 }
105 }
106+ styleTool: root.styleTool
104 }
107 }
105
108
106 MouseArea {
109 MouseArea {
qml/Dash/Previews/Preview.qml+3
@@ -36,6 +36,9 @@ Item {
36 //! \brief Should be set to true if this preview is currently displayed.
36 //! \brief Should be set to true if this preview is currently displayed.
37 property bool isCurrent: false
37 property bool isCurrent: false
38
38
39+ //! \brief The StyleTool component.
40+ property var styleTool: null
41+
39 clip: true
42 clip: true
40
43
41 Binding {
44 Binding {
qml/Dash/Previews/PreviewWidgetFactory.qml+3
@@ -31,6 +31,9 @@ Loader {
31 //! Widget data, forwarded to the widget as is.
31 //! Widget data, forwarded to the widget as is.
32 property var widgetData: null
32 property var widgetData: null
33
33
34+ //! The StyleTool component.
35+ property var styleTool: null
36+
34 //! Set to true if the parent preview is displayed.
37 //! Set to true if the parent preview is displayed.
35 property bool isCurrentPreview: false
38 property bool isCurrentPreview: false
36
39
tests/mocks/Unity/fake_scope.cpp+3−1
@@ -14,6 +14,8 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
15 */
16
16
17+#include <QUrl>
18+
17#include "fake_scope.h"
19#include "fake_scope.h"
18#include "fake_department.h"
20#include "fake_department.h"
19#include "fake_resultsmodel.h"
21#include "fake_resultsmodel.h"
@@ -163,7 +165,7 @@ QVariantMap Scope::customizations() const
163 m["foreground-color"] = "blue";
165 m["foreground-color"] = "blue";
164 } else if (m_id == "MockScope5") {
166 } else if (m_id == "MockScope5") {
165 QVariantMap pageHeader;
167 QVariantMap pageHeader;
166− pageHeader["logo"] = "../../tests/qmltests/Components/tst_PageHeader/logo-ubuntu-orange.svg";
168+ pageHeader["logo"] = QUrl("../../../tests/qmltests/Components/tst_PageHeader/logo-ubuntu-orange.svg");
167 m["page-header"] = pageHeader;
169 m["page-header"] = pageHeader;
168 }
170 }
169 return m;
171 return m;
tests/plugins/Dash/cardcreator/1.res+2−2
@@ -5,7 +5,7 @@ AbstractButton {
5 property var cardData;
5 property var cardData;
6 property var artShapeBorderSource: undefined;
6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8− property color foregroundColor: "grey";
8+ property var styleTool: Object({ foreground: "grey" })
9 property int headerAlignment: Text.AlignLeft;
9 property int headerAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1;
10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1);
11 property size fixedArtShapeSize: Qt.size(-1, -1);
@@ -76,7 +76,7 @@ leftMargin: units.gu(1);
76 wrapMode: Text.Wrap;
76 wrapMode: Text.Wrap;
77 maximumLineCount: 2;
77 maximumLineCount: 2;
78 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
78 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
79− color: root.foregroundColor;
79+ color: root.styleTool.foreground;
80 visible: showHeader ;
80 visible: showHeader ;
81 text: root.title;
81 text: root.title;
82 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
82 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
tests/plugins/Dash/cardcreator/2.res+3−3
@@ -5,7 +5,7 @@ AbstractButton {
5 property var cardData;
5 property var cardData;
6 property var artShapeBorderSource: undefined;
6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8− property color foregroundColor: "grey";
8+ property var styleTool: Object({ foreground: "grey" })
9 property int headerAlignment: Text.AlignLeft;
9 property int headerAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1;
10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1);
11 property size fixedArtShapeSize: Qt.size(-1, -1);
@@ -88,7 +88,7 @@ Column {
88 wrapMode: Text.Wrap;
88 wrapMode: Text.Wrap;
89 maximumLineCount: 2;
89 maximumLineCount: 2;
90 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
90 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
91− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : root.foregroundColor;
91+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : root.styleTool.foreground;
92 visible: showHeader ;
92 visible: showHeader ;
93 text: root.title;
93 text: root.title;
94 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
94 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
@@ -103,7 +103,7 @@ Label {
103 elide: Text.ElideRight;
103 elide: Text.ElideRight;
104 fontSize: "small";
104 fontSize: "small";
105 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
105 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
106− color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : root.foregroundColor;
106+ color: backgroundLoader.active && backgroundLoader.item && backgroundLoader.item.luminance < 0.7 ? "white" : root.styleTool.foreground;
107 visible: titleLabel.visible && titleLabel.text;
107 visible: titleLabel.visible && titleLabel.text;
108 text: cardData && cardData["subtitle"] || "";
108 text: cardData && cardData["subtitle"] || "";
109 font.weight: Font.Light;
109 font.weight: Font.Light;
tests/plugins/Dash/cardcreator/3.res+3−3
@@ -5,7 +5,7 @@ AbstractButton {
5 property var cardData;
5 property var cardData;
6 property var artShapeBorderSource: undefined;
6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8− property color foregroundColor: "grey";
8+ property var styleTool: Object({ foreground: "grey" })
9 property int headerAlignment: Text.AlignLeft;
9 property int headerAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1;
10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1);
11 property size fixedArtShapeSize: Qt.size(-1, -1);
@@ -76,7 +76,7 @@ leftMargin: units.gu(1);
76 wrapMode: Text.Wrap;
76 wrapMode: Text.Wrap;
77 maximumLineCount: 2;
77 maximumLineCount: 2;
78 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
78 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
79− color: root.foregroundColor;
79+ color: root.styleTool.foreground;
80 visible: showHeader ;
80 visible: showHeader ;
81 text: root.title;
81 text: root.title;
82 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
82 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
@@ -94,7 +94,7 @@ Label {
94 elide: Text.ElideRight;
94 elide: Text.ElideRight;
95 fontSize: "small";
95 fontSize: "small";
96 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
96 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
97− color: root.foregroundColor;
97+ color: root.styleTool.foreground;
98 visible: titleLabel.visible && titleLabel.text;
98 visible: titleLabel.visible && titleLabel.text;
99 text: cardData && cardData["subtitle"] || "";
99 text: cardData && cardData["subtitle"] || "";
100 font.weight: Font.Light;
100 font.weight: Font.Light;
tests/plugins/Dash/cardcreator/4.res+3−3
@@ -5,7 +5,7 @@ AbstractButton {
5 property var cardData;
5 property var cardData;
6 property var artShapeBorderSource: undefined;
6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8− property color foregroundColor: "grey";
8+ property var styleTool: Object({ foreground: "grey" })
9 property int headerAlignment: Text.AlignLeft;
9 property int headerAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1;
10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1);
11 property size fixedArtShapeSize: Qt.size(-1, -1);
@@ -69,7 +69,7 @@ data: [ Label {
69 wrapMode: Text.Wrap;
69 wrapMode: Text.Wrap;
70 maximumLineCount: 2;
70 maximumLineCount: 2;
71 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
71 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
72− color: root.foregroundColor;
72+ color: root.styleTool.foreground;
73 visible: showHeader ;
73 visible: showHeader ;
74 text: root.title;
74 text: root.title;
75 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
75 font.weight: components && components["subtitle"] ? Font.DemiBold : Font.Normal;
@@ -84,7 +84,7 @@ Label {
84 elide: Text.ElideRight;
84 elide: Text.ElideRight;
85 fontSize: "small";
85 fontSize: "small";
86 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
86 font.pixelSize: Math.round(FontUtils.sizeToPixels(fontSize) * fontScale);
87− color: root.foregroundColor;
87+ color: root.styleTool.foreground;
88 visible: titleLabel.visible && titleLabel.text;
88 visible: titleLabel.visible && titleLabel.text;
89 text: cardData && cardData["subtitle"] || "";
89 text: cardData && cardData["subtitle"] || "";
90 font.weight: Font.Light;
90 font.weight: Font.Light;
tests/plugins/Dash/cardcreator/5.res+1−1
@@ -5,7 +5,7 @@ AbstractButton {
5 property var cardData;
5 property var cardData;
6 property var artShapeBorderSource: undefined;
6 property var artShapeBorderSource: undefined;
7 property real fontScale: 1.0;
7 property real fontScale: 1.0;
8− property color foregroundColor: "grey";
8+ property var styleTool: Object({ foreground: "grey" })
9 property int headerAlignment: Text.AlignLeft;
9 property int headerAlignment: Text.AlignLeft;
10 property int fixedHeaderHeight: -1;
10 property int fixedHeaderHeight: -1;
11 property size fixedArtShapeSize: Qt.size(-1, -1);
11 property size fixedArtShapeSize: Qt.size(-1, -1);
tests/qmltests/Components/tst_PageHeader.qml+4−1
@@ -213,7 +213,10 @@ Item {
213
213
214 searchEntryEnabled: true
214 searchEntryEnabled: true
215 title: "%^$%^%^&%^&%^$%GHR%"
215 title: "%^$%^%^&%^&%^$%GHR%"
216+ styleTool: QtObject {
217+ readonly property color foreground: "grey"
216− imageSource: showImageCheckBox.checked ? titleImageSource : ""
218+ readonly property url headerLogo: showImageCheckBox.checked ? pageHeader.titleImageSource : ""
219+ }
217 showBackButton: showBackButtonCheckBox.checked
220 showBackButton: showBackButtonCheckBox.checked
218
221
219 property string titleImageSource: Qt.resolvedUrl("tst_PageHeader/logo-ubuntu-orange.svg")
222 property string titleImageSource: Qt.resolvedUrl("tst_PageHeader/logo-ubuntu-orange.svg")