Merge lp:~unity-team/unity8/uitkPageHeader into lp:unity8

Proposed by Michael Terry
Status: Merged
Approved by: Michael Terry
Approved revision: 2331
Merged at revision: 2425
Proposed branch: lp:~unity-team/unity8/uitkPageHeader
Merge into: lp:unity8
Prerequisite: lp:~mzanetti/unity8/reenable-skipped-tests
Diff against target: 510 lines (+120/-124)
9 files modified
qml/Components/Header.qml (+0/-28)
qml/Dash/DashPageHeader.qml (+32/-37)
qml/Dash/GenericScopeView.qml (+5/-0)
qml/Stages/Splash.qml (+6/-17)
tests/qmltests/Dash/tst_Dash.qml (+8/-8)
tests/qmltests/Dash/tst_DashContent.qml (+64/-5)
tests/qmltests/Dash/tst_DashPageHeader.qml (+0/-24)
tests/qmltests/Dash/tst_GenericScopeView.qml (+2/-2)
tests/qmltests/Dash/tst_PreviewView.qml (+3/-3)
To merge this branch: bzr merge lp:~unity-team/unity8/uitkPageHeader
Reviewer Review Type Date Requested Status
Andrea Cimitan (community) Approve
Review via email: mp+294967@code.launchpad.net

Commit message

Use PageHeader instead Ambiance's PageHeadStyle

Description of the change

This is a carry-over from https://code.launchpad.net/~cimi/unity8/uitkPageHeader/+merge/294937

I just needed to rebase it to avoid conflicts. Will carry its approval over as well.

To post a comment you must log in.
lp:~unity-team/unity8/uitkPageHeader updated
2332. By Michael Terry

Fix splash header color

Revision history for this message
Andrea Cimitan (cimi) wrote :

thank you

review: Approve
lp:~unity-team/unity8/uitkPageHeader updated
2333. By Michael Terry

