diff options
author | Juha Vuolle <juha.vuolle@insta.fi> | 2022-09-29 17:53:56 +0300 |
---|---|---|
committer | Juha Vuolle <juha.vuolle@insta.fi> | 2022-10-04 08:11:45 +0300 |
commit | 7a94c109e6805b35150522b6714f04e63d751888 (patch) | |
tree | 4ce31ad1feb0de16bda4c591ad18c165db833b1d /examples/sensors | |
parent | d5d24fd5fe095337063891204e4fee4c6914b165 (diff) |
Remove disabled sensor gesture code
Support for sensor gestures in their then-current form was removed
in Qt 6 (QTBUG-95747). This commit removes the disabled code. This is
to avoid distraction when keeping the repository up-to-date with rest of
Qt.
The gestures may be reintroduced in some shape or form in the future
(QTBUG-97066). For those reference purposes the old code can be found
in the git history.
Fixes: QTBUG-107065
Change-Id: If2c50171f84d483dde55600422d138d550124bdc
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'examples/sensors')
39 files changed, 0 insertions, 1686 deletions
diff --git a/examples/sensors/CMakeLists.txt b/examples/sensors/CMakeLists.txt index cd7cdb5c..f1b382a6 100644 --- a/examples/sensors/CMakeLists.txt +++ b/examples/sensors/CMakeLists.txt @@ -4,15 +4,10 @@ if(TARGET Qt::Quick) qt_internal_add_example(grue) qt_internal_add_example(maze) -# qt_internal_add_example(qmlsensorgestures) qt_internal_add_example(qmlqtsensors) qt_internal_add_example(sensor_explorer) -# qt_internal_add_example(shakeit) if(TARGET Qt::Svg) qt_internal_add_example(accelbubble) qt_internal_add_example(sensorsshowcase) endif() endif() -# if(TARGET Qt::Widgets) -# qt_internal_add_example(sensorgestures) -# endif() diff --git a/examples/sensors/qmlsensorgestures/Button.qml b/examples/sensors/qmlsensorgestures/Button.qml deleted file mode 100644 index 1a07ceaa..00000000 --- a/examples/sensors/qmlsensorgestures/Button.qml +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick - -//Implementation of the Button control. -Item { - id: button - width: 30 - height: 30 - property alias buttonText: innerText.text; - property color color: "white" - property color hoverColor: "#aaaaaa" - property color pressColor: "slategray" - property int fontSize: 10 - property int borderWidth: 1 - property int borderRadius: 2 - scale: state === "Pressed" ? 0.96 : 1.0 - onEnabledChanged: state = "" - signal clicked - - //define a scale animation - Behavior on scale { - NumberAnimation { - duration: 100 - easing.type: Easing.InOutQuad - } - } - - //Rectangle to draw the button - Rectangle { - id: rectangleButton - anchors.fill: parent - radius: borderRadius - color: button.enabled ? button.color : "grey" - border.width: borderWidth - border.color: "black" - - Text { - id: innerText - font.pointSize: fontSize - anchors.centerIn: parent - } - } - - //change the color of the button in differen button states - states: [ - State { - name: "Hovering" - PropertyChanges { - target: rectangleButton - color: hoverColor - } - }, - State { - name: "Pressed" - PropertyChanges { - target: rectangleButton - color: pressColor - } - } - ] - - //define transmission for the states - transitions: [ - Transition { - from: ""; to: "Hovering" - ColorAnimation { duration: 200 } - }, - Transition { - from: "*"; to: "Pressed" - ColorAnimation { duration: 10 } - } - ] - - //Mouse area to react on click events - MouseArea { - hoverEnabled: true - anchors.fill: button - onEntered: { button.state='Hovering'} - onExited: { button.state=''} - onClicked: { button.clicked();} - onPressed: { button.state="Pressed" } - onReleased: { - if (containsMouse) - button.state="Hovering"; - else - button.state=""; - } - } -} diff --git a/examples/sensors/qmlsensorgestures/CMakeLists.txt b/examples/sensors/qmlsensorgestures/CMakeLists.txt deleted file mode 100644 index 7cf64252..00000000 --- a/examples/sensors/qmlsensorgestures/CMakeLists.txt +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(qmlsensorgestures LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/qmlsensorgestures") - -find_package(Qt6 REQUIRED COMPONENTS Quick) - -qt_add_executable(qmlsensorgestures - main.cpp -) - -set_target_properties(qmlsensorgestures PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(qmlsensorgestures PUBLIC - Qt::Quick -) - -# Resources: -set(qml_resource_files - "Button.qml" - "GestureList.qml" - "GestureView.qml" - "GesturesView.qml" - "qmlsensorgestures.qml" -) - -qt6_add_resources(qmlsensorgestures "qml" - PREFIX - "/" - FILES - ${qml_resource_files} -) - -install(TARGETS qmlsensorgestures - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) - -add_subdirectory(plugin) diff --git a/examples/sensors/qmlsensorgestures/GestureList.qml b/examples/sensors/qmlsensorgestures/GestureList.qml deleted file mode 100644 index f7bc39dd..00000000 --- a/examples/sensors/qmlsensorgestures/GestureList.qml +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick -import QtSensors - -/* Layout - gesturerect - / ----------------------------------------/ -|-------------------------------------| -|| labelGesture || -|-------------------------------------| -|-------------------------------------| -|| |<---- gestureListRect -|| || -|| || -|| gestureList || -|| || -|| || -|| || -|| || -|| || -|| || -|-------------------------------------| -*/ - -Rectangle { - id: gesturerect - border.width: 1 - anchors.margins: 5 - - property string selectedGesture: "" - - SensorGesture { - id: gesture - } - - Text { - id: labelGesture - anchors.top: gesturerect.top - anchors.left: gesturerect.left - anchors.right: gesturerect.right - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 30 - font.bold: true - text: "Gestures" - } - - Rectangle { - id: gestureListRect - border.width: 1 - anchors.top: labelGesture.bottom - anchors.left: gesturerect.left - anchors.right: gesturerect.right - anchors.bottom: gesturerect.bottom - anchors.margins: 5 - -//! [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] - } -//! [6] - - Component { - id: gestureListDelegate - - Rectangle { - width: gestureList.width - height: itemText.height - color: (index === gestureList.currentIndex ? "#999933" : "#FFFFFF") - - Text { - id: itemText - text: model.modelData - } - MouseArea { - anchors.fill: parent - onClicked: { - gestureList.currentIndex = index - selectedGesture = model.modelData - } - } - } - } - } -} diff --git a/examples/sensors/qmlsensorgestures/GestureView.qml b/examples/sensors/qmlsensorgestures/GestureView.qml deleted file mode 100644 index a7cde34d..00000000 --- a/examples/sensors/qmlsensorgestures/GestureView.qml +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick - -//! [0] -import QtSensors -//! [0] - -/* Layout - gesturerect - / ----------------------------------------/ -| ----------------------------------- | -| | id: titleText | | -| ----------------------------------- | -| | -| | -| ----------------------------------- | -| | id: detectionText | | -| ----------------------------------- | -| | -| | -| | -| ----------------------------------- | -| | id: valueText | | -| ----------------------------------- | -| | -| | -| | -| ------------------------------ | -| | id: gestureStartStopButton | | -| ------------------------------ | ---------------------------------------- -*/ - -Rectangle { - id: gestureRect - border.width: 1 - anchors.margins: 5 -//! [2] - property alias gestureId: sensorGesture.gestures -//! [2] - property alias gestureTitle: titleText.text - property alias enabled: sensorGesture.enabled - property string oldGesture: "" - property int count: 0 - -//! [1] - SensorGesture { - id: sensorGesture - enabled: false - onDetected: { - if (gesture !== oldGesture) - count = 0; - valueText.text = gesture + " " + count; - oldGesture = gesture; - count++; - } - onEnabledChanged: { - valueText.text = "" - } - } -//! [1] - - Text { - id: titleText - anchors.top: gestureRect.top - anchors.left: gestureRect.left - anchors.right: gestureRect.right - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 20 - font.bold: true - text: "" - } - - Text { - id: detectionText - anchors.top: titleText.bottom - anchors.left: gestureRect.left - anchors.right: gestureRect.right - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 15 - text: "Detection:" - } - - Text { - id: valueText - anchors.top: detectionText.bottom - anchors.left: gestureRect.left - anchors.right: gestureRect.right - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 15 - visible: sensorGesture.enabled - } - - Button{ - id: gestureStartStopButton - anchors.left: gestureRect.left - anchors.bottom: gestureRect.bottom - height: 30 - width: 100 - buttonText: (sensorGesture.enabled ? "Stop" : "Start") - enabled: true; - onClicked: { - if (gestureStartStopButton.buttonText === "Start") { - sensorGesture.enabled = true; - } - else { - sensorGesture.enabled = false; - } - } - } -} diff --git a/examples/sensors/qmlsensorgestures/GesturesView.qml b/examples/sensors/qmlsensorgestures/GesturesView.qml deleted file mode 100644 index 3cd7e0a7..00000000 --- a/examples/sensors/qmlsensorgestures/GesturesView.qml +++ /dev/null @@ -1,119 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick -import QtSensors - -/* Layout - gesturerect - / ----------------------------------------/ -| ----------------------------------- | -| | id: titleText | | -| ----------------------------------- | -| | -| | -| ----------------------------------- | -| | id: detectionText | | -| ----------------------------------- | -| | -| | -| | -| ----------------- ----------------- | -| | id: valueText | | id: valueText1| | -| ----------------- ----------------- | -| | -| | -| | -| ------------------------------ | -| | id: gestureStartStopButton | | -| ------------------------------ | ---------------------------------------- -*/ - -Rectangle { - id: gestureRect - border.width: 1 - anchors.margins: 5 - property alias enabled: sensorGesture.enabled - property int count: 0 - property int count1: 0 - - SensorGesture { - id: sensorGesture - enabled: true - gestures: availableGestures - onDetected:{ - if (gesture === "QtSensors.shake") - gestureRect.count++; - else - gestureRect.count1++; - } - onEnabledChanged: { - gestureRect.count = 0; - gestureRect.count1 = 0; - } - } - - Text { - id: titleText - anchors.top: gestureRect.top - anchors.left: gestureRect.left - anchors.right: gestureRect.right - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 20 - font.bold: true - text: "Gesture Counter" - } - - Text { - id: detectionText - anchors.top: titleText.bottom - anchors.left: gestureRect.left - anchors.right: gestureRect.right - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 15 - text: "Shake : SecondCounter" - } - - Text { - id: valueText - anchors.top: detectionText.bottom - anchors.left: gestureRect.left - width: gestureRect.width / 2 - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 15 - text: gestureRect.count - visible: sensorGesture.enabled - } - - Text { - id: valueText1 - anchors.top: detectionText.bottom - anchors.right: gestureRect.right - width: gestureRect.width / 2 - horizontalAlignment: Text.AlignHCenter - font.pixelSize: 15 - text: gestureRect.count1 - visible: sensorGesture.enabled - } - - Button{ - id: gestureStartStopButton - anchors.left: gestureRect.left - anchors.bottom: gestureRect.bottom - height: 30 - width: 100 - buttonText: (sensorGesture.enabled ? "Stop" : "Start") - enabled: true; - onClicked: { - if (gestureStartStopButton.buttonText === "Start") { - sensorGesture.enabled = true; - } - else { - sensorGesture.enabled = false; - } - } - } -} diff --git a/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc b/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc deleted file mode 100644 index 4a742213..00000000 --- a/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \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 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/main.cpp b/examples/sensors/qmlsensorgestures/main.cpp deleted file mode 100644 index bf5bb9ac..00000000 --- a/examples/sensors/qmlsensorgestures/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "../stub.h" -SENSORS_EXAMPLE_MAIN(qmlsensorgestures) diff --git a/examples/sensors/qmlsensorgestures/plugin/CMakeLists.txt b/examples/sensors/qmlsensorgestures/plugin/CMakeLists.txt deleted file mode 100644 index 98969df4..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(qtsensorgestures_counterplugin LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Sensors) - -qt_add_plugin(qtsensorgestures_counterplugin) - -target_sources(qtsensorgestures_counterplugin PRIVATE - qcountergestureplugin.cpp qcountergestureplugin.h - qcounterrecognizer.cpp qcounterrecognizer.h -) - -set_target_properties(qtsensorgestures_counterplugin PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(qtsensorgestures_counterplugin PUBLIC - Qt::Core - Qt::Gui - Qt::Sensors -) - -install(TARGETS qtsensorgestures_counterplugin - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/sensors/qmlsensorgestures/plugin/plugin.pro b/examples/sensors/qmlsensorgestures/plugin/plugin.pro deleted file mode 100644 index bb519c8d..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/plugin.pro +++ /dev/null @@ -1,30 +0,0 @@ -QT += sensors -TARGET = qtsensorgestures_counterplugin - -QTDIR_build { -# This is only for the Qt build. Do not use externally. We mean it. -PLUGIN_TYPE = sensorgestures -PLUGIN_CLASS_NAME = QCounterGesturePlugin -PLUGIN_EXTENDS = - -load(qt_plugin) -CONFIG += install_ok -} else { - -TEMPLATE = lib -CONFIG += plugin - -target.path += $$[QT_INSTALL_PLUGINS]/sensorgestures -INSTALLS += target - -} - -HEADERS += \ - qcountergestureplugin.h \ - qcounterrecognizer.h -SOURCES += \ - qcountergestureplugin.cpp \ - qcounterrecognizer.cpp - -OTHER_FILES += \ - plugin.json - diff --git a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp deleted file mode 100644 index d55412f2..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include <QtPlugin> -#include <QStringList> -#include <QObject> - -#include "qcountergestureplugin.h" -#include <qsensorgestureplugininterface.h> -#include <qsensorgesturemanager.h> -#include "qcounterrecognizer.h" - - -QCounterGesturePlugin::QCounterGesturePlugin() -{ -} - -QCounterGesturePlugin::~QCounterGesturePlugin() -{ -} - -QStringList QCounterGesturePlugin::supportedIds() const -{ - QStringList list; - list << "QtSensors.SecondCounter"; - return list; -} - - -QList <QSensorGestureRecognizer *> QCounterGesturePlugin::createRecognizers() -{ - QList <QSensorGestureRecognizer *> recognizers; - - QSensorGestureRecognizer *sRec = new QCounterGestureRecognizer(this); - recognizers.append(sRec); - - return recognizers; -} diff --git a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h b/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h deleted file mode 100644 index 6f216970..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef QCOUNTERGESTUREPLUGIN_H -#define QCOUNTERGESTUREPLUGIN_H - -#include <QObject> -#include <QStringList> - -#include <qsensorgestureplugininterface.h> - -class QCounterGesturePlugin : public QObject, public QSensorGesturePluginInterface -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID "org.qt-project.QSensorGesturePluginInterface") - Q_INTERFACES(QSensorGesturePluginInterface) - -public: - explicit QCounterGesturePlugin(); - ~QCounterGesturePlugin(); - - QList<QSensorGestureRecognizer *> createRecognizers() override; - - QStringList gestureSignals() const; - QStringList supportedIds() const override; - QString name() const override { return "CounterGestures"; } -}; - -#endif // QCOUNTERGESTUREPLUGIN_H diff --git a/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp b/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp deleted file mode 100644 index 2e872674..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include <QDebug> -#include <QTimer> - -#include "qcounterrecognizer.h" - -QCounterGestureRecognizer::QCounterGestureRecognizer(QObject *parent) - : QSensorGestureRecognizer(parent) -{ -} - -QCounterGestureRecognizer::~QCounterGestureRecognizer() -{ - -} - -void QCounterGestureRecognizer::create() -{ - connect(&_timer,SIGNAL(timeout()),this,SLOT(timeout())); - _timer.setInterval(1000); -} - -bool QCounterGestureRecognizer::start() -{ - Q_EMIT detected(id()); - _timer.start(); - return _timer.isActive(); -} - -bool QCounterGestureRecognizer::stop() -{ - _timer.stop(); - return true; -} - - -bool QCounterGestureRecognizer::isActive() -{ - return _timer.isActive(); -} - -QString QCounterGestureRecognizer::id() const -{ - return QString("QtSensors.SecondCounter"); -} - -void QCounterGestureRecognizer::timeout() -{ - Q_EMIT detected(id()); -} diff --git a/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h b/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h deleted file mode 100644 index 857860ea..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef QCOUNTERGESTURERECOGNIZER_H -#define QCOUNTERGESTURERECOGNIZER_H - -#include <QDebug> -#include <QtCore/QTimer> -#include <qsensorgesturerecognizer.h> - -class QCounterGestureRecognizer : public QSensorGestureRecognizer -{ - Q_OBJECT -public: - - QCounterGestureRecognizer(QObject *parent = 0); - ~QCounterGestureRecognizer(); - - void create() override; - - QString id() const override; - bool start() override; - bool stop() override; - bool isActive() override; - -private slots: - void timeout(); - -private: - QTimer _timer; -}; - -#endif // QCOUNTERGESTURERECOGNIZER_H diff --git a/examples/sensors/qmlsensorgestures/qml.pro b/examples/sensors/qmlsensorgestures/qml.pro deleted file mode 100644 index 7b7e4493..00000000 --- a/examples/sensors/qmlsensorgestures/qml.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app -TARGET = qmlsensorgestures -QT += quick -qtConfig(static):QTPLUGIN += qtsensorgestures_plugin qtsensorgestures_shakeplugin - -SOURCES = main.cpp - -OTHER_FILES = \ - $$files(*.qml) - -target.path = $$[QT_INSTALL_EXAMPLES]/sensors/qmlsensorgestures -INSTALLS += target - -RESOURCES += \ - qml.qrc diff --git a/examples/sensors/qmlsensorgestures/qml.qrc b/examples/sensors/qmlsensorgestures/qml.qrc deleted file mode 100644 index af48a3ed..00000000 --- a/examples/sensors/qmlsensorgestures/qml.qrc +++ /dev/null @@ -1,9 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>Button.qml</file> - <file>GestureList.qml</file> - <file>GesturesView.qml</file> - <file>GestureView.qml</file> - <file>qmlsensorgestures.qml</file> - </qresource> -</RCC> diff --git a/examples/sensors/qmlsensorgestures/qmlsensorgestures.pro b/examples/sensors/qmlsensorgestures/qmlsensorgestures.pro deleted file mode 100644 index 011f5f95..00000000 --- a/examples/sensors/qmlsensorgestures/qmlsensorgestures.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = subdirs -CONFIG += ordered - -SUBDIRS = \ - plugin \ - qml.pro diff --git a/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml b/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml deleted file mode 100644 index 7fed5792..00000000 --- a/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -//Import the declarative plugins -import QtQuick -import QtSensors - -/* Layout --------------------------------------------------- -| ---------------------------------------------- | -| | | | -| | | | -| | | | -| | gestureList | | -| | | | -| | | | -| | | | -| | | | -| | | | -| | | | -| | | | -| | | | -| ---------------------------------------------- | -| ---------------------------------------------- | -| | | | -| | gesture | | -| | | | -| | | | -| ---------------------------------------------- | -| ---------------------------------------------- | -| | | | -| | gestures | | -| | | | -| | | | -| ---------------------------------------------- | --------------------------------------------------- -*/ - -Rectangle { - id: viewArea - width: 320 - height: 460 - color: '#d6d6d6' - - GestureList { - id: gestureList - parent: viewArea - anchors.left: viewArea.left - anchors.top: viewArea.top - anchors.right: viewArea.right - height: viewArea.height / 2 -//! [3] - onSelectedGestureChanged: { - gesture.enabled = false; - gesture.gestureId = gestureList.selectedGesture; -//! [3] - gesture.gestureTitle = gestureList.selectedGesture; -//! [4] - } -//! [4] - } - - GestureView { - id: gesture - parent: viewArea - anchors.left: viewArea.left - anchors.top: gestureList.bottom - anchors.right: viewArea.right - height: 100 - } - - GesturesView { - id: gestures - parent: viewArea - anchors.left: viewArea.left - anchors.top: gesture.bottom - anchors.right: viewArea.right - height: 100 - } -} diff --git a/examples/sensors/sensorgestures/CMakeLists.txt b/examples/sensors/sensorgestures/CMakeLists.txt deleted file mode 100644 index 46aa22da..00000000 --- a/examples/sensors/sensorgestures/CMakeLists.txt +++ /dev/null @@ -1,39 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(gesture LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) -set(CMAKE_AUTOUIC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/sensorgestures") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Sensors Widgets) - -qt_add_executable(gesture - main.cpp - mainwindow.cpp mainwindow.h mainwindow.ui -) - -set_target_properties(gesture PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(gesture PUBLIC - Qt::Core - Qt::Gui - Qt::Sensors - Qt::Widgets -) - -install(TARGETS gesture - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png b/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png Binary files differdeleted file mode 100644 index 4d453cf2..00000000 --- a/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png +++ /dev/null diff --git a/examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc b/examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc deleted file mode 100644 index 4a88a1ad..00000000 --- a/examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example sensorgestures - \title Qt Sensors - C++ Sensor Gestures Example - \ingroup qtsensors-examples - \brief The sensor gesture example demonstrates the steps for creating a C++ application - that uses sensor gestures and the included shake sensor. - \image sensorgesturecpp.png - - QSensorGestures class defines one predefined signal, \c { void detected(const QString &) } - - As well, Sensor Gesture Recognizers may implement any number of their own custom signals. - - Our shake recognizer defines one custom signal, \c {void shake()}, as well as the predefined - detected signal. - - \section1 SensorGestures Class Implementation - - In order to know about custom signals that may be available, we need to ask the QSensorGestureManager about them, - - Using the QSensorGesture::gestureIds() function, the manager will return a QStringList of known and valid gesture Ids. - \snippet sensorgestures/mainwindow.cpp 0 - - We can then use this to create a QSensorGesture object that we can use to connect signals to, - and start the detection process. A QSensorGesture object will take a list of one or more - recognizer ids in it's constructor. - - \snippet sensorgestures/mainwindow.cpp 1 - - and later stop the detection process. - - \snippet sensorgestures/mainwindow.cpp 2 - - The QSensorGesture object will contain all the signals of the valid requested recognizers found on the system. - - You can discover which of the requested recognizer ID's that were not found by using QSensorGesture::invalidIds(); - - By using QSensorGesture::gestureSignals(), you can get a QStringList of usable signals. - - -*/ diff --git a/examples/sensors/sensorgestures/main.cpp b/examples/sensors/sensorgestures/main.cpp deleted file mode 100644 index 30b745ec..00000000 --- a/examples/sensors/sensorgestures/main.cpp +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include <QtWidgets/QApplication> -#include "mainwindow.h" - -int main(int argc, char *argv[]) -{ - QApplication a(argc, argv); - MainWindow w; - w.show(); - - return a.exec(); -} diff --git a/examples/sensors/sensorgestures/mainwindow.cpp b/examples/sensors/sensorgestures/mainwindow.cpp deleted file mode 100644 index 99af9bfa..00000000 --- a/examples/sensors/sensorgestures/mainwindow.cpp +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include <QtCore/QDebug> -#include <QtWidgets/QTreeWidget> - -#include "mainwindow.h" -#include "ui_mainwindow.h" - -#include <qsensorgesture.h> -#include <qsensorgesturemanager.h> - -MainWindow::MainWindow(QWidget *parent) - : QMainWindow(parent), - ui(new Ui::MainWindow) -{ - ui->setupUi(this); - //! [0] - - QSensorGestureManager manager; - - for (const QString &gesture : manager.gestureIds()) { - - QTreeWidgetItem *gestureId = new QTreeWidgetItem(ui->treeWidget); - QStringList recognizerSignals = manager.recognizerSignals(gesture); - gestureId->setText(0,gesture); - - for (int i = 0; i < recognizerSignals.count(); i++) { - QTreeWidgetItem *oneSignal = new QTreeWidgetItem(gestureId); - oneSignal->setText(0,recognizerSignals.at(i)); - } - ui->treeWidget->insertTopLevelItem(0,gestureId); - } - //! [0] - - - ui->textEdit->setReadOnly(true); -} - -MainWindow::~MainWindow() -{ - delete ui; -} - -void MainWindow::detectedShake(const QString &name) -{ - QString str = "<font size=+2><B>"+name+"</b></font><br>"; - ui->textEdit->insertHtml(str); - ui->textEdit->ensureCursorVisible(); -} - -void MainWindow::on_pushButton_clicked() -{ - ui->textEdit->clear(); -} - -void MainWindow::onShake() -{ - QString str = "<font size=+2><B>onShake()</b></font><br>"; - ui->textEdit->insertHtml(str); - ui->textEdit->ensureCursorVisible(); -} - -void MainWindow::on_startPushButton_clicked() -{ - if (ui->treeWidget->currentItem() == 0) - return; - QString currentRecognizer; - - if (ui->treeWidget->currentItem()->childCount() == 0) { - currentRecognizer = ui->treeWidget->currentItem()->parent()->text(0); - } else { - currentRecognizer = ui->treeWidget->currentItem()->text(0); - } - - if (recognizerMap.contains(currentRecognizer)) - return; - //! [1] - QSensorGestureManager manager; - QSensorGesture *thisGesture = new QSensorGesture(QStringList() << currentRecognizer, this); - - if (currentRecognizer.contains("QtSensors.shake")) { - connect(thisGesture,SIGNAL(shake()), - this,SLOT(onShake())); - } - - connect(thisGesture,SIGNAL(detected(QString)), - this,SLOT(detectedShake(QString))); - thisGesture->startDetection(); - - //! [1] - - recognizerMap.insert(currentRecognizer,thisGesture); - - QString str = QString("<font size=+2><B>Started %1</b></font><br>").arg(currentRecognizer); - ui->textEdit->insertHtml(str); - ui->textEdit->ensureCursorVisible(); -} - -void MainWindow::on_stopPushButton_clicked() -{ - if (ui->treeWidget->currentItem() == 0) - return; - QString currentRecognizer; - - if (ui->treeWidget->currentItem()->childCount() == 0) { - currentRecognizer = ui->treeWidget->currentItem()->parent()->text(0); - } else { - currentRecognizer = ui->treeWidget->currentItem()->text(0); - } - - if (!recognizerMap.contains(currentRecognizer)) - return; - //! [2] - - recognizerMap[currentRecognizer]->stopDetection(); - - if (currentRecognizer == "QtSensors.shake") { - disconnect(recognizerMap[currentRecognizer],SIGNAL(shake()), - this,SLOT(onShake())); - } - disconnect(recognizerMap[currentRecognizer],SIGNAL(detected(QString)), - this,SLOT(detectedShake(QString))); - //! [2] - - recognizerMap.take(currentRecognizer); - - QString str = QString("<font size=+2><B>Stopped %1</b></font><br>").arg(currentRecognizer); - ui->textEdit->insertHtml(str); - ui->textEdit->ensureCursorVisible(); -} diff --git a/examples/sensors/sensorgestures/mainwindow.h b/examples/sensors/sensorgestures/mainwindow.h deleted file mode 100644 index 2eb37b14..00000000 --- a/examples/sensors/sensorgestures/mainwindow.h +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include <QtWidgets/QMainWindow> -#include <qsensorgesture.h> -QT_BEGIN_NAMESPACE -namespace Ui { - class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = 0); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - QMap <QString, QSensorGesture *> recognizerMap; - -private slots: - void detectedShake(const QString&); - void onShake(); - - void on_pushButton_clicked(); - - void on_startPushButton_clicked(); - void on_stopPushButton_clicked(); -}; - - -QT_END_NAMESPACE - -#endif // MAINWINDOW_H diff --git a/examples/sensors/sensorgestures/mainwindow.ui b/examples/sensors/sensorgestures/mainwindow.ui deleted file mode 100644 index baccf98c..00000000 --- a/examples/sensors/sensorgestures/mainwindow.ui +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>MainWindow</class> - <widget class="QMainWindow" name="MainWindow"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>423</width> - <height>474</height> - </rect> - </property> - <property name="windowTitle"> - <string>MainWindow</string> - </property> - <widget class="QWidget" name="centralWidget"> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QTreeWidget" name="treeWidget"> - <column> - <property name="text"> - <string>Gesture Recognizer Id</string> - </property> - </column> - </widget> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="startPushButton"> - <property name="text"> - <string>Start</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="stopPushButton"> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QTextEdit" name="textEdit"> - <property name="html"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html></string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QPushButton" name="pushButton"> - <property name="text"> - <string>Clear</string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menuBar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>423</width> - <height>22</height> - </rect> - </property> - </widget> - <widget class="QToolBar" name="mainToolBar"> - <attribute name="toolBarArea"> - <enum>TopToolBarArea</enum> - </attribute> - <attribute name="toolBarBreak"> - <bool>false</bool> - </attribute> - </widget> - <widget class="QStatusBar" name="statusBar"/> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/examples/sensors/sensorgestures/sensorgestures.pro b/examples/sensors/sensorgestures/sensorgestures.pro deleted file mode 100644 index 9310ecd9..00000000 --- a/examples/sensors/sensorgestures/sensorgestures.pro +++ /dev/null @@ -1,16 +0,0 @@ -TEMPLATE = app -TARGET = gesture -QT += sensors widgets -qtConfig(static):QTPLUGIN += qtsensorgestures_plugin qtsensorgestures_shakeplugin - -requires(qtConfig(treewidget)) - -SOURCES += main.cpp\ - mainwindow.cpp - -HEADERS += mainwindow.h - -FORMS += mainwindow.ui - -target.path = $$[QT_INSTALL_EXAMPLES]/sensors/sensorgestures -INSTALLS += target diff --git a/examples/sensors/sensors.pro b/examples/sensors/sensors.pro index 62bb9e06..1b637bac 100644 --- a/examples/sensors/sensors.pro +++ b/examples/sensors/sensors.pro @@ -7,15 +7,10 @@ qtHaveModule(quick) { maze \ qmlqtsensors \ sensor_explorer - # qmlsensorgestures \ - # shakeit qtHaveModule(svg): SUBDIRS += \ accelbubble } -# qtHaveModule(widgets): SUBDIRS += \ -# sensorgestures - EXAMPLE_FILES += \ stub.h diff --git a/examples/sensors/shakeit/CMakeLists.txt b/examples/sensors/shakeit/CMakeLists.txt deleted file mode 100644 index 4a0e222c..00000000 --- a/examples/sensors/shakeit/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -# Copyright (C) 2022 The Qt Company Ltd. -# SPDX-License-Identifier: BSD-3-Clause - -cmake_minimum_required(VERSION 3.16) -project(shakeit LANGUAGES CXX) - -set(CMAKE_AUTOMOC ON) - -if(NOT DEFINED INSTALL_EXAMPLESDIR) - set(INSTALL_EXAMPLESDIR "examples") -endif() - -set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/shakeit") - -find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick) - -qt_add_executable(shakeit - main.cpp -) - -set_target_properties(shakeit PROPERTIES - WIN32_EXECUTABLE TRUE - MACOSX_BUNDLE TRUE -) - -target_link_libraries(shakeit PUBLIC - Qt::Core - Qt::Gui - Qt::Quick -) - -# Resources: -set(shakeit_resource_files - "audio/loopy2a_mono.wav" - "audio/phone.wav" - "content/triangle.png" - "content/triangle2.png" - "content/triangle3.png" - "shakeit.qml" -) - -qt6_add_resources(shakeit "shakeit" - PREFIX - "/" - FILES - ${shakeit_resource_files} -) - -install(TARGETS shakeit - RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}" - BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}" - LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}" -) diff --git a/examples/sensors/shakeit/audio/loopy2a_mono.wav b/examples/sensors/shakeit/audio/loopy2a_mono.wav Binary files differdeleted file mode 100644 index 7d76cb65..00000000 --- a/examples/sensors/shakeit/audio/loopy2a_mono.wav +++ /dev/null diff --git a/examples/sensors/shakeit/audio/phone.wav b/examples/sensors/shakeit/audio/phone.wav Binary files differdeleted file mode 100644 index 884e9ac2..00000000 --- a/examples/sensors/shakeit/audio/phone.wav +++ /dev/null diff --git a/examples/sensors/shakeit/content/triangle.png b/examples/sensors/shakeit/content/triangle.png Binary files differdeleted file mode 100644 index f366537e..00000000 --- a/examples/sensors/shakeit/content/triangle.png +++ /dev/null diff --git a/examples/sensors/shakeit/content/triangle2.png b/examples/sensors/shakeit/content/triangle2.png Binary files differdeleted file mode 100644 index 9318d5a3..00000000 --- a/examples/sensors/shakeit/content/triangle2.png +++ /dev/null diff --git a/examples/sensors/shakeit/content/triangle3.png b/examples/sensors/shakeit/content/triangle3.png Binary files differdeleted file mode 100644 index 4cc5ccda..00000000 --- a/examples/sensors/shakeit/content/triangle3.png +++ /dev/null diff --git a/examples/sensors/shakeit/doc/images/shakeit.png b/examples/sensors/shakeit/doc/images/shakeit.png Binary files differdeleted file mode 100644 index 5ca1b58c..00000000 --- a/examples/sensors/shakeit/doc/images/shakeit.png +++ /dev/null diff --git a/examples/sensors/shakeit/doc/src/shakeit.qdoc b/examples/sensors/shakeit/doc/src/shakeit.qdoc deleted file mode 100644 index 2dfb33bb..00000000 --- a/examples/sensors/shakeit/doc/src/shakeit.qdoc +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only - -/*! - \example shakeit - \title Qt Sensors - ShakeIt QML Example - \ingroup qtsensors-examples - \image shakeit.png - - \section2 ShakeIt in QML - \brief The sensor gesture example demonstrates the steps for creating a QML application - that uses sensor gestures and the included shake sensor. - - Writing a QML application that uses the Shake QML sensorgestures type requires the following steps: - - Import the Sensors Declarative module. - - \snippet shakeit/shakeit.qml 0 - - Add a SensorGesture QML type. - - \snippet shakeit/shakeit.qml 1 - - In the SensorGesture type, specify which gesture to be used. - Note that this can be a comma separated list. Here we are only interested in one - gesture recognizer. - - \snippet shakeit/shakeit.qml 2 - - Use the 'enabled' property to start the sensor gesture. - - \snippet shakeit/shakeit.qml 3 - - Use the onDetected signal to do stuff. - - \snippet shakeit/shakeit.qml 4 - - There are additional gestures to shake which are supported: - whip, twistRight, hover, cover, turnover and pickup. -*/ diff --git a/examples/sensors/shakeit/main.cpp b/examples/sensors/shakeit/main.cpp deleted file mode 100644 index d550f8bc..00000000 --- a/examples/sensors/shakeit/main.cpp +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -#include "../stub.h" -SENSORS_EXAMPLE_MAIN(shakeit) diff --git a/examples/sensors/shakeit/shakeit.pro b/examples/sensors/shakeit/shakeit.pro deleted file mode 100644 index 327c669b..00000000 --- a/examples/sensors/shakeit/shakeit.pro +++ /dev/null @@ -1,17 +0,0 @@ -TEMPLATE = app -TARGET = shakeit -QT += quick sensors -qtConfig(static):QTPLUGIN += qtsensorgestures_plugin qtsensorgestures_shakeplugin - -SOURCES = main.cpp - -RESOURCES += \ - shakeit.qrc - -OTHER_FILES = \ - $$files(*.qml) \ - audio \ - content - -target.path = $$[QT_INSTALL_EXAMPLES]/sensors/shakeit -INSTALLS += target diff --git a/examples/sensors/shakeit/shakeit.qml b/examples/sensors/shakeit/shakeit.qml deleted file mode 100644 index 683e3b16..00000000 --- a/examples/sensors/shakeit/shakeit.qml +++ /dev/null @@ -1,328 +0,0 @@ -// Copyright (C) 2017 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -//! [0] -import QtSensors -//! [0] - -Rectangle { - id: window - anchors.fill: parent - - state: "default" - - Text { - id: label - text: qsTr("Shake to rotate triangles") - y: parent.height / 4 - anchors.horizontalCenter: parent.horizontalCenter - } - Image { - id: triangle1 - smooth: true - source: "content/triangle.png" - x: parent.width / 2 - (triangle1.width / 2) - y: parent.height / 2 - (triangle1.height); - Behavior on x { SmoothedAnimation { velocity: 200 } } - Behavior on y { SmoothedAnimation { velocity: 200 } } - transform: Rotation { - id: myRot - } - } - Image { - id: triangle2 - smooth: true - source: "content/triangle2.png" - x: parent.width / 2 - (triangle1.width + triangle2.width / 2) - y: parent.height / 2 + (triangle2.height / 2); - Behavior on x { SmoothedAnimation { velocity: 200 } } - Behavior on y { SmoothedAnimation { velocity: 200 } } - } - Image { - id: triangle3 - smooth: true - source: "content/triangle3.png" - x: parent.width / 2 + (triangle1.width / 2) - y: parent.height / 2 + (triangle3.height / 2); - Behavior on x { SmoothedAnimation { velocity: 200 } } - Behavior on y { SmoothedAnimation { velocity: 200 } } - } - - states: [ - State { - name: "rotated" - PropertyChanges { target: triangle1; rotation: 180 } - PropertyChanges { target: triangle2; rotation: 90 } - PropertyChanges { target: triangle3; rotation: 270 } - }, - State { - name: "default" - PropertyChanges { target: triangle1; rotation: 0; - x: parent.width / 2 - (triangle1.width / 2) - y: parent.height / 2 - (triangle1.height) - scale: 1; - - } - PropertyChanges { target: triangle2; rotation: 0; - x: parent.width / 2 - (triangle1.width + triangle2.width / 2) - y: parent.height / 2 + (triangle2.height / 2); - scale: 1; - } - PropertyChanges { target: triangle3; rotation: 0; - x: parent.width / 2 + (triangle1.width / 2) - y: parent.height / 2 + (triangle3.height / 2); - scale: 1; - } - }, - State { - name: "whipped" - PropertyChanges { target: triangle1; rotation: 0; x:0; } - PropertyChanges { target: triangle2; rotation: 0; x:0; - y: triangle1.x + triangle1.height; } - PropertyChanges { target: triangle3; rotation: 0; x:0; - y: triangle2.y + triangle2.height; } - }, - State { - name: "twistedR" - PropertyChanges { target: triangle1; rotation: 270; - x:window.width - triangle1.width; - } - PropertyChanges { target: triangle2; rotation: 180; - x:window.width - triangle2.width; - } - PropertyChanges { target: triangle3; rotation: 90; - x:window.width - triangle3.width; - y:triangle2.y + triangle2.height; - } - }, - State { - name: "twistedL" - PropertyChanges { target: triangle1; rotation: 270; - x:0; - } - PropertyChanges { target: triangle2; rotation: 180; - x:0; - } - PropertyChanges { target: triangle3; rotation: 90; - x:0; - y:triangle2.y + triangle2.height; - } - }, - State { - name: "covered" - PropertyChanges { target: triangle1; rotation: 0; - x: window.width / 3 - triangle1.width / 2; - y: window.height - triangle1.height; - } - PropertyChanges { target: triangle2; rotation: 0; - x: window.width / 2 - triangle2.width / 2; // middle - y: window.height - triangle2.height; - } - PropertyChanges { target: triangle3; rotation: 0; - x: (window.width / 3 + window.width / 3) - triangle3.width / 2; - y: window.height - triangle3.height; - } - }, - State { - name: "hovered" - PropertyChanges { target: triangle1; rotation: 90; - x: window.width / 3 - triangle1.width / 2; - y: triangle1.height; - } - PropertyChanges { target: triangle2; rotation: 270; - x: window.width / 2 - triangle2.width / 2; // middle - y: triangle2.height; - } - PropertyChanges { target: triangle3; rotation: 195; - x: (window.width / 3 + window.width / 3) - triangle3.width / 2; - y: triangle3.height - } - }, - State { - name :"slammed" - PropertyChanges { target: triangle1; rotation: 0; - x: 0; - y: 0 + 30 - } - PropertyChanges { target: triangle2; rotation: 0; - x: window.width - triangle2.width; - y: 0 + 30 - ;} - PropertyChanges { target: triangle3; rotation: 0; - x: window.width / 2 - triangle3.width / 2; - y:window.height - triangle3.height; - } - }, - State { - name: "doubletapped" - PropertyChanges { target: triangle1; rotation: 114; - transformOrigin: Item.BottomLeft - } - PropertyChanges { target: triangle2; rotation: 120; - transformOrigin: Item.BottomLeft - } - }, - State { - name: "turnedover" - PropertyChanges { target: triangle1; rotation: 180; - } - PropertyChanges { target: triangle2; rotation: 180; - } - PropertyChanges { target: triangle3; rotation: 180; - } - }, - State { - name: "pickedup" - PropertyChanges { target: triangle1; scale: 1.5; - } - PropertyChanges { target: triangle2; scale: 1.5; - } - PropertyChanges { target: triangle3; scale: 1.5; - } - } - ] - - - transitions: [ - Transition { - - ParallelAnimation { - NumberAnimation { properties: "x,y"; easing.type: Easing.OutBounce; - duration: 2000; } - RotationAnimation { id: t1Rotation; target: triangle1; duration: 1000; - direction: RotationAnimation.Clockwise } - RotationAnimation { id: t2Rotation; target: triangle2; duration: 2000; - direction: RotationAnimation.Counterclockwise } - RotationAnimation { id: t3Rotation; target: triangle3; duration: 2000; - direction: RotationAnimation.Clockwise } - } - - }, Transition { - to: "slammed" - SequentialAnimation { - NumberAnimation { properties: "x"; easing.type: Easing.OutBounce;duration: 500; } - - } - }, Transition { - to: "doubletapped" - SequentialAnimation { - PropertyAction { target: triangle1; property: "transformOrigin" } - PropertyAction { target: triangle2; property: "transformOrigin" } - NumberAnimation { target: triangle1; properties: "rotation"; - easing.type: Easing.OutBounce;duration: 500; } - NumberAnimation { target: triangle2; properties: "rotation"; - easing.type: Easing.OutBounce;duration: 1500; } - } - }, Transition { - from: "doubletapped" - SequentialAnimation { - NumberAnimation { properties: "rotation"; - easing.type: Easing.OutBounce;duration: 1500; } - PropertyAction { target: triangle1; property: "transformOrigin" } - PropertyAction { target: triangle2; property: "transformOrigin" } - } - }, Transition { - to: "turnedover" - SequentialAnimation { - NumberAnimation { properties: "rotation"; - easing.type: Easing.OutBounce;duration: 750; } - PropertyAction { target: triangle1; property: "transformOrigin" } - PropertyAction { target: triangle2; property: "transformOrigin" } - } - }, Transition { - from: "turnedover" - SequentialAnimation { - NumberAnimation { properties: "rotation"; - easing.type: Easing.OutBounce;duration: 750; } - PropertyAction { target: triangle1; property: "transformOrigin" } - PropertyAction { target: triangle2; property: "transformOrigin" } - } - }, Transition { - to: "pickedup" - SequentialAnimation { - NumberAnimation { properties: "scale"; - easing.type: Easing.OutBounce;duration: 750; } - } - }, Transition { - from: "pickedup" - SequentialAnimation { - NumberAnimation { properties: "scale"; - easing.type: Easing.OutBounce;duration: 750; } - } - } - ] - -//! [1] - SensorGesture { -//! [1] - id: sensorGesture -//! [3] - enabled: true -//! [3] -//! [2] - gestures : ["QtSensors.shake", "QtSensors.whip", "QtSensors.twist", "QtSensors.cover", - "QtSensors.hover", "QtSensors.turnover", "QtSensors.pickup", "QtSensors.slam", - "QtSensors.doubletap"] -//! [2] -//! [4] - onDetected:{ - console.debug(gesture) - - label.text = gesture - - if (gesture == "shake") { - window.state == "rotated" ? window.state = "default" : window.state = "rotated" - timer.start() - } - if (gesture == "whip") { - window.state == "whipped" ? window.state = "default" : window.state = "whipped" - timer.start() - } - if (gesture == "twistRight") { - window.state == "twistedR" ? window.state = "default" : window.state = "twistedR" - timer.start() - } - if (gesture == "twistLeft") { - window.state == "twistedL" ? window.state = "default" : window.state = "twistedL" - timer.start() - } - if (gesture == "cover") { - window.state == "covered" ? window.state = "default" : window.state = "covered" - timer.start() - } - if (gesture == "hover") { - window.state == "hovered" ? window.state = "default" : window.state = "hovered" - timer.start() - } - if (gesture == "turnover") { - window.state == "turnedover" ? window.state = "default" : window.state = "hovered" - timer.start() - } - if (gesture == "pickup") { - window.state == "pickedup" ? window.state = "default" : window.state = "pickedup" - timer.start() - } - if (gesture == "slam") { - window.state == "slammed" ? window.state = "default" : window.state = "slammed" - timer.start() - } - if (gesture == "doubletap") { - window.state == "doubletapped" ? window.state = "default" : window.state = "doubletapped" - timer.start() - } - } -//! [4] - } - Timer { - id: timer - running: false - repeat: false - interval: 3000 - onTriggered: { - console.log("timer triggered") - window.state = "default" - label.text = "Try another gesture" - } - } -} diff --git a/examples/sensors/shakeit/shakeit.qrc b/examples/sensors/shakeit/shakeit.qrc deleted file mode 100644 index 1a2c75d8..00000000 --- a/examples/sensors/shakeit/shakeit.qrc +++ /dev/null @@ -1,10 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>shakeit.qml</file> - <file>audio/loopy2a_mono.wav</file> - <file>audio/phone.wav</file> - <file>content/triangle.png</file> - <file>content/triangle2.png</file> - <file>content/triangle3.png</file> - </qresource> -</RCC> |