2019-01-29 02:11:32 +03:00
/ * *
* Battery Buddy , a Sailfish application to prolong battery lifetime
*
2020-03-21 04:27:09 +03:00
* Copyright ( C ) 2019 - 2020 Matti Viljanen
2019-01-29 02:11:32 +03:00
*
* Battery Buddy is free software: you can redistribute it and / or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation , either version 3 of the
* License , or ( at your option ) any later version .
*
* Battery Buddy is distributed in the hope that it will be useful , but WITHOUT ANY WARRANTY ;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE .
*
* See the GNU General Public License for more details . You should have received a copy of the GNU
* General Public License along with CarBudget . If not , see < http: //www.gnu.org/licenses/>.
*
* Author: Matti Viljanen
* /
import QtQuick 2.0
import Sailfish . Silica 1.0
2020-03-20 23:57:59 +03:00
import "../components"
2019-01-29 02:11:32 +03:00
Page {
id: settingsPage
2020-03-21 05:03:40 +03:00
onStatusChanged: {
if ( status === PageStatus . Activating ) {
autoStopCharging . checked = settings . notificationsEnabled
}
}
2020-03-20 18:26:29 +03:00
SilicaFlickable {
anchors.fill: parent
contentHeight: header . height + settingsColumn . height + Theme . horizontalPageMargin
2019-01-29 02:11:32 +03:00
2020-03-21 04:22:47 +03:00
VerticalScrollDecorator { flickable: mainFlickable }
2020-03-21 04:25:26 +03:00
PullDownMenu {
MenuItem {
text: qsTr ( "About" , "About this application" )
onClicked: pageStack . push ( Qt . resolvedUrl ( "AboutPage.qml" ) )
}
}
2020-03-20 18:26:29 +03:00
PageHeader {
id: header
title: qsTr ( "Settings" )
2019-01-29 02:11:32 +03:00
}
2020-03-20 18:26:29 +03:00
Column {
id: settingsColumn
anchors {
top: header . bottom
left: parent . left
right: parent . right
}
spacing: Theme . paddingMedium
Label {
x: Theme . paddingLarge
2020-03-21 04:22:47 +03:00
text: qsTr ( "Charging settings" )
2020-03-20 18:26:29 +03:00
color: Theme . highlightColor
}
TextSwitch {
id: autoStopCharging
text: qsTr ( "Stop charging when limit reached" )
description: qsTr ( "This option stops charging when battery has reached the percentage set in Charging limit value, and resumes charging when charge has decreased below Continue charge limit value. Generally a value close to the Charging limit value is recommened, such as 80% and 75%." )
onCheckedChanged: settings . limitEnabled = checked
}
2020-03-20 23:57:59 +03:00
MySlider {
2020-03-20 21:57:06 +03:00
id: highLimitSlider
handleVisible: enabled
width: parent . width
label: qsTr ( "Stop charging limit" )
2020-03-21 00:01:50 +03:00
minimumValue: 21
2020-03-20 21:57:06 +03:00
maximumValue: 95
stepSize: 1
2020-03-21 04:22:47 +03:00
Component.onCompleted: value = settings . highLimit
2020-03-20 21:57:06 +03:00
valueText: value + "%"
2020-03-20 23:57:59 +03:00
highlightDirection: Qt . RightToLeft
2020-03-20 21:57:06 +03:00
onValueChanged: {
2020-03-21 00:00:30 +03:00
settings . highLimit = value
2020-03-20 21:57:06 +03:00
if ( lowLimitSlider . value >= value )
lowLimitSlider . value = value - 1
}
}
2020-03-20 23:57:59 +03:00
MySlider {
2020-03-20 21:57:06 +03:00
id: lowLimitSlider
2020-03-20 18:26:29 +03:00
handleVisible: enabled
width: parent . width
label: qsTr ( "Resume charging limit" )
2020-03-20 21:57:06 +03:00
minimumValue: 20
2020-03-21 00:01:50 +03:00
maximumValue: 94
2020-03-20 18:26:29 +03:00
stepSize: 1
2020-03-21 04:22:47 +03:00
Component.onCompleted: value = settings . lowLimit
2020-03-20 18:26:29 +03:00
valueText: value + "%"
2020-03-20 21:57:06 +03:00
onValueChanged: {
2020-03-21 00:00:30 +03:00
settings . lowLimit = value
2020-03-20 21:57:06 +03:00
if ( highLimitSlider . value <= value )
highLimitSlider . value = value + 1
}
2020-03-20 18:26:29 +03:00
}
Label {
x: Theme . paddingLarge
2020-03-21 04:22:47 +03:00
text: qsTr ( "Notification settings" )
2020-03-20 18:26:29 +03:00
color: Theme . highlightColor
}
2020-03-21 04:22:47 +03:00
TextSwitch {
id: notificationsSwitch
text: qsTr ( "Use notifications" )
description: qsTr ( "When the application is minimized, display visual and audible notifications about reached battery charge levels." )
Component.onCompleted: checked = settings . notificationsEnabled
onCheckedChanged: settings . notificationsEnabled = checked
2020-03-20 18:26:29 +03:00
}
2020-03-21 04:22:47 +03:00
MySlider {
id: highAlertSlider
width: parent . width
label: qsTr ( "Charging limit" )
minimumValue: 11
maximumValue: 100
stepSize: 1
Component.onCompleted: value = settings . highAlert
valueText: value + "%"
highlightDirection: Qt . RightToLeft
onValueChanged: {
settings . highAlert = value
if ( lowAlertSlider . value >= value )
lowAlertSlider . value = value - 1
2020-03-20 18:26:29 +03:00
}
2020-03-21 04:22:47 +03:00
}
MySlider {
id: lowAlertSlider
width: parent . width
label: qsTr ( "Discharging limit" )
minimumValue: 10
maximumValue: 99
stepSize: 1
Component.onCompleted: value = settings . lowAlert
valueText: value + "%"
onValueChanged: {
settings . lowAlert = value
if ( highAlertSlider . value <= value )
highAlertSlider . value = value + 1
2020-03-20 18:26:29 +03:00
}
}
2020-03-21 04:22:47 +03:00
MySlider {
width: parent . width
label: qsTr ( "Notification interval" )
minimumValue: 60
maximumValue: 600
stepSize: 10
Component.onCompleted: value = settings . interval
valueText: Math . floor ( value / 60 ) + ( value % 60 < 10 ? ":0" + value % 60 : ":" + value % 60 )
onValueChanged: settings . interval = value
}
2019-01-29 02:11:32 +03:00
}
}
}