And specify dividerColor

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== removed file 'qml/Components/Header.qml'
2--- qml/Components/Header.qml 2016-01-25 10:12:48 +0000
3+++ qml/Components/Header.qml 1970-01-01 00:00:00 +0000
4@@ -1,28 +0,0 @@
5-/*
6- * Copyright (C) 2014 Canonical, Ltd.
7- *
8- * This program is free software; you can redistribute it and/or modify
9- * it under the terms of the GNU General Public License as published by
10- * the Free Software Foundation; version 3.
11- *
12- * This program is distributed in the hope that it will be useful,
13- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15- * GNU General Public License for more details.
16- *
17- * You should have received a copy of the GNU General Public License
18- * along with this program. If not, see <http://www.gnu.org/licenses/>.
19- */
20-
21-import Ubuntu.Components 1.3
22-import Ubuntu.Components.Themes.Ambiance 1.3
23-
24-PageHeadStyle {
25- // FIXME: Don't use this but PageHeader from Ubuntu.Components 1.3.
26- id: root
27-
28- property var styledItem: root
29- property string title
30- property var config: PageHeadConfiguration {}
31- property var contents: null
32-}
33
34=== modified file 'qml/Dash/DashPageHeader.qml'
35--- qml/Dash/DashPageHeader.qml 2016-04-27 15:01:10 +0000
36+++ qml/Dash/DashPageHeader.qml 2016-05-19 15:22:50 +0000
37@@ -16,7 +16,7 @@
38
39 import QtQuick 2.4
40 import Ubuntu.Components 1.3
41-import Ubuntu.Components.Themes.Ambiance 1.3
42+import Ubuntu.Components.Popups 1.3
43 import Ubuntu.Components.ListItems 1.3
44 import "../Components"
45
46@@ -78,13 +78,13 @@
47 }
48 }
49
50- function closePopup(keepFocus) {
51+ function closePopup(keepFocus, keepSearch) {
52 if (extraPanel.visible) {
53 extraPanel.visible = false;
54 } else if (!keepFocus) {
55- unfocus();
56+ unfocus(keepSearch);
57 }
58- if (!searchTextField.text && !root.navigationTag && searchHistory.count == 0) {
59+ if (!keepSearch && !searchTextField.text && !root.navigationTag && searchHistory.count == 0) {
60 headerContainer.showSearch = false;
61 }
62 }
63@@ -97,9 +97,9 @@
64 closePopup(keepFocus);
65 }
66
67- function unfocus() {
68+ function unfocus(keepSearch) {
69 searchTextField.focus = false;
70- if (!searchTextField.text && !root.navigationTag) {
71+ if (!keepSearch && !searchTextField.text && !root.navigationTag) {
72 headerContainer.showSearch = false;
73 }
74 }
75@@ -142,7 +142,7 @@
76 objectName: "headerContainer"
77 clip: contentY < height
78 anchors { left: parent.left; top: parent.top; right: parent.right }
79- height: header.contentHeight
80+ height: header.__styleInstance.contentHeight
81 contentHeight: headersColumn.height
82 interactive: false
83 contentY: showSearch ? 0 : height
84@@ -173,22 +173,18 @@
85 id: headersColumn
86 anchors { left: parent.left; right: parent.right }
87
88- PageHeadStyle {
89- // FIXME: Replace PageHeadStyle from the Ambiance theme by the new PageHeader from Ubuntu.Components 1.3.
90+ PageHeader {
91 id: searchHeader
92 anchors { left: parent.left; right: parent.right }
93 opacity: headerContainer.clip || headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
94- __separator_visible: false
95- // Required to keep PageHeadStyle noise down as it expects the Page's properties around.
96- property var styledItem: searchHeader
97- property color dividerColor: "transparent" // Doesn't matter as we don't have PageHeadSections
98- property color panelColor: background.topColor
99- panelForegroundColor: config.foregroundColor
100- backgroundColor: "transparent"
101- config: PageHeadConfiguration {
102+
103+ StyleHints {
104 foregroundColor: root.scopeStyle ? root.scopeStyle.headerForeground : theme.palette.normal.baseText
105+ backgroundColor: "transparent"
106+ dividerColor: "transparent"
107 }
108- property var contents: Item {
109+
110+ contents: Item {
111 anchors.fill: parent
112
113 TextField {
114@@ -273,7 +269,7 @@
115 anchors.fill: parent
116 anchors.margins: units.gu(2)
117 name: "filters"
118- color: root.activeFiltersCount > 0 ? UbuntuColors.orange : header.config.foregroundColor
119+ color: root.activeFiltersCount > 0 ? UbuntuColors.orange : header.__styleInstance.foregroundColor
120 }
121
122 onClicked: {
123@@ -283,6 +279,7 @@
124
125 AbstractButton {
126 id: cancelButton
127+ objectName: "cancelButton"
128 width: cancelLabel.width + cancelLabel.anchors.rightMargin + cancelLabel.anchors.leftMargin
129 anchors {
130 top: parent.top
131@@ -296,7 +293,7 @@
132 Label {
133 id: cancelLabel
134 text: i18n.tr("Cancel")
135- color: header.panelForegroundColor
136+ color: header.__styleInstance.foregroundColor
137 verticalAlignment: Text.AlignVCenter
138 anchors {
139 verticalCenter: parent.verticalCenter
140@@ -309,28 +306,27 @@
141 }
142 }
143
144- PageHeadStyle {
145- // FIXME: Replace PageHeadStyle from the Ambiance theme by the new PageHeader from Ubuntu.Components 1.3.
146+ PageHeader {
147 id: header
148 objectName: "innerPageHeader"
149 anchors { left: parent.left; right: parent.right }
150 height: headerContainer.height
151 opacity: headerContainer.clip || !headerContainer.showSearch ? 1 : 0 // setting visible false cause column to relayout
152- __separator_visible: false
153- property var styledItem: header
154- property color dividerColor: "transparent" // Doesn't matter as we don't have PageHeadSections
155- property color panelColor: background.topColor
156- panelForegroundColor: config.foregroundColor
157- backgroundColor: "transparent"
158- config: PageHeadConfiguration {
159- title: root.title
160+ title: root.title
161+
162+ StyleHints {
163 foregroundColor: root.scopeStyle ? root.scopeStyle.headerForeground : theme.palette.normal.baseText
164- backAction: Action {
165- iconName: backIsClose ? "close" : "back"
166- visible: root.showBackButton
167- onTriggered: root.backClicked()
168- }
169-
170+ backgroundColor: "transparent"
171+ dividerColor: "transparent"
172+ }
173+
174+ leadingActionBar.actions: Action {
175+ iconName: backIsClose ? "close" : "back"
176+ visible: root.showBackButton
177+ onTriggered: root.backClicked()
178+ }
179+
180+ trailingActionBar {
181 actions: [
182 Action {
183 objectName: "store"
184@@ -366,7 +362,6 @@
185 ]
186 }
187
188- property var contents: null
189 Component.onCompleted: root.refreshLogo()
190
191 Component {
192
193=== modified file 'qml/Dash/GenericScopeView.qml'
194--- qml/Dash/GenericScopeView.qml 2016-05-04 18:08:35 +0000
195+++ qml/Dash/GenericScopeView.qml 2016-05-19 15:22:50 +0000
196@@ -662,6 +662,10 @@
197 onShowFiltersPopup: { // item
198 extraPanel.visible = false;
199 scopeView.filtersPopover = PopupUtils.open(Qt.resolvedUrl("FiltersPopover.qml"), item, { "contentWidth": scopeView.width - units.gu(2) } );
200+ scopeView.filtersPopover.Component.onDestruction.connect(function () {
201+ categoryView.pageHeader.closePopup(false, true);
202+ categoryView.pageHeader.unfocus(true); // remove the focus from the search field
203+ })
204 }
205 }
206
207@@ -683,6 +687,7 @@
208 onHistoryItemClicked: {
209 SearchHistoryModel.addQuery(text);
210 categoryView.pageHeader.searchQuery = text;
211+ categoryView.pageHeader.unfocus();
212 }
213
214 onDashNavigationLeafClicked: {
215
216=== modified file 'qml/Stages/Splash.qml'
217--- qml/Stages/Splash.qml 2016-03-08 20:59:22 +0000
218+++ qml/Stages/Splash.qml 2016-05-19 15:22:50 +0000
219@@ -29,7 +29,7 @@
220 property color footerColor: d.undefinedColor
221 property alias imageSource: overlaidImage.source
222 property url icon
223- property alias title: headerConfig.title
224+ property alias title: header.title
225 property alias showHeader: header.visible
226
227 Ambiance.Palette {
228@@ -75,25 +75,14 @@
229 style: Component { MainViewStyle {theme: styledItem.fakeTheme} }
230 }
231
232- Ambiance.PageHeadStyle {
233- // FIXME: Replace PageHeadStyle by PageHeader from Ubuntu.Components 1.3.
234+ PageHeader {
235 id: header
236- anchors {
237- left: parent.left;
238- right: parent.right
239- }
240- property var styledItem: header
241- // FIXME Keep in sync with SDK's MainView.qml values of these two colors
242- property color dividerColor: Qt.darker(styledItem.backgroundColor, 1.1)
243- property color panelColor: Qt.lighter(styledItem.backgroundColor, 1.1)
244- panelForegroundColor: config.foregroundColor
245- backgroundColor: "transparent"
246- config: PageHeadConfiguration {
247- id: headerConfig
248+ anchors { left: parent.left; right: parent.right }
249+ StyleHints {
250 foregroundColor: styledItem.fakeTheme.palette.normal.backgroundText
251+ backgroundColor: "transparent"
252+ dividerColor: styledItem.fakeTheme.palette.normal.base
253 }
254-
255- property var contents: null
256 }
257
258 Image {
259
260=== modified file 'tests/qmltests/Dash/tst_Dash.qml'
261--- tests/qmltests/Dash/tst_Dash.qml 2016-05-19 15:22:49 +0000
262+++ tests/qmltests/Dash/tst_Dash.qml 2016-05-19 15:22:50 +0000
263@@ -125,7 +125,7 @@
264 // Go back
265 var scopesList = findChild(dash, "scopesList");
266 var scopesListPageHeader = findChild(scopesList, "pageHeader");
267- var backButton = findChild(findChild(scopesListPageHeader, "innerPageHeader"), "customBackButton");
268+ var backButton = findChild(scopesListPageHeader, "innerPageHeader").leadingActionBar;
269 mouseClick(backButton);
270 tryCompare(bottomEdgeController, "progress", 0);
271 }
272@@ -200,7 +200,7 @@
273
274 // Go back
275 var dashTempScopeItemHeader = findChild(dashTempScopeItem, "scopePageHeader");
276- var backButton = findChild(findChild(dashTempScopeItemHeader, "innerPageHeader"), "customBackButton");
277+ var backButton = findChild(dashTempScopeItemHeader, "innerPageHeader").leadingActionBar;
278 mouseClick(backButton);
279
280 // Check temp scope is gone
281@@ -226,7 +226,7 @@
282 // Go back
283 var scopesList = findChild(dash, "scopesList");
284 var scopesListPageHeader = findChild(scopesList, "pageHeader");
285- var backButton = findChild(findChild(scopesListPageHeader, "innerPageHeader"), "customBackButton");
286+ var backButton = findChild(scopesListPageHeader, "innerPageHeader").leadingActionBar;
287 mouseClick(backButton);
288 tryCompare(bottomEdgeController, "progress", 0);
289 }
290@@ -338,7 +338,7 @@
291 // Exit edit mode and go back
292 var scopesList = findChild(dash, "scopesList");
293 var scopesListPageHeader = findChild(scopesList, "pageHeader");
294- var backButton = findChild(findChild(scopesListPageHeader, "innerPageHeader"), "customBackButton");
295+ var backButton = findChild(scopesListPageHeader, "innerPageHeader").leadingActionBar;
296 mouseClick(backButton);
297 mouseClick(backButton);
298 tryCompare(bottomEdgeController, "progress", 0);
299@@ -383,7 +383,7 @@
300 // Exit edit mode
301 var scopesList = findChild(dash, "scopesList");
302 var scopesListPageHeader = findChild(scopesList, "pageHeader");
303- var backButton = findChild(findChild(scopesListPageHeader, "innerPageHeader"), "customBackButton");
304+ var backButton = findChild(scopesListPageHeader, "innerPageHeader").leadingActionBar;
305 mouseClick(backButton);
306
307 // Click on third scope
308@@ -493,7 +493,7 @@
309
310 // Go back
311 var dashTempScopeItemHeader = findChild(dashTempScopeItem, "scopePageHeader");
312- var backButton = findChild(findChild(dashTempScopeItemHeader, "innerPageHeader"), "customBackButton");
313+ var backButton = findChild(dashTempScopeItemHeader, "innerPageHeader").leadingActionBar;
314 mouseClick(backButton);
315
316 // Check temp scope is gone
317@@ -561,7 +561,7 @@
318
319 // Go back
320 var dashTempScopeItemHeader = findChild(dashTempScopeItem, "scopePageHeader");
321- var backButton = findChild(findChild(dashTempScopeItemHeader, "innerPageHeader"), "customBackButton");
322+ var backButton = findChild(dashTempScopeItemHeader, "innerPageHeader").leadingActionBar;
323 mouseClick(backButton);
324
325 // Check temp scope is gone
326@@ -593,7 +593,7 @@
327
328 // Go back
329 var dashTempScopeItemHeader = findChild(dashTempScopeItem, "scopePageHeader");
330- var backButton = findChild(findChild(dashTempScopeItemHeader, "innerPageHeader"), "customBackButton");
331+ var backButton = findChild(dashTempScopeItemHeader, "innerPageHeader").leadingActionBar;
332 mouseClick(backButton);
333
334 // Check temp scope is gone
335
336=== modified file 'tests/qmltests/Dash/tst_DashContent.qml'
337--- tests/qmltests/Dash/tst_DashContent.qml 2016-03-29 03:47:39 +0000
338+++ tests/qmltests/Dash/tst_DashContent.qml 2016-05-19 15:22:50 +0000
339@@ -215,7 +215,7 @@
340 verify(pageHeader, "Could not find the scope page header.");
341 var innerHeader = findChild(pageHeader, "innerPageHeader");
342 verify(innerHeader, "Could not find the scope page header.");
343- compare(innerHeader.config.title, scopesModel.getScope(data.index).name);
344+ compare(innerHeader.title, scopesModel.getScope(data.index).name);
345 }
346
347 function test_is_active_data() {
348@@ -515,10 +515,18 @@
349 }
350
351 function test_navigationShowFilterPopup() {
352- goToSecondLevel();
353-
354 var dashContentList = findChild(dashContent, "dashContentList");
355+ var pageHeader = findChild(dashContentList.currentItem, "scopePageHeader")
356 var settingsButton = findChild(dashContentList.currentItem, "settingsButton");
357+ var searchButton = findChild(dashContentList.currentItem, "search_button");
358+ var cancelButton = findChild(dashContentList.currentItem, "cancelButton");
359+ var searchTextField = findChild(pageHeader, "searchTextField");
360+ var peExtraPanel = findChild(dashContentList.currentItem, "peExtraPanel");
361+ var headerContainer = findChild(pageHeader, "headerContainer");
362+
363+ // test that closing the filters popover without a search unfocuses and removes the navigation
364+ mouseClick(searchButton);
365+ tryCompare(peExtraPanel, "visible", true);
366
367 var filtersPopover = findChild(shell, "filtersPopover")
368 verify(!filtersPopover);
369@@ -526,8 +534,33 @@
370 mouseClick(settingsButton);
371
372 filtersPopover = findChild(shell, "filtersPopover")
373-
374- verify(filtersPopover);
375+ verify(filtersPopover);
376+
377+ mouseClick(shell, shell.width - 1, shell.height - 1);
378+
379+ tryCompare(pageHeader.extraPanel, "visible", false);
380+ tryCompare(headerContainer, "showSearch", true);
381+ tryCompare(searchTextField, "focus", false);
382+
383+ mouseClick(cancelButton);
384+ tryCompare(headerContainer, "showSearch", false);
385+ tryCompare(headerContainer, "contentY", headerContainer.height);
386+
387+ // test within a navigation
388+ goToSecondLevel();
389+
390+ filtersPopover = findChild(shell, "filtersPopover")
391+ verify(!filtersPopover);
392+
393+ mouseClick(settingsButton);
394+
395+ filtersPopover = findChild(shell, "filtersPopover")
396+ verify(filtersPopover);
397+
398+ mouseClick(shell, shell.width - 1, shell.height - 1);
399+
400+ tryCompare(pageHeader.extraPanel, "visible", false);
401+ tryCompare(headerContainer, "showSearch", true);
402 }
403
404 function test_primaryFilter() {
405@@ -625,5 +658,31 @@
406 tryCompareFunction(function() { return dashContentList.currentItem.item.scope.id == nextScopeId; }, true);
407 compare(dashContentList.currentIndex, 0);
408 }
409+
410+ function test_extraPanel() {
411+ var dashContentList = findChild(dashContent, "dashContentList");
412+ var pageHeader = findChild(dashContentList.currentItem, "scopePageHeader")
413+ pageHeader.searchEntryEnabled = true;
414+ pageHeader.searchHistory.clear();
415+
416+ pageHeader.searchHistory.addQuery("Search1");
417+ pageHeader.searchHistory.addQuery("Search2");
418+
419+ pageHeader.triggerSearch();
420+ tryCompare(pageHeader.extraPanel, "visible", true);
421+
422+ var searchTextField = findChild(pageHeader, "searchTextField");
423+ compare(searchTextField.focus, true);
424+
425+ var recentSearches = findChild(pageHeader.extraPanel, "recentSearchesRepeater");
426+ verify(recentSearches, "Could not find recent searches");
427+
428+ waitForRendering(recentSearches);
429+
430+ mouseClick(recentSearches.itemAt(0));
431+ compare(pageHeader.searchQuery, "Search2");
432+ tryCompare(pageHeader.extraPanel, "visible", false);
433+ compare(searchTextField.focus, false);
434+ }
435 }
436 }
437
438=== modified file 'tests/qmltests/Dash/tst_DashPageHeader.qml'
439--- tests/qmltests/Dash/tst_DashPageHeader.qml 2016-03-29 03:47:39 +0000
440+++ tests/qmltests/Dash/tst_DashPageHeader.qml 2016-05-19 15:22:50 +0000
441@@ -147,30 +147,6 @@
442 doResetSearch();
443 }
444
445- function test_extraPanel() {
446- searchEnabled = true;
447- pageHeader.searchHistory.clear();
448-
449- pageHeader.searchHistory.addQuery("Search1");
450- pageHeader.searchHistory.addQuery("Search2");
451-
452- pageHeader.triggerSearch();
453-
454- tryCompare(pageHeader.extraPanel, "visible", true);
455-
456- var searchTextField = findChild(pageHeader, "searchTextField");
457- compare(searchTextField.focus, true);
458-
459- var recentSearches = findChild(pageHeader.extraPanel, "recentSearchesRepeater");
460- verify(recentSearches, "Could not find recent searches");
461- waitForRendering(recentSearches);
462- mouseClick(recentSearches.itemAt(0));
463-
464- compare(pageHeader.searchQuery, "Search2");
465- tryCompare(pageHeader.extraPanel, "visible", false);
466- compare(searchTextField.focus, false);
467- }
468-
469 function test_popup_closing_data() {
470 return [
471 { tag: "with search text", searchText: "foobar", hideSearch: false },
472
473=== modified file 'tests/qmltests/Dash/tst_GenericScopeView.qml'
474--- tests/qmltests/Dash/tst_GenericScopeView.qml 2016-03-29 03:47:39 +0000
475+++ tests/qmltests/Dash/tst_GenericScopeView.qml 2016-05-19 15:22:50 +0000
476@@ -442,8 +442,8 @@
477
478 var innerHeader = findChild(header, "innerPageHeader");
479 verify(innerHeader, "Could not find the inner header");
480- verify(Qt.colorEqual(innerHeader.config.foregroundColor, data.foreground),
481- "Foreground color not equal: %1 != %2".arg(innerHeader.config.foregroundColor).arg(data.foreground));
482+ verify(Qt.colorEqual(innerHeader.__styleInstance.foregroundColor, data.foreground),
483+ "Foreground color not equal: %1 != %2".arg(innerHeader.__styleInstance.foregroundColor).arg(data.foreground));
484
485 var background = findChild(header, "headerBackground");
486 verify(background, "Could not find the background");
487
488=== modified file 'tests/qmltests/Dash/tst_PreviewView.qml'
489--- tests/qmltests/Dash/tst_PreviewView.qml 2016-03-29 03:47:39 +0000
490+++ tests/qmltests/Dash/tst_PreviewView.qml 2016-05-19 15:22:50 +0000
491@@ -98,7 +98,7 @@
492 var header = findChild(view, "innerPageHeader");
493 verify(header, "Could not find the preview header");
494
495- compare(header.config.title, "Mock Scope");
496+ compare(header.title, "Mock Scope");
497 }
498
499 function test_header_style() {
500@@ -107,8 +107,8 @@
501
502 var innerHeader = findChild(header, "innerPageHeader");
503 verify(innerHeader, "Could not find the inner header");
504- verify(Qt.colorEqual(innerHeader.config.foregroundColor, UbuntuColors.darkGrey),
505- "Foreground color not equal: %1 != %2".arg(innerHeader.config.foregroundColor).arg(UbuntuColors.darkGrey));
506+ verify(Qt.colorEqual(innerHeader.__styleInstance.foregroundColor, UbuntuColors.darkGrey),
507+ "Foreground color not equal: %1 != %2".arg(innerHeader.__styleInstance.foregroundColor).arg(UbuntuColors.darkGrey));
508
509 var background = findChild(header, "headerBackground");
510 verify(background, "Could not find the background");

Subscribers

People subscribed via source and target branches