Commit 1116cff4 authored by Thomas Hartmann's avatar Thomas Hartmann

Adding simple coffee demo

parent 6fbdb8d3
/******************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Quick Ultralite module.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
******************************************************************************/
import QtQuick 2.0
Item {
id: root
property real milkAmount: 6
property real coffeeAmount: 4
property real foamAmount: 40
property real sugarAmount: 2
property string coffeeName: ""
signal brew(string coffeeName, real coffeeAmount, real milkAmount, real foamAmount)
signal back
Rectangle {
id: rectangle
color: "#443224"
anchors.fill: parent
Image {
id: background
x: 12
y: 30
source: "images/cup structure/cup elements/coffee_cup_back.png"
}
Item {
id: foam
x: 12
width: 457
y: milk.y - foamAmount
height: background.height - (y - background.y)
clip: true
Image {
anchors.bottom: parent.bottom
source: "images/cup structure/liquids/liquid_foam.png"
}
visible: coffeeName !== "Espresso"
}
Item {
id: milk
x: 12
width: 457
y: background.y + (400 - coffee.height - root.milkAmount * 15 + 20)
height: background.height - (y - background.y)
clip: true
Image {
source: "images/cup structure/liquids/liquid_milk.png"
anchors.bottom: parent.bottom
}
visible: coffeeName !== "Espresso"
}
Item {
id: coffee
x: 12
width: 457
height: root.coffeeAmount * 40
anchors.bottom: background.bottom
clip: true
Image {
anchors.bottom: parent.bottom
source: "images/cup structure/liquids/liquid_coffee.png"
}
}
Image {
id: cupFront
x: 11
y: 30
source: "images/cup structure/cup elements/coffee_cup_front.png"
}
Text {
x: 499
y: 230
color: "#ffffff"
text: qsTr("HOT MILK")
font.pixelSize: 18
visible: coffeeName !== "Espresso"
}
Text {
x: 486
y: 328
color: "#ffffff"
text: qsTr("ESPRESSO COFFEE")
font.pixelSize: 18
}
Image {
x: 414
y: 134
visible: coffeeName !== "Espresso"
source: "images/ui controls/line.png"
}
Text {
x: 512
y: 119
color: "#ffffff"
text: qsTr("MILK FOAM")
font.pixelSize: 18
visible: coffeeName !== "Espresso"
}
Image {
x: 404
y: 242
source: "images/ui controls/line.png"
visible: coffeeName !== "Espresso"
}
Image {
x: 388
y: 342
source: "images/ui controls/line.png"
}
Item {
id: sugarItem
x: 181
y: 279
width: 119
height: 111
Rectangle {
x: 21
y: 28
width: 48
height: 48
color: "#ffffff"
opacity: root.sugarAmount / 10
}
Rectangle {
x: 74
y: 60
width: 32
height: 32
color: "#ffffff"
visible: root.sugarAmount > 5
opacity: root.sugarAmount / 30
}
Rectangle {
x: 45
y: 82
width: 24
height: 24
color: "#ffffff"
opacity: root.sugarAmount / 25
}
}
}
Rectangle {
id: slider
color: "grey"
width: 20
radius: width / 2
height: parent.height * 0.65
x: parent.width * 0.9
y: parent.height * 0.10
property real minY: 0
property real maxY: height
Rectangle {
id: handle
x: -width / 2 + parent.width / 2
y: (10 - (coffeeName !== "Espresso" ? milkAmount : coffeeAmount)) / 10 * slider.maxY - width / 2
width: root.width * 0.07
height: width
radius: width / 2
color: "white"
}
MouseArea {
id: ta
anchors.fill: parent
anchors.margins: -10
onMouseYChanged: {
var newY = ta.mouseY
var value = Math.max(slider.minY, Math.min(slider.maxY, newY))
handle.y = value - handle.width / 2
if (coffeeName !== "Espresso")
milkAmount = 10 - 10 * value / slider.maxY
else
coffeeAmount = 10 - 10 * value / slider.maxY
}
}
}
Image {
source: "images/icons/contents/milk.png"
anchors.horizontalCenter: slider.horizontalCenter
anchors.bottom: slider.top
}
NavigationButton {
text: "Brew"
anchors.right: parent.right
anchors.bottom: parent.bottom
onClicked: brew(coffeeName, coffeeAmount, milkAmount, foamAmount)
}
NavigationButton {
forward: false
anchors.left: parent.left
anchors.bottom: parent.bottom
onClicked: back()
}
function startAdjusting(name, coffeePreset, milkPreset , foamPreset) {
coffeeName = name
coffeeAmount = coffeePreset
milkAmount = milkPreset
foamAmount = foamPreset
}
}
/******************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Quick Ultralite module.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
******************************************************************************/
import QtQuick 2.12
Item {
id: root
signal clicked
property alias text: brewLabel.text
property bool forward: true
width: row.width
height: row.height
Row {
id: row
spacing: 17
Image {
id: image
anchors.verticalCenter: parent.verticalCenter
source: "images/ui controls/buttons/back/white.png"
visible: !forward
}
Text {
id: brewLabel
color: "#ffffff"
font.pixelSize: 64
}
Image {
id: image2
anchors.verticalCenter: parent.verticalCenter
source: "images/ui controls/buttons/go/white.png"
visible: forward
}
}
MouseArea {
id: mouseArea
anchors.fill: row
anchors.margins: -10
onClicked: root.clicked()
}
}
/******************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Quick Ultralite module.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
******************************************************************************/
import QtQuick 2.10
Item {
id: root
property real milkAmount: 0
property real coffeeAmount: 0
property real foamAmount: 0
property real milkTarget: 0
property real coffeeTarget: 0
property real foamTarget: 0
signal done
SequentialAnimation {
id: brewAnimation
PauseAnimation {
duration: 200
}
NumberAnimation {
target: root
property: "coffeeAmount"
duration: 3000
from: 0
to: coffeeTarget
}
PauseAnimation {
duration: milkTarget === 0 ? 0 : 200
}
NumberAnimation {
target: root
property: "milkAmount"
duration: milkTarget === 0 ? 0 : 1000
from: 0
to: milkTarget
}
PauseAnimation {
duration: foamTarget === 0 ? 0 : 200
}
NumberAnimation {
target: root
property: "foamAmount"
duration: foamTarget === 0 ? 0 : 500
from: 0
to: foamTarget
}
}
Rectangle {
id: rectangle
color: "#443224"
anchors.fill: parent
Image {
id: background
x: 12
y: 30
source: "images/cup structure/cup elements/coffee_cup_back.png"
}
Item {
id: foam
x: 12
width: 457
y: milk.y - foamAmount
height: background.height - (y - background.y)
clip: true
Image {
anchors.bottom: parent.bottom
source: "images/cup structure/liquids/liquid_foam.png"
}
}
Item {
id: milk
x: 12
width: 457
y: background.y + (400 - coffee.height - root.milkAmount * 15 + 20)
height: background.height - (y - background.y)
clip: true
Image {
source: "images/cup structure/liquids/liquid_milk.png"
anchors.bottom: parent.bottom
}
}
Item {
id: coffee
x: 12
width: 457
height: root.coffeeAmount * 40
anchors.bottom: background.bottom
clip: true
Image {
anchors.bottom: parent.bottom
source: "images/cup structure/liquids/liquid_coffee.png"
}
}
Image {
id: cupFront
x: 11
y: 30
source: "images/cup structure/cup elements/coffee_cup_front.png"
}
Column {
id: textColumn
anchors.left: background.right
anchors.top: background.top
Text {
font.pixelSize: 58
color: "#ffffff"
text: "Brewing"
}
Text {
id: coffeeText
font.pixelSize: 58
color: "#ffffff"
}
Text {
font.pixelSize: 64
color: "#ffffff"
text: !brewingTimer.running ? "..."
: brewingTimer.counter % 4 == 3 ? "..."
: brewingTimer.counter % 4 == 2 ? ".."
: brewingTimer.counter % 4 == 1 ? "."
: ""
}
}
NavigationButton {
id: doneText
anchors.bottom: background.bottom
anchors.left: textColumn.left
visible: !brewAnimation.running
text: "DONE"
forward: false
onClicked: done()
}
}
Timer {
id: brewingTimer
property bool ledEnabled: false
property int counter: 0
repeat: true
interval: 500
running: brewAnimation.running
onRunningChanged: counter = 0
onTriggered: {
counter++
ledEnabled = !ledEnabled
// LED.setEnabled(ledEnabled)
}
}
function startBrewing(name, coffeeTarget, milkTarget, foamTarget) {
coffeeText.text = name
coffeeAmount = 0
milkAmount = 0
foamAmount = 0
root.coffeeTarget = coffeeTarget
root.milkTarget = milkTarget
root.foamTarget = foamTarget
brewAnimation.start()
}
}
import QtQuick 2.12
import mcucoffee 1.0
Rectangle {
width: Constants.width
height: Constants.height
color: Constants.backgroundColor
Text {
text: qsTr("Hello mcucoffee")
anchors.centerIn: parent
font.family: Constants.font.family
}
}
/******************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Quick Ultralite module.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
******************************************************************************/
import QtQuick 2.0
Item {
signal select(string coffeeName, real coffeeAmount, real milkAmount, real foamAmount)
Text {
font.pixelSize: 64
color: "#ffffff"
text: "Select coffee"
anchors.horizontalCenter: parent.horizontalCenter
y: 16
}
Row {
id: row
anchors.fill: parent
spacing: (parent.width - espresso.width * 3) / 2
Item {
width: espresso.width
height: parent.height
Image {
id: espresso
y: 120
height: parent.height
fillMode: Image.PreserveAspectFit
source: "images/icons/coffees/Espresso.png"
MouseArea {
anchors.fill: parent
onClicked: {
select("Espresso", 6, 0, 0);
}
}
}
Text {
font.pixelSize: 32
color: "#ffffff"
text: "Espresso"
y: parent.height * 0.83
anchors.horizontalCenter: parent.horizontalCenter
}
}
Item {
width: espresso.width
height: parent.height
Image {
id: latte
y: 120
height: parent.height
fillMode: Image.PreserveAspectFit
source: "images/icons/coffees/Latte.png"
MouseArea {
anchors.fill: parent
onClicked: {
select("Latte", 4, 8, 40);
}
}
}
Text {
font.pixelSize: 32
color: "#ffffff"
text: "Latte"
y: parent.height * 0.83
anchors.horizontalCenter: parent.horizontalCenter
}
}
Item {
width: espresso.width
height: parent.height
Image {
id: cappucino
y: 120
height: parent.height
fillMode: Image.PreserveAspectFit
source: "images/icons/coffees/cappucino.png"
MouseArea {
anchors.fill: parent
onClicked: {
select("Cappucino", 4, 4, 40);
}
}
}
Text {
font.pixelSize: 32
color: "#ffffff"
text: "Cappucino"
y: parent.height * 0.83
anchors.horizontalCenter: parent.horizontalCenter
}
}
}
}
/*##^##
Designer {
D{i:0;height:480;width:800}
}
##^##*/
/******************************************************************************
**
** Copyright (C) 2020 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Quick Ultralite module.
**
** $QT_BEGIN_LICENSE:COMM$
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/contact-us.
**
** $QT_END_LICENSE$
**
******************************************************************************/
//pragma main;
import QtQuick 2.10