Check battery level automatically every minute and play sound when necessary
This commit is contained in:
parent
ac9e3a088b
commit
28ed6b936d
2 changed files with 33 additions and 6 deletions
|
@ -31,15 +31,15 @@ DISTFILES += qml/harbour-batterybuddy.qml \
|
||||||
|
|
||||||
# Begin: include sound files
|
# Begin: include sound files
|
||||||
|
|
||||||
OTHER_FILES += sounds/upperLimit.ogg \
|
#OTHER_FILES += sounds/upperLimit.ogg \
|
||||||
sounds/lowerLimit.ogg \
|
# sounds/lowerLimit.ogg \
|
||||||
|
|
||||||
DEPLOYMENT_PATH = /usr/share/$${TARGET}
|
#DEPLOYMENT_PATH = /usr/share/$${TARGET}
|
||||||
|
|
||||||
sounds.files = sounds
|
#sounds.files = sounds
|
||||||
sounds.path = $${DEPLOYMENT_PATH}
|
#sounds.path = $${DEPLOYMENT_PATH}
|
||||||
|
|
||||||
INSTALLS += sounds
|
#INSTALLS += sounds
|
||||||
|
|
||||||
# End: include sound files
|
# End: include sound files
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import QtQuick 2.0
|
import QtQuick 2.0
|
||||||
|
import QtMultimedia 5.6
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
|
|
||||||
Page {
|
Page {
|
||||||
|
@ -7,6 +8,32 @@ Page {
|
||||||
// The effective value will be restricted by ApplicationWindow.allowedOrientations
|
// The effective value will be restricted by ApplicationWindow.allowedOrientations
|
||||||
allowedOrientations: Orientation.All
|
allowedOrientations: Orientation.All
|
||||||
|
|
||||||
|
MediaPlayer {
|
||||||
|
id: alertLow
|
||||||
|
audioRole: MediaPlayer.NotificationRole
|
||||||
|
autoLoad: true
|
||||||
|
source: settings.lowAlertFile
|
||||||
|
}
|
||||||
|
|
||||||
|
MediaPlayer {
|
||||||
|
id: alertHigh
|
||||||
|
audioRole: MediaPlayer.NotificationRole
|
||||||
|
autoLoad: true
|
||||||
|
source: settings.highAlertFile
|
||||||
|
}
|
||||||
|
|
||||||
|
Timer {
|
||||||
|
interval: 60000
|
||||||
|
running: true
|
||||||
|
repeat: true
|
||||||
|
onTriggered: {
|
||||||
|
if(battery.charge <= settings.lowerLimit && battery.charging === false)
|
||||||
|
alertLow.play()
|
||||||
|
else if(battery.charge >= settings.upperLimit && battery.charging === true)
|
||||||
|
alertLow.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// To enable PullDownMenu, place our content in a SilicaFlickable
|
// To enable PullDownMenu, place our content in a SilicaFlickable
|
||||||
SilicaFlickable {
|
SilicaFlickable {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
|
Loading…
Reference in a new issue