From 1bcaaef7d3a30a7bad37b717d0fcad4ba8a27e95 Mon Sep 17 00:00:00 2001 From: Titta Heikkala Date: Tue, 21 Feb 2017 13:03:54 +0200 Subject: iot-sensortag: Clean up onSensorChanged signal handlers Removed onSensorChanged signal handlers from charts as they are not needed. Instead, react to changes of sensor properties. Change-Id: Ib848d3ddfeed550538d35793b24eeb137a57a171 Reviewed-by: Maurice Kalinowski --- .../iot-sensortag/resources/base/LightChart.qml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'tradeshow/iot-sensortag/resources/base/LightChart.qml') diff --git a/tradeshow/iot-sensortag/resources/base/LightChart.qml b/tradeshow/iot-sensortag/resources/base/LightChart.qml index f170e81..a51787d 100644 --- a/tradeshow/iot-sensortag/resources/base/LightChart.qml +++ b/tradeshow/iot-sensortag/resources/base/LightChart.qml @@ -57,10 +57,6 @@ BaseChart { title: qsTr("Light Intensity") rightSide: true - onSensorChanged: if (sensor) { - sensor.lightIntensityChanged.connect(contentItem.getLightText) - } - content: Item { id: container @@ -68,21 +64,18 @@ BaseChart { property alias lightText: lightMainText.text property alias lightImg: brightnessImg - property real lightValue: 0 + property real lightValue: sensor ? sensor.lightIntensityLux : 0 property real maxLightValue: 1 property real normalizedLightValue: 0 - function getLightText() - { - lightValue = sensor.lightIntensityLux; - contentItem.lightText = lightValue.toFixed(1); + onLightValueChanged: { + contentItem.lightText = lightValue.toFixed(1) if (lightValue > maxLightValue) - { - maxLightValue = lightValue; - } - normalizedLightValue = lightValue / maxLightValue; - lightImg.opacity = normalizedLightValue; + maxLightValue = lightValue + + normalizedLightValue = lightValue / maxLightValue + lightImg.opacity = normalizedLightValue } Image { -- cgit v1.2.3