Return if the value changed
This commit is contained in:
parent
d359c95a40
commit
5235b5b0a0
2 changed files with 9 additions and 3 deletions
|
@ -74,9 +74,13 @@ int Settings::bound(int value, int min, int max) {
|
|||
return (value <= min ? min : (value >= max ? max : value));
|
||||
}
|
||||
|
||||
void Settings::loadInteger(const char* key, int *value, int min, int max) {
|
||||
bool Settings::loadInteger(const char* key, int *value, int min, int max) {
|
||||
oldValue = *value;
|
||||
*value = bound(mySettings->value(key, *value).toInt(), min, max);
|
||||
qInfo() << "Loaded" << key << *value;
|
||||
if(oldValue != *value) {
|
||||
qInfo() << "Loaded" << key << *value;
|
||||
}
|
||||
return oldValue != *value;
|
||||
}
|
||||
|
||||
void Settings::updateConfig(QString path) {
|
||||
|
|
|
@ -51,6 +51,8 @@ private:
|
|||
QSettings* mySettings = nullptr;
|
||||
QFileSystemWatcher *watcher = nullptr;
|
||||
|
||||
int oldValue;
|
||||
|
||||
// Default values
|
||||
int lowAlert = 25;
|
||||
int highAlert = 75;
|
||||
|
@ -88,7 +90,7 @@ private:
|
|||
const char* sNotificationHighText = "notificationHighText";
|
||||
|
||||
int bound(int value, int min, int max);
|
||||
void loadInteger(const char *key, int *value, int min, int max);
|
||||
bool loadInteger(const char *key, int *value, int min, int max);
|
||||
|
||||
private slots:
|
||||
void updateConfig(QString path);
|
||||
|
|
Loading…
Reference in a new issue