Increase debug log verbosity
This commit is contained in:
parent
073defa4fc
commit
02b3f40524
4 changed files with 116 additions and 25 deletions
|
@ -14,6 +14,8 @@ TARGET = harbour-batterybuddy
|
||||||
|
|
||||||
CONFIG += sailfishapp sailfishapp_i18n
|
CONFIG += sailfishapp sailfishapp_i18n
|
||||||
|
|
||||||
|
#DEFINES += QT_NO_DEBUG_OUTPUT
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/battery.h \
|
src/battery.h \
|
||||||
src/settings.h
|
src/settings.h
|
||||||
|
|
|
@ -48,6 +48,9 @@ int main(int argc, char *argv[])
|
||||||
QGuiApplication* app = SailfishApp::application(argc, argv);
|
QGuiApplication* app = SailfishApp::application(argc, argv);
|
||||||
QQuickView* view = SailfishApp::createView();
|
QQuickView* view = SailfishApp::createView();
|
||||||
|
|
||||||
|
qDebug() << "Application name:" << app->applicationName();
|
||||||
|
qDebug() << "Organization name:" << app->organizationName();
|
||||||
|
|
||||||
Settings* settings = new Settings();
|
Settings* settings = new Settings();
|
||||||
Battery* battery = new Battery(settings);
|
Battery* battery = new Battery(settings);
|
||||||
|
|
||||||
|
|
101
src/settings.cpp
101
src/settings.cpp
|
@ -45,16 +45,96 @@ Settings::Settings(QObject *parent) : QObject(parent)
|
||||||
|
|
||||||
Settings::~Settings()
|
Settings::~Settings()
|
||||||
{
|
{
|
||||||
mySettings.setValue(sLowAlert, QByteArray::number(lowAlert));
|
saveInteger(sLowAlert, &lowAlert);
|
||||||
mySettings.setValue(sHighAlert, QByteArray::number(highAlert));
|
saveInteger(sHighAlert, &highAlert);
|
||||||
mySettings.setValue(sInterval, QByteArray::number(interval));
|
saveInteger(sInterval, &interval);
|
||||||
mySettings.setValue(sLimitEnabled, QByteArray::number(limitEnabled));
|
saveInteger(sLimitEnabled, &limitEnabled);
|
||||||
mySettings.setValue(sNotificationsEnabled, QByteArray::number(notificationsEnabled));
|
saveInteger(sNotificationsEnabled, ¬ificationsEnabled);
|
||||||
mySettings.setValue(sLowLimit, QByteArray::number(lowLimit));
|
saveInteger(sLowLimit, &lowLimit);
|
||||||
mySettings.setValue(sHighLimit, QByteArray::number(highLimit));
|
saveInteger(sHighLimit, &highLimit);
|
||||||
qInfo() << "Settings saved";
|
mySettings.sync();
|
||||||
|
qInfo() << "Settings saved:" << mySettings.status() == QSettings::NoError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Settings::getLowAlert() {
|
||||||
|
return lowAlert;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Settings::getHighAlert() {
|
||||||
|
return highAlert;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Settings::getInterval() {
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Settings::getLowLimit() {
|
||||||
|
return lowLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Settings::getHighLimit() {
|
||||||
|
return highLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::getLimitEnabled() {
|
||||||
|
return limitEnabled == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Settings::getNotificationsEnabled() {
|
||||||
|
return notificationsEnabled == 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Settings::getLowAlertFile() {
|
||||||
|
return lowAlertFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Settings::getHighAlertFile() {
|
||||||
|
return highAlertFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setLowAlert(int newLimit) {
|
||||||
|
lowAlert = newLimit;
|
||||||
|
emit lowAlertChanged();
|
||||||
|
qDebug() << "Change" << sLowAlert << newLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setHighAlert(int newLimit) {
|
||||||
|
highAlert = newLimit;
|
||||||
|
emit highAlertChanged();
|
||||||
|
qDebug() << "Change" << sHighAlert << newLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setInterval(int newInterval) {
|
||||||
|
interval = newInterval;
|
||||||
|
emit intervalChanged();
|
||||||
|
qDebug() << "Change" << sInterval << newInterval;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setLowLimit(int newLimit) {
|
||||||
|
lowLimit = newLimit;
|
||||||
|
emit lowLimitChanged();
|
||||||
|
qDebug() << "Change" << sLowLimit << newLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setHighLimit(int newLimit) {
|
||||||
|
highLimit = newLimit;
|
||||||
|
emit highLimitChanged();
|
||||||
|
qDebug() << "Change" << sHighLimit << newLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setLimitEnabled(bool newEnabled) {
|
||||||
|
limitEnabled = (newEnabled ? 1 : 0);
|
||||||
|
emit limitEnabledChanged();
|
||||||
|
qDebug() << "Change" << sLimitEnabled << newEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::setNotificationsEnabled(bool newEnabled) {
|
||||||
|
notificationsEnabled = (newEnabled ? 1 : 0);
|
||||||
|
emit notificationsEnabledChanged();
|
||||||
|
qDebug() << "Change" << sNotificationsEnabled << newEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int Settings::bound(int value, int min, int max) {
|
int Settings::bound(int value, int min, int max) {
|
||||||
return (value <= min ? min : (value >= max ? max : value));
|
return (value <= min ? min : (value >= max ? max : value));
|
||||||
}
|
}
|
||||||
|
@ -63,3 +143,8 @@ 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;
|
qInfo() << "Loaded" << key << *value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::saveInteger(const char* key, int *value) {
|
||||||
|
mySettings.setValue(key, QByteArray::number(*value));
|
||||||
|
qInfo() << "Saved" << key << *value;
|
||||||
|
}
|
||||||
|
|
|
@ -39,23 +39,23 @@ public:
|
||||||
Settings(QObject* parent = nullptr);
|
Settings(QObject* parent = nullptr);
|
||||||
~Settings();
|
~Settings();
|
||||||
|
|
||||||
int getLowAlert() { return lowAlert; }
|
int getLowAlert();
|
||||||
int getHighAlert() { return highAlert; }
|
int getHighAlert();
|
||||||
int getInterval() { return interval; }
|
int getInterval();
|
||||||
int getLowLimit() { return lowLimit; }
|
int getLowLimit();
|
||||||
int getHighLimit() { return highLimit; }
|
int getHighLimit();
|
||||||
bool getLimitEnabled() { return limitEnabled == 1; }
|
bool getLimitEnabled();
|
||||||
bool getNotificationsEnabled() { return notificationsEnabled == 1; }
|
bool getNotificationsEnabled();
|
||||||
QString getLowAlertFile() { return lowAlertFile; }
|
QString getLowAlertFile();
|
||||||
QString getHighAlertFile() { return highAlertFile;}
|
QString getHighAlertFile();
|
||||||
|
|
||||||
void setLowAlert(int newLimit) { lowAlert = newLimit; emit lowAlertChanged(); }
|
void setLowAlert(int newLimit);
|
||||||
void setHighAlert(int newLimit) { highAlert = newLimit; emit highAlertChanged(); }
|
void setHighAlert(int newLimit);
|
||||||
void setInterval(int newInterval) { interval = newInterval; emit intervalChanged(); }
|
void setInterval(int newInterval);
|
||||||
void setLowLimit(int newLimit) { lowLimit = newLimit; emit lowLimitChanged(); }
|
void setLowLimit(int newLimit);
|
||||||
void setHighLimit(int newLimit) { highLimit = newLimit; emit highLimitChanged(); }
|
void setHighLimit(int newLimit);
|
||||||
void setLimitEnabled(bool newEnabled) { limitEnabled = (newEnabled ? 1 : 0); emit limitEnabledChanged(); }
|
void setLimitEnabled(bool newEnabled);
|
||||||
void setNotificationsEnabled(bool newEnabled) { notificationsEnabled = (newEnabled ? 1 : 0); emit notificationsEnabledChanged(); }
|
void setNotificationsEnabled(bool newEnabled);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -84,7 +84,8 @@ private:
|
||||||
const char* sHighAlertFile = "highAlertFile";
|
const char* sHighAlertFile = "highAlertFile";
|
||||||
|
|
||||||
int bound(int value, int min, int max);
|
int bound(int value, int min, int max);
|
||||||
void loadInteger(const char *key, int* value, int min, int max);
|
void loadInteger(const char *key, int *value, int min, int max);
|
||||||
|
void saveInteger(const char *key, int *value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
int lowAlertChanged();
|
int lowAlertChanged();
|
||||||
|
|
Loading…
Reference in a new issue