~ci-train-bot/ubuntu-settings-components/ubuntu-settings-components-ubuntu-zesty-2106

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
/*
 * Copyright 2013 Canonical Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * Authored by Andrea Cimitan <andrea.cimitan@canonical.com>
 */

import QtQuick 2.4
import Ubuntu.Components 1.3
import Ubuntu.Settings.Components 0.1
import Ubuntu.Settings.Menus 0.1

Item {
    id: page
    property string title: "Settings Components"
    property bool pointerMode: false

    width: parent && parent.width ? parent.width : units.gu(42)
    height: parent && parent.width ? parent.height : units.gu(75)

    ListModel {
        id: mediaPlayerModel
        ListElement { song: "You're The First, The Last, My Everything"; artist: "Barry White"; album: "Hot Soul"; albumArt: "artwork/beach.jpg"}
        ListElement { song: "Stony Ground"; artist: "Richard Thompson"; album: "Electric"; albumArt: "artwork/farm.jpg"}
        ListElement { song: "Los Robots"; artist: "Kraftwerk"; album: "The Man-Machine"; albumArt: "artwork/insane.jpg"}
    }

    ListModel {
        id: timeZoneModel
        ListElement { city: "San Francisco"; time: "3:00am" }
        ListElement { city: "London"; time: "11:00am" }
        ListElement { city: "Rome"; time: "12:00am" }
    }

    ListModel {
        id: eventModel
        ListElement { icon: "image://theme/calendar"; eventColor: "yellow"; text: "Lunch with Lola"; time: "1:10 PM" }
        ListElement { icon: "image://theme/calendar"; eventColor: "green"; text: "Gym"; time: "6:30 PM" }
        ListElement { icon: "image://theme/calendar"; eventColor: "red"; text: "Birthday Party"; time: "9:00 PM" }
    }

    Flickable {
        id: flickable

        anchors.fill: parent
        contentWidth: column.width
        contentHeight: column.height

        Column {
            id: column

            width: flickable.width
            height: childrenRect.height

            StandardMenu {
                text: i18n.tr("Standard Menu\nLook at me, I'm a new line.")
                onTriggered: console.log("Triggered")
            }

            ButtonMenu {
                text: i18n.tr("Toggle divider menu.")
                buttonText: divider.visible ? i18n.tr("Hide") : i18n.tr("Show")
                onButtonClicked: divider.visible = !divider.visible
            }

            StandardMenu {
                text: i18n.tr("Removable menu.")
                removable: true
                onItemRemoved: console.log("Item removed");
            }

            StandardMenu {
                text: i18n.tr("Inverted colors Version")
                backColor: theme.palette.normal.baseText
                foregroundColor: theme.palette.normal.base
                highlightColor: theme.palette.highlighted.backgroundText
            }

            StandardMenu {
                iconName: "calendar"
                iconColor: "red"
                text: i18n.tr("Standard Menu with Component")
                slots: Button {
                    text: "Press Me"
                    onClicked: print("Button pressed!")
                    color: theme.palette.normal.foreground
                }
            }

            SeparatorMenu {}

            SliderMenu {
                id: slider
                text: i18n.tr("Slider")
                minimumValue: 0
                maximumValue: 100
                value: 20

                minIcon: "image://theme/audio-volume-low"
                maxIcon: "image://theme/audio-volume-high"
            }

            ProgressBarMenu {
                text: i18n.tr("ProgressBar")
                value: slider.value
                minimumValue: 0
                maximumValue: 100
            }

            ProgressValueMenu {
                text: i18n.tr("ProgressValue")
                value: slider.value
            }

            SeparatorMenu {}

            ButtonMenu {
                text: i18n.tr("Button")
                buttonText: i18n.tr("Hello world!")
            }

            CheckableMenu {
                text: i18n.tr("Checkable")
                checked: true
                onCheckedChanged: print("Checked status is", checked);
                onTriggered: print("Triggered", value)
            }

            SwitchMenu {
                text: i18n.tr("Switch")
                checked: true
                onCheckedChanged: print("Checked status is", checked);
                onTriggered: print("Triggered", value)
            }

            SectionMenu {
                text: i18n.tr("Section Starts Here")
                busy: true
            }

            SeparatorMenu {}

            CalendarMenu {
                id: calendar
                eventDays: currentDate.getMonth() % 2 ? [5, 20] : []
            }

            SwitchMenu {
                text: i18n.tr("Show week numbers in calendar")
                checked: calendar.showWeekNumbers
                onCheckedChanged: calendar.showWeekNumbers = checked
            }

            UserSessionMenu {
                name: i18n.tr("Lola Chang")
                iconSource: "image://theme/contact"
                active: true
                onTriggered: active = !active
            }

            MediaPlayerMenu {
                id: mediaPlayer
                property int index: 0

                playerName: "Rhythmbox"
                playerIcon: Qt.resolvedUrl("../tests/artwork/rhythmbox.png")
                albumArt: mediaPlayerModel.get(index).albumArt;
                song: mediaPlayerModel.get(index).song;
                artist: mediaPlayerModel.get(index).artist;
                album: mediaPlayerModel.get(index).album;
                showTrack: mediaControl.playing
            }

            PlaybackItemMenu {
                id: mediaControl
                canPlay: true
                canGoNext: mediaPlayer.index < mediaPlayerModel.count - 1
                canGoPrevious: mediaPlayer.index > 0
                playing: false

                onPrevious: mediaPlayer.index = Math.max(mediaPlayer.index - 1, 0)
                onNext: mediaPlayer.index = Math.min(mediaPlayer.index + 1, mediaPlayerModel.count - 1)
                onPlay: { playing = !playing; }
            }

            AccessPointMenu {
                active: true
                secure: true
                adHoc: false
                signalStrength: 50
                text: "Access Point"

                onTriggered: active = !active
            }

            AccessPointMenu {
                active: false
                secure: true
                adHoc: true
                signalStrength: 50
                text: "Access Point"

                onTriggered: active = !active
            }

            AccessPointMenu {
                text: "Access Point"
                onTriggered: active = !active
            }

            ModemInfoItem {
                simIdentifierText: "SIM 1"
                statusText: "EE 4G"
                statusIcon: "gsm-3g-full"
                roaming: true
                locked: false
                onTriggered: roaming = !roaming
            }

            ModemInfoItem {
                simIdentifierText: "SIM 2"
                statusText: "Ubuntu 5G"
                statusIcon: "gsm-3g-medium-secure"
                roaming: false
                locked: true
                onUnlock: locked = false
                onTriggered: {
                    if (locked) {
                        roaming = !roaming
                    } else {
                        locked = true
                    }
                }
            }

            SeparatorMenu {}

            RadioMenu {
                id: applesRadio
                text: i18n.tr("Apples")
                checked: true
                onTriggered: orangesRadio.checked = !checked
            }

            RadioMenu {
                id: orangesRadio
                text: i18n.tr("Oranges")
                onTriggered: applesRadio.checked = !checked
            }

            SeparatorMenu {}

            GroupedMessageMenu {
                text: "Group Message"
                count: "4100"
            }

            Column {
                anchors {
                    left: parent.left
                    right: parent.right
                }

                Repeater {
                    model: timeZoneModel

                    TimeZoneMenu {
                        city: model.city
                        time: model.time
                        pointerMode: page.pointerMode
                    }
                }
            }

            Column {
                anchors {
                    left: parent.left
                    right: parent.right
                }

                Repeater {
                    model: eventModel

                    EventMenu {
                        iconSource: model.icon
                        text: model.text
                        eventColor: model.eventColor
                        time: model.time
                        enabled: false
                        pointerMode: page.pointerMode
                    }
                }
            }

            Component.onCompleted: {
                for (var i = 0; i < children.length; ++i) {
                    if (children[i].pointerMode !== undefined) {
                        children[i].pointerMode = Qt.binding(function() { return page.pointerMode })
                    }
                }
            }
        }
    }
}