implement settings for health alert
This commit is contained in:
parent
93fa677a6f
commit
dfbf1ec078
2 changed files with 46 additions and 20 deletions
|
@ -43,7 +43,7 @@ Page {
|
|||
highLimitSlider.value = settings.highLimit
|
||||
lowLimitSlider.value = settings.lowLimit
|
||||
highAlertSlider.value = settings.highAlert
|
||||
healthAlertSlider.value = settings.healthAlert
|
||||
healthSelector.currentIndex = settings.healthAlert
|
||||
lowAlertSlider.value = settings.lowAlert
|
||||
highIntervalSlider.value = settings.highNotificationsInterval
|
||||
lowIntervalSlider.value = settings.lowNotificationsInterval
|
||||
|
@ -368,28 +368,39 @@ Page {
|
|||
largeChange: 60
|
||||
}
|
||||
|
||||
Label {
|
||||
x: Theme.paddingLarge
|
||||
text: qsTr("Health Notification settings")
|
||||
color: Theme.highlightColor
|
||||
}
|
||||
Label {
|
||||
text: qsTr("Display visual and audible notifications about battery health, when the battery temperature is below or above safe values.")
|
||||
anchors {
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
leftMargin: Theme.horizontalPageMargin*2
|
||||
rightMargin: Theme.horizontalPageMargin
|
||||
}
|
||||
color: Theme.primaryColor
|
||||
font.pixelSize: Theme.fontSizeExtraSmall
|
||||
wrapMode: Text.Wrap
|
||||
}
|
||||
|
||||
SectionHeader { text: qsTr("Battery health notification") }
|
||||
|
||||
MySlider {
|
||||
id: healthAlertSlider
|
||||
minimumValue: 0
|
||||
maximumValue: 2
|
||||
stepSize: 1
|
||||
onValueChanged: {
|
||||
if(healthAlertSlider.value <= value)
|
||||
healthAlertSlider.value = value + 1
|
||||
ComboBox {
|
||||
id: healthSelector
|
||||
width: parent.width
|
||||
label: qsTr("Warn on Health status" + ":")
|
||||
currentIndex: settings.healthAlert
|
||||
menu: ContextMenu {
|
||||
MenuItem { text: qsTr("None") }
|
||||
MenuItem { text: qsTr("Warning") }
|
||||
MenuItem { text: qsTr("Critical") }
|
||||
}
|
||||
valueText: {
|
||||
if (value === 0)
|
||||
return "None"
|
||||
if (value === 1)
|
||||
return "Warning"
|
||||
if (value === 2)
|
||||
return "Critical"
|
||||
}
|
||||
onReleased: save()
|
||||
function save(){
|
||||
settings.healthAlert = value
|
||||
onValueChanged: save()
|
||||
function save() {
|
||||
settings.healthAlert = healthSelector.currentIndex
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,8 +31,10 @@ Settings::Settings(Logger *newLogger, QObject *parent) : QObject(parent)
|
|||
// Read in the values
|
||||
loadInteger(sLowAlert, lowAlert, 5, 99);
|
||||
loadInteger(sHighAlert, highAlert, 6, 100);
|
||||
loadInteger(sHealthAlert, healthAlert, 0, 2);
|
||||
loadInteger(sHighNotificationsInterval, highNotificationsInterval, 50, 610);
|
||||
loadInteger(sLowNotificationsInterval, lowNotificationsInterval, 50, 610);
|
||||
loadInteger(sHealthNotificationsInterval, healthNotificationsInterval, 50, 610);
|
||||
loadInteger(sLimitEnabled, limitEnabled, 0, 1);
|
||||
loadInteger(sLowLimit, lowLimit, 5, 99);
|
||||
loadInteger(sHighLimit, highLimit, 6, 100);
|
||||
|
@ -43,10 +45,12 @@ Settings::Settings(Logger *newLogger, QObject *parent) : QObject(parent)
|
|||
loadString(sNotificationTitle, notificationTitle);
|
||||
loadString(sNotificationLowText, notificationLowText);
|
||||
loadString(sNotificationHighText, notificationHighText);
|
||||
loadString(sNotificationHealthText, notificationHealthText);
|
||||
|
||||
saveString(sNotificationTitle, tr("Battery charge %1%"), notificationTitle);
|
||||
saveString(sNotificationLowText, tr("Please connect the charger."), notificationLowText);
|
||||
saveString(sNotificationHighText, tr("Please disconnect the charger."), notificationHighText);
|
||||
saveString(sNotificationHealthText, tr("Battery health"), notificationHealthText);
|
||||
}
|
||||
|
||||
Settings::~Settings()
|
||||
|
@ -105,6 +109,12 @@ void Settings::setLowNotificationsInterval(const int newInterval) {
|
|||
}
|
||||
}
|
||||
|
||||
void Settings::setHealthNotificationsInterval(const int newInterval) {
|
||||
if(saveInteger(sHealthNotificationsInterval, newInterval, healthNotificationsInterval)) {
|
||||
emit healthNotificationsIntervalChanged(healthNotificationsInterval);
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setLowLimit(const int newLimit) {
|
||||
if(saveInteger(sLowLimit, newLimit, lowLimit)) {
|
||||
emit lowLimitChanged(lowLimit);
|
||||
|
@ -136,6 +146,11 @@ void Settings::setNotificationHighText(const QString newText) {
|
|||
emit notificationHighTextChanged(notificationHighText);
|
||||
}
|
||||
|
||||
void Settings::setNotificationHealthText(const QString newText) {
|
||||
if(saveString(sNotificationHealthText, newText, notificationHealthText))
|
||||
emit notificationHealthTextChanged(notificationHealthText);
|
||||
}
|
||||
|
||||
void Settings::setLogLevel(const int newLogLevel) {
|
||||
if(saveInteger(sLogLevel, newLogLevel, logLevel))
|
||||
emit logLevelChanged(logLevel);
|
||||
|
|
Loading…
Reference in a new issue