This repository has been archived on 2024-06-03. You can view files and clone it, but cannot push or open issues or pull requests.
app/resources/qml/connections/StartpadConn.qml

98 lines
2.3 KiB
QML
Raw Permalink Normal View History

import QtQuick 2.0
Item {
id: startpadConn
height: 0
width: 0
opacity: 0
visible: false
signal pushed()
property bool connected: false
property var status: {'status': startpadConn.state, 'progress': get_progress()}
2018-09-09 20:18:00 +02:00
property bool active
Timer {
//timer that refreshes the connection state to the buzzer
id: connectionRefreshTimer
running: root.state !== "RUNNING" && root.state !== "STARTING" && startpadConn.status !== "connecting"
repeat: false
interval: 1000
onTriggered: {
_cppStartpadConn.refresh()
if(!_cppStartpadConn.get("connected") && startpadConn.state !== "connecting"){
startpadConn.state = "disconnected"
}
connectionRefreshTimer.start()
}
}
Timer {
//timer that checks, if the button has been pushed
id: running_refresh_timer
2018-09-09 20:18:00 +02:00
running: (root.state === "RUNNING" || root.state === "STARTING") && active
repeat: false
interval: 1
onTriggered: {
if(_cppStartpadConn.buzzer_triggered()){
startpadConn.pushed()
}
2018-09-09 20:18:00 +02:00
if(root.state === "RUNNING" || root.state === "STARTING" && active){
running_refresh_timer.start()
}
}
}
Timer {
id: prog_refresh
running: startpadConn.state === "connecting"
interval: 1
repeat: true
onTriggered: {
startpadConn.status.progress = get_progress()
}
}
states: [
State {
name: "disconnected"
PropertyChanges {
target: startpadConn
}
},
State {
name: "connecting"
PropertyChanges {
target: startpadConn
}
},
State {
name: "connected"
PropertyChanges {
target: startpadConn
}
}
]
function connect(){
startpadConn.state = "connecting"
if(_cppStartpadConn.connect()){
startpadConn.state = "connected"
return(true)
}
else {
startpadConn.state = "disconnected"
return(false)
}
}
function get_progress(){
return(_cppStartpadConn.get("connection_progress"))
}
}