diff options
author | Topi Reinio <topi.reinio@digia.com> | 2013-10-09 13:26:10 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-11-04 11:46:55 +0100 |
commit | 76d4cae393305a1a87e53b88ef80a2a1a87758b7 (patch) | |
tree | 161fac4d236e2434873754322562497ebdb6229f /examples | |
parent | b8b341cb805502bd0cc4a61d67aebe9984f59eb4 (diff) | |
download | qtsensors-76d4cae393305a1a87e53b88ef80a2a1a87758b7.tar.gz |
Doc: Clean up SensorGesture QML example
Fix warnings, fix property names and strings shown in
the UI. Also touch the documentation and correct a
typo in the qdoc file name.
Task-number: QTBUG-33877
Change-Id: Ie790708ac4d1f8d72af03b52ee361d0bf3994adc
Reviewed-by: Lorn Potter <lorn.potter@jollamobile.com>
Diffstat (limited to 'examples')
-rw-r--r-- | examples/sensors/qmlsensorgestures/GestureList.qml | 15 | ||||
-rw-r--r-- | examples/sensors/qmlsensorgestures/GestureView.qml | 35 | ||||
-rw-r--r-- | examples/sensors/qmlsensorgestures/GesturesView.qml | 54 | ||||
-rw-r--r-- | examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc (renamed from examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc) | 41 | ||||
-rw-r--r-- | examples/sensors/qmlsensorgestures/qmlsensorgestures.qml | 6 |
5 files changed, 80 insertions, 71 deletions
diff --git a/examples/sensors/qmlsensorgestures/GestureList.qml b/examples/sensors/qmlsensorgestures/GestureList.qml index ea79af3..a7cf096 100644 --- a/examples/sensors/qmlsensorgestures/GestureList.qml +++ b/examples/sensors/qmlsensorgestures/GestureList.qml @@ -68,8 +68,7 @@ Rectangle { border.width: 1 anchors.margins: 5 - property string selectedGesture: ""; - signal selectedGestureChanged(); + property string selectedGesture: "" SensorGesture { id: gesture @@ -98,15 +97,20 @@ Rectangle { //! [4] ListView { id: gestureList +//! [4] anchors.fill: gestureListRect anchors.margins: 5 +//! [5] model: gesture.availableGestures +//! [5] focus: true currentIndex: -1 delegate: gestureListDelegate clip: true +//! [6] } -//! [4] +//! [6] + Component { id: gestureListDelegate @@ -122,9 +126,8 @@ Rectangle { MouseArea { anchors.fill: parent onClicked: { - gestureList.currentIndex = index; - selectedGesture = model.modelData; - selectedGestureChanged(); + gestureList.currentIndex = index + selectedGesture = model.modelData } } } diff --git a/examples/sensors/qmlsensorgestures/GestureView.qml b/examples/sensors/qmlsensorgestures/GestureView.qml index c12c6f2..8449f18 100644 --- a/examples/sensors/qmlsensorgestures/GestureView.qml +++ b/examples/sensors/qmlsensorgestures/GestureView.qml @@ -73,26 +73,26 @@ import QtSensors 5.0 */ Rectangle { - id: gesturerect + id: gestureRect border.width: 1 anchors.margins: 5 //! [2] - property alias gestureid: sensorGesture.gestures + property alias gestureId: sensorGesture.gestures //! [2] - property alias gesturetitle: titleText.text + property alias gestureTitle: titleText.text property alias enabled: sensorGesture.enabled - property string oldgesture: "" + property string oldGesture: "" property int count: 0 //! [1] SensorGesture { id: sensorGesture enabled: false - onDetected:{ - if (gesture !== oldgesture) + onDetected: { + if (gesture !== oldGesture) count = 0; valueText.text = gesture + " " + count; - oldgesture = gesture; + oldGesture = gesture; count++; } onEnabledChanged: { @@ -103,9 +103,9 @@ Rectangle { Text { id: titleText - anchors.top: gesturerect.top - anchors.left: gesturerect.left - anchors.right: gesturerect.right + anchors.top: gestureRect.top + anchors.left: gestureRect.left + anchors.right: gestureRect.right horizontalAlignment: Text.AlignHCenter font.pixelSize: 20 font.bold: true @@ -115,28 +115,27 @@ Rectangle { Text { id: detectionText anchors.top: titleText.bottom - anchors.left: gesturerect.left - anchors.right: gesturerect.right + anchors.left: gestureRect.left + anchors.right: gestureRect.right horizontalAlignment: Text.AlignHCenter font.pixelSize: 15 - text: "detection:" + text: "Detection:" } Text { id: valueText anchors.top: detectionText.bottom - anchors.left: gesturerect.left - anchors.right: gesturerect.right + anchors.left: gestureRect.left + anchors.right: gestureRect.right horizontalAlignment: Text.AlignHCenter font.pixelSize: 15 - text: ("") visible: sensorGesture.enabled } Button{ id: gestureStartStopButton - anchors.left: gesturerect.left - anchors.bottom: gesturerect.bottom + anchors.left: gestureRect.left + anchors.bottom: gestureRect.bottom height: 30 width: 100 buttonText: (sensorGesture.enabled ? "Stop" : "Start") diff --git a/examples/sensors/qmlsensorgestures/GesturesView.qml b/examples/sensors/qmlsensorgestures/GesturesView.qml index ceab8d1..46e8fea 100644 --- a/examples/sensors/qmlsensorgestures/GesturesView.qml +++ b/examples/sensors/qmlsensorgestures/GesturesView.qml @@ -70,86 +70,86 @@ import QtSensors 5.0 */ Rectangle { - id: gesturerect + id: gestureRect border.width: 1 anchors.margins: 5 - property alias enabled: sensorGuesture.enabled + property alias enabled: sensorGesture.enabled property int count: 0 property int count1: 0 SensorGesture { - id: sensorGuesture + id: sensorGesture enabled: true gestures: availableGestures onDetected:{ if (gesture === "QtSensors.shake") - gesturerect.count++; + gestureRect.count++; else - gesturerect.count1++; + gestureRect.count1++; } onEnabledChanged: { - gesturerect.count = 0; - gesturerect.count1 = 0; + gestureRect.count = 0; + gestureRect.count1 = 0; } } Text { id: titleText - anchors.top: gesturerect.top - anchors.left: gesturerect.left - anchors.right: gesturerect.right + anchors.top: gestureRect.top + anchors.left: gestureRect.left + anchors.right: gestureRect.right horizontalAlignment: Text.AlignHCenter font.pixelSize: 20 font.bold: true - text: "templates gestures" + text: "Gesture Counter" } Text { id: detectionText anchors.top: titleText.bottom - anchors.left: gesturerect.left - anchors.right: gesturerect.right + anchors.left: gestureRect.left + anchors.right: gestureRect.right horizontalAlignment: Text.AlignHCenter font.pixelSize: 15 - text: "shake : SecondCounter" + text: "Shake : SecondCounter" } Text { id: valueText anchors.top: detectionText.bottom - anchors.left: gesturerect.left - width: gesturerect.width / 2 + anchors.left: gestureRect.left + width: gestureRect.width / 2 horizontalAlignment: Text.AlignHCenter font.pixelSize: 15 - text: gesturerect.count - visible: sensorGuesture.enabled + text: gestureRect.count + visible: sensorGesture.enabled } Text { id: valueText1 anchors.top: detectionText.bottom - anchors.right: gesturerect.right - width: gesturerect.width / 2 + anchors.right: gestureRect.right + width: gestureRect.width / 2 horizontalAlignment: Text.AlignHCenter font.pixelSize: 15 - text: gesturerect.count1 - visible: sensorGuesture.enabled + text: gestureRect.count1 + visible: sensorGesture.enabled } Button{ id: gestureStartStopButton - anchors.left: gesturerect.left - anchors.bottom: gesturerect.bottom + anchors.left: gestureRect.left + anchors.bottom: gestureRect.bottom height: 30 width: 100 - buttonText: (sensorGuesture.enabled ? "Stop" : "Start") + buttonText: (sensorGesture.enabled ? "Stop" : "Start") enabled: true; onClicked: { if (gestureStartStopButton.buttonText === "Start") { - sensorGuesture.enabled = true; + sensorGesture.enabled = true; } else { - sensorGuesture.enabled = false; + sensorGesture.enabled = false; } } } diff --git a/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc b/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc index 83f3171..6d81071 100644 --- a/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc +++ b/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc @@ -30,34 +30,39 @@ \title Qt Sensors - SensorGesture QML Type example \ingroup qtsensors-examples - \brief This example demonstrates use of the SensorGesture QML type. + \brief Demonstrates the use of SensorGesture QML type. -\section1 Overview - To write a QML application that will use the gesture plugin you need to to the following steps: + \section1 Overview + To write a QML application that will use the gesture plugin, following + steps are needed: - Import the QtSensors 5.x declarative plugin: + Import the QtSensors 5.x module: -\snippet qmlsensorgestures/GestureView.qml 0 + \snippet qmlsensorgestures/GestureView.qml 0 - Add the SensorGesture QML type into your qml file. + Add the SensorGesture QML type into your qml file. -\snippet qmlsensorgestures/GestureView.qml 1 + \snippet qmlsensorgestures/GestureView.qml 1 - Each SensorGesture QML type contains a property called gestures. + Each SensorGesture QML type contains a property called gestures. This example + uses an alias \c gestureId for this property. - In this example an alias 'gestureid' for this property is used. + \snippet qmlsensorgestures/GestureView.qml 2 -\snippet qmlsensorgestures/GestureView.qml 2 + Then, the gesture or gestures to use can be specified using the alias: - By using this alias property you define which gestures should be used: + \snippet qmlsensorgestures/qmlsensorgestures.qml 3 + \dots 12 + \snippet qmlsensorgestures/qmlsensorgestures.qml 4 -\snippet qmlsensorgestures/qmlsensorgestures.qml 3 + A list of all available gestures is accessible through the + \c availableGestures property: - A list of all available gestures can be created by calling the 'availableGestures' property: + \snippet qmlsensorgestures/GestureList.qml 4 + \codeline + \snippet qmlsensorgestures/GestureList.qml 5 + \dots 12 + \snippet qmlsensorgestures/GestureList.qml 6 -\snippet qmlsensorgestures/GestureList.qml 4 - -\sa {Qt Sensors - ShakeIt QML Example} -\sa {Qt Sensor Gestures} + \sa {Qt Sensors - ShakeIt QML Example}, {Qt Sensor Gestures} */ - diff --git a/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml b/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml index af1f04a..60a598e 100644 --- a/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml +++ b/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml @@ -89,10 +89,12 @@ Rectangle { //! [3] onSelectedGestureChanged: { gesture.enabled = false; - gesture.gestureid = gestureList.selectedGesture; + gesture.gestureId = gestureList.selectedGesture; //! [3] - gesture.gesturetitle = gestureList.selectedGesture; + gesture.gestureTitle = gestureList.selectedGesture; +//! [4] } +//! [4] } GestureView { |