Rename timers and processes
This commit is contained in:
parent
6bb39bde4f
commit
a5a8d4fbda
1 changed files with 14 additions and 12 deletions
|
@ -31,6 +31,7 @@ Page {
|
||||||
"empty": qsTr("empty", "Battery fully depleted"),
|
"empty": qsTr("empty", "Battery fully depleted"),
|
||||||
"unknown": qsTr("unknown", "Battery not detected, or faulty, or something")
|
"unknown": qsTr("unknown", "Battery not detected, or faulty, or something")
|
||||||
}
|
}
|
||||||
|
property bool serviceRunning: true
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: startupTimer
|
id: startupTimer
|
||||||
|
@ -39,44 +40,45 @@ Page {
|
||||||
running: true
|
running: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
console.log("Startup timer started")
|
console.log("Startup timer started")
|
||||||
daemonStatus.start("/bin/systemctl", ["--user", "status", "harbour-batterybuddy.service"])
|
daemonStatus.start()
|
||||||
pageStack.pushAttached(Qt.resolvedUrl("SettingsPage.qml"))
|
pageStack.pushAttached(Qt.resolvedUrl("SettingsPage.qml"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: daemonControlTimer
|
id: daemonControl
|
||||||
interval: 100
|
interval: 100
|
||||||
running: false
|
running: false
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
var action = daemonStatus.serviceRunning ? "stop" : "start"
|
var action = serviceRunning ? "stop" : "start"
|
||||||
console.log("Action: " + action)
|
console.log("Action: " + action)
|
||||||
daemonControl.start("/bin/systemctl", ["--user", action, "harbour-batterybuddy.service"])
|
_controlProcess.start("/bin/systemctl", ["--user", action, "harbour-batterybuddy.service"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: daemonControl
|
// Only used by daemonControl timer
|
||||||
|
id: _controlProcess
|
||||||
onFinished: {
|
onFinished: {
|
||||||
daemonStatusTimer.start()
|
daemonStatus.start()
|
||||||
console.debug("Service control return code " + errorCode())
|
console.debug("Service control return code " + errorCode())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Timer {
|
Timer {
|
||||||
id: daemonStatusTimer
|
id: daemonStatus
|
||||||
interval: 2000
|
interval: 2000
|
||||||
running: false
|
running: false
|
||||||
repeat: false
|
repeat: false
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
daemonStatus.start("/bin/systemctl", ["--user", "status", "harbour-batterybuddy.service"])
|
_statusProcess.start("/bin/systemctl", ["--user", "status", "harbour-batterybuddy.service"])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Process {
|
Process {
|
||||||
id: daemonStatus
|
// Only used by daemonStatus timer
|
||||||
property bool serviceRunning: true
|
id: _statusProcess
|
||||||
onFinished: {
|
onFinished: {
|
||||||
if(errorCode() === 0) {
|
if(errorCode() === 0) {
|
||||||
serviceRunning = true
|
serviceRunning = true
|
||||||
|
@ -192,7 +194,7 @@ Page {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
text: qsTr("Start")
|
text: qsTr("Start")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
daemonControlTimer.start()
|
daemonControl.start()
|
||||||
enabled = false
|
enabled = false
|
||||||
}
|
}
|
||||||
enabled: false
|
enabled: false
|
||||||
|
@ -205,7 +207,7 @@ Page {
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
text: qsTr("Stop")
|
text: qsTr("Stop")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
daemonControlTimer.start()
|
daemonControl.start()
|
||||||
enabled = false
|
enabled = false
|
||||||
}
|
}
|
||||||
enabled: false
|
enabled: false
|
||||||
|
|
Loading…
Reference in a new issue