on xenial help sign in
Add divider dots.

Approved by: Michał Sawicz

commitdbb2769c60f4db05d0210416f98a6aa8a6b098ec authorYing-Chun Liu <paul.liu@canonical.com> dateWed 6 Aug 2014, 19:37 (12 years ago) parent68abd8ed45d3e8
6 files changed+46
qml/Components/PageHeader.qml+21 qml/Components/graphics/pagination_dot_off@30.png qml/Components/graphics/pagination_dot_on@30.png qml/Dash/DashContent.qml+2 qml/Dash/GenericScopeView.qml+2 tests/qmltests/Components/tst_PageHeader.qml+21
qml/Components/PageHeader.qml+21
@@ -35,6 +35,8 @@ Item {
3535 property bool searchInProgress: false
3636
3737 property alias bottomItem: bottomContainer.children
38+ property int paginationCount: 0
39+ property int paginationIndex: -1
3840
3941 // TODO We should use foreground for the icons
4042 // of the toolbar but unfortunately Action does not have
@@ -294,6 +296,25 @@ Item {
294296 }
295297 }
296298
299+ Row {
300+ spacing: units.gu(.5)
301+ Repeater {
302+ objectName: "paginationRepeater"
303+ model: root.paginationCount
304+ Image {
305+ objectName: "paginationDots_" + index
306+ height: units.gu(1)
307+ width: height
308+ source: (index == root.paginationIndex) ? "graphics/pagination_dot_on.png" : "graphics/pagination_dot_off.png"
309+ }
310+ }
311+ anchors {
312+ top: headerContainer.bottom
313+ horizontalCenter: headerContainer.horizontalCenter
314+ topMargin: units.gu(.5)
315+ }
316+ }
317+
297318 Component {
298319 id: popoverComponent
299320 Popover {
qml/Components/graphics/pagination_dot_off@30.pngnew file

Binary file not shown.

qml/Components/graphics/pagination_dot_on@30.pngnew file

Binary file not shown.

qml/Dash/DashContent.qml+2
@@ -144,6 +144,8 @@ Item {
144144 item.scope = Qt.binding(function() { return scope })
145145 item.isCurrent = Qt.binding(function() { return visible && ListView.isCurrentItem })
146146 dashContent.scopeLoaded(item.scope.id)
147+ item.paginationCount = Qt.binding(function() { return dashContentList.count } )
148+ item.paginationIndex = Qt.binding(function() { return dashContentList.currentIndex } )
147149 }
148150 Connections {
149151 target: isCurrent ? scope : null
qml/Dash/GenericScopeView.qml+2
@@ -33,6 +33,8 @@ FocusScope {
3333 property bool hasBackAction: false
3434 property bool enableHeightBehaviorOnNextCreation: false
3535 property var categoryView: categoryView
36+ property alias paginationCount: pageHeader.paginationCount
37+ property alias paginationIndex: pageHeader.paginationIndex
3638
3739 property var scopeStyle: ScopeStyle {
3840 style: scope ? scope.customizations : {}
tests/qmltests/Components/tst_PageHeader.qml+21
@@ -192,6 +192,27 @@ Item {
192192 ];
193193 }
194194
195+ function test_pagination() {
196+ var paginationRepeater = findChild(pageHeader, "paginationRepeater");
197+ tryCompare(paginationRepeater, "count", 0);
198+ pageHeader.paginationCount = 5;
199+ tryCompare(paginationRepeater, "count", 5);
200+ for (var i=0; i<pageHeader.paginationCount; i++) {
201+ pageHeader.paginationIndex = i;
202+ for (var j=0; j<paginationRepeater.count; j++) {
203+ var paginationDot = findChild(pageHeader, "paginationDots_"+j);
204+ if (i==j) {
205+ compare(paginationDot.source.toString().indexOf("pagination_dot_on") > -1, true);
206+ } else {
207+ compare(paginationDot.source.toString().indexOf("pagination_dot_off") > -1, true);
208+ }
209+ }
210+ }
211+ pageHeader.paginationIndex = -1;
212+ pageHeader.paginationCount = 0;
213+ tryCompare(paginationRepeater, "count", 0);
214+ }
215+
195216 function test_popup_closing(data) {
196217 searchEnabled = true;
197218 pageHeader.searchHistory.clear();