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
|
||||
|
||||
#DEFINES += QT_NO_DEBUG_OUTPUT
|
||||
|
||||
HEADERS += \
|
||||
src/battery.h \
|
||||
src/settings.h
|
||||
|
|
|
@ -48,6 +48,9 @@ int main(int argc, char *argv[])
|
|||
QGuiApplication* app = SailfishApp::application(argc, argv);
|
||||
QQuickView* view = SailfishApp::createView();
|
||||
|
||||
qDebug() << "Application name:" << app->applicationName();
|
||||
qDebug() << "Organization name:" << app->organizationName();
|
||||
|
||||
Settings* settings = new 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()
|
||||
{
|
||||
mySettings.setValue(sLowAlert, QByteArray::number(lowAlert));
|
||||
mySettings.setValue(sHighAlert, QByteArray::number(highAlert));
|
||||
mySettings.setValue(sInterval, QByteArray::number(interval));
|
||||
mySettings.setValue(sLimitEnabled, QByteArray::number(limitEnabled));
|
||||
mySettings.setValue(sNotificationsEnabled, QByteArray::number(notificationsEnabled));
|
||||
mySettings.setValue(sLowLimit, QByteArray::number(lowLimit));
|
||||
mySettings.setValue(sHighLimit, QByteArray::number(highLimit));
|
||||
qInfo() << "Settings saved";
|
||||
saveInteger(sLowAlert, &lowAlert);
|
||||
saveInteger(sHighAlert, &highAlert);
|
||||
saveInteger(sInterval, &interval);
|
||||
saveInteger(sLimitEnabled, &limitEnabled);
|
||||
saveInteger(sNotificationsEnabled, ¬ificationsEnabled);
|
||||
saveInteger(sLowLimit, &lowLimit);
|
||||
saveInteger(sHighLimit, &highLimit);
|
||||
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) {
|
||||
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);
|
||||
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();
|
||||
|
||||
int getLowAlert() { return lowAlert; }
|
||||
int getHighAlert() { return highAlert; }
|
||||
int getInterval() { return interval; }
|
||||
int getLowLimit() { return lowLimit; }
|
||||
int getHighLimit() { return highLimit; }
|
||||
bool getLimitEnabled() { return limitEnabled == 1; }
|
||||
bool getNotificationsEnabled() { return notificationsEnabled == 1; }
|
||||
QString getLowAlertFile() { return lowAlertFile; }
|
||||
QString getHighAlertFile() { return highAlertFile;}
|
||||
int getLowAlert();
|
||||
int getHighAlert();
|
||||
int getInterval();
|
||||
int getLowLimit();
|
||||
int getHighLimit();
|
||||
bool getLimitEnabled();
|
||||
bool getNotificationsEnabled();
|
||||
QString getLowAlertFile();
|
||||
QString getHighAlertFile();
|
||||
|
||||
void setLowAlert(int newLimit) { lowAlert = newLimit; emit lowAlertChanged(); }
|
||||
void setHighAlert(int newLimit) { highAlert = newLimit; emit highAlertChanged(); }
|
||||
void setInterval(int newInterval) { interval = newInterval; emit intervalChanged(); }
|
||||
void setLowLimit(int newLimit) { lowLimit = newLimit; emit lowLimitChanged(); }
|
||||
void setHighLimit(int newLimit) { highLimit = newLimit; emit highLimitChanged(); }
|
||||
void setLimitEnabled(bool newEnabled) { limitEnabled = (newEnabled ? 1 : 0); emit limitEnabledChanged(); }
|
||||
void setNotificationsEnabled(bool newEnabled) { notificationsEnabled = (newEnabled ? 1 : 0); emit notificationsEnabledChanged(); }
|
||||
void setLowAlert(int newLimit);
|
||||
void setHighAlert(int newLimit);
|
||||
void setInterval(int newInterval);
|
||||
void setLowLimit(int newLimit);
|
||||
void setHighLimit(int newLimit);
|
||||
void setLimitEnabled(bool newEnabled);
|
||||
void setNotificationsEnabled(bool newEnabled);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -84,7 +84,8 @@ private:
|
|||
const char* sHighAlertFile = "highAlertFile";
|
||||
|
||||
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:
|
||||
int lowAlertChanged();
|
||||
|
|
Loading…
Reference in a new issue