Add Settings object, alert level sliders
This commit is contained in:
parent
284d37755a
commit
ac9e3a088b
3 changed files with 30 additions and 2 deletions
|
@ -15,7 +15,8 @@ TARGET = harbour-batterybuddy
|
||||||
CONFIG += sailfishapp
|
CONFIG += sailfishapp
|
||||||
|
|
||||||
SOURCES += src/harbour-batterybuddy.cpp \
|
SOURCES += src/harbour-batterybuddy.cpp \
|
||||||
src/battery.cpp
|
src/battery.cpp \
|
||||||
|
src/settings.cpp
|
||||||
|
|
||||||
DISTFILES += qml/harbour-batterybuddy.qml \
|
DISTFILES += qml/harbour-batterybuddy.qml \
|
||||||
qml/cover/CoverPage.qml \
|
qml/cover/CoverPage.qml \
|
||||||
|
@ -55,4 +56,5 @@ CONFIG += sailfishapp_i18n
|
||||||
TRANSLATIONS += translations/harbour-batterybuddy-de.ts
|
TRANSLATIONS += translations/harbour-batterybuddy-de.ts
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/battery.h
|
src/battery.h \
|
||||||
|
src/settings.h
|
||||||
|
|
|
@ -39,6 +39,28 @@ Page {
|
||||||
label: qsTr("Charging")
|
label: qsTr("Charging")
|
||||||
value: battery.charging ? "yes" : "no";
|
value: battery.charging ? "yes" : "no";
|
||||||
}
|
}
|
||||||
|
Slider {
|
||||||
|
id: highSlider
|
||||||
|
width: parent.width
|
||||||
|
label: qsTr("Upper limit")
|
||||||
|
minimumValue: 60
|
||||||
|
maximumValue: 99
|
||||||
|
stepSize: 1
|
||||||
|
value: settings.upperLimit
|
||||||
|
valueText: highSlider.value
|
||||||
|
onValueChanged: settings.upperLimit = highSlider.value
|
||||||
|
}
|
||||||
|
Slider {
|
||||||
|
id: lowSlider
|
||||||
|
width: parent.width
|
||||||
|
label: qsTr("Lower limit")
|
||||||
|
minimumValue: 10
|
||||||
|
maximumValue: 40
|
||||||
|
stepSize: 1
|
||||||
|
value: settings.lowerLimit
|
||||||
|
valueText: lowSlider.value
|
||||||
|
onValueChanged: settings.lowerLimit = lowSlider.value
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
|
#include "settings.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
@ -28,12 +29,15 @@ int main(int argc, char *argv[])
|
||||||
QQuickView* view = SailfishApp::createView();
|
QQuickView* view = SailfishApp::createView();
|
||||||
|
|
||||||
Battery battery;
|
Battery battery;
|
||||||
|
Settings settings;
|
||||||
|
|
||||||
QTimer updater;
|
QTimer updater;
|
||||||
QObject::connect(&updater, SIGNAL(timeout()), &battery, SLOT(updateData()));
|
QObject::connect(&updater, SIGNAL(timeout()), &battery, SLOT(updateData()));
|
||||||
updater.start(15000);
|
updater.start(15000);
|
||||||
|
|
||||||
view->engine()->addImportPath("/usr/share/harbour-carbudget/qml");
|
view->engine()->addImportPath("/usr/share/harbour-carbudget/qml");
|
||||||
view->rootContext()->setContextProperty("battery", &battery);
|
view->rootContext()->setContextProperty("battery", &battery);
|
||||||
|
view->rootContext()->setContextProperty("settings", &settings);
|
||||||
view->setSource(SailfishApp::pathTo("qml/harbour-batterybuddy.qml"));
|
view->setSource(SailfishApp::pathTo("qml/harbour-batterybuddy.qml"));
|
||||||
view->showFullScreen();
|
view->showFullScreen();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue