harbour-batterybuddy/qml/pages/MainPage.qml

98 lines
2.8 KiB
QML
Raw Normal View History

2019-01-05 16:49:35 +03:00
import QtQuick 2.0
import QtMultimedia 5.6
2019-01-05 16:49:35 +03:00
import Sailfish.Silica 1.0
Page {
id: page
// The effective value will be restricted by ApplicationWindow.allowedOrientations
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()
}
}
2019-01-05 16:49:35 +03:00
// To enable PullDownMenu, place our content in a SilicaFlickable
SilicaFlickable {
anchors.fill: parent
// Tell SilicaFlickable the height of its content.
contentHeight: column.height
2019-01-05 21:16:04 +03:00
PullDownMenu {
MenuItem {
2019-01-06 00:37:44 +03:00
text: qsTr("About")
2019-01-05 21:16:04 +03:00
onClicked: pageStack.push(Qt.resolvedUrl("AboutPage.qml"))
}
2019-01-06 00:37:44 +03:00
MenuItem {
text: qsTr("More info")
onClicked: pageStack.push(Qt.resolvedUrl("InfoPage.qml"))
}
2019-01-05 21:16:04 +03:00
}
2019-01-05 16:49:35 +03:00
// Place our content in a Column. The PageHeader is always placed at the top
// of the page, followed by our content.
Column {
id: column
width: page.width
spacing: Theme.paddingLarge
PageHeader {
title: qsTr("Battery Buddy")
}
DetailItem {
label: qsTr("Charge level")
value: battery.charge;
2019-01-05 16:49:35 +03:00
}
DetailItem {
label: qsTr("Charging")
value: battery.charging ? "yes" : "no";
2019-01-05 16:49:35 +03:00
}
Slider {
id: highSlider
width: parent.width
label: qsTr("Upper limit")
minimumValue: 60
maximumValue: 99
stepSize: 1
value: settings.upperLimit
valueText: highSlider.value
onValueChanged: settings.upperLimit = highSlider.value
}
Slider {
id: lowSlider
width: parent.width
label: qsTr("Lower limit")
minimumValue: 10
maximumValue: 40
stepSize: 1
value: settings.lowerLimit
valueText: lowSlider.value
onValueChanged: settings.lowerLimit = lowSlider.value
}
2019-01-05 16:49:35 +03:00
}
}
}