Make sure that the same config file is used with the daemon
This commit is contained in:
parent
542a5b7636
commit
1ee2d9e708
2 changed files with 14 additions and 11 deletions
|
@ -19,16 +19,19 @@
|
|||
|
||||
Settings::Settings(QObject *parent) : QObject(parent)
|
||||
{
|
||||
mySettings = new QSettings("harbour-batterybuddy", "harbour-batterybuddy");
|
||||
qDebug() << "Using" << mySettings->fileName();
|
||||
|
||||
// Migrate old settings
|
||||
if(mySettings.contains("lowerLimit")) {
|
||||
mySettings.setValue(sLowAlert, mySettings.value("lowerLimit"));
|
||||
mySettings.remove("lowerLimit");
|
||||
if(mySettings->contains("lowerLimit")) {
|
||||
mySettings->setValue(sLowAlert, mySettings->value("lowerLimit"));
|
||||
mySettings->remove("lowerLimit");
|
||||
qInfo() << "Migrated old lowerLimit value";
|
||||
}
|
||||
|
||||
if(mySettings.contains("upperLimit")) {
|
||||
mySettings.setValue(sHighAlert, mySettings.value("upperLimit"));
|
||||
mySettings.remove("upperLimit");
|
||||
if(mySettings->contains("upperLimit")) {
|
||||
mySettings->setValue(sHighAlert, mySettings->value("upperLimit"));
|
||||
mySettings->remove("upperLimit");
|
||||
qInfo() << "Migrated old upperLimit value";
|
||||
}
|
||||
|
||||
|
@ -52,8 +55,8 @@ Settings::~Settings()
|
|||
saveInteger(sNotificationsEnabled, ¬ificationsEnabled);
|
||||
saveInteger(sLowLimit, &lowLimit);
|
||||
saveInteger(sHighLimit, &highLimit);
|
||||
mySettings.sync();
|
||||
qInfo() << "Settings saved:" << (mySettings.status() == QSettings::NoError);
|
||||
mySettings->sync();
|
||||
qInfo() << "Settings saved:" << (mySettings->status() == QSettings::NoError);
|
||||
}
|
||||
|
||||
int Settings::getLowAlert() {
|
||||
|
@ -140,11 +143,11 @@ int Settings::bound(int value, int min, int max) {
|
|||
}
|
||||
|
||||
void Settings::loadInteger(const char* key, int *value, int min, int max) {
|
||||
*value = bound(mySettings.value(key, *value).toInt(), min, max);
|
||||
*value = bound(mySettings->value(key, *value).toInt(), min, max);
|
||||
qInfo() << "Loaded" << key << *value;
|
||||
}
|
||||
|
||||
void Settings::saveInteger(const char* key, int *value) {
|
||||
mySettings.setValue(key, QByteArray::number(*value));
|
||||
mySettings->setValue(key, QByteArray::number(*value));
|
||||
qInfo() << "Saved" << key << *value;
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
|
||||
|
||||
private:
|
||||
QSettings mySettings;
|
||||
QSettings *mySettings;
|
||||
|
||||
// Default values
|
||||
int lowAlert = 25;
|
||||
|
|
Loading…
Reference in a new issue