~zsombi/ubuntu-ui-toolkit/listitemSelectModeBugs

« back to all changes in this revision

Viewing changes to examples/ubuntu-ui-toolkit-gallery/ubuntu-ui-toolkit-gallery.qml

  • Committer: Tarmac
  • Author(s): Zsombor Egri
  • Date: 2015-09-28 17:05:48 UTC
  • mfrom: (1649.1.5 aplMoreAsynchronous)
  • Revision ID: tarmac-20150928170548-bbvgbijhv8c5ee6l
Add pages to columns in AdaptivePageLayout only when the page loading completes. Fixes: https://bugs.launchpad.net/bugs/1492343, https://bugs.launchpad.net/bugs/1499178.

Approved by Zoltan Balogh, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import QtQuick 2.4
18
18
import Ubuntu.Components 1.3
19
 
import Ubuntu.Components.ListItems 1.3 as ListItem
 
19
//import Ubuntu.Components.ListItems 1.3 as ListItem
20
20
 
21
21
MainView {
22
22
    id: gallery
88
88
                    iconName: 'torch-off'
89
89
                    visible: gallery.theme.name == 'Ubuntu.Components.Themes.SuruDark'
90
90
                    onTriggered: gallery.theme.name = 'Ubuntu.Components.Themes.Ambiance'
 
91
                },
 
92
                Action {
 
93
                    text: i18n.tr('About')
 
94
                    iconName: "info"
 
95
                    onTriggered: layout.addPageToCurrentColumn(mainPage, Qt.resolvedUrl("About.qml"))
91
96
                }
92
97
            ]
93
98
 
 
99
            onActiveChanged: {
 
100
                if (layout.columns < 2) {
 
101
                    widgetList.currentIndex = -1;
 
102
                }
 
103
                if (active) {
 
104
                    widgetList.openPage();
 
105
                }
 
106
            }
 
107
 
94
108
            Rectangle {
95
109
                color: Qt.rgba(0.0, 0.0, 0.0, 0.01)
96
110
                anchors.fill: parent
97
111
 
98
 
                ListView {
 
112
                UbuntuListView {
99
113
                    id: widgetList
100
114
                    objectName: "widgetList"
101
115
                    anchors.fill: parent
102
116
                    model: widgetsModel
103
117
                    currentIndex: -1
104
 
                    delegate: ListItem.Standard {
105
 
                        text: model.label
 
118
 
 
119
                    onCurrentIndexChanged: openPage()
 
120
 
 
121
                    function openPage() {
 
122
                        if (!mainPage.active || currentIndex < 0) return;
 
123
                        var modelData = model.get(currentIndex);
 
124
                        var source = Qt.resolvedUrl(modelData.source);
 
125
                        layout.addPageToNextColumn(mainPage, source, {title: modelData.label});
 
126
                    }
 
127
 
 
128
                    delegate: ListItem {
106
129
                        objectName: model.objectName
107
 
                        enabled: model.source != ""
108
 
                        progression: true
109
 
                        selected: index === widgetList.currentIndex
110
 
                        onClicked: {
111
 
                            var source = Qt.resolvedUrl(model.source);
112
 
                            layout.addPageToNextColumn(mainPage, source, {title: model.label});
113
 
 
114
 
                            widgetList.currentIndex = index;
115
 
                        }
116
 
                    }
 
130
                        contentItem {
 
131
                            anchors.leftMargin: units.gu(2)
 
132
                            anchors.rightMargin: units.gu(2)
 
133
                        }
 
134
                        enabled: source != ""
 
135
                        onClicked: widgetList.currentIndex = index
 
136
                        Label {
 
137
                            id: labelItem
 
138
                            anchors {
 
139
                                fill: parent
 
140
                                rightMargin: units.gu(4)
 
141
                            }
 
142
                            text: label
 
143
                            verticalAlignment: Text.AlignVCenter
 
144
                        }
 
145
                        Icon {
 
146
                            name: "next"
 
147
                            width: units.gu(2)
 
148
                            height: units.gu(2)
 
149
                            anchors {
 
150
                                verticalCenter: parent.verticalCenter
 
151
                                right: parent.right
 
152
                            }
 
153
                        }
 
154
                    }
 
155
                    highlight: Rectangle {
 
156
                        color: theme.palette.selected.background
 
157
                    }
 
158
                    highlightMoveDuration: 0
117
159
                }
118
160
            }
119
161
        }