From 21350aac26961e48e2610f157725a2a8873b285b Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Mon, 2 Oct 2017 12:54:24 +0200 Subject: iot-sensortag: Use double-click to select connection Change-Id: I46c3860799018e51f74df8d24dd54eccab02db7a Reviewed-by: Oliver Wolff --- .../resources/base/SensorSettings.qml | 52 ++++++++++++---------- 1 file changed, 29 insertions(+), 23 deletions(-) diff --git a/tradeshow/iot-sensortag/resources/base/SensorSettings.qml b/tradeshow/iot-sensortag/resources/base/SensorSettings.qml index 7661325..5302816 100644 --- a/tradeshow/iot-sensortag/resources/base/SensorSettings.qml +++ b/tradeshow/iot-sensortag/resources/base/SensorSettings.qml @@ -63,6 +63,30 @@ Rectangle { height: 800 anchors.horizontalCenter: parent.horizontalCenter + function createSensorConnection() { + clickBait.deactivate() + + var currentPool = getCurrentPool(); + if (currentPool.dataProviders[sensorListView.currentIndex] === singleSensorSource) { + console.log("Same data provider selected, nothing to change...") + return; + } + + if (singleSensorSource) + singleSensorSource.endDataFetching(); + // UI gets information about the intended setup of the + // sensor even though they have not been really discovered yet + if (currentPool) { + singleSensorSource = currentPool.dataProviders[sensorListView.currentIndex] + currentPool.currentProviderIndex = sensorListView.currentIndex + + seriesStorage.setDataProviderPool(currentPool); + seriesStorage.dataProviderPoolChanged(); + + singleSensorSource.startDataFetching() + } + } + Image { source: "images/bg_blue.jpg" anchors.fill: parent @@ -151,6 +175,10 @@ Rectangle { MouseArea { anchors.fill: parent onClicked: sensorListView.currentIndex = index + onDoubleClicked: { + sensorListView.currentIndex = index + createSensorConnection() + } } } } @@ -173,29 +201,7 @@ Rectangle { id: connectButtonArea anchors.fill: parent enabled: sensorListView.currentIndex != -1 - onClicked: { - clickBait.deactivate() - - var currentPool = getCurrentPool(); - if (currentPool.dataProviders[sensorListView.currentIndex] === singleSensorSource) { - console.log("Same data provider selected, nothing to change...") - return; - } - - if (singleSensorSource) - singleSensorSource.endDataFetching(); - // UI gets information about the intended setup of the - // sensor even though they have not been really discovered yet - if (currentPool) { - singleSensorSource = currentPool.dataProviders[sensorListView.currentIndex] - currentPool.currentProviderIndex = sensorListView.currentIndex - - seriesStorage.setDataProviderPool(currentPool); - seriesStorage.dataProviderPoolChanged(); - - singleSensorSource.startDataFetching() - } - } + onClicked: createSensorConnection() } } -- cgit v1.2.3