Skip to content

Commit

Permalink
Merge branch 'feature/menu-life' into 'main'
Browse files Browse the repository at this point in the history
Feature/menu life

See merge request asxa86/aspire!21
  • Loading branch information
ASxa86 committed Nov 15, 2024
2 parents b0916dc + d571152 commit 5fbee70
Show file tree
Hide file tree
Showing 7 changed files with 302 additions and 282 deletions.
1 change: 0 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"inherits": [
"host-x64-windows",
"target-x64-windows",
"config-build-dir",
"use-visualstudio",
"use-vcpkg"
]
Expand Down
1 change: 1 addition & 0 deletions app/edh/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ qt_add_qml_module(${PROJECT_NAME}
VERSION 1.0
QML_FILES
Main.qml
MenuLife.qml
ModelPlayers.qml
Counter.qml
TextEDH.qml
Expand Down
153 changes: 99 additions & 54 deletions app/edh/Counter.qml
Original file line number Diff line number Diff line change
@@ -1,75 +1,120 @@
import QtQuick
import aspire

Rectangle {
Item {
id: root

property alias text: txtLife.text
property alias textTime: time.text
property bool active: false
clip: true

signal decrementClicked()
signal incrementClicked()
signal timeTriggered(int seconds)
required property int index
required property color background
required property bool selected
required property int life
required property int time

ButtonCircle {
property point center: Qt.point(parent.width / 8, parent.height / 2)
width: parent.width * 0.75
height: width
x: center.x - width / 2
y: center.y - height / 2

onClicked: root.decrementClicked()
Rectangle {
id: mask
anchors.fill: parent
radius: width / 16
visible: false
layer.enabled: true
}

ButtonCircle {
property point center: Qt.point(parent.width - parent.width / 8, parent.height / 2)
width: parent.width * 0.75
height: width
x: center.x - width / 2
y: center.y - height / 2
Rectangle {
id: glow
anchors.fill: parent
layer.enabled: true
layer.effect: MultiEffect {
blurEnabled: true
blur: 0.1
brightness: 0.5
}

radius: width / 16
color: "darkgoldenrod"
opacity: selected ? 1 : 0
scale: 0.99

onClicked: root.incrementClicked()
TapHandler {
onLongPressed: {
Actions.select(index);
}
}
}

TextEDH {
id: txtLife
Item {
anchors.fill: parent
layer.enabled: true
layer.effect: MultiEffect {
source: counter
maskSource: mask
maskEnabled: true
}

anchors.centerIn: parent
font.pixelSize: Math.min(parent.width, parent.height) / 2
}
scale: 0.98

Rectangle {
width: parent.width
height: parent.height * 0.1
Rectangle {
anchors.fill: parent

Component.onCompleted: {
color = Style.color.cardback;
color.a = 0.3;
}
gradient: Gradient {
GradientStop { position: 0.0; color: root.background }
GradientStop { position: 1.0; color: Qt.darker(root.background) }
}

TextEDH {
id: time
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: parent.height
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 15
}
}
ButtonCircle {
property point center: Qt.point(parent.width / 8, parent.height / 2)
width: parent.width * 0.75
height: width
x: center.x - width / 2
y: center.y - height / 2

onActiveChanged: {
timer.running = root.active
}
onClicked: Actions.updateLife(root.index, root.life - 1)
}

ButtonCircle {
property point center: Qt.point(parent.width - parent.width / 8, parent.height / 2)
width: parent.width * 0.75
height: width
x: center.x - width / 2
y: center.y - height / 2

onClicked: Actions.updateLife(root.index, root.life + 1)
}

TextEDH {
anchors.centerIn: parent
font.pixelSize: Math.min(parent.width, parent.height) / 2
text: root.life.toString()
}

Rectangle {
width: parent.width
height: parent.height * 0.1

Component.onCompleted: {
color = Style.color.cardback;
color.a = 0.3;
}

TextEDH {
verticalAlignment: Text.AlignVCenter
horizontalAlignment: Text.AlignHCenter
font.pixelSize: parent.height
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
anchors.leftMargin: 15
text: Qt.formatTime(new Date(root.time), "mm:ss")
}
}

Timer {
id: timer
interval: 1000
repeat: true
Timer {
id: timer
interval: 100
repeat: true
running: root.selected

onTriggered: {
root.timeTriggered(interval / 1000)
onTriggered: Actions.updateTime(root.index, root.time + interval)
}
}
}
}
}
Loading

0 comments on commit 5fbee70

Please sign in to comment.