summaryrefslogtreecommitdiffstats
path: root/basicsuite/sensors
diff options
context:
space:
mode:
authorKalle Viironen <kalle.viironen@digia.com>2014-04-15 15:10:27 +0300
committerKalle Viironen <kalle.viironen@digia.com>2014-04-15 15:10:38 +0300
commitd757a8ee2d86c3f4b694f8fdff5defa7b0dbab75 (patch)
tree27b30b37643ebfe4615d7eb645b72cd42a4316cb /basicsuite/sensors
parent80c1335ec02c038329603486315d06d7bddc1326 (diff)
parent63d998641077d9074281f402ae7becb41c037a2c (diff)
Merge branch 'stable' into releaseQtEE_v2.1.0
* stable: (21 commits) Revert "Show PieMenu in enterprise controls list view." Show PieMenu in enterprise controls list view. Fix PieMenu not showing in enterprise-gallery launcher demo. Update enterprise controls demos to version 1.1 Revert "Add input field for decimal numbers" Doc: Update documentation version to 2.1.0 [launchersettings] Fix UI scaling [about-b2qt] Use Screen element for setting width/height Change default font for demos to support arabic numbers [launchersettings] Small fixes in wifi settings section sensorexplorer: Use identifier field when description is empty Make sensors demo not rely on measurement errors Doc: Update screenshot for the textinput demo Remove incorrect assingment of QUrl to bool qt5-everywhere: update working radio playlist Show launchersettings and sensors demos in QtCreator Doc: Switch to use the global Qt template for example docs Updated preview_l.jpg for textinput demo Rearrange the order of demos in the launcher Merge updates from upstream into keyboard example ... Change-Id: I83f65cb50cf53609d9bb131c94c3d020882a2ccd
Diffstat (limited to 'basicsuite/sensors')
-rw-r--r--basicsuite/sensors/Accelbubble.qml64
-rw-r--r--basicsuite/sensors/title.txt2
2 files changed, 44 insertions, 22 deletions
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()
}
}
}
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