2023-09-01 10:48:19 +00:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
2022-06-03 11:26:02 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
2020-12-01 12:57:32 +00:00
|
|
|
import QtQuick
|
2017-07-04 17:20:08 +00:00
|
|
|
|
|
|
|
ApplicationFlowForm {
|
|
|
|
id: applicationFlow
|
2023-09-01 10:48:19 +00:00
|
|
|
state: "Home"
|
2017-07-04 17:20:08 +00:00
|
|
|
property int animationDuration: 400
|
2023-09-01 10:48:19 +00:00
|
|
|
property string platform: Qt.platform.os
|
|
|
|
property int brewTime
|
|
|
|
property int coffeeAmount
|
|
|
|
property int milkAmount
|
|
|
|
property int foamAmount
|
|
|
|
property double sugarAmount
|
|
|
|
|
2025-07-16 12:26:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
stack.initialItem: Home {
|
|
|
|
id: home
|
|
|
|
visible: true
|
|
|
|
//! [On clicked]
|
|
|
|
getStartedbutton.onClicked: {
|
|
|
|
applicationFlow.state = "Coffee-selection"
|
2025-07-16 13:23:43 +00:00
|
|
|
applicationFlow.stack.pushItem(applicationFlow.choosingCoffee, {appFlow: applicationFlow})
|
2025-07-16 12:26:59 +00:00
|
|
|
}
|
|
|
|
//! [On clicked]
|
|
|
|
}
|
|
|
|
|
2023-11-24 13:31:37 +00:00
|
|
|
//! [Theme button]
|
2023-09-01 10:48:19 +00:00
|
|
|
function themeButton() {
|
|
|
|
if (Colors.currentTheme == Colors.dark) {
|
|
|
|
Colors.currentTheme = Colors.light
|
|
|
|
} else {
|
|
|
|
Colors.currentTheme = Colors.dark
|
|
|
|
}
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|
2023-11-24 13:31:37 +00:00
|
|
|
//! [Theme button]
|
2023-09-01 10:48:19 +00:00
|
|
|
function cappuccino() {
|
|
|
|
applicationFlow.state = "Settings"
|
|
|
|
applicationFlow.coffeeName = "Cappuccino"
|
|
|
|
coffeeAmount = 60
|
|
|
|
milkAmount = 60
|
|
|
|
foamAmount = 60
|
|
|
|
brewTime = 5000
|
2025-07-16 09:49:59 +00:00
|
|
|
stack.pushItem(settings, {appFlow: applicationFlow})
|
2023-09-01 10:48:19 +00:00
|
|
|
coffeeText.text = "Cappuccino"
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|
2023-09-01 10:48:19 +00:00
|
|
|
function espresso() {
|
|
|
|
applicationFlow.state = "Settings"
|
|
|
|
applicationFlow.coffeeName = "Espresso"
|
|
|
|
coffeeAmount = 80
|
|
|
|
milkAmount = 0
|
|
|
|
foamAmount = 0
|
|
|
|
brewTime = 4000
|
2025-07-16 09:49:59 +00:00
|
|
|
stack.pushItem(settings, {appFlow: applicationFlow})
|
2023-09-01 10:48:19 +00:00
|
|
|
coffeeText.text = "Espresso"
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|
2023-09-01 10:48:19 +00:00
|
|
|
function latte() {
|
|
|
|
applicationFlow.state = "Settings"
|
|
|
|
applicationFlow.coffeeName = "Latte"
|
|
|
|
coffeeAmount = 40
|
|
|
|
milkAmount = 20
|
|
|
|
foamAmount = 60
|
|
|
|
brewTime = 6000
|
2025-07-16 09:49:59 +00:00
|
|
|
stack.pushItem(settings, {appFlow: applicationFlow})
|
2023-09-01 10:48:19 +00:00
|
|
|
coffeeText.text = "Latte"
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|
2023-09-01 10:48:19 +00:00
|
|
|
function macchiato() {
|
|
|
|
applicationFlow.state = "Settings"
|
|
|
|
applicationFlow.coffeeName = "Macchiato"
|
|
|
|
coffeeAmount = 100
|
|
|
|
milkAmount = 5
|
|
|
|
foamAmount = 10
|
|
|
|
brewTime = 8000
|
2025-07-16 09:49:59 +00:00
|
|
|
stack.pushItem(settings, {appFlow: applicationFlow})
|
2023-09-01 10:48:19 +00:00
|
|
|
coffeeText.text = "Macchiato"
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|
2023-09-01 10:48:19 +00:00
|
|
|
function backButton() {
|
|
|
|
stack.pop()
|
|
|
|
applicationFlow.state = applicationFlow.previousState
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|
2023-09-01 10:48:19 +00:00
|
|
|
function confirmButton() {
|
2025-07-16 12:26:59 +00:00
|
|
|
stack.pushItem(insert, {appFlow: applicationFlow})
|
2023-09-01 10:48:19 +00:00
|
|
|
applicationFlow.state = "Insert"
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|
2023-09-01 10:48:19 +00:00
|
|
|
function continueButton() {
|
2025-07-16 11:59:20 +00:00
|
|
|
stack.pushItem(progress, {appFlow: applicationFlow})
|
2023-09-01 10:48:19 +00:00
|
|
|
applicationFlow.state = "Progress"
|
|
|
|
applicationFlow.progressBarValue = 1
|
|
|
|
applicationFlow.progressCupState = "1"
|
|
|
|
if (applicationFlow.coffeeName == "Cappuccino") {
|
|
|
|
applicationFlow.cappuccinos = applicationFlow.cappuccinos - 1
|
|
|
|
} else if (applicationFlow.coffeeName == "Espresso") {
|
|
|
|
applicationFlow.espressos = applicationFlow.espressos - 1
|
|
|
|
} else if (applicationFlow.coffeeName == "Latte") {
|
|
|
|
applicationFlow.lattes = applicationFlow.lattes - 1
|
|
|
|
} else {
|
|
|
|
applicationFlow.macchiatos = applicationFlow.macchiatos - 1
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|
|
|
|
}
|
2023-09-01 10:48:19 +00:00
|
|
|
function cancelButton() {
|
|
|
|
applicationFlow.state = "Coffee-selection"
|
|
|
|
stack.pop(stack.get(1))
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|
2023-09-01 10:48:19 +00:00
|
|
|
function onFinished() {
|
2025-07-16 12:26:59 +00:00
|
|
|
stack.pushItem(ready, {appFlow: applicationFlow})
|
2023-09-01 10:48:19 +00:00
|
|
|
applicationFlow.state = "Ready"
|
|
|
|
}
|
|
|
|
function onReturnToStart() {
|
|
|
|
stack.pop(stack.get(0))
|
|
|
|
applicationFlow.state = "Home"
|
|
|
|
applicationFlow.progressBarValue = 0
|
|
|
|
applicationFlow.progressCupState = "0"
|
|
|
|
}
|
2025-07-16 13:53:21 +00:00
|
|
|
|
|
|
|
toolbar.onBackClicked: applicationFlow.backButton()
|
|
|
|
toolbar.onThemeChangeRequested: applicationFlow.themeButton()
|
|
|
|
|
2023-11-24 13:31:37 +00:00
|
|
|
//! [States]
|
2023-09-01 10:48:19 +00:00
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "Home"
|
|
|
|
PropertyChanges {
|
|
|
|
target: toolbar
|
|
|
|
backButton.opacity: 0
|
|
|
|
backButton.enabled: false
|
|
|
|
themeButton.opacity: 0
|
|
|
|
themeButton.enabled: false
|
|
|
|
logo.sourceSize.width: 70
|
|
|
|
logo.sourceSize.height: 50
|
|
|
|
}
|
2023-11-24 13:31:37 +00:00
|
|
|
//! [States]
|
2023-09-01 10:48:19 +00:00
|
|
|
PropertyChanges {
|
|
|
|
target: coffeeText
|
|
|
|
visible: false
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: stack
|
|
|
|
anchors.top: coffeeText.bottom
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "Coffee-selection"
|
|
|
|
PropertyChanges {
|
|
|
|
target: applicationFlow
|
|
|
|
previousState: "Home"
|
|
|
|
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: coffeeText
|
|
|
|
text: "Coffee Selection"
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: toolbar
|
|
|
|
backButton.opacity: 0
|
|
|
|
backButton.enabled: false
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: stack
|
|
|
|
anchors.top: coffeeText.bottom
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "Settings"
|
|
|
|
PropertyChanges {
|
|
|
|
target: applicationFlow
|
|
|
|
previousState: "Coffee-selection"
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: stack
|
|
|
|
anchors.top: coffeeText.bottom
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "Insert"
|
|
|
|
PropertyChanges {
|
|
|
|
target: applicationFlow
|
|
|
|
previousState: "Settings"
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: stack
|
|
|
|
anchors.top: coffeeText.bottom
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "Progress"
|
|
|
|
PropertyChanges {
|
|
|
|
target: applicationFlow
|
|
|
|
previousState: "Insert"
|
|
|
|
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: toolbar
|
|
|
|
backButton.opacity: 0
|
|
|
|
backButton.enabled: false
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: stack
|
|
|
|
anchors.top: coffeeText.bottom
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "Ready"
|
|
|
|
PropertyChanges {
|
|
|
|
target: applicationFlow
|
|
|
|
previousState: "Progress"
|
|
|
|
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: toolbar
|
|
|
|
backButton.opacity: 0
|
|
|
|
backButton.enabled: false
|
|
|
|
}
|
|
|
|
PropertyChanges {
|
|
|
|
target: stack
|
|
|
|
anchors.top: coffeeText.bottom
|
|
|
|
}
|
|
|
|
}
|
2017-07-04 17:20:08 +00:00
|
|
|
|
2023-09-01 10:48:19 +00:00
|
|
|
]
|
2017-07-04 17:20:08 +00:00
|
|
|
}
|