Skip to content

Commit

Permalink
Last changes for openrepos release. This is 0.9.7-8.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Drescher committed Dec 19, 2017
1 parent ed4a047 commit 9cbbab9
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 44 deletions.
6 changes: 4 additions & 2 deletions harbour-laufhelden.pro
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ SOURCES += src/harbour-laufhelden.cpp \
src/logwriter.cpp \
src/plotwidget.cpp \
src/light.cpp \
src/pebblemanagercomm.cpp
src/pebblemanagercomm.cpp \
src/pebblewatchcomm.cpp

OTHER_FILES += qml/harbour-laufhelden.qml \
qml/cover/CoverPage.qml \
Expand Down Expand Up @@ -62,7 +63,8 @@ HEADERS += \
src/logwriter.h \
src/plotwidget.h \
src/light.h \
src/pebblemanagercomm.h
src/pebblemanagercomm.h \
src/pebblewatchcomm.h

DISTFILES += \
qml/pages/MainPage.qml \
Expand Down
2 changes: 2 additions & 0 deletions qml/harbour-laufhelden.qml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ ApplicationWindow
property bool bPebbleConnected: false
property bool bPebbleSportAppRequired: false
property string sPebblePath: ""
property string sPebbleNameAddress: ""
//*** Pebble End ***

//Init C++ classes, libraries
Expand All @@ -62,6 +63,7 @@ ApplicationWindow
PlotWidget{ id: id_PlotWidget }
Light{ id: id_Light }
PebbleManagerComm{ id: id_PebbleManagerComm }
PebbleWatchComm{ id: id_PebbleWatchComm }
TrackRecorder
{
id: recorder
Expand Down
2 changes: 1 addition & 1 deletion qml/pages/AboutPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Page
anchors.horizontalCenter: parent.horizontalCenter
font.pixelSize: Theme.fontSizeExtraSmall
color: Theme.secondaryColor
text: qsTr("Date: ") + "16.11.2017";
text: qsTr("Date: ") + "19.12.2017";
}
Label
{
Expand Down
7 changes: 6 additions & 1 deletion qml/pages/MainPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,20 @@ Page
console.log("sPebbleList: " + sPebbleList);

if (sPebbleList !== undefined && sPebbleList.length > 0)
{
sPebblePath = sPebbleList[0];
id_PebbleWatchComm.setServicePath(sPebblePath); //This sets the path with the BT address to the C++ class and inits the DBUS communication object
}
}

//Sport app on the pebble is no longer required
bPebbleSportAppRequired = false;

//If pebble is NOT connected, check if it's connected now
if (sPebblePath !== "" && settings.enablePebble && !bPebbleConnected)
bPebbleConnected = pebbleComm.bIsPebbleConnected();
{
bPebbleConnected = id_PebbleWatchComm.isConnected();
}
}

//This is loaded everytime the page is displayed
Expand Down
47 changes: 32 additions & 15 deletions qml/pages/PebbleSettingsPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ Page

//Read version of Rockpool and check if it is sufficient
fncCheckVersion(id_PebbleManagerComm.getRockpoolVersion());

//This sets the path with the BT address to the C++ class and inits the DBUS communication object
id_PebbleWatchComm.setServicePath(sPebblePath);
}
else
{
Expand Down Expand Up @@ -95,7 +98,11 @@ Page

//Check if pebble is connected
if (settings.enablePebble && !bPebbleConnected)
bPebbleConnected = pebbleComm.bIsPebbleConnected();
bPebbleConnected = id_PebbleWatchComm.isConnected();

//If pebble is connected read name and address
if (bPebbleConnected)
sPebbleNameAddress = id_PebbleWatchComm.getName() + ", " + id_PebbleWatchComm.getAddress();
}
}

Expand Down Expand Up @@ -273,6 +280,26 @@ Page
}
}

