prepare settings for health alert
This commit is contained in:
parent
ce994a0d1e
commit
93fa677a6f
3 changed files with 102 additions and 14 deletions
|
@ -43,9 +43,11 @@ Page {
|
||||||
highLimitSlider.value = settings.highLimit
|
highLimitSlider.value = settings.highLimit
|
||||||
lowLimitSlider.value = settings.lowLimit
|
lowLimitSlider.value = settings.lowLimit
|
||||||
highAlertSlider.value = settings.highAlert
|
highAlertSlider.value = settings.highAlert
|
||||||
|
healthAlertSlider.value = settings.healthAlert
|
||||||
lowAlertSlider.value = settings.lowAlert
|
lowAlertSlider.value = settings.lowAlert
|
||||||
highIntervalSlider.value = settings.highNotificationsInterval
|
highIntervalSlider.value = settings.highNotificationsInterval
|
||||||
lowIntervalSlider.value = settings.lowNotificationsInterval
|
lowIntervalSlider.value = settings.lowNotificationsInterval
|
||||||
|
healthIntervalSlider.value = settings.healthNotificationsInterval
|
||||||
if(logger.debug) logger.log("SettingsPage values updated")
|
if(logger.debug) logger.log("SettingsPage values updated")
|
||||||
daemonCheck.start()
|
daemonCheck.start()
|
||||||
}
|
}
|
||||||
|
@ -365,6 +367,59 @@ Page {
|
||||||
smallChange: 10
|
smallChange: 10
|
||||||
largeChange: 60
|
largeChange: 60
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SectionHeader { text: qsTr("Battery health notification") }
|
||||||
|
|
||||||
|
MySlider {
|
||||||
|
id: healthAlertSlider
|
||||||
|
minimumValue: 0
|
||||||
|
maximumValue: 2
|
||||||
|
stepSize: 1
|
||||||
|
onValueChanged: {
|
||||||
|
if(healthAlertSlider.value <= value)
|
||||||
|
healthAlertSlider.value = value + 1
|
||||||
|
}
|
||||||
|
valueText: {
|
||||||
|
if (value === 0)
|
||||||
|
return "None"
|
||||||
|
if (value === 1)
|
||||||
|
return "Warning"
|
||||||
|
if (value === 2)
|
||||||
|
return "Critical"
|
||||||
|
}
|
||||||
|
onReleased: save()
|
||||||
|
function save(){
|
||||||
|
settings.healthAlert = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SectionHeader { text: qsTr("Battery health warning interval") }
|
||||||
|
|
||||||
|
MySlider {
|
||||||
|
id: healthIntervalSlider
|
||||||
|
minimumValue: 50
|
||||||
|
maximumValue: 610
|
||||||
|
stepSize: 10
|
||||||
|
valueText: updateValueText()
|
||||||
|
onValueChanged: updateValueText()
|
||||||
|
function updateValueText() {
|
||||||
|
if(value == 50)
|
||||||
|
return qsTr("Once")
|
||||||
|
if(value == 610)
|
||||||
|
return qsTr("Never")
|
||||||
|
return Math.floor(value / 60) + (value % 60 < 10 ? ":0" + value % 60 : ":" + value % 60)
|
||||||
|
}
|
||||||
|
onReleased: save()
|
||||||
|
function save() {
|
||||||
|
settings.healthNotificationsInterval = value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
AdjustmentButtons {
|
||||||
|
targetSlider: healthIntervalSlider
|
||||||
|
smallChange: 10
|
||||||
|
largeChange: 60
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,20 +56,24 @@ Settings::~Settings()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getters condensed.
|
// Getters condensed.
|
||||||
int Settings::getLowAlert() { return lowAlert; }
|
int Settings::getLowAlert() { return lowAlert; }
|
||||||
int Settings::getHighAlert() { return highAlert; }
|
int Settings::getHighAlert() { return highAlert; }
|
||||||
int Settings::getHighNotificationsInterval() { return highNotificationsInterval; }
|
int Settings::getHealthAlert() { return healthAlert; }
|
||||||
int Settings::getLowNotificationsInterval() { return lowNotificationsInterval; }
|
int Settings::getHighNotificationsInterval() { return highNotificationsInterval; }
|
||||||
int Settings::getLowLimit() { return lowLimit; }
|
int Settings::getLowNotificationsInterval() { return lowNotificationsInterval; }
|
||||||
int Settings::getHighLimit() { return highLimit; }
|
int Settings::getHealthNotificationsInterval() { return healthNotificationsInterval; }
|
||||||
bool Settings::getLimitEnabled() { return limitEnabled == 1; }
|
int Settings::getLowLimit() { return lowLimit; }
|
||||||
QString Settings::getLowAlertFile() { return lowAlertFile; }
|
int Settings::getHighLimit() { return highLimit; }
|
||||||
QString Settings::getHighAlertFile() { return highAlertFile; }
|
bool Settings::getLimitEnabled() { return limitEnabled == 1; }
|
||||||
QString Settings::getLogFilename() { return logFilename; }
|
QString Settings::getLowAlertFile() { return lowAlertFile; }
|
||||||
QString Settings::getNotificationTitle() { return notificationTitle; }
|
QString Settings::getHighAlertFile() { return highAlertFile; }
|
||||||
QString Settings::getNotificationLowText() { return notificationLowText; }
|
QString Settings::getHealthAlertFile() { return healthAlertFile; }
|
||||||
QString Settings::getNotificationHighText() { return notificationHighText; }
|
QString Settings::getLogFilename() { return logFilename; }
|
||||||
int Settings::getLogLevel() { return logLevel; }
|
QString Settings::getNotificationTitle() { return notificationTitle; }
|
||||||
|
QString Settings::getNotificationLowText() { return notificationLowText; }
|
||||||
|
QString Settings::getNotificationHighText() { return notificationHighText; }
|
||||||
|
QString Settings::getNotificationHealthText() { return notificationHealthText; }
|
||||||
|
int Settings::getLogLevel() { return logLevel; }
|
||||||
|
|
||||||
void Settings::setLowAlert(const int newLimit) {
|
void Settings::setLowAlert(const int newLimit) {
|
||||||
if(saveInteger(sLowAlert, newLimit, lowAlert)) {
|
if(saveInteger(sLowAlert, newLimit, lowAlert)) {
|
||||||
|
@ -83,6 +87,12 @@ void Settings::setHighAlert(const int newLimit) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::setHealthAlert(const int newLimit) {
|
||||||
|
if(saveInteger(sHealthAlert, newLimit, healthAlert)) {
|
||||||
|
emit healthAlertChanged(healthAlert);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Settings::setHighNotificationsInterval(const int newInterval) {
|
void Settings::setHighNotificationsInterval(const int newInterval) {
|
||||||
if(saveInteger(sHighNotificationsInterval, newInterval, highNotificationsInterval)) {
|
if(saveInteger(sHighNotificationsInterval, newInterval, highNotificationsInterval)) {
|
||||||
emit highNotificationsIntervalChanged(highNotificationsInterval);
|
emit highNotificationsIntervalChanged(highNotificationsInterval);
|
||||||
|
|
|
@ -27,16 +27,20 @@ class Settings : public QObject
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(int highAlert READ getHighAlert WRITE setHighAlert NOTIFY highAlertChanged)
|
Q_PROPERTY(int highAlert READ getHighAlert WRITE setHighAlert NOTIFY highAlertChanged)
|
||||||
Q_PROPERTY(int lowAlert READ getLowAlert WRITE setLowAlert NOTIFY lowAlertChanged)
|
Q_PROPERTY(int lowAlert READ getLowAlert WRITE setLowAlert NOTIFY lowAlertChanged)
|
||||||
|
Q_PROPERTY(int healthAlert READ getHealthAlert WRITE setHealthAlert NOTIFY healthAlertChanged)
|
||||||
Q_PROPERTY(int highNotificationsInterval READ getHighNotificationsInterval WRITE setHighNotificationsInterval NOTIFY highNotificationsIntervalChanged)
|
Q_PROPERTY(int highNotificationsInterval READ getHighNotificationsInterval WRITE setHighNotificationsInterval NOTIFY highNotificationsIntervalChanged)
|
||||||
Q_PROPERTY(int lowNotificationsInterval READ getLowNotificationsInterval WRITE setLowNotificationsInterval NOTIFY lowNotificationsIntervalChanged)
|
Q_PROPERTY(int lowNotificationsInterval READ getLowNotificationsInterval WRITE setLowNotificationsInterval NOTIFY lowNotificationsIntervalChanged)
|
||||||
|
Q_PROPERTY(int healthNotificationsInterval READ getHealthNotificationsInterval WRITE setHealthNotificationsInterval NOTIFY healthNotificationsIntervalChanged)
|
||||||
Q_PROPERTY(int highLimit READ getHighLimit WRITE setHighLimit NOTIFY highLimitChanged)
|
Q_PROPERTY(int highLimit READ getHighLimit WRITE setHighLimit NOTIFY highLimitChanged)
|
||||||
Q_PROPERTY(int lowLimit READ getLowLimit WRITE setLowLimit NOTIFY lowLimitChanged)
|
Q_PROPERTY(int lowLimit READ getLowLimit WRITE setLowLimit NOTIFY lowLimitChanged)
|
||||||
Q_PROPERTY(bool limitEnabled READ getLimitEnabled WRITE setLimitEnabled NOTIFY limitEnabledChanged)
|
Q_PROPERTY(bool limitEnabled READ getLimitEnabled WRITE setLimitEnabled NOTIFY limitEnabledChanged)
|
||||||
Q_PROPERTY(QString highAlertFile READ getHighAlertFile NOTIFY highAlertFileChanged)
|
Q_PROPERTY(QString highAlertFile READ getHighAlertFile NOTIFY highAlertFileChanged)
|
||||||
Q_PROPERTY(QString lowAlertFile READ getLowAlertFile NOTIFY lowAlertFileChanged)
|
Q_PROPERTY(QString lowAlertFile READ getLowAlertFile NOTIFY lowAlertFileChanged)
|
||||||
|
Q_PROPERTY(QString healthAlertFile READ getHealthAlertFile NOTIFY healthAlertFileChanged)
|
||||||
Q_PROPERTY(QString notificationTitle READ getNotificationTitle WRITE setNotificationTitle NOTIFY notificationTitleChanged)
|
Q_PROPERTY(QString notificationTitle READ getNotificationTitle WRITE setNotificationTitle NOTIFY notificationTitleChanged)
|
||||||
Q_PROPERTY(QString notificationLowText READ getNotificationLowText WRITE setNotificationLowText NOTIFY notificationLowTextChanged)
|
Q_PROPERTY(QString notificationLowText READ getNotificationLowText WRITE setNotificationLowText NOTIFY notificationLowTextChanged)
|
||||||
Q_PROPERTY(QString notificationHighText READ getNotificationHighText WRITE setNotificationHighText NOTIFY notificationHighTextChanged)
|
Q_PROPERTY(QString notificationHighText READ getNotificationHighText WRITE setNotificationHighText NOTIFY notificationHighTextChanged)
|
||||||
|
Q_PROPERTY(QString notificationHealthText READ getNotificationHealthText WRITE setNotificationHealthText NOTIFY notificationHealthTextChanged)
|
||||||
Q_PROPERTY(QString logFilename READ getLogFilename NOTIFY logFilenameChanged)
|
Q_PROPERTY(QString logFilename READ getLogFilename NOTIFY logFilenameChanged)
|
||||||
Q_PROPERTY(int logLevel READ getLogLevel WRITE setLogLevel NOTIFY logLevelChanged)
|
Q_PROPERTY(int logLevel READ getLogLevel WRITE setLogLevel NOTIFY logLevelChanged)
|
||||||
|
|
||||||
|
@ -46,29 +50,36 @@ public:
|
||||||
|
|
||||||
int getLowAlert();
|
int getLowAlert();
|
||||||
int getHighAlert();
|
int getHighAlert();
|
||||||
|
int getHealthAlert();
|
||||||
int getHighNotificationsInterval();
|
int getHighNotificationsInterval();
|
||||||
int getLowNotificationsInterval();
|
int getLowNotificationsInterval();
|
||||||
|
int getHealthNotificationsInterval();
|
||||||
int getLowLimit();
|
int getLowLimit();
|
||||||
int getHighLimit();
|
int getHighLimit();
|
||||||
bool getLimitEnabled();
|
bool getLimitEnabled();
|
||||||
QString getLowAlertFile();
|
QString getLowAlertFile();
|
||||||
QString getHighAlertFile();
|
QString getHighAlertFile();
|
||||||
|
QString getHealthAlertFile();
|
||||||
QString getNotificationTitle();
|
QString getNotificationTitle();
|
||||||
QString getNotificationLowText();
|
QString getNotificationLowText();
|
||||||
QString getNotificationHighText();
|
QString getNotificationHighText();
|
||||||
|
QString getNotificationHealthText();
|
||||||
QString getLogFilename();
|
QString getLogFilename();
|
||||||
int getLogLevel();
|
int getLogLevel();
|
||||||
|
|
||||||
void setLowAlert(const int newLimit);
|
void setLowAlert(const int newLimit);
|
||||||
void setHighAlert(const int newLimit);
|
void setHighAlert(const int newLimit);
|
||||||
|
void setHealthAlert(const int newLimit);
|
||||||
void setHighNotificationsInterval(const int newInterval);
|
void setHighNotificationsInterval(const int newInterval);
|
||||||
void setLowNotificationsInterval(const int newInterval);
|
void setLowNotificationsInterval(const int newInterval);
|
||||||
|
void setHealthNotificationsInterval(const int newInterval);
|
||||||
void setLowLimit(const int newLimit);
|
void setLowLimit(const int newLimit);
|
||||||
void setHighLimit(const int newLimit);
|
void setHighLimit(const int newLimit);
|
||||||
void setLimitEnabled(const bool newEnabled);
|
void setLimitEnabled(const bool newEnabled);
|
||||||
void setNotificationTitle(const QString newText);
|
void setNotificationTitle(const QString newText);
|
||||||
void setNotificationLowText(const QString newText);
|
void setNotificationLowText(const QString newText);
|
||||||
void setNotificationHighText(const QString newText);
|
void setNotificationHighText(const QString newText);
|
||||||
|
void setNotificationHealthText(const QString newText);
|
||||||
void setLogLevel(const int newLogLevel);
|
void setLogLevel(const int newLogLevel);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -79,32 +90,40 @@ private:
|
||||||
// Default values
|
// Default values
|
||||||
int lowAlert = 25;
|
int lowAlert = 25;
|
||||||
int highAlert = 75;
|
int highAlert = 75;
|
||||||
|
int healthAlert = 1; // warn
|
||||||
int highNotificationsInterval = 60;
|
int highNotificationsInterval = 60;
|
||||||
int lowNotificationsInterval = 60;
|
int lowNotificationsInterval = 60;
|
||||||
|
int healthNotificationsInterval = 60;
|
||||||
int limitEnabled = 1; // Converted to boolean for QML
|
int limitEnabled = 1; // Converted to boolean for QML
|
||||||
int lowLimit = 65;
|
int lowLimit = 65;
|
||||||
int highLimit = 70;
|
int highLimit = 70;
|
||||||
QString lowAlertFile = "/usr/share/sounds/jolla-ambient/stereo/general_warning.wav";
|
QString lowAlertFile = "/usr/share/sounds/jolla-ambient/stereo/general_warning.wav";
|
||||||
QString highAlertFile = "/usr/share/sounds/jolla-ambient/stereo/positive_confirmation.wav";
|
QString highAlertFile = "/usr/share/sounds/jolla-ambient/stereo/positive_confirmation.wav";
|
||||||
|
QString healthAlertFile = lowAlertFile;
|
||||||
QString notificationTitle;
|
QString notificationTitle;
|
||||||
QString notificationLowText;
|
QString notificationLowText;
|
||||||
QString notificationHighText;
|
QString notificationHighText;
|
||||||
|
QString notificationHealthText;
|
||||||
QString logFilename;
|
QString logFilename;
|
||||||
int logLevel;
|
int logLevel;
|
||||||
|
|
||||||
// To avoid repeating the same string over and over and over...
|
// To avoid repeating the same string over and over and over...
|
||||||
const char* sLowAlert = "lowAlert";
|
const char* sLowAlert = "lowAlert";
|
||||||
const char* sHighAlert = "highAlert";
|
const char* sHighAlert = "highAlert";
|
||||||
|
const char* sHealthAlert = "healthAlert";
|
||||||
const char* sHighNotificationsInterval = "highNotificationsInterval";
|
const char* sHighNotificationsInterval = "highNotificationsInterval";
|
||||||
const char* sLowNotificationsInterval = "lowNotificationsInterval";
|
const char* sLowNotificationsInterval = "lowNotificationsInterval";
|
||||||
|
const char* sHealthNotificationsInterval = "healthNotificationsInterval";
|
||||||
const char* sLimitEnabled = "limitEnabled";
|
const char* sLimitEnabled = "limitEnabled";
|
||||||
const char* sLowLimit = "lowLimit";
|
const char* sLowLimit = "lowLimit";
|
||||||
const char* sHighLimit = "highLimit";
|
const char* sHighLimit = "highLimit";
|
||||||
const char* sLowAlertFile = "lowAlertFile";
|
const char* sLowAlertFile = "lowAlertFile";
|
||||||
const char* sHighAlertFile = "highAlertFile";
|
const char* sHighAlertFile = "highAlertFile";
|
||||||
|
const char* sHealthAlertFile = "healthAlertFile";
|
||||||
const char* sNotificationTitle = "notificationTitle";
|
const char* sNotificationTitle = "notificationTitle";
|
||||||
const char* sNotificationLowText = "notificationLowText";
|
const char* sNotificationLowText = "notificationLowText";
|
||||||
const char* sNotificationHighText = "notificationHighText";
|
const char* sNotificationHighText = "notificationHighText";
|
||||||
|
const char* sNotificationHealthText = "notificationHealthText";
|
||||||
const char* sLogFilename = "logFilename";
|
const char* sLogFilename = "logFilename";
|
||||||
const char* sLogLevel = "logLevel";
|
const char* sLogLevel = "logLevel";
|
||||||
|
|
||||||
|
@ -117,16 +136,20 @@ private:
|
||||||
signals:
|
signals:
|
||||||
void lowAlertChanged(int);
|
void lowAlertChanged(int);
|
||||||
void highAlertChanged(int);
|
void highAlertChanged(int);
|
||||||
|
void healthAlertChanged(int);
|
||||||
void highNotificationsIntervalChanged(int);
|
void highNotificationsIntervalChanged(int);
|
||||||
void lowNotificationsIntervalChanged(int);
|
void lowNotificationsIntervalChanged(int);
|
||||||
|
void healthNotificationsIntervalChanged(int);
|
||||||
void limitEnabledChanged(bool);
|
void limitEnabledChanged(bool);
|
||||||
void lowLimitChanged(int);
|
void lowLimitChanged(int);
|
||||||
void highLimitChanged(int);
|
void highLimitChanged(int);
|
||||||
void lowAlertFileChanged(QString);
|
void lowAlertFileChanged(QString);
|
||||||
void highAlertFileChanged(QString);
|
void highAlertFileChanged(QString);
|
||||||
|
void healthAlertFileChanged(QString);
|
||||||
void notificationTitleChanged(QString);
|
void notificationTitleChanged(QString);
|
||||||
void notificationLowTextChanged(QString);
|
void notificationLowTextChanged(QString);
|
||||||
void notificationHighTextChanged(QString);
|
void notificationHighTextChanged(QString);
|
||||||
|
void notificationHealthTextChanged(QString);
|
||||||
void logFilenameChanged(QString);
|
void logFilenameChanged(QString);
|
||||||
void logLevelChanged(int);
|
void logLevelChanged(int);
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue