~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: Zsombor Egri
  • Date: 2015-11-16 06:35:05 UTC
  • mfrom: (1664.1.1 listitemSelectModeBugs)
  • Revision ID: zsombor.egri@canonical.com-20151116063505-cwn2qfks7qzk10g9
re-sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
    AdaptivePageLayout {
37
37
        id: layout
38
38
        anchors.fill: parent
39
 
        primaryPage: mainPage
 
39
        primaryPageSource: Qt.resolvedUrl("MainPage.qml")
40
40
 
41
41
        layouts: [
42
42
            PageColumnsLayout {
59
59
                }
60
60
            }
61
61
        ]
62
 
 
63
 
        Page {
64
 
            id: mainPage
65
 
            title: "Ubuntu UI Toolkit"
66
 
 
67
 
            head.actions: [
68
 
                Action {
69
 
                    text: i18n.tr('Right to Left')
70
 
                    iconName: 'flash-on'
71
 
                    visible: !gallery.rtl
72
 
                    onTriggered: gallery.rtl = !gallery.rtl
73
 
                },
74
 
                Action {
75
 
                    text: i18n.tr('Left to Right')
76
 
                    iconName: 'flash-off'
77
 
                    visible: gallery.rtl
78
 
                    onTriggered: gallery.rtl = !gallery.rtl
79
 
                },
80
 
                Action {
81
 
                    text: i18n.tr('Use dark theme')
82
 
                    iconName: 'torch-on'
83
 
                    visible: gallery.theme.name == 'Ubuntu.Components.Themes.Ambiance'
84
 
                    onTriggered: gallery.theme.name = 'Ubuntu.Components.Themes.SuruDark'
85
 
                },
86
 
                Action {
87
 
                    text: i18n.tr('Use light theme')
88
 
                    iconName: 'torch-off'
89
 
                    visible: gallery.theme.name == 'Ubuntu.Components.Themes.SuruDark'
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"))
96
 
                }
97
 
            ]
98
 
 
99
 
            onActiveChanged: {
100
 
                if (layout.columns < 2) {
101
 
                    widgetList.currentIndex = -1;
102
 
                }
103
 
                if (active) {
104
 
                    widgetList.openPage();
105
 
                }
106
 
            }
107
 
 
108
 
            Rectangle {
109
 
                color: Qt.rgba(0.0, 0.0, 0.0, 0.01)
110
 
                anchors.fill: parent
111
 
 
112
 
                UbuntuListView {
113
 
                    id: widgetList
114
 
                    objectName: "widgetList"
115
 
                    anchors.fill: parent
116
 
                    model: widgetsModel
117
 
                    currentIndex: -1
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 {
129
 
                        objectName: model.objectName
130
 
                        contentItem {
131
 
                            anchors.leftMargin: units.gu(2)
132
 
                            anchors.rightMargin: units.gu(2)
133
 
                        }
134
 
                        enabled: source != ""
135
 
                        // Used by Autopilot
136
 
                        property string text: label
137
 
                        onClicked: widgetList.currentIndex = index
138
 
                        Label {
139
 
                            id: labelItem
140
 
                            anchors {
141
 
                                fill: parent
142
 
                                rightMargin: units.gu(4)
143
 
                            }
144
 
                            text: label
145
 
                            verticalAlignment: Text.AlignVCenter
146
 
                        }
147
 
                        Icon {
148
 
                            name: "next"
149
 
                            width: units.gu(2)
150
 
                            height: units.gu(2)
151
 
                            anchors {
152
 
                                verticalCenter: parent.verticalCenter
153
 
                                right: parent.right
154
 
                            }
155
 
                        }
156
 
                    }
157
 
                    highlight: Rectangle {
158
 
                        color: theme.palette.selected.background
159
 
                    }
160
 
                    highlightMoveDuration: 0
161
 
                }
162
 
            }
163
 
        }
164
 
    }
165
 
 
166
 
    WidgetsModel {
167
 
        id: widgetsModel
168
62
    }
169
63
}