From 76d4cae393305a1a87e53b88ef80a2a1a87758b7 Mon Sep 17 00:00:00 2001 From: Topi Reinio Date: Wed, 9 Oct 2013 13:26:10 +0200 Subject: 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 --- examples/sensors/qmlsensorgestures/GestureList.qml | 15 +++-- examples/sensors/qmlsensorgestures/GestureView.qml | 35 ++++++----- .../sensors/qmlsensorgestures/GesturesView.qml | 54 ++++++++--------- .../doc/src/qmlsensorgestures.qdoc | 68 ++++++++++++++++++++++ .../doc/src/qmlsensorgtestures.qdoc | 63 -------------------- .../qmlsensorgestures/qmlsensorgestures.qml | 6 +- 6 files changed, 125 insertions(+), 116 deletions(-) create mode 100644 examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc delete mode 100644 examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc (limited to 'examples') diff --git a/examples/sensors/qmlsensorgestures/GestureList.qml b/examples/sensors/qmlsensorgestures/GestureList.qml index ea79af3b..a7cf0964 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 c12c6f28..8449f18a 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 ceab8d10..46e8fead 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/qmlsensorgestures.qdoc b/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc new file mode 100644 index 00000000..6d810711 --- /dev/null +++ b/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: http://www.gnu.org/copyleft/fdl.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +/*! + \example qmlsensorgestures + \title Qt Sensors - SensorGesture QML Type example + \ingroup qtsensors-examples + + \brief Demonstrates the use of SensorGesture QML type. + + \section1 Overview + To write a QML application that will use the gesture plugin, following + steps are needed: + + Import the QtSensors 5.x module: + + \snippet qmlsensorgestures/GestureView.qml 0 + + Add the SensorGesture QML type into your qml file. + + \snippet qmlsensorgestures/GestureView.qml 1 + + Each SensorGesture QML type contains a property called gestures. This example + uses an alias \c gestureId for this property. + + \snippet qmlsensorgestures/GestureView.qml 2 + + Then, the gesture or gestures to use can be specified using the alias: + + \snippet qmlsensorgestures/qmlsensorgestures.qml 3 + \dots 12 + \snippet qmlsensorgestures/qmlsensorgestures.qml 4 + + A list of all available gestures is accessible through the + \c availableGestures property: + + \snippet qmlsensorgestures/GestureList.qml 4 + \codeline + \snippet qmlsensorgestures/GestureList.qml 5 + \dots 12 + \snippet qmlsensorgestures/GestureList.qml 6 + + \sa {Qt Sensors - ShakeIt QML Example}, {Qt Sensor Gestures} +*/ diff --git a/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc b/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc deleted file mode 100644 index 83f3171d..00000000 --- a/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgtestures.qdoc +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example qmlsensorgestures - \title Qt Sensors - SensorGesture QML Type example - \ingroup qtsensors-examples - - \brief This example demonstrates use of the SensorGesture QML type. - -\section1 Overview - To write a QML application that will use the gesture plugin you need to to the following steps: - - Import the QtSensors 5.x declarative plugin: - -\snippet qmlsensorgestures/GestureView.qml 0 - - Add the SensorGesture QML type into your qml file. - -\snippet qmlsensorgestures/GestureView.qml 1 - - Each SensorGesture QML type contains a property called gestures. - - In this example an alias 'gestureid' for this property is used. - -\snippet qmlsensorgestures/GestureView.qml 2 - - By using this alias property you define which gestures should be used: - -\snippet qmlsensorgestures/qmlsensorgestures.qml 3 - - A list of all available gestures can be created by calling the 'availableGestures' property: - -\snippet qmlsensorgestures/GestureList.qml 4 - -\sa {Qt Sensors - ShakeIt QML Example} -\sa {Qt Sensor Gestures} -*/ - diff --git a/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml b/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml index af1f04a7..60a598e0 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 { -- cgit v1.2.3