summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorLincoln Ramsay <lincoln.ramsay@nokia.com>2012-03-02 14:13:39 +1000
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-10-03 09:22:38 +0200
commit4c61854d60fb5d2c68c6dcb1fb5bdf5c0dead3e2 (patch)
treeb41d70a37b8a1ff76c32025d8562a94581a3bd22 /examples
parentfb68fb8c052ae08fabed8f49256e79b0d0915fb0 (diff)
Add TiltSensor to QtMobility.sensors 1.3
This has been adapted from the TiltSensor type in QtSensors 5.0 import but the code there has been split into multiple pieces. There's a C++ class, a generic backend and a QML interface. Change-Id: Ic09465a5f76250a02a13938abe4789958137376f Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/sensors/maze/maze.qml2
-rw-r--r--examples/sensors/qmlqtsensors/qmlqtsensors.qml87
2 files changed, 4 insertions, 85 deletions
diff --git a/examples/sensors/maze/maze.qml b/examples/sensors/maze/maze.qml
index 46775056..46262877 100644
--- a/examples/sensors/maze/maze.qml
+++ b/examples/sensors/maze/maze.qml
@@ -173,9 +173,7 @@ ApplicationWindow {
//! [1]
TiltSensor{
id: tiltSensor
- unit: TiltSensor.Degrees
enabled: true
- accuracy: 5.0
}
//! [1]
diff --git a/examples/sensors/qmlqtsensors/qmlqtsensors.qml b/examples/sensors/qmlqtsensors/qmlqtsensors.qml
index fe21c4b4..d285cc94 100644
--- a/examples/sensors/qmlqtsensors/qmlqtsensors.qml
+++ b/examples/sensors/qmlqtsensors/qmlqtsensors.qml
@@ -102,7 +102,6 @@ ApplicationWindow {
height: 480
color: "transparent"
- property int accuracy: 1
property string speed: "Slow"
Text {
@@ -148,76 +147,12 @@ ApplicationWindow {
//! [1]
TiltSensor {
id: tilt
- unit: TiltSensor.Degrees
enabled: false
- accuracy: 1.0
speed: TiltSensor.Slow
}
//! [1]
Rectangle{
- id: accuracyRect
- anchors.top: labelTilt.bottom
- anchors.topMargin: 5
- anchors.left: mainWnd.left
- anchors.leftMargin: 5
- anchors.right: mainWnd.right
- anchors.rightMargin: mainWnd.width / 2
- height: 110
- color: "transparent"
-
- Text{
- id: textAccuracy
- anchors.top: accuracyRect.top
- anchors.left: accuracyRect.left
- text: "Accuracy"
- font.bold: true
- }
-
- Text{
- id: textAccuracyValue
- anchors.top: textAccuracy.bottom
- anchors.topMargin: 5
- anchors.left: accuracyHigher.left
- anchors.right: accuracyHigher.right
- text: mainWnd.accuracy
- verticalAlignment: Text.AlignVCenter
- }
-
- Button{
- id: accuracyLower
- anchors.top: textAccuracyValue.bottom
- anchors.left: accuracyRect.left
- height: 30
- width: 40
- text: "-"
-
- onClicked:{
- if (mainWnd.accuracy > 1){
- mainWnd.accuracy--;
- tilt.accuracy = mainWnd.accuracy;
- }
- }
- }
-
- Button{
- id: accuracyHigher
- anchors.top: textAccuracyValue.bottom
- anchors.left: accuracyLower.right
- height: 30
- width: 40
- text: "+"
-
- onClicked:{
- if (mainWnd.accuracy < 10){
- mainWnd.accuracy++;
- tilt.accuracy = mainWnd.accuracy;
- }
- }
- }
- }
-
- Rectangle{
id: speedRect
anchors.top: labelTilt.bottom
anchors.topMargin: 5
@@ -291,7 +226,7 @@ ApplicationWindow {
id: calibrate
anchors.left: mainWnd.left
anchors.leftMargin: 5
- anchors.top: accuracyRect.bottom
+ anchors.top: speedRect.bottom
height: 30
width: 80
text: "Calibrate"
@@ -302,22 +237,8 @@ ApplicationWindow {
}
Button{
- id: useRadian
- anchors.top: calibrate.bottom
- anchors.left: mainWnd.left
- anchors.leftMargin: 5
- height: 30
- width: 80
- text: (tilt !== null ? tilt.unit === TiltSensor.Radians ? "Degree" : "Radians" : "Degree")
-
- onClicked:{
- tilt.unit = (useRadian.text === "Radians" ? TiltSensor.Radians : TiltSensor.Degrees);
- }
- }
-
- Button{
id: tiltStart
- anchors.top: useRadian.bottom
+ anchors.top: calibrate.bottom
anchors.left: mainWnd.left
anchors.leftMargin: 5
height: 30
@@ -341,7 +262,7 @@ ApplicationWindow {
anchors.bottom: useRadian.bottom
verticalAlignment: Text.AlignVCenter
//! [3]
- text: "X Rotation: " + tilt.xRotation + (tilt.unit === TiltSensor.Radians ? " rad" : "°")
+ text: "X Rotation: " + tilt.xRotation + "°"
//! [3]
}
@@ -355,7 +276,7 @@ ApplicationWindow {
anchors.bottom: tiltStart.bottom
verticalAlignment: Text.AlignVCenter
//! [4]
- text: "Y Rotation: " + tilt.yRotation + (tilt.unit === TiltSensor.Radians ? " rad" : "°")
+ text: "Y Rotation: " + tilt.yRotation + "°"
//! [4]
}