Refresh battery data automatically
This commit is contained in:
parent
790064e56b
commit
284d37755a
2 changed files with 8 additions and 1 deletions
|
@ -4,6 +4,7 @@
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
class Battery : public QObject
|
class Battery : public QObject
|
||||||
{
|
{
|
||||||
|
@ -18,9 +19,10 @@ public:
|
||||||
int getCharge();
|
int getCharge();
|
||||||
bool getCharging();
|
bool getCharging();
|
||||||
|
|
||||||
private:
|
public slots:
|
||||||
void updateData();
|
void updateData();
|
||||||
|
|
||||||
|
private:
|
||||||
QFile* chargeFile;
|
QFile* chargeFile;
|
||||||
QFile* chargingFile;
|
QFile* chargingFile;
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <QQmlContext>
|
#include <QQmlContext>
|
||||||
#include <QQuickView>
|
#include <QQuickView>
|
||||||
#include <QQmlEngine>
|
#include <QQmlEngine>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
#include "battery.h"
|
#include "battery.h"
|
||||||
|
|
||||||
|
@ -27,6 +28,10 @@ int main(int argc, char *argv[])
|
||||||
QQuickView* view = SailfishApp::createView();
|
QQuickView* view = SailfishApp::createView();
|
||||||
|
|
||||||
Battery battery;
|
Battery battery;
|
||||||
|
QTimer updater;
|
||||||
|
QObject::connect(&updater, SIGNAL(timeout()), &battery, SLOT(updateData()));
|
||||||
|
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->setSource(SailfishApp::pathTo("qml/harbour-batterybuddy.qml"));
|
view->setSource(SailfishApp::pathTo("qml/harbour-batterybuddy.qml"));
|
||||||
|
|
Loading…
Reference in a new issue