2020-10-01 14:19:47 +02:00
|
|
|
import QtQuick 2.0
|
|
|
|
import QtQuick.Controls 2.9
|
|
|
|
import QtGraphicalEffects 1.0
|
|
|
|
|
|
|
|
import de.itsblue.ScStw 2.0
|
|
|
|
import de.itsblue.ScStw.Styling 2.0
|
|
|
|
import de.itsblue.ScStw.Styling.Components 1.0
|
|
|
|
|
|
|
|
DelayButton {
|
|
|
|
id : control
|
|
|
|
|
|
|
|
text: "start"
|
|
|
|
property color backgroundColor: appTheme.theme.colors.button
|
|
|
|
property bool progressControlActivated: false
|
|
|
|
property double startProgress
|
2020-10-05 20:41:42 +02:00
|
|
|
property double oldStartProgress: -1
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
delay: progressControlActivated ? 2000:0
|
|
|
|
|
2020-10-05 20:41:42 +02:00
|
|
|
onStartProgressChanged: {
|
|
|
|
if(startProgress > oldStartProgress)
|
|
|
|
oldStartProgress = startProgress
|
|
|
|
else {
|
|
|
|
startProgressAnimation.from = oldStartProgress
|
|
|
|
startProgressAnimation.to = startProgress
|
|
|
|
startProgressAnimation.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
Text {
|
|
|
|
id: labelText
|
|
|
|
text: control.text
|
|
|
|
anchors.centerIn: parent
|
|
|
|
font.pixelSize: parent.height * 0.16
|
|
|
|
font.family: "Helvetica"
|
|
|
|
color: enabled ? appTheme.theme.colors.text:appTheme.theme.colors.disabledText
|
|
|
|
}
|
|
|
|
|
2020-10-05 20:41:42 +02:00
|
|
|
NumberAnimation {
|
|
|
|
id: startProgressAnimation
|
|
|
|
|
|
|
|
to: 0
|
|
|
|
target: control
|
|
|
|
properties: "oldStartProgress"
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
Behavior on text {
|
|
|
|
//animate a text change
|
|
|
|
enabled: true
|
|
|
|
FadeAnimation {
|
|
|
|
target: labelText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Text {
|
|
|
|
}
|
|
|
|
|
|
|
|
background: Item {
|
|
|
|
RectangularGlow {
|
|
|
|
glowRadius: 0.001
|
|
|
|
spread: 0.2
|
|
|
|
color: "black"
|
|
|
|
|
|
|
|
visible: true
|
|
|
|
|
|
|
|
cornerRadius: background.radius
|
|
|
|
anchors.fill: background
|
|
|
|
scale: 0.75
|
|
|
|
opacity: Math.pow( control.opacity, 100 )
|
|
|
|
}
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: background
|
|
|
|
implicitWidth: 100
|
|
|
|
implicitHeight: 100
|
|
|
|
color: control.down ? Qt.darker(control.backgroundColor, 1.2) : control.backgroundColor
|
|
|
|
radius: size / 2
|
|
|
|
|
|
|
|
readonly property real size: Math.min(control.width, control.height)
|
|
|
|
width: size
|
|
|
|
height: size
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
Behavior on color {
|
|
|
|
ColorAnimation {
|
|
|
|
duration: 200
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Canvas {
|
|
|
|
id: canvas
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
Connections {
|
|
|
|
target: control
|
|
|
|
onProgressChanged: canvas.requestPaint()
|
2020-10-05 20:41:42 +02:00
|
|
|
onOldStartProgressChanged: canvas.requestPaint()
|
2020-10-01 14:19:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
onPaint: {
|
|
|
|
var progress
|
2020-10-06 14:01:11 +02:00
|
|
|
var showHoldProgress = ((control.oldStartProgress <= 0 || control.oldStartProgress === 1) && control.progressControlActivated)
|
2020-10-02 19:58:25 +02:00
|
|
|
|
2020-10-01 14:19:47 +02:00
|
|
|
if(showHoldProgress)
|
|
|
|
progress = control.progress
|
|
|
|
else
|
2020-10-05 20:41:42 +02:00
|
|
|
progress = control.oldStartProgress < 0 ? 0:1-control.oldStartProgress
|
2020-10-01 14:19:47 +02:00
|
|
|
|
|
|
|
|
|
|
|
var ctx = getContext("2d")
|
|
|
|
ctx.clearRect(0, 0, width, height)
|
|
|
|
ctx.strokeStyle = showHoldProgress ? appTheme.theme.colors.error:"grey"
|
|
|
|
ctx.lineWidth = parent.width * 0.02
|
|
|
|
ctx.beginPath()
|
|
|
|
var startAngle = Math.PI * 1.5
|
|
|
|
var endAngle = startAngle + progress * Math.PI * 2
|
|
|
|
ctx.arc(width / 2, height / 2, width / 2 - ctx.lineWidth / 2 - 2, startAngle, endAngle)
|
|
|
|
ctx.stroke()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|