Rectangle
{
visible: (iCheckPebbleStep > 0)
anchors.fill: parent
color: "black"
z: 2

ProgressBar
{
id: progressBarCheckPebble
width: parent.width
anchors.centerIn: parent
maximumValue: 6
valueText: value.toString() + "/" + maximumValue.toString()
label: ""
visible: (iCheckPebbleStep > 0)
value: iCheckPebbleStep
}
}


SilicaFlickable
{
Expand All @@ -287,8 +314,8 @@ Page
spacing: Theme.paddingLarge
PageHeader
{
title: qsTr("Pebble settings")
}
title: bPebbleConnected ? sPebbleNameAddress : qsTr("Pebble settings")
}
TextSwitch
{
id: id_TextSwitch_enablePebble
Expand All @@ -307,10 +334,10 @@ Page
visible: id_TextSwitch_enablePebble.checked
color: Theme.highlightColor
width: parent.width
}
}
Item
{
visible: id_TextSwitch_enablePebble.checked

width: parent.width
height: id_BTN_TestPebble.height

Expand Down Expand Up @@ -513,16 +540,6 @@ Page
JSTools.fncGenerateHelperArray();
}
}
}
ProgressBar
{
id: progressBarCheckPebble
width: parent.width
maximumValue: 6
valueText: value.toString() + "/" + maximumValue.toString()
label: ""
visible: (iCheckPebbleStep > 0)
value: iCheckPebbleStep
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion qml/pages/PreRecordPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Page

//Check if pebble is connected
if (sPebblePath !== "" && settings.enablePebble && !bPebbleConnected)
bPebbleConnected = pebbleComm.bIsPebbleConnected();
bPebbleConnected = id_PebbleWatchComm.isConnected();

//Launch pebble sport app
if (sPebblePath !== "" && settings.enablePebble && bPebbleConnected)
Expand Down
2 changes: 1 addition & 1 deletion qml/pages/RecordPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Page

//Check if pebble is connected
if (sPebblePath !== "" && settings.enablePebble && !bPebbleConnected)
bPebbleConnected = pebbleComm.bIsPebbleConnected();
bPebbleConnected = id_PebbleWatchComm.isConnected();

//Load threshold settings and convert them to JS array
Thresholds.fncConvertSaveStringToArray(settings.thresholds);
Expand Down
20 changes: 4 additions & 16 deletions qml/tools/PebbleComm.qml
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,6 @@ Item
interfaceDBUSPebble.call('SendAppData', [sAppID, oData]);
}

function bGetPebbleAddress()
{
return interfaceDBUSPebble.getProperty('Address');
}

function bGetPebbleName()
{
return interfaceDBUSPebble.getProperty('Name');
}

function bIsPebbleConnected()
{
return interfaceDBUSPebble.getProperty('IsConnected');
}


