summaryrefslogtreecommitdiffstats
path: root/examples/demos/coffee/SettingsForm.ui.qml
blob: 03a282ddc2a992a792b69929a8a301151af92973 (plain)
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
import QtQuick
import QtQuick.Layouts
import QtQuick.Controls.Basic
import QtQuick.Effects

Item {
    // Height, width and any other size related properties containing odd looking float or other dividers, multipliers, etc.
    // that do not seem to have any logical origin are just arbitrary and based on original design
    // and/or personal preference on what looks nice.
    property string coffeeName: ""
    id: root
    property alias confirmButton: confirmButton
    property alias rectangle: rectangle
    property alias coffeeSlider: coffeeSlider
    property alias milkSlider: milkSlider
    property alias foamSlider: foamSlider
    property alias sugarSlider: sugarSlider
    property alias box: box
    property alias sugarText: sugarText
    property alias handle: handle
    property int coffeeAmount
    property int milkAmount
    property int foamAmount
    property double sugarAmount

    states: [
        State {
            name: "portrait"
            PropertyChanges {
                target: grid
                flow: GridLayout.TopToBottom
                rows: 3
                columns: 1
                rowSpacing: 20
            }
            PropertyChanges {
                target: cup
                Layout.row: 0
                Layout.preferredWidth: height / 1.16
                Layout.preferredHeight: root.height / 3
            }
            PropertyChanges {
                target: rectangle
                Layout.row: 1
                Layout.preferredWidth: root.width / 1.12
                Layout.preferredHeight: root.height / 2.5
            }
            PropertyChanges {
                target: confirmButton
                Layout.alignment: Qt.AlignHCenter
                Layout.row: 2
                Layout.preferredWidth: root.width / 2.2
                Layout.preferredHeight: root.height / 14
            }
        },
        State {
            name: "landscape"
            PropertyChanges {
                target: grid
                flow: GridLayout.LeftToRight
                rows: 2
                columns: 3
            }
            PropertyChanges {
                target: cup
                Layout.column: 0
                Layout.preferredWidth: root.width / 4
                Layout.preferredHeight: root.height / 5
                Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
            }

            PropertyChanges {
                target: rectangle
                Layout.preferredWidth: root.width / 2
                Layout.preferredHeight: root.height / 1.4
                Layout.leftMargin: root.width / 20
                Layout.alignment: Qt.AlignBottom
                Layout.column: 2
            }
            PropertyChanges {
                target: confirmButton
                Layout.alignment: Qt.AlignHCenter | Qt.AlignBottom
                Layout.row: 1
                Layout.columnSpan: 3
                Layout.preferredWidth: root.width / 4
                Layout.preferredHeight: root.height / 8
            }
        }
    ]
    GridLayout {
        id: grid
        flow: GridLayout.TopToBottom
        anchors.horizontalCenter: parent.horizontalCenter

        Cup {
            id: cup
            milkAmount: milkSlider.value
            coffeeAmount: coffeeSlider.value
            foamAmount: foamSlider.value
            sugarAmount: sugarSlider.position
            Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
        }

        Rectangle {
            id: rectangle
            radius: 8
            gradient: Colors.greyBorder
            Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
            property int textPixelSize: 16
            Rectangle {
                id: rectangle2
                radius: 8
                color: Colors.currentTheme.cardColor
                width: parent.width - 2
                height: parent.height - 2
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.verticalCenter: parent.verticalCenter
                ColumnLayout {
                    anchors.fill: parent
                    anchors.margins: 10
                    spacing: 10
                    RowLayout {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        Rectangle {
                            Layout.preferredWidth: parent.width / 4
                            Layout.fillHeight: true
                            color: Colors.currentTheme.cardColor
                            Text {
                                id: text1
                                anchors.left: parent.left
                                anchors.verticalCenter: parent.verticalCenter
                                text: "Coffee"
                                color: Colors.currentTheme.textColor
                                font.pixelSize: rectangle.textPixelSize
                            }
                        }
                        Rectangle {
                            Layout.fillWidth: true
                            Layout.fillHeight: true
                            color: Colors.currentTheme.cardColor
                            CustomSlider {
                                id: coffeeSlider
                                from: 0
                                to: 100
                                value: coffeeAmount
                                liquidAmount: value
                                width: parent.width
                                height: 10
                                anchors.verticalCenter: parent.verticalCenter
                            }
                        }
                    }
                    RowLayout {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        Rectangle {
                            Layout.preferredWidth: parent.width / 4
                            Layout.fillHeight: true
                            color: Colors.currentTheme.cardColor
                            Text {
                                id: text2
                                anchors.left: parent.left
                                anchors.verticalCenter: parent.verticalCenter
                                text: "Milk"
                                color: Colors.currentTheme.textColor
                                font.pixelSize: rectangle.textPixelSize
                            }
                        }
                        Rectangle {
                            Layout.fillWidth: true
                            Layout.fillHeight: true
                            color: Colors.currentTheme.cardColor
                            CustomSlider {
                                id: milkSlider
                                from: 0
                                to: 60
                                value: milkAmount
                                liquidAmount: value
                                width: parent.width
                                height: 10
                                anchors.verticalCenter: parent.verticalCenter
                            }
                        }
                    }
                    RowLayout {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        Rectangle {
                            Layout.preferredWidth: parent.width / 4
                            Layout.fillHeight: true
                            color: Colors.currentTheme.cardColor
                            Text {
                                id: text3
                                anchors.left: parent.left
                                anchors.verticalCenter: parent.verticalCenter
                                text: "Foam"
                                color: Colors.currentTheme.textColor
                                font.pixelSize: rectangle.textPixelSize
                            }
                        }
                        Rectangle {
                            Layout.fillWidth: true
                            Layout.fillHeight: true
                            color: Colors.currentTheme.cardColor
                            CustomSlider {
                                id: foamSlider
                                from: 0
                                to: 60
                                value: foamAmount
                                liquidAmount: value
                                width: parent.width
                                height: 10
                                anchors.verticalCenter: parent.verticalCenter
                            }
                        }
                    }
                    RowLayout {
                        Layout.fillWidth: true
                        Layout.fillHeight: true
                        Rectangle {
                            Layout.preferredWidth: parent.width / 4
                            Layout.fillHeight: true
                            color: Colors.currentTheme.cardColor
                            Text {
                                id: text4
                                anchors.left: parent.left
                                anchors.verticalCenter: parent.verticalCenter
                                text: "Sugar"
                                color: Colors.currentTheme.textColor
                                font.pixelSize: rectangle.textPixelSize
                            }
                        }
                        Rectangle {
                            Layout.fillWidth: true
                            Layout.fillHeight: true
                            color: Colors.currentTheme.cardColor
                            Slider {
                                id: sugarSlider
                                snapMode: Slider.SnapAlways
                                stepSize: 0.25
                                value: sugarAmount
                                width: parent.width
                                height: 10
                                anchors.verticalCenter: parent.verticalCenter
                                transitions: Transition {
                                    NumberAnimation {
                                        properties: "scale"
                                        duration: 10
                                        easing.type: Easing.InOutQuad
                                    }
                                }
                                background: Rectangle {
                                    x: sugarSlider.leftPadding
                                    anchors.verticalCenter: parent.verticalCenter
                                    width: sugarSlider.availableWidth
                                    height: 4
                                    radius: 2
                                    color: Colors.currentTheme.background

                                    Rectangle {
                                        id: firstBar
                                        width: parent.width / 4
                                        height: parent.height
                                        color: (sugarSlider.value > 0) ? Colors.green : Colors.grey
                                        radius: 2
                                    }

                                    Rectangle {
                                        id: secondBar
                                        anchors.left: firstBar.right
                                        width: parent.width / 4
                                        height: parent.height
                                        color: (sugarSlider.value
                                                > 0.25) ? Colors.green : Colors.grey
                                        radius: 2
                                    }

                                    Rectangle {
                                        id: thirdBar
                                        anchors.left: secondBar.right
                                        width: parent.width / 4
                                        height: parent.height
                                        color: (sugarSlider.value
                                                > 0.50) ? Colors.green : Colors.grey
                                        radius: 2
                                    }

                                    Rectangle {
                                        id: fourthBar
                                        anchors.right: parent.right
                                        width: parent.width / 4
                                        height: parent.height
                                        color: (sugarSlider.value
                                                > 0.75) ? Colors.green : Colors.grey
                                        radius: 2
                                    }
                                }
                                handle: Rectangle {
                                    id: handle
                                    x: sugarSlider.leftPadding + sugarSlider.visualPosition
                                       * (sugarSlider.availableWidth - width)
                                    anchors.verticalCenter: parent.verticalCenter
                                    width: 14
                                    height: width
                                    radius: 100
                                    color: Colors.green
                                    Image {
                                        id: sugarMark
                                        source: "./images/icons/Polygon.svg"
                                        anchors.bottom: parent.top
                                        anchors.horizontalCenter: parent.horizontalCenter
                                        anchors.bottomMargin: 1
                                    }

                                    Rectangle {
                                        id: box
                                        anchors.bottom: sugarMark.top
                                        anchors.horizontalCenter: parent.horizontalCenter
                                        anchors.bottomMargin: 1
                                        implicitWidth: sugarText.width + 8
                                        implicitHeight: sugarText.height + 4
                                        radius: 4
                                        color: Colors.currentTheme.background
                                        border.color: Colors.grey
                                        Text {
                                            id: sugarText
                                            property int sugarAmount: 0
                                            anchors.verticalCenter: parent.verticalCenter
                                            anchors.horizontalCenter: parent.horizontalCenter
                                            text: sugarAmount + "p"
                                            font.pixelSize: 12
                                            clip: false
                                            color: Colors.currentTheme.textColor
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            MultiEffect {
                source: rectangle2
                anchors.fill: rectangle2
                shadowEnabled: true
                shadowColor: Colors.shadow
                shadowOpacity: 0.5
            }
        }
        CustomButton {
            id: confirmButton
            Layout.alignment: Qt.AlignHCenter | Qt.AlignTop
            Layout.minimumWidth: 150
            Layout.minimumHeight: 40
            buttonText: "Start"
            showIcon: false
        }
    }
}