Skip to content

Instantly share code, notes, and snippets.

@kimmoli

kimmoli/steps.qml

Last active Oct 4, 2018
Embed
What would you like to do?
import QtQuick 2.0
import Sailfish.Silica 1.0
import org.nemomobile.dbus 2.0
Page
{
property var stepsNow: 0
Component.onCompleted:
{
stpcntrd.getSteps()
stpcntrd.setAutoUpdate(true)
}
Component.onDestruction:
{
stpcntrd.setAutoUpdate(false)
}
Label
{
anchors.centerIn: parent
text: "Step count: " + stepsNow
font.pixelSize: Theme.fontSizeLarge
}
DBusInterface
{
id: stpcntrd
service: 'com.kimmoli.stpcntrd'
path: '/'
iface: 'com.kimmoli.stpcntrd'
signalsEnabled: true
function steps(val)
{
console.log("steps: ", val)
stepsNow = val
}
function setAutoUpdate(val)
{
typedCall('setAutoUpdate',
[ { 'type': 'b', 'value' : val } ],
function(result) { console.log('stepcounter auto update ', val) },
function() { console.log('stepcounter call failed') }
)
}
function getSteps()
{
typedCall('getSteps',
[],
function(result) { stepsNow = result },
function() { console.log('stepcounter call failed') }
)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.