From 4c61854d60fb5d2c68c6dcb1fb5bdf5c0dead3e2 Mon Sep 17 00:00:00 2001 From: Lincoln Ramsay Date: Fri, 2 Mar 2012 14:13:39 +1000 Subject: 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 --- examples/sensors/maze/maze.qml | 2 - examples/sensors/qmlqtsensors/qmlqtsensors.qml | 87 ++------------------------ 2 files changed, 4 insertions(+), 85 deletions(-) (limited to 'examples') diff --git a/examples/sensors/maze/maze.qml b/examples/sensors/maze/maze.qml index 4677505..4626287 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 fe21c4b..d285cc9 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,75 +147,11 @@ 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 @@ -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" @@ -301,23 +236,9 @@ 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] } -- cgit v1.2.1