Add controls to enable/disable the daemon at startup
This commit is contained in:
parent
b25292582c
commit
a8a301cee2
6 changed files with 120 additions and 8 deletions
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
|
import Process 1.0
|
||||||
import "../components"
|
import "../components"
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
|
@ -24,6 +25,14 @@ Page {
|
||||||
allowedOrientations: Orientation.Portrait | Orientation.Landscape | Orientation.LandscapeInverted
|
allowedOrientations: Orientation.Portrait | Orientation.Landscape | Orientation.LandscapeInverted
|
||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: startupTimer
|
||||||
|
interval: 100
|
||||||
|
repeat: false
|
||||||
|
running: true
|
||||||
|
onTriggered: {
|
||||||
autoStopCharging.checked = settings.limitEnabled
|
autoStopCharging.checked = settings.limitEnabled
|
||||||
highLimitSlider.value = settings.highLimit
|
highLimitSlider.value = settings.highLimit
|
||||||
lowLimitSlider.value = settings.lowLimit
|
lowLimitSlider.value = settings.lowLimit
|
||||||
|
@ -32,6 +41,54 @@ Page {
|
||||||
lowAlertSlider.value = settings.lowAlert
|
lowAlertSlider.value = settings.lowAlert
|
||||||
intervalSlider.value = settings.interval
|
intervalSlider.value = settings.interval
|
||||||
console.debug("SettingsPage values updated")
|
console.debug("SettingsPage values updated")
|
||||||
|
daemonCheck.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: daemonToggle
|
||||||
|
interval: 100
|
||||||
|
running: false
|
||||||
|
repeat: false
|
||||||
|
onTriggered: {
|
||||||
|
var action = daemonEnabledSwitch.checked ? "disable" : "enable"
|
||||||
|
console.log("Action: " + action)
|
||||||
|
_toggleProcess.start("/bin/systemctl", ["--user", action, "harbour-batterybuddy.service"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
// Only used by daemonToggle timer
|
||||||
|
id: _toggleProcess
|
||||||
|
onFinished: {
|
||||||
|
daemonCheck.start()
|
||||||
|
console.debug("Service toggle " + (errorCode() === 0 ? "succeeded" : "failed"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
id: daemonCheck
|
||||||
|
interval: 0
|
||||||
|
running: false
|
||||||
|
repeat: false
|
||||||
|
onTriggered: {
|
||||||
|
_checkProcess.start("/bin/systemctl", ["--user", "is-enabled", "harbour-batterybuddy.service"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Process {
|
||||||
|
// Only used by daemonCheck timer
|
||||||
|
id: _checkProcess
|
||||||
|
onFinished: {
|
||||||
|
if(errorCode() === 0) {
|
||||||
|
daemonEnabledSwitch.checked = true
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
daemonEnabledSwitch.checked = false
|
||||||
|
}
|
||||||
|
daemonEnabledSwitch.busy = false
|
||||||
|
console.info("Service is " + (errorCode() === 0 ? "enabled" : "disabled"))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SilicaFlickable {
|
SilicaFlickable {
|
||||||
|
@ -174,6 +231,21 @@ Page {
|
||||||
valueText: Math.floor(value / 60) + (value % 60 < 10 ? ":0" + value % 60 : ":" + value % 60)
|
valueText: Math.floor(value / 60) + (value % 60 < 10 ? ":0" + value % 60 : ":" + value % 60)
|
||||||
onReleased: settings.interval = value
|
onReleased: settings.interval = value
|
||||||
}
|
}
|
||||||
|
Label {
|
||||||
|
x: Theme.paddingLarge
|
||||||
|
text: qsTr("Background service")
|
||||||
|
color: Theme.highlightColor
|
||||||
|
}
|
||||||
|
TextSwitch {
|
||||||
|
id: daemonEnabledSwitch
|
||||||
|
text: qsTr("Start background service at startup")
|
||||||
|
checked: true
|
||||||
|
onClicked: {
|
||||||
|
busy = true
|
||||||
|
checked = !checked
|
||||||
|
daemonToggle.start()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,5 +310,13 @@ Buddy</translation>
|
||||||
<source>This option disables charging automatically when the battery has charged above the pausing percentage and enables it again when the battery has depleted below the resuming percentage.</source>
|
<source>This option disables charging automatically when the battery has charged above the pausing percentage and enables it again when the battery has depleted below the resuming percentage.</source>
|
||||||
<translation>Tämä valinta keskeyttää akun latauksen automaattisesti, kun akku on latautunut keskeytysrajaan asti, ja jatkaa latausta uudelleen, kun akku on purkautunut jatkamisrajaan asti.</translation>
|
<translation>Tämä valinta keskeyttää akun latauksen automaattisesti, kun akku on latautunut keskeytysrajaan asti, ja jatkaa latausta uudelleen, kun akku on purkautunut jatkamisrajaan asti.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Background service</source>
|
||||||
|
<translation>Taustapalvelu</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Start background service at startup</source>
|
||||||
|
<translation>Käynnistä taustapalvelu kun puhelin käynnistyy</translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
|
@ -309,5 +309,13 @@ Buddy</source>
|
||||||
<source>Notification interval</source>
|
<source>Notification interval</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Background service</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Start background service at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
|
@ -312,5 +312,13 @@ Buddy</translation>
|
||||||
<source>This option disables charging automatically when the battery has charged above the pausing percentage and enables it again when the battery has depleted below the resuming percentage.</source>
|
<source>This option disables charging automatically when the battery has charged above the pausing percentage and enables it again when the battery has depleted below the resuming percentage.</source>
|
||||||
<translation>Detta alternativ inaktiverar laddningen automatiskt, när batteriet har laddats upp över pausprocenten och aktiverar det igen, när batteriet har laddats ur under återupptagandeprocent.</translation>
|
<translation>Detta alternativ inaktiverar laddningen automatiskt, när batteriet har laddats upp över pausprocenten och aktiverar det igen, när batteriet har laddats ur under återupptagandeprocent.</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Background service</source>
|
||||||
|
<translation>Bakgrundstjänst</translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Start background service at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
|
@ -310,5 +310,13 @@ Buddy(电池搭档)</translation>
|
||||||
<source>Notification interval</source>
|
<source>Notification interval</source>
|
||||||
<translation>通知间隔</translation>
|
<translation>通知间隔</translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Background service</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Start background service at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
|
@ -309,5 +309,13 @@ Buddy</source>
|
||||||
<source>This option disables charging automatically when the battery has charged above the pausing percentage and enables it again when the battery has depleted below the resuming percentage.</source>
|
<source>This option disables charging automatically when the battery has charged above the pausing percentage and enables it again when the battery has depleted below the resuming percentage.</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Background service</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Start background service at startup</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
</TS>
|
</TS>
|
||||||
|
|
Loading…
Reference in a new issue