DBusInterface
{
id:interfaceDBUSPebble
Expand All @@ -66,8 +50,12 @@ Item
console.log("Pebble connected");

if (!bPebbleConnected)
{
fncShowMessage(2,qsTr("Pebble connected"), 1200);

sPebbleNameAddress = id_PebbleWatchComm.getName() + ", " + id_PebbleWatchComm.getAddress();
}

//Pebble just got connected, check if sport app is required
if (bPebbleSportAppRequired && !bPebbleConnected)
pebbleComm.fncLaunchPebbleApp("4dab81a6-d2fc-458a-992c-7a1f3b96a970");
Expand Down
2 changes: 1 addition & 1 deletion rpm/harbour-laufhelden.changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
* Wed Dec 06 2017 Jens Drescher <[email protected]> 0.9.7-8
* Wed Dec 19 2017 Jens Drescher <[email protected]> 0.9.7-8
- added new feature/settings: Pebble smartwatch support
- added new feature: edit workout name/description/type
- fixed a bug: mediaplayer pause/resume was not working
Expand Down
2 changes: 2 additions & 0 deletions src/harbour-laufhelden.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "plotwidget.h"
#include "light.h"
#include "pebblemanagercomm.h"
#include "pebblewatchcomm.h"


int main(int argc, char *argv[]) {
Expand All @@ -53,6 +54,7 @@ int main(int argc, char *argv[]) {
qmlRegisterType<PlotWidget,1>("harbour.laufhelden", 1, 0, "PlotWidget");
qmlRegisterType<Light,1>("harbour.laufhelden", 1, 0, "Light");
qmlRegisterType<PebbleManagerComm,1>("harbour.laufhelden", 1, 0, "PebbleManagerComm");
qmlRegisterType<PebbleWatchComm,1>("harbour.laufhelden", 1, 0, "PebbleWatchComm");

QQuickView *view = SailfishApp::createView();
view->rootContext()->setContextProperty("appVersion", app->applicationVersion());
Expand Down
3 changes: 1 addition & 2 deletions src/pebblemanagercomm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ PebbleManagerComm::PebbleManagerComm(QObject *parent) : QObject(parent)

PebbleManagerComm::~PebbleManagerComm()
{

this->dbusPebbleManager = NULL;
}

QList<QString> PebbleManagerComm::getListWatches()
Expand Down Expand Up @@ -51,5 +51,4 @@ QString PebbleManagerComm::getRockpoolVersion()
qDebug()<<"DBus error: " << reply.error().message();
return "";
}

}
7 changes: 3 additions & 4 deletions src/pebblemanagercomm.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ class PebbleManagerComm : public QObject
~PebbleManagerComm();

Q_INVOKABLE QString getRockpoolVersion();
Q_INVOKABLE QList<QString> getListWatches();

private:
QDBusInterface *dbusPebbleManager;
Q_INVOKABLE QList<QString> getListWatches();

private:
QDBusInterface *dbusPebbleManager;
};

#endif // PEBBLEMANAGERCOMM_H
72 changes: 72 additions & 0 deletions src/pebblewatchcomm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include <QDebug>
#include "pebblewatchcomm.h"

PebbleWatchComm::PebbleWatchComm(QObject *parent) : QObject(parent)
{
this->dbusPebble = NULL;
}

PebbleWatchComm::~PebbleWatchComm()
{
this->dbusPebble = NULL;
}

void PebbleWatchComm::setServicePath(QString sServicePath)
{
this->dbusPebble = new QDBusInterface(SERVER_SERVICE, sServicePath, SERVER_INTERFACE, QDBusConnection::sessionBus(), this);
}

QString PebbleWatchComm::getAddress()
{
if (this->dbusPebble == NULL)
return "";

QDBusReply<QString> reply = dbusPebble->call("Address");

if (reply.isValid())
{
return reply.value();
}
else
{
qDebug()<<"DBus error: " << reply.error().message();
return "";
}
}

QString PebbleWatchComm::getName()
{
if (this->dbusPebble == NULL)
return "";

QDBusReply<QString> reply = dbusPebble->call("Name");

if (reply.isValid())
{
return reply.value();
}
else
{
qDebug()<<"DBus error: " << reply.error().message();
return "";
}
}

bool PebbleWatchComm::isConnected()
{
if (this->dbusPebble == NULL)
return false;

QDBusReply<bool> reply = dbusPebble->call("IsConnected");

if (reply.isValid())
{
return reply.value();
}
else
{
qDebug()<<"DBus error: " << reply.error().message();
return false;
}
}

27 changes: 27 additions & 0 deletions src/pebblewatchcomm.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef PEBBLEWATCHCOMM_H
#define PEBBLEWATCHCOMM_H

#include <QtDBus/QtDBus>
#include <QObject>

#define SERVER_INTERFACE "org.rockwork.Pebble"
#define SERVER_SERVICE "org.rockwork"

class PebbleWatchComm : public QObject
{
Q_OBJECT

public:
PebbleWatchComm(QObject * parent = NULL);
~PebbleWatchComm();

Q_INVOKABLE void setServicePath(QString sServicePath);
Q_INVOKABLE QString getAddress();
Q_INVOKABLE QString getName();
Q_INVOKABLE bool isConnected();

private:
QDBusInterface *dbusPebble;
};

#endif // PEBBLEWATCHCOMM_H

0 comments on commit 9cbbab9

Please sign in to comment.