From ce45d362fc96b01f044170c0f405c8f5ccb64ec5 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Thu, 6 Mar 2014 14:33:22 +0100 Subject: Rearrange the order of demos in the launcher The launcher will sort the demos alphabetically based on their titles, and then removes leading digits (see cf9b6d17). This allows us to control the order of the demos. This change sets the following order, from left to right: About Qt Enterprise Embedded Launcher Settings Qt5 Everywhere Qt5 Cinematic Demo Qt5 Launch Presentation Virtual Keyboard Qt Quick Enterprise Controls - Dashboard Qt Quick Enterprise Controls - Gallery Controls: Touch Qt Charts - Gallery Media Player Camera Photo Gallery Graphical Effects Sensors Demo Change-Id: I80e5fb66b55f5b5541acc70410c555d4d971e220 Reviewed-by: Eirik Aavitsland --- basicsuite/sensors/title.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'basicsuite/sensors') diff --git a/basicsuite/sensors/title.txt b/basicsuite/sensors/title.txt index 558b7c0..a3a5b97 100644 --- a/basicsuite/sensors/title.txt +++ b/basicsuite/sensors/title.txt @@ -1 +1 @@ -Sensors Demo +140. Sensors Demo -- cgit v1.2.3 From 9939d72b1e2f67a7af52cc798ae4fd9742d086f6 Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Wed, 19 Mar 2014 12:37:19 +0100 Subject: Make sensors demo not rely on measurement errors MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The former implementation only updates the bubble when notified by a sensor changed event. This is not optimal because when the accelerometer is kept at a constant tilt the value does not change anymore but the bubble has to move further nevertheless. Change-Id: I24793b4c8da3fdc75eb3054acd88976d053149e3 Reviewed-by: Topi Reiniƶ Reviewed-by: Eirik Aavitsland --- basicsuite/sensors/Accelbubble.qml | 64 +++++++++++++++++++++++++------------- 1 file changed, 43 insertions(+), 21 deletions(-) (limited to 'basicsuite/sensors') diff --git a/basicsuite/sensors/Accelbubble.qml b/basicsuite/sensors/Accelbubble.qml index 7fba4d4..c5aeefc 100644 --- a/basicsuite/sensors/Accelbubble.qml +++ b/basicsuite/sensors/Accelbubble.qml @@ -42,6 +42,33 @@ import QtQuick 2.0 import QtSensors 5.0 Item { + function calc() { + if (xAnimation.running || yAnimation.running) + return + + var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * .8) + var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * .8) + + if (newX < 0) + newX = 0 + if (newY < 0) + newY = 0 + + var right = field.width - bubble.width + var bottom = field.height - bubble.height + + if (newX > right) + newX = right + if (newY > bottom) + newY = bottom + + bubble.x = newX + bubble.y = newY + + yBehavior.enabled = true + xBehavior.enabled = true + } + Rectangle { id: field color: "lightblue" @@ -52,26 +79,13 @@ Item { Accelerometer { id: accel active:true - onReadingChanged: { - var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * .1) - var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * .1) - - if (newX < 0) - newX = 0 - if (newY < 0) - newY = 0 - - var right = field.width - bubble.width - var bottom = field.height - bubble.height - - if (newX > right) - newX = right - if (newY > bottom) - newY = bottom + } - bubble.x = newX - bubble.y = newY - } + Timer { + interval: 100 + running: true + repeat: true + onTriggered: calc() } Image { @@ -85,15 +99,23 @@ Item { smooth: true Behavior on y { + id: yBehavior + enabled: false SmoothedAnimation { + id: yAnimation easing.type: Easing.Linear - duration: 100 + duration: 40 + onRunningChanged: calc() } } Behavior on x { + id: xBehavior + enabled: false SmoothedAnimation { + id: xAnimation easing.type: Easing.Linear - duration: 100 + duration: 40 + onRunningChanged: calc() } } } -- cgit v1.2.3