summaryrefslogtreecommitdiffstats
path: root/examples/sensors
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sensors')
-rw-r--r--examples/sensors/CMakeLists.txt18
-rw-r--r--examples/sensors/accelbubble/CMakeLists.txt64
-rw-r--r--examples/sensors/accelbubble/Info.plist34
-rw-r--r--examples/sensors/accelbubble/accelbubble.pro28
-rw-r--r--examples/sensors/accelbubble/accelbubble.qml86
-rw-r--r--examples/sensors/accelbubble/accelbubble.qrc6
-rw-r--r--examples/sensors/accelbubble/android/AndroidManifest.xml47
-rw-r--r--examples/sensors/accelbubble/content/Bluebubble.svg10
-rw-r--r--examples/sensors/accelbubble/doc/images/accelbubble.pngbin5025 -> 0 bytes
-rw-r--r--examples/sensors/accelbubble/doc/src/accelbubble.qdoc32
-rw-r--r--examples/sensors/accelbubble/main.cpp14
-rw-r--r--examples/sensors/grue/CMakeLists.txt68
-rw-r--r--examples/sensors/grue/console_app/CMakeLists.txt47
-rw-r--r--examples/sensors/grue/console_app/console_app.pro17
-rw-r--r--examples/sensors/grue/console_app/main.cpp52
-rw-r--r--examples/sensors/grue/doc/images/qtsensors-examples-grue.pngbin7511 -> 0 bytes
-rw-r--r--examples/sensors/grue/doc/src/grue.qdoc113
-rw-r--r--examples/sensors/grue/grue.pngbin9319 -> 0 bytes
-rw-r--r--examples/sensors/grue/grue.pro13
-rw-r--r--examples/sensors/grue/grue.qml79
-rw-r--r--examples/sensors/grue/grue.xcfbin23704 -> 0 bytes
-rw-r--r--examples/sensors/grue/grue_plugin_import_custom.cpp5
-rw-r--r--examples/sensors/grue/icon.xcfbin22397 -> 0 bytes
-rw-r--r--examples/sensors/grue/main.cpp14
-rw-r--r--examples/sensors/grue/plugin/CMakeLists.txt64
-rw-r--r--examples/sensors/grue/plugin/gruesensor.cpp112
-rw-r--r--examples/sensors/grue/plugin/gruesensor.h43
-rw-r--r--examples/sensors/grue/plugin/gruesensor_p.h29
-rw-r--r--examples/sensors/grue/plugin/gruesensorimpl.cpp103
-rw-r--r--examples/sensors/grue/plugin/gruesensorimpl.h40
-rw-r--r--examples/sensors/grue/plugin/main.cpp42
-rw-r--r--examples/sensors/grue/plugin/plugin.json1
-rw-r--r--examples/sensors/grue/plugin/plugin.pro27
-rw-r--r--examples/sensors/grue/qml.pro40
-rw-r--r--examples/sensors/grue/qml.qrc6
-rw-r--r--examples/sensors/grue/qmlgruesensor.cpp11
-rw-r--r--examples/sensors/grue/qmlgruesensor.h19
-rw-r--r--examples/sensors/grue/use_grue_static_plugin.pri17
-rw-r--r--examples/sensors/maze/CMakeLists.txt77
-rw-r--r--examples/sensors/maze/Congratulation.qml24
-rw-r--r--examples/sensors/maze/Info.plist32
-rw-r--r--examples/sensors/maze/LabyrinthSquare.qml43
-rw-r--r--examples/sensors/maze/Mouse.qml45
-rw-r--r--examples/sensors/maze/android/AndroidManifest.xml47
-rw-r--r--examples/sensors/maze/components/ApplicationWindow.qml14
-rw-r--r--examples/sensors/maze/components/Button.qml38
-rw-r--r--examples/sensors/maze/components/images/button_background_disabled.pngbin579 -> 0 bytes
-rw-r--r--examples/sensors/maze/components/images/button_background_normal.pngbin901 -> 0 bytes
-rw-r--r--examples/sensors/maze/components/images/button_background_pressed.pngbin228 -> 0 bytes
-rw-r--r--examples/sensors/maze/content/00.pngbin70 -> 0 bytes
-rw-r--r--examples/sensors/maze/content/01.pngbin540 -> 0 bytes
-rw-r--r--examples/sensors/maze/content/cheese.pngbin156 -> 0 bytes
-rw-r--r--examples/sensors/maze/content/cheeseeating.gifbin650 -> 0 bytes
-rw-r--r--examples/sensors/maze/content/congratulations.gifbin10811 -> 0 bytes
-rw-r--r--examples/sensors/maze/content/mouse_down.gifbin974 -> 0 bytes
-rw-r--r--examples/sensors/maze/content/start.pngbin505 -> 0 bytes
-rw-r--r--examples/sensors/maze/doc/src/maze.qdoc41
-rw-r--r--examples/sensors/maze/lib.js264
-rw-r--r--examples/sensors/maze/main.cpp5
-rw-r--r--examples/sensors/maze/maze.pro19
-rw-r--r--examples/sensors/maze/maze.qml251
-rw-r--r--examples/sensors/maze/maze.qrc21
-rw-r--r--examples/sensors/qmlqtsensors/CMakeLists.txt54
-rw-r--r--examples/sensors/qmlqtsensors/components/ApplicationWindow.qml12
-rw-r--r--examples/sensors/qmlqtsensors/components/Button.qml38
-rw-r--r--examples/sensors/qmlqtsensors/components/Divider.qml24
-rw-r--r--examples/sensors/qmlqtsensors/components/images/button_background_disabled.pngbin579 -> 0 bytes
-rw-r--r--examples/sensors/qmlqtsensors/components/images/button_background_normal.pngbin901 -> 0 bytes
-rw-r--r--examples/sensors/qmlqtsensors/components/images/button_background_pressed.pngbin228 -> 0 bytes
-rw-r--r--examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc46
-rw-r--r--examples/sensors/qmlqtsensors/main.cpp5
-rw-r--r--examples/sensors/qmlqtsensors/qmlqtsensors.pro16
-rw-r--r--examples/sensors/qmlqtsensors/qmlqtsensors.qml212
-rw-r--r--examples/sensors/qmlqtsensors/qmlqtsensors.qrc11
-rw-r--r--examples/sensors/qmlsensorgestures/Button.qml92
-rw-r--r--examples/sensors/qmlsensorgestures/CMakeLists.txt52
-rw-r--r--examples/sensors/qmlsensorgestures/GestureList.qml99
-rw-r--r--examples/sensors/qmlsensorgestures/GestureView.qml115
-rw-r--r--examples/sensors/qmlsensorgestures/GesturesView.qml119
-rw-r--r--examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc44
-rw-r--r--examples/sensors/qmlsensorgestures/main.cpp5
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/CMakeLists.txt39
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/plugin.pro30
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp38
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h29
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp52
-rw-r--r--examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h33
-rw-r--r--examples/sensors/qmlsensorgestures/qml.pro15
-rw-r--r--examples/sensors/qmlsensorgestures/qml.qrc9
-rw-r--r--examples/sensors/qmlsensorgestures/qmlsensorgestures.pro6
-rw-r--r--examples/sensors/qmlsensorgestures/qmlsensorgestures.qml80
-rw-r--r--examples/sensors/sensor_explorer/CMakeLists.txt44
-rw-r--r--examples/sensors/sensor_explorer/doc/images/qtsensors-examples-sensor-explorer.pngbin47605 -> 0 bytes
-rw-r--r--examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc118
-rw-r--r--examples/sensors/sensor_explorer/main.cpp20
-rw-r--r--examples/sensors/sensor_explorer/qml.qrc5
-rw-r--r--examples/sensors/sensor_explorer/sensor_explorer.pro22
-rw-r--r--examples/sensors/sensor_explorer/sensor_explorer.qml127
-rw-r--r--examples/sensors/sensor_explorer/sensormodels.cpp191
-rw-r--r--examples/sensors/sensor_explorer/sensormodels.h63
-rw-r--r--examples/sensors/sensorgestures/CMakeLists.txt39
-rw-r--r--examples/sensors/sensorgestures/doc/images/sensorgesturecpp.pngbin33013 -> 0 bytes
-rw-r--r--examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc43
-rw-r--r--examples/sensors/sensorgestures/main.cpp14
-rw-r--r--examples/sensors/sensorgestures/mainwindow.cpp131
-rw-r--r--examples/sensors/sensorgestures/mainwindow.h39
-rw-r--r--examples/sensors/sensorgestures/mainwindow.ui84
-rw-r--r--examples/sensors/sensorgestures/sensorgestures.pro16
-rw-r--r--examples/sensors/sensors.pro20
-rw-r--r--examples/sensors/sensorsshowcase/Accelerometer.qml70
-rw-r--r--examples/sensors/sensorsshowcase/CMakeLists.txt74
-rw-r--r--examples/sensors/sensorsshowcase/Compass.qml61
-rw-r--r--examples/sensors/sensorsshowcase/Gyroscope.qml128
-rw-r--r--examples/sensors/sensorsshowcase/Magnetometer.qml68
-rw-r--r--examples/sensors/sensorsshowcase/Main.qml116
-rw-r--r--examples/sensors/sensorsshowcase/ProgressXYZBar.qml45
-rw-r--r--examples/sensors/sensorsshowcase/Proximity.qml55
-rw-r--r--examples/sensors/sensorsshowcase/accelerometer.qml122
-rw-r--r--examples/sensors/sensorsshowcase/android/AndroidManifest.xml26
-rw-r--r--examples/sensors/sensorsshowcase/android/res/drawable-hdpi/icon.pngbin0 -> 1352 bytes
-rw-r--r--examples/sensors/sensorsshowcase/android/res/drawable-ldpi/icon.pngbin0 -> 578 bytes
-rw-r--r--examples/sensors/sensorsshowcase/android/res/drawable-mdpi/icon.pngbin0 -> 962 bytes
-rw-r--r--examples/sensors/sensorsshowcase/android/res/drawable-xhdpi/icon.pngbin0 -> 1944 bytes
-rw-r--r--examples/sensors/sensorsshowcase/android/res/drawable-xxhdpi/icon.pngbin0 -> 3030 bytes
-rw-r--r--examples/sensors/sensorsshowcase/android/res/drawable-xxxhdpi/icon.pngbin0 -> 4290 bytes
-rw-r--r--examples/sensors/sensorsshowcase/compass.qml64
-rw-r--r--examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.pngbin29205 -> 0 bytes
-rw-r--r--examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.webpbin0 -> 11922 bytes
-rw-r--r--examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.pngbin33722 -> 0 bytes
-rw-r--r--examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.webpbin0 -> 16784 bytes
-rw-r--r--examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc27
-rw-r--r--examples/sensors/sensorsshowcase/gyroscope.qml174
-rw-r--r--examples/sensors/sensorsshowcase/images/qt_logo.pngbin6208 -> 14809 bytes
-rw-r--r--examples/sensors/sensorsshowcase/magnetometer.qml103
-rw-r--r--examples/sensors/sensorsshowcase/main.cpp16
-rw-r--r--examples/sensors/sensorsshowcase/proximity.qml71
-rw-r--r--examples/sensors/sensorsshowcase/qmldir9
-rw-r--r--examples/sensors/sensorsshowcase/qtquickcontrols2.conf6
-rw-r--r--examples/sensors/sensorsshowcase/sensorsshowcase.pro53
-rw-r--r--examples/sensors/sensorsshowcase/sensorsshowcase.qml76
-rw-r--r--examples/sensors/sensorsshowcase/sensorsshowcase.qrc13
-rw-r--r--examples/sensors/sensorsshowcase/sensorsupport.h41
-rw-r--r--examples/sensors/shakeit/CMakeLists.txt53
-rw-r--r--examples/sensors/shakeit/audio/loopy2a_mono.wavbin67772 -> 0 bytes
-rw-r--r--examples/sensors/shakeit/audio/phone.wavbin22094 -> 0 bytes
-rw-r--r--examples/sensors/shakeit/content/triangle.pngbin7251 -> 0 bytes
-rw-r--r--examples/sensors/shakeit/content/triangle2.pngbin5633 -> 0 bytes
-rw-r--r--examples/sensors/shakeit/content/triangle3.pngbin5101 -> 0 bytes
-rw-r--r--examples/sensors/shakeit/doc/images/shakeit.pngbin29380 -> 0 bytes
-rw-r--r--examples/sensors/shakeit/doc/src/shakeit.qdoc40
-rw-r--r--examples/sensors/shakeit/main.cpp5
-rw-r--r--examples/sensors/shakeit/shakeit.pro17
-rw-r--r--examples/sensors/shakeit/shakeit.qml328
-rw-r--r--examples/sensors/shakeit/shakeit.qrc10
-rw-r--r--examples/sensors/stub.h15
155 files changed, 723 insertions, 5636 deletions
diff --git a/examples/sensors/CMakeLists.txt b/examples/sensors/CMakeLists.txt
index cd7cdb5c..bf1120c8 100644
--- a/examples/sensors/CMakeLists.txt
+++ b/examples/sensors/CMakeLists.txt
@@ -1,18 +1,6 @@
# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-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()
+if(TARGET Qt::Quick AND TARGET Qt::Svg)
+ qt_internal_add_example(sensorsshowcase)
endif()
-# if(TARGET Qt::Widgets)
-# qt_internal_add_example(sensorgestures)
-# endif()
diff --git a/examples/sensors/accelbubble/CMakeLists.txt b/examples/sensors/accelbubble/CMakeLists.txt
deleted file mode 100644
index b5d6507a..00000000
--- a/examples/sensors/accelbubble/CMakeLists.txt
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(accelbubble LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/accelbubble")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Sensors Svg Xml)
-
-qt_add_executable(accelbubble
- main.cpp
-)
-
-set_target_properties(accelbubble PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-if(ANDROID)
- set_property(TARGET accelbubble PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
- ${CMAKE_CURRENT_SOURCE_DIR}/android)
- endif()
-if(APPLE)
- if(IOS)
- set_property(TARGET accelbubble PROPERTY
- MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
- )
- endif()
-endif()
-
-target_link_libraries(accelbubble PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Quick
- Qt::Sensors
- Qt::Svg
- Qt::Xml
-)
-
-# Resources:
-set(accelbubble_resource_files
- "accelbubble.qml"
- "content/Bluebubble.svg"
-)
-
-qt6_add_resources(accelbubble "accelbubble"
- PREFIX
- "/"
- FILES
- ${accelbubble_resource_files}
-)
-
-install(TARGETS accelbubble
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/sensors/accelbubble/Info.plist b/examples/sensors/accelbubble/Info.plist
deleted file mode 100644
index 90725455..00000000
--- a/examples/sensors/accelbubble/Info.plist
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDisplayName</key>
- <string>accelbubble</string>
- <key>CFBundleExecutable</key>
- <string>accelbubble</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleIdentifier</key>
- <string>com.digia.accelbubble</string>
- <key>CFBundleName</key>
- <string>accelbubble</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>1.0</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>1.0</string>
- <key>LSRequiresIPhoneOS</key>
- <true/>
- <key>NOTE</key>
- <string>This file was generated by Qt/QMake.</string>
- <key>UILaunchStoryboardName</key>
- <string>LaunchScreen</string>
- <key>UISupportedInterfaceOrientations</key>
- <array>
- <string>UIInterfaceOrientationPortrait</string>
- </array>
-</dict>
-</plist>
diff --git a/examples/sensors/accelbubble/accelbubble.pro b/examples/sensors/accelbubble/accelbubble.pro
deleted file mode 100644
index d3b20a9d..00000000
--- a/examples/sensors/accelbubble/accelbubble.pro
+++ /dev/null
@@ -1,28 +0,0 @@
-TEMPLATE = app
-TARGET = accelbubble
-QT += quick sensors svg xml
-SOURCES = main.cpp
-
-RESOURCES += \
- accelbubble.qrc
-
-OTHER_FILES = \
- $$files(*.qml) \
- content \
- images \
- android/AndroidManifest.xml
-
-target.path = $$[QT_INSTALL_EXAMPLES]/sensors/accelbubble
-INSTALLS += target
-
-ios {
-QMAKE_INFO_PLIST = Info.plist
-
-# manual plugin loading needed with older Qt
-# QTPLUGIN += qsvg qtsensors_ios qtsensors_generic
-}
-
-ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
-
-EXAMPLE_FILES += \
- Info.plist
diff --git a/examples/sensors/accelbubble/accelbubble.qml b/examples/sensors/accelbubble/accelbubble.qml
deleted file mode 100644
index 65901169..00000000
--- a/examples/sensors/accelbubble/accelbubble.qml
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-
-import QtQuick
-import QtQuick.Controls
-
-//! [0]
-import QtSensors
-//! [0]
-
-
-ApplicationWindow {
- title: "Accelerate Bubble"
- id: mainWindow
- width: 320
- height: 480
- visible: true
- readonly property double radians_to_degrees: 180 / Math.PI
-
-//! [1]
- Accelerometer {
- id: accel
- dataRate: 100
-//! [1]
-//! [2]
- active:true
-//! [2]
-
-//! [3]
- onReadingChanged: {
- var newX = (bubble.x + calcRoll(accel.reading.x, accel.reading.y, accel.reading.z) * .1)
- var newY = (bubble.y - calcPitch(accel.reading.x, accel.reading.y, accel.reading.z) * .1)
-
- if (isNaN(newX) || isNaN(newY))
- return;
-
- if (newX < 0)
- newX = 0
-
- if (newX > mainWindow.width - bubble.width)
- newX = mainWindow.width - bubble.width
-
- if (newY < 18)
- newY = 18
-
- if (newY > mainWindow.height - bubble.height)
- newY = mainWindow.height - bubble.height
-
- bubble.x = newX
- bubble.y = newY
- }
-//! [3]
- }
-
- function calcPitch(x,y,z) {
- return -Math.atan2(y, Math.hypot(x, z)) * mainWindow.radians_to_degrees;
- }
- function calcRoll(x,y,z) {
- return -Math.atan2(x, Math.hypot(y, z)) * mainWindow.radians_to_degrees;
- }
-
- Image {
- id: bubble
- source: "content/Bluebubble.svg"
- smooth: true
- property real centerX: mainWindow.width / 2
- property real centerY: mainWindow.height / 2
- property real bubbleCenter: bubble.width / 2
- x: centerX - bubbleCenter
- y: centerY - bubbleCenter
-
- Behavior on y {
- SmoothedAnimation {
- easing.type: Easing.Linear
- duration: 100
- }
- }
- Behavior on x {
- SmoothedAnimation {
- easing.type: Easing.Linear
- duration: 100
- }
- }
- }
-}
diff --git a/examples/sensors/accelbubble/accelbubble.qrc b/examples/sensors/accelbubble/accelbubble.qrc
deleted file mode 100644
index 5cb6945a..00000000
--- a/examples/sensors/accelbubble/accelbubble.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>accelbubble.qml</file>
- <file>content/Bluebubble.svg</file>
- </qresource>
-</RCC>
diff --git a/examples/sensors/accelbubble/android/AndroidManifest.xml b/examples/sensors/accelbubble/android/AndroidManifest.xml
deleted file mode 100644
index 537c705e..00000000
--- a/examples/sensors/accelbubble/android/AndroidManifest.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.qtproject.example.accelbubble"
- android:installLocation="auto"
- android:versionCode="1"
- android:versionName="1.0">
- <!-- The comment below will be replaced with dependencies permissions upon deployment.
- Remove the comment if you do not require these default permissions. -->
- <!-- %%INSERT_PERMISSIONS -->
-
- <!-- The comment below will be replaced with dependencies permissions upon deployment.
- Remove the comment if you do not require these default features. -->
- <!-- %%INSERT_FEATURES -->
-
- <supports-screens
- android:anyDensity="true"
- android:largeScreens="true"
- android:normalScreens="true"
- android:smallScreens="true" />
- <application
- android:name="org.qtproject.qt.android.bindings.QtApplication"
- android:extractNativeLibs="true"
- android:hardwareAccelerated="true"
- android:label="-- %%INSERT_APP_NAME%% --"
- android:requestLegacyExternalStorage="true">
- <activity
- android:name="org.qtproject.qt.android.bindings.QtActivity"
- android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
- android:label="-- %%INSERT_APP_NAME%% --"
- android:launchMode="singleTop"
- android:screenOrientation="portrait">
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- <meta-data
- android:name="android.app.lib_name"
- android:value="-- %%INSERT_APP_LIB_NAME%% --" />
- <meta-data
- android:name="android.app.background_running"
- android:value="false" />
- <meta-data
- android:name="android.app.extract_android_style"
- android:value="minimal" />
- </activity>
- </application>
-</manifest>
diff --git a/examples/sensors/accelbubble/content/Bluebubble.svg b/examples/sensors/accelbubble/content/Bluebubble.svg
deleted file mode 100644
index d9c406c4..00000000
--- a/examples/sensors/accelbubble/content/Bluebubble.svg
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0"?>
-<svg xmlns="http://www.w3.org/2000/svg" version="1.2" baseProfile="tiny">
- <defs>
- <radialGradient id="grad1" cx="0.5" cy="0.7" r="0.7" fx="0.5" fy="0.4">
- <stop offset="0" style="stop-color:rgb(255,255,255)" />
- <stop offset="1.5" style="stop-color:rgb(0,102,153)" />
- </radialGradient>
- </defs>
- <circle cx="100" cy="80" r="42" fill="url(#grad1)"/>
-</svg>
diff --git a/examples/sensors/accelbubble/doc/images/accelbubble.png b/examples/sensors/accelbubble/doc/images/accelbubble.png
deleted file mode 100644
index ad4cfc07..00000000
--- a/examples/sensors/accelbubble/doc/images/accelbubble.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/accelbubble/doc/src/accelbubble.qdoc b/examples/sensors/accelbubble/doc/src/accelbubble.qdoc
deleted file mode 100644
index 527d82fb..00000000
--- a/examples/sensors/accelbubble/doc/src/accelbubble.qdoc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example accelbubble
- \title Qt Sensors - Accel Bubble
- \brief The AccelBubble example demonstrates the Accelerometer QML type.
- \ingroup qtsensors-examples
-
- \image accelbubble.png
-
-\section1 Overview
- Writing a QML application that uses the Accelerometer QML sensors type requires the following steps:
-
- Import the Sensors Declarative module.
-
-\snippet accelbubble/accelbubble.qml 0
-
- Add an Accelerometer QML type.
-
-\snippet accelbubble/accelbubble.qml 1
-
- Use the 'active' property to start the sensor
-
-\snippet accelbubble/accelbubble.qml 2
-
- Move the bubble according to a factor of the accelerator sensor
-
-\snippet accelbubble/accelbubble.qml 3
-
-*/
-
diff --git a/examples/sensors/accelbubble/main.cpp b/examples/sensors/accelbubble/main.cpp
deleted file mode 100644
index ad71fc00..00000000
--- a/examples/sensors/accelbubble/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 <QtGui/QGuiApplication>
-#include <QtQml/QQmlApplicationEngine>
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc,argv);
- QQmlApplicationEngine engine(QUrl("qrc:///accelbubble.qml"));
-
- return app.exec();
-}
diff --git a/examples/sensors/grue/CMakeLists.txt b/examples/sensors/grue/CMakeLists.txt
deleted file mode 100644
index acc5da45..00000000
--- a/examples/sensors/grue/CMakeLists.txt
+++ /dev/null
@@ -1,68 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(grue_app LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/grue")
-
-find_package(Qt6 REQUIRED COMPONENTS Quick Sensors)
-
-qt_add_executable(grue_app
- main.cpp qmlgruesensor.h qmlgruesensor.cpp
-)
-
-set_target_properties(grue_app PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(grue_app PUBLIC
- Qt::Quick
- Qt::Sensors
-)
-
-qt6_add_qml_module(grue_app
- VERSION 1.0
- URI "QMLGrueSensor"
- QML_FILES
- grue.qml
- RESOURCES
- grue.png
-)
-
-add_subdirectory(plugin)
-
-# Need to link to the plugin manually in a static Qt build.
-if(NOT QT6_IS_SHARED_LIBS_BUILD)
- target_link_libraries(grue_app PRIVATE qtsensors_grue)
- target_sources(grue_app PRIVATE grue_plugin_import_custom.cpp)
-endif()
-
-set(build_console_app TRUE)
-
-# The console app is not a macos bundle, so the shared library plugin wouldn't be found
-if(APPLE AND QT6_IS_SHARED_LIBS_BUILD)
- set(build_console_app FALSE)
-endif()
-
-# Gui-less apps don't make sense for these platforms
-if(IOS OR EMSCRIPTEN OR ANDROID)
- set(build_console_app FALSE)
-endif()
-
-if(build_console_app)
- add_subdirectory(console_app)
-endif()
-
-install(TARGETS grue_app
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/sensors/grue/console_app/CMakeLists.txt b/examples/sensors/grue/console_app/CMakeLists.txt
deleted file mode 100644
index 410de341..00000000
--- a/examples/sensors/grue/console_app/CMakeLists.txt
+++ /dev/null
@@ -1,47 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(detect_grue LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/grue")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Sensors)
-
-qt_add_executable(detect_grue
- main.cpp
-)
-
-set_target_properties(detect_grue PROPERTIES
- WIN32_EXECUTABLE FALSE
- MACOSX_BUNDLE FALSE
-)
-
-if(WIN32 OR (UNIX AND NOT APPLE))
- set_target_properties(detect_grue PROPERTIES
- RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..
- )
-endif()
-
-target_link_libraries(detect_grue PUBLIC
- Qt::Core
- Qt::Sensors
-)
-
-# Need to link to the plugin manually in a static Qt build.
-if(NOT QT6_IS_SHARED_LIBS_BUILD)
- target_link_libraries(detect_grue PRIVATE qtsensors_grue)
- target_sources(detect_grue PRIVATE ../grue_plugin_import_custom.cpp)
-endif()
-
-install(TARGETS detect_grue
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/sensors/grue/console_app/console_app.pro b/examples/sensors/grue/console_app/console_app.pro
deleted file mode 100644
index 97021f1d..00000000
--- a/examples/sensors/grue/console_app/console_app.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-TEMPLATE = app
-TARGET = detect_grue
-CONFIG += console
-CONFIG -= app_bundle
-QT = core sensors
-
-DESTDIR = $$OUT_PWD/..
-
-SOURCES = main.cpp
-
-grue_plugin_base_dir = ..
-include(../use_grue_static_plugin.pri)
-
-target.path = $$[QT_INSTALL_EXAMPLES]/sensors/grue
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
diff --git a/examples/sensors/grue/console_app/main.cpp b/examples/sensors/grue/console_app/main.cpp
deleted file mode 100644
index 7de66334..00000000
--- a/examples/sensors/grue/console_app/main.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 <QtCore>
-#include <qsensor.h>
-
-class Filter : public QSensorFilter
-{
- int lastPercent;
-public:
- Filter()
- : QSensorFilter()
- , lastPercent(0)
- {
- }
-
- bool filter(QSensorReading *reading) override
- {
- int percent = reading->property("chanceOfBeingEaten").value<int>();
- if (percent == 0) {
- qDebug() << "It is light. You are safe from Grues.";
- } else if (lastPercent == 0) {
- qDebug() << "It is dark. You are likely to be eaten by a Grue.";
- }
- if (percent == 100) {
- qDebug() << "You have been eaten by a Grue!";
- QCoreApplication::instance()->quit();
- } else if (percent)
- qDebug() << "Your chance of being eaten by a Grue:" << percent << "percent.";
- lastPercent = percent;
- return false;
- }
-};
-
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
-
- QSensor sensor("GrueSensor");
-
- Filter filter;
- sensor.addFilter(&filter);
- sensor.start();
-
- if (!sensor.isActive()) {
- qWarning("The Grue sensor didn't start. You're on your own!");
- return 1;
- }
-
- return app.exec();
-}
-
diff --git a/examples/sensors/grue/doc/images/qtsensors-examples-grue.png b/examples/sensors/grue/doc/images/qtsensors-examples-grue.png
deleted file mode 100644
index f4348271..00000000
--- a/examples/sensors/grue/doc/images/qtsensors-examples-grue.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/grue/doc/src/grue.qdoc b/examples/sensors/grue/doc/src/grue.qdoc
deleted file mode 100644
index f187865a..00000000
--- a/examples/sensors/grue/doc/src/grue.qdoc
+++ /dev/null
@@ -1,113 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example grue
- \title Qt Sensors - Grue Sensor Example
- \brief The Qt Sensors - Grue sensor example demonstrates all the steps from
- creating a new sensor to using it.
- \ingroup qtsensors-examples
-
- \image qtsensors-examples-grue.png
-
- The sensor definition and implementation are in a new sensor plugin that client
- apps can use for detecting Grues (imaginary monsters that live in the dark).
-
- \list
- \li \l{Grue Sensor Plugin}
- \endlist
-
- The sensor plugin can be used by C++ applications as shown in the console
- application example.
-
- \list
- \li \l{Grue Sensor Console Application}
- \endlist
-
- QML applications can use the new sensor by importing the QMLGrueSensor class.
-
- \list
- \li \l{Grue Sensor QML Application}
- \endlist
-
- \section1 Grue Sensor Plugin
-
- The Grue sensor is defined in a new sensor plugin that applications can use.
-
- The plugin provides the sensor reading property that describes your chance of
- being eaten. This chance is increasing in the dark until it is 100% when
- you are eaten by the Grue and at that point the plugin stops further processing.
- In case of the plugin receiving light again before that happens the chance of
- being eaten resets to 0%.
-
- This example was created using the make_sensor.pl script which can be found in
- src/sensors. As such, it contains some generated code that defines the convenience
- classes GrueFilter and GrueSensor.
-
- \section1 Grue Sensor Implementation
-
- The Grue sensor implementation lives in the plugin that is loaded by the Qt
- Sensors library. The source code is available in the \c{grue/plugin} subdirectory.
-
- The Grue sensor needs a backend before it can be used. The backend provided
- is rather basic and it relies on some kind of light sensor to work but it
- gets the job done. If new hardware that can detect the actual presence of Grues
- becomes available a backend could be created that supports this hardware and
- applications using the Grue sensor would be able to use it without any changes.
-
- There are a few mandatory parts to a backend. They are the start and stop methods
- and the setReading call. The start and stop methods are used to start and stop
- any underlying hardware. In the case of this backend they start and stop a
- light sensor. In the start method, the backend should call the \c{sensorStopped()}
- or \c{sensorBusy()} methods if it cannot start.
-
- \snippet grue/plugin/gruesensorimpl.cpp start
-
- The setReading method is needed so that the sensors library knows where the
- readings are coming from. This backend has a local copy of the reading so
- it passes a pointer to the function.
-
- \snippet grue/plugin/gruesensorimpl.cpp setReading
-
- However it is also possible to pass null to the setReading method in which
- case the sensors library will create an instance and return a pointer.
-
- \code
- // Create a reading instance for us to use
- m_reading = setReading<GrueSensorReading>(0);
- \endcode
-
- The Grue sensor backend also supplies some metadata.
-
- The backend checks 2 things, how dark it is and how long you have been in the dark.
- It uses the \c{readingChanged()} signal to know when to check the light sensor's
- value. Once it is dark, it uses a timer to increase your chance of being eaten.
-
- The Grue sensor backend is delivered as a plugin. The plugin has a factory object
- that registers the types available and does the actual instantiation of the backend.
-
- \section1 Grue Sensor Console Application
-
- The Grue sensor console application demonstrates use of the Grue sensor.
- The source code is available in the \c{grue/console_app} subdirectory.
-
- This is a simple commandline application. It demonstrates how to use the generic
- access feature of Qt Sensors to avoid a link-time dependency on a library.
-
- \section1 Grue Sensor C++ Class Registration for QML
-
- The QMLGrueSensor class is registered for QML, so the class name can be used
- as an import and the class properties can be accessed from QML.
-
- \section1 Grue Sensor QML Application
-
- The Grue sensor QML application demonstrates the use of QMLGrueSensor QML type.
-
- The application consists of a single QML file and an image. It is built as an
- executable with C++ code that runs the QML, but it can also be launched directly
- using the \c qmlscene tool.
-
- \code
- qmlscene -I . grue.qml
- \endcode
-*/
diff --git a/examples/sensors/grue/grue.png b/examples/sensors/grue/grue.png
deleted file mode 100644
index 2727d393..00000000
--- a/examples/sensors/grue/grue.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/grue/grue.pro b/examples/sensors/grue/grue.pro
deleted file mode 100644
index cd23d1f4..00000000
--- a/examples/sensors/grue/grue.pro
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS += plugin
-
-# Gui-less apps don't make sense for these platforms
-!uikit:!android:!wasm: SUBDIRS += console_app
-
-# There console app is not a macos bundle, so the shared library plugin wouldn't be found
-macos:qtConfig(shared): SUBDIRS -= console_app
-
-qtHaveModule(quick): SUBDIRS += qml.pro
-
-
diff --git a/examples/sensors/grue/grue.qml b/examples/sensors/grue/grue.qml
deleted file mode 100644
index d3a90aa8..00000000
--- a/examples/sensors/grue/grue.qml
+++ /dev/null
@@ -1,79 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtSensors
-import QtQuick.Layouts
-import QMLGrueSensor
-
-Rectangle {
- id: root
- anchors.fill: parent
- color: "black"
-
- property int percent: -1
- property string text: ""
- property real grueOpacity: 0.0
-
- function updateStatus(newPercent, newOpacity, newText) {
- if (root.percent === newPercent)
- return;
-
- // Delay updating the visual status to prevent flicker
- timer.interval = (newPercent < root.percent) ? 500 : 0;
-
- root.percent = newPercent;
- root.text = newText;
- root.grueOpacity = newOpacity;
-
- timer.start()
- }
-
- Timer {
- id: timer
- running: false
- repeat: false
- onTriggered: {
- text.text = root.text
- grueimg.opacity = root.grueOpacity
- }
- }
-
- QMLGrueSensor {
- id: sensor
- active: true
- onReadingChanged: {
- var percent = reading.chanceOfBeingEaten;
- if (percent === 0) {
- updateStatus(percent, 0.0, "It is light.<br>You are safe from Grues.");
- }
- else if (percent === 100) {
- updateStatus(percent, 1.0, "You have been eaten by a Grue!");
- sensor.active = false;
- }
- else if (percent > 0) {
- updateStatus(percent, 0.05 + (percent * 0.001),
- "It is dark.<br>You are " + percent +" % " +
- "likely to be eaten by a Grue.");
- }
- }
- }
-
- Text {
- id: text
- anchors.fill: parent
- wrapMode: Text.WordWrap
- text: "I can't tell if you're going to be eaten by a Grue or not. You're on your own!"
- font.pixelSize: 30
- color: "lightgray"
- }
-
- Image {
- id: grueimg
- anchors.bottom: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- source: "grue.png"
- opacity: 0.0
- Behavior on opacity { PropertyAnimation { duration: 250 } }
- }
-}
diff --git a/examples/sensors/grue/grue.xcf b/examples/sensors/grue/grue.xcf
deleted file mode 100644
index 2837ed7e..00000000
--- a/examples/sensors/grue/grue.xcf
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/grue/grue_plugin_import_custom.cpp b/examples/sensors/grue/grue_plugin_import_custom.cpp
deleted file mode 100644
index 0dcf6a1a..00000000
--- a/examples/sensors/grue/grue_plugin_import_custom.cpp
+++ /dev/null
@@ -1,5 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtPlugin>
-Q_IMPORT_PLUGIN(GrueSensorPlugin)
diff --git a/examples/sensors/grue/icon.xcf b/examples/sensors/grue/icon.xcf
deleted file mode 100644
index 8416c49f..00000000
--- a/examples/sensors/grue/icon.xcf
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/grue/main.cpp b/examples/sensors/grue/main.cpp
deleted file mode 100644
index af119c5a..00000000
--- a/examples/sensors/grue/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 <QGuiApplication>
-#include <QQuickView>
-
-int main(int argc, char **argv)
-{
- QGuiApplication app(argc,argv);
- QQuickView view;
- view.setSource(QUrl("qrc:/QMLGrueSensor/grue.qml"));
- view.show();
- return app.exec();
-}
diff --git a/examples/sensors/grue/plugin/CMakeLists.txt b/examples/sensors/grue/plugin/CMakeLists.txt
deleted file mode 100644
index 11e8aee8..00000000
--- a/examples/sensors/grue/plugin/CMakeLists.txt
+++ /dev/null
@@ -1,64 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(qtsensors_grue LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/grue/sensors")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Sensors)
-
-qt_add_plugin(qtsensors_grue
- PLUGIN_TYPE sensors
-)
-
-target_sources(qtsensors_grue PRIVATE
- gruesensorimpl.cpp gruesensorimpl.h
- gruesensor.cpp gruesensor.h gruesensor_p.h
- main.cpp
-)
-
-set_target_properties(qtsensors_grue PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-if(WIN32 OR (UNIX AND NOT APPLE))
- set_target_properties(qtsensors_grue PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../sensors
- )
-endif()
-
-if(APPLE AND QT6_IS_SHARED_LIBS_BUILD)
- set_target_properties(qtsensors_grue PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../grue_app.app/Contents/Plugins/sensors
- )
-endif()
-
-target_link_libraries(qtsensors_grue PUBLIC
- Qt::Core
- Qt::Sensors
-)
-
-if(ANDROID)
- add_custom_target(gruesensorplugin_android_copy ALL
- COMMAND "${CMAKE_COMMAND}"
- -E copy_if_different
- "$<TARGET_FILE:qtsensors_grue>"
- "${CMAKE_CURRENT_BINARY_DIR}/../android-build/libs/${CMAKE_ANDROID_ARCH_ABI}/$<TARGET_FILE_NAME:qtsensors_grue>"
- COMMENT "Copying sensor plugin lib to grue_app android libs folder.")
-
- add_dependencies(gruesensorplugin_android_copy qtsensors_grue)
-endif()
-
-install(TARGETS qtsensors_grue
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/sensors/grue/plugin/gruesensor.cpp b/examples/sensors/grue/plugin/gruesensor.cpp
deleted file mode 100644
index 9bc3784b..00000000
--- a/examples/sensors/grue/plugin/gruesensor.cpp
+++ /dev/null
@@ -1,112 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "gruesensor.h"
-#include "gruesensor_p.h"
-
-IMPLEMENT_READING(GrueSensorReading)
-
-/*
- \omit
- \class GrueSensorReading
-
- \brief The GrueSensorReading class holds readings from the Grue sensor.
-
- The Grue Sensor informs you of your chance of being eaten by a Grue.
-
- Grues love the dark so as long as your surroundings are relatively light
- you are safe. However the more time you spend in the dark, the higher
- your chances are of being eaten by a Grue.
-*/
-
-/*
- \property GrueSensorReading::chanceOfBeingEaten
- \brief holds your chance of being eaten.
-
- The value is the probability (from 0 to 100) that a Grue will eat you.
- A probability of 100 means you are currently being eaten. The darker
- it is, the more likely you are to be eaten by a Grue. The longer you
- stay in a dark area, the more likely you are to be eaten by a Grue.
- If you are in a lit room, the probability will be 0 as Grues fear light.
- \endomit
-*/
-
-int GrueSensorReading::chanceOfBeingEaten() const
-{
- return d->chanceOfBeingEaten;
-}
-
-void GrueSensorReading::setChanceOfBeingEaten(int chanceOfBeingEaten)
-{
- d->chanceOfBeingEaten = chanceOfBeingEaten;
-}
-
-// =====================================================================
-
-// begin generated code
-
-/*
- \omit
- \class GrueFilter
-
- \brief The GrueFilter class is a convenience wrapper around QSensorFilter.
-
- The only difference is that the filter() method features a pointer to GrueSensorReading
- instead of QSensorReading.
- \endomit
-*/
-
-/*
- \omit
- \fn GrueFilter::filter(GrueSensorReading *reading)
-
- Called when \a reading changes. Returns false to prevent the reading from propagating.
-
- \sa QSensorFilter::filter()
- \endomit
-*/
-
-char const * const GrueSensor::sensorType("GrueSensor");
-
-/*
- \omit
- \class GrueSensor
-
- \brief The GrueSensor class is a convenience wrapper around QSensor.
-
- The only behavioural difference is that this class sets the type properly.
-
- This class also features a reading() function that returns a GrueSensorReading instead of a QSensorReading.
-
- For details about how the sensor works, see \l GrueSensorReading.
-
- \sa GrueSensorReading
- \endomit
-*/
-
-/*
- \omit
- \fn GrueSensor::GrueSensor(QObject *parent)
-
- Construct the sensor as a child of \a parent.
- \endomit
-*/
-
-/*
- \fn GrueSensor::~GrueSensor()
-
- Destroy the sensor. Stops the sensor if it has not already been stopped.
-*/
-
-/*
- \omit
- \fn GrueSensor::reading() const
-
- Returns the reading class for this sensor.
-
- \sa QSensor::reading()
- \endomit
-*/
-// end generated code
-
-#include "moc_gruesensor.cpp"
diff --git a/examples/sensors/grue/plugin/gruesensor.h b/examples/sensors/grue/plugin/gruesensor.h
deleted file mode 100644
index 9677e621..00000000
--- a/examples/sensors/grue/plugin/gruesensor.h
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef GRUESENSOR_H
-#define GRUESENSOR_H
-
-#include <qsensor.h>
-
-class GrueSensorReadingPrivate;
-
-class GrueSensorReading : public QSensorReading
-{
- Q_OBJECT
- Q_PROPERTY(int chanceOfBeingEaten READ chanceOfBeingEaten WRITE setChanceOfBeingEaten)
- DECLARE_READING(GrueSensorReading)
-public:
- int chanceOfBeingEaten() const;
- void setChanceOfBeingEaten(int chanceOfBeingEaten);
-};
-
-// begin generated code
-
-class GrueFilter : public QSensorFilter
-{
-public:
- virtual bool filter(GrueSensorReading *reading) = 0;
-private:
- bool filter(QSensorReading *reading) override { return filter(static_cast<GrueSensorReading*>(reading)); }
-};
-
-class GrueSensor : public QSensor
-{
- Q_OBJECT
- Q_PROPERTY(GrueSensorReading* reading READ reading)
-public:
- explicit GrueSensor(QObject *parent = 0) : QSensor(GrueSensor::sensorType, parent) {}
- virtual ~GrueSensor() {}
- GrueSensorReading *reading() const { return static_cast<GrueSensorReading*>(QSensor::reading()); }
- static char const * const sensorType;
-};
-// end generated code
-
-#endif
diff --git a/examples/sensors/grue/plugin/gruesensor_p.h b/examples/sensors/grue/plugin/gruesensor_p.h
deleted file mode 100644
index 4804f8cf..00000000
--- a/examples/sensors/grue/plugin/gruesensor_p.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 GRUESENSOR_P_H
-#define GRUESENSOR_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-class GrueSensorReadingPrivate
-{
-public:
- GrueSensorReadingPrivate()
- : chanceOfBeingEaten(-1)
- {
- }
-
- int chanceOfBeingEaten;
-};
-
-#endif
diff --git a/examples/sensors/grue/plugin/gruesensorimpl.cpp b/examples/sensors/grue/plugin/gruesensorimpl.cpp
deleted file mode 100644
index 7bfdb092..00000000
--- a/examples/sensors/grue/plugin/gruesensorimpl.cpp
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "gruesensorimpl.h"
-#include <QDebug>
-#include <QTimer>
-
-char const * const gruesensorimpl::id("grue.gruesensor");
-
-gruesensorimpl::gruesensorimpl(QSensor *sensor)
- : QSensorBackend(sensor)
- , lightLevel(QAmbientLightReading::Undefined)
-{
- // We need a light sensor
- lightSensor = new QAmbientLightSensor(this);
- connect(lightSensor, SIGNAL(readingChanged()), this, SLOT(lightChanged()));
- lightSensor->connectToBackend();
-
- // We need a timer
- darkTimer = new QTimer(this);
- darkTimer->setInterval(1000);
- connect(darkTimer, SIGNAL(timeout()), this, SLOT(increaseChance()));
-
- // We use this as our timestamp source
- timer.start();
-
-//! [setReading]
- // Register our reading instance
- setReading<GrueSensorReading>(&m_reading);
-//! [setReading]
-
-//! [metadata]
- // Supply metadata
- // We can run as fast as the light sensor does
- setDataRates(lightSensor);
- // Only one output range, 0 to 1 in .1 increments
- addOutputRange(0, 1, 0.1);
- setDescription(QLatin1String("Grue Sensor"));
-//! [metadata]
-}
-
-void gruesensorimpl::start()
-{
-//! [start]
- lightSensor->setDataRate(sensor()->dataRate());
- lightSensor->start();
- // If the light sensor doesn't work we don't work either
- if (!lightSensor->isActive())
- sensorStopped();
- if (lightSensor->isBusy())
- sensorBusy();
-//! [start]
-}
-
-void gruesensorimpl::stop()
-{
- lightSensor->stop();
-}
-
-void gruesensorimpl::lightChanged()
-{
- if (lightLevel == lightSensor->reading()->lightLevel())
- return;
-
- lightLevel = lightSensor->reading()->lightLevel();
-
- int chance = 0;
- darkTimer->stop();
-
- switch (lightSensor->reading()->lightLevel()) {
- case QAmbientLightReading::Dark:
- // It is dark. You are likely to be eaten by a grue.
- chance = 10;
- darkTimer->start();
- break;
- default:
- break;
- }
-
- // Only send an update if the value has changed.
- if (chance != m_reading.chanceOfBeingEaten() || m_reading.timestamp() == 0) {
- m_reading.setTimestamp(timer.elapsed());
- m_reading.setChanceOfBeingEaten(chance);
- newReadingAvailable();
- }
-}
-
-void gruesensorimpl::increaseChance()
-{
- // The longer you stay in the dark, the higher your chance of being eaten
- int chance = m_reading.chanceOfBeingEaten() + 10;
-
- m_reading.setTimestamp(timer.elapsed());
- m_reading.setChanceOfBeingEaten(chance);
-
- newReadingAvailable();
-
- // No point in using the timer anymore if we've hit 100... you can't get more
- // likely to be eaten than 100%
- if (chance >= 100)
- darkTimer->stop();
-}
-
diff --git a/examples/sensors/grue/plugin/gruesensorimpl.h b/examples/sensors/grue/plugin/gruesensorimpl.h
deleted file mode 100644
index 001af4dd..00000000
--- a/examples/sensors/grue/plugin/gruesensorimpl.h
+++ /dev/null
@@ -1,40 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef GRUESENSORIMPL_H
-#define GRUESENSORIMPL_H
-
-#include <qsensorbackend.h>
-#include "gruesensor.h"
-#include <qambientlightsensor.h>
-#include <QElapsedTimer>
-
-QT_BEGIN_NAMESPACE
-class QTimer;
-QT_END_NAMESPACE
-
-class gruesensorimpl : public QSensorBackend
-{
- Q_OBJECT
-public:
- static char const * const id;
-
- gruesensorimpl(QSensor *sensor);
-
- void start() override;
- void stop() override;
-
-private Q_SLOTS:
- void lightChanged();
- void increaseChance();
-
-private:
- GrueSensorReading m_reading;
- QAmbientLightSensor *lightSensor;
- QTimer *darkTimer;
- QElapsedTimer timer;
- QAmbientLightReading::LightLevel lightLevel;
-};
-
-#endif
-
diff --git a/examples/sensors/grue/plugin/main.cpp b/examples/sensors/grue/plugin/main.cpp
deleted file mode 100644
index 39b9a585..00000000
--- a/examples/sensors/grue/plugin/main.cpp
+++ /dev/null
@@ -1,42 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "gruesensorimpl.h"
-#include <qsensorplugin.h>
-#include <qsensorbackend.h>
-#include <qsensormanager.h>
-#include <QFile>
-#include <QDebug>
-
-class GrueSensorPlugin : public QObject, public QSensorPluginInterface, public QSensorChangesInterface, public QSensorBackendFactory
-{
- Q_OBJECT
- Q_PLUGIN_METADATA(IID "com.qt-project.Qt.QSensorPluginInterface/1.0" FILE "plugin.json")
- Q_INTERFACES(QSensorPluginInterface QSensorChangesInterface)
-public:
- void registerSensors() override
- {
- }
-
- void sensorsChanged() override
- {
- if (!QSensor::defaultSensorForType(QAmbientLightSensor::sensorType).isEmpty()) {
- // There is a light sensor available. Register the backend
- if (!QSensorManager::isBackendRegistered(GrueSensor::sensorType, gruesensorimpl::id))
- QSensorManager::registerBackend(GrueSensor::sensorType, gruesensorimpl::id, this);
- } else {
- if (QSensorManager::isBackendRegistered(GrueSensor::sensorType, gruesensorimpl::id))
- QSensorManager::unregisterBackend(GrueSensor::sensorType, gruesensorimpl::id);
- }
- }
-
- QSensorBackend *createBackend(QSensor *sensor) override
- {
- if (sensor->identifier() == gruesensorimpl::id)
- return new gruesensorimpl(sensor);
-
- return 0;
- }
-};
-
-#include "main.moc"
diff --git a/examples/sensors/grue/plugin/plugin.json b/examples/sensors/grue/plugin/plugin.json
deleted file mode 100644
index ab372059..00000000
--- a/examples/sensors/grue/plugin/plugin.json
+++ /dev/null
@@ -1 +0,0 @@
-{ "Keys": [ "grue" ] }
diff --git a/examples/sensors/grue/plugin/plugin.pro b/examples/sensors/grue/plugin/plugin.pro
deleted file mode 100644
index aa03d6c9..00000000
--- a/examples/sensors/grue/plugin/plugin.pro
+++ /dev/null
@@ -1,27 +0,0 @@
-TEMPLATE = lib
-CONFIG += plugin
-TARGET = $$qtLibraryTarget(plugins_sensors_qtsensors_grue)
-PLUGIN_TYPE = sensors
-
-QT = core sensors
-
-macos:!qtConfig(static): DESTDIR = ../grue_app.app/Contents/MacOS/$$PLUGIN_TYPE
-else: DESTDIR = ../$$PLUGIN_TYPE
-
-HEADERS += gruesensorimpl.h \
- gruesensor.h \
- gruesensor_p.h
-
-SOURCES += gruesensorimpl.cpp \
- main.cpp \
- gruesensor.cpp
-
-
-# Install the plugin under Grue example directory
-target.path=$$[QT_INSTALL_EXAMPLES]/sensors/grue/$$PLUGIN_TYPE
-INSTALLS += target
-
-CONFIG += install_ok # Do not cargo-cult this!
-
-OTHER_FILES += \
- plugin.json
diff --git a/examples/sensors/grue/qml.pro b/examples/sensors/grue/qml.pro
deleted file mode 100644
index 6bce739c..00000000
--- a/examples/sensors/grue/qml.pro
+++ /dev/null
@@ -1,40 +0,0 @@
-TEMPLATE = app
-TARGET = grue_app
-QT += qml quick sensors
-
-# Avoid going to release/debug subdirectory
-win32: DESTDIR = ./
-
-SOURCES = main.cpp \
- qmlgruesensor.cpp
-
-HEADERS += \
- qmlgruesensor.h
-
-grue_plugin_base_dir = .
-include(use_grue_static_plugin.pri)
-
-CONFIG += qmltypes
-QML_IMPORT_NAME = QMLGrueSensor
-QML_IMPORT_MAJOR_VERSION = 1
-
-RESOURCES += \
- qml.qrc
-
-OTHER_FILES = \
- $$files(*.qml) \
- grue.png
-
-target.path = $$[QT_INSTALL_EXAMPLES]/sensors/grue
-INSTALLS += target
-
-EXAMPLE_FILES += \
- grue.xcf \
- icon.xcf
-
-android{
- CONFIG += file_copies
- COPIES += androidPluginCopy
- androidPluginCopy.files = $$OUT_PWD/sensors/libplugins_sensors_qtsensors_grue_armeabi-v7a.so
- androidPluginCopy.path = android-build/libs/armeabi-v7a
-}
diff --git a/examples/sensors/grue/qml.qrc b/examples/sensors/grue/qml.qrc
deleted file mode 100644
index 01f4e2bf..00000000
--- a/examples/sensors/grue/qml.qrc
+++ /dev/null
@@ -1,6 +0,0 @@
-<RCC>
- <qresource prefix="/QMLGrueSensor">
- <file>grue.qml</file>
- <file>grue.png</file>
- </qresource>
-</RCC>
diff --git a/examples/sensors/grue/qmlgruesensor.cpp b/examples/sensors/grue/qmlgruesensor.cpp
deleted file mode 100644
index 312b4968..00000000
--- a/examples/sensors/grue/qmlgruesensor.cpp
+++ /dev/null
@@ -1,11 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "qmlgruesensor.h"
-
-
-QMLGrueSensor::QMLGrueSensor():QSensor("GrueSensor") // QLightSensor
-{
- connectToBackend();
- start();
-}
diff --git a/examples/sensors/grue/qmlgruesensor.h b/examples/sensors/grue/qmlgruesensor.h
deleted file mode 100644
index 9ee14568..00000000
--- a/examples/sensors/grue/qmlgruesensor.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef QMLGRUESENSOR_H
-#define QMLGRUESENSOR_H
-
-#include <QtQml/qqml.h>
-#include <QtSensors/qsensor.h>
-
-class QMLGrueSensor : public QSensor
-{
- Q_OBJECT
- QML_ELEMENT
-
-public:
- QMLGrueSensor();
-};
-
-#endif // QMLGRUESENSOR_H
diff --git a/examples/sensors/grue/use_grue_static_plugin.pri b/examples/sensors/grue/use_grue_static_plugin.pri
deleted file mode 100644
index 6ccee1cd..00000000
--- a/examples/sensors/grue/use_grue_static_plugin.pri
+++ /dev/null
@@ -1,17 +0,0 @@
-# Need to manually link to the plugin when using a static Qt build.
-qtConfig(static) {
- SOURCES += $$grue_plugin_base_dir/grue_plugin_import_custom.cpp
- LIBS += -L$$grue_plugin_base_dir/sensors
- # For iOS, xcode takes care of the debug suffix
- macx-xcode {
- LIBS += -lplugins_sensors_qtsensors_grue$($${QMAKE_XCODE_LIBRARY_SUFFIX_SETTING})
- # For desktop platforms we need to do it per-platform.
- } else {
- lib_to_link = plugins_sensors_qtsensors_grue
- if(!debug_and_release|build_pass):CONFIG(debug, debug|release) {
- macos:lib_to_link = $${lib_to_link}_debug
- win32:lib_to_link = $${lib_to_link}d
- }
- LIBS += -l$$lib_to_link
- }
-}
diff --git a/examples/sensors/maze/CMakeLists.txt b/examples/sensors/maze/CMakeLists.txt
deleted file mode 100644
index 258291c4..00000000
--- a/examples/sensors/maze/CMakeLists.txt
+++ /dev/null
@@ -1,77 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(maze LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/maze")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Sensors)
-
-qt_add_executable(maze
- main.cpp
-)
-
-set_target_properties(maze PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-if(ANDROID)
- set_property(TARGET maze PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
- ${CMAKE_CURRENT_SOURCE_DIR}/android)
- endif()
-if(APPLE)
- if(IOS)
- set_property(TARGET maze PROPERTY
- MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
- )
- endif()
-endif()
-
-target_link_libraries(maze PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Quick
- Qt::Sensors
-)
-
-# Resources:
-set(maze_resource_files
- "Congratulation.qml"
- "LabyrinthSquare.qml"
- "Mouse.qml"
- "components/ApplicationWindow.qml"
- "components/Button.qml"
- "components/images/button_background_disabled.png"
- "components/images/button_background_normal.png"
- "components/images/button_background_pressed.png"
- "content/00.png"
- "content/01.png"
- "content/cheese.png"
- "content/cheeseeating.gif"
- "content/congratulations.gif"
- "content/mouse_down.gif"
- "content/start.png"
- "lib.js"
- "maze.qml"
-)
-
-qt6_add_resources(maze "maze"
- PREFIX
- "/"
- FILES
- ${maze_resource_files}
-)
-
-install(TARGETS maze
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/sensors/maze/Congratulation.qml b/examples/sensors/maze/Congratulation.qml
deleted file mode 100644
index a1e54ada..00000000
--- a/examples/sensors/maze/Congratulation.qml
+++ /dev/null
@@ -1,24 +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 the javascript functions for this game
-import "lib.js" as Lib
-
-//Implementation of the Congratulation control
-Item {
- x: Lib.cellDimension
- y: Lib.cellDimension
- width: Lib.cellDimension * (Lib.dimension - 2)
- height: Lib.cellDimension * (Lib.dimension - 2)
-
- //Containing a animated gif image
- AnimatedImage {
- id: img
- anchors.fill: parent
- visible: true
- source: "content/congratulations.gif"
- }
-}
diff --git a/examples/sensors/maze/Info.plist b/examples/sensors/maze/Info.plist
deleted file mode 100644
index 2458247c..00000000
--- a/examples/sensors/maze/Info.plist
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
-<plist version="1.0">
-<dict>
- <key>CFBundleDisplayName</key>
- <string>maze</string>
- <key>CFBundleExecutable</key>
- <string>maze</string>
- <key>CFBundleGetInfoString</key>
- <string>Created by Qt/QMake</string>
- <key>CFBundleIdentifier</key>
- <string>com.qt.sensorsmaze</string>
- <key>CFBundleName</key>
- <string>maze</string>
- <key>CFBundlePackageType</key>
- <string>APPL</string>
- <key>CFBundleShortVersionString</key>
- <string>1.0</string>
- <key>CFBundleSignature</key>
- <string>????</string>
- <key>CFBundleVersion</key>
- <string>1.0</string>
- <key>LSRequiresIPhoneOS</key>
- <true/>
- <key>UILaunchStoryboardName</key>
- <string>LaunchScreen</string>
- <key>UISupportedInterfaceOrientations</key>
- <array>
- <string>UIInterfaceOrientationPortrait</string>
- </array>
-</dict>
-</plist>
diff --git a/examples/sensors/maze/LabyrinthSquare.qml b/examples/sensors/maze/LabyrinthSquare.qml
deleted file mode 100644
index d9e72db7..00000000
--- a/examples/sensors/maze/LabyrinthSquare.qml
+++ /dev/null
@@ -1,43 +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 the javascript functions for this game
-import "lib.js" as Lib
-
-//Implementation of the Labyrinth square control.
-Rectangle {
- id: sq
- x: 0
- y: 0
- width: Lib.cellDimension
- height: Lib.cellDimension
- color: "white"
- property int val: 0
- property AnimatedImage picture: img
-
- //Dependent of its position and the labyrinth value a square can be the start, cheese, empty or a wall
- AnimatedImage {
- id: img
- anchors.fill: parent
- source: ""
- }
-
- function updateImage()
- {
- if (sq.val == -1)
- sq.picture.source = "content/start.png";
- else if (sq.val == 3)
- sq.picture.source = "content/cheese.png";
- else if (sq.val == 4){
- sq.picture.source = "content/cheeseeating.gif";
- sq.picture.playing = true;
- }
- else if (sq.val == 1)
- sq.picture.source = "content/01.png";
- else
- sq.picture.source = "content/00.png";
- }
-}
diff --git a/examples/sensors/maze/Mouse.qml b/examples/sensors/maze/Mouse.qml
deleted file mode 100644
index 155f0bd6..00000000
--- a/examples/sensors/maze/Mouse.qml
+++ /dev/null
@@ -1,45 +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 the javascript functions for this game
-import "lib.js" as Lib
-
-//Implementation of the Mouse control.
-Item {
- id: mouse
- x: 0
- y: 0
- width: Lib.cellDimension
- height: Lib.cellDimension
- property int angle
- readonly property double radians_to_degrees: 180 / Math.PI
-
- AnimatedImage {
- id: img
- source: "content/mouse_down.gif"
- anchors.fill: parent
- visible: true
- }
-
- //Function for moving the mouse
- function move(newx, newy)
- {
- if (mouse.x === newx && mouse.y === newy)
- return
- // somehow this actually works
-//! [0]
- var a = newy - mouse.y
- var b = newx - mouse.x
- angle = Math.atan2(-b, a) * mouse.radians_to_degrees
- if (angle < 0)
- angle = 360 + angle
-
- img.rotation = angle
- mouse.x = newx;
- mouse.y = newy;
-//! [0]
- }
-}
diff --git a/examples/sensors/maze/android/AndroidManifest.xml b/examples/sensors/maze/android/AndroidManifest.xml
deleted file mode 100644
index 8efe1ed3..00000000
--- a/examples/sensors/maze/android/AndroidManifest.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.qtproject.example.maze"
- android:installLocation="auto"
- android:versionCode="1"
- android:versionName="1.0">
- <!-- The comment below will be replaced with dependencies permissions upon deployment.
- Remove the comment if you do not require these default permissions. -->
- <!-- %%INSERT_PERMISSIONS -->
-
- <!-- The comment below will be replaced with dependencies permissions upon deployment.
- Remove the comment if you do not require these default features. -->
- <!-- %%INSERT_FEATURES -->
-
- <supports-screens
- android:anyDensity="true"
- android:largeScreens="true"
- android:normalScreens="true"
- android:smallScreens="true" />
- <application
- android:name="org.qtproject.qt.android.bindings.QtApplication"
- android:extractNativeLibs="true"
- android:hardwareAccelerated="true"
- android:label="-- %%INSERT_APP_NAME%% --"
- android:requestLegacyExternalStorage="true">
- <activity
- android:name="org.qtproject.qt.android.bindings.QtActivity"
- android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
- android:label="-- %%INSERT_APP_NAME%% --"
- android:launchMode="singleTop"
- android:screenOrientation="portrait">
- <intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
- </intent-filter>
- <meta-data
- android:name="android.app.lib_name"
- android:value="-- %%INSERT_APP_LIB_NAME%% --" />
- <meta-data
- android:name="android.app.background_running"
- android:value="false" />
- <meta-data
- android:name="android.app.extract_android_style"
- android:value="minimal" />
- </activity>
- </application>
-</manifest>
diff --git a/examples/sensors/maze/components/ApplicationWindow.qml b/examples/sensors/maze/components/ApplicationWindow.qml
deleted file mode 100644
index 3f87d724..00000000
--- a/examples/sensors/maze/components/ApplicationWindow.qml
+++ /dev/null
@@ -1,14 +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
-
-Rectangle {
- id: appWnd
- x: 0
- y: 0
- width: 320
- height: 480
- color: "#ececec"
-}
diff --git a/examples/sensors/maze/components/Button.qml b/examples/sensors/maze/components/Button.qml
deleted file mode 100644
index 953424a4..00000000
--- a/examples/sensors/maze/components/Button.qml
+++ /dev/null
@@ -1,38 +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: 100
- property alias text: innerText.text
- signal clicked
-
- Image {
- id: backgroundImage
- anchors.fill: parent
- source: (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
- }
-
- Text {
- id: innerText
- anchors.centerIn: parent
- color: "white"
- font.bold: true
- }
-
- //Mouse area to react on click events
- MouseArea {
- anchors.fill: button
- onClicked: { button.clicked();}
- onPressed: {
- backgroundImage.source = "images/button_background_pressed.png" }
- onReleased: {
- backgroundImage.source = (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
- }
- }
-}
diff --git a/examples/sensors/maze/components/images/button_background_disabled.png b/examples/sensors/maze/components/images/button_background_disabled.png
deleted file mode 100644
index 62a00b9a..00000000
--- a/examples/sensors/maze/components/images/button_background_disabled.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/components/images/button_background_normal.png b/examples/sensors/maze/components/images/button_background_normal.png
deleted file mode 100644
index 1fecad5b..00000000
--- a/examples/sensors/maze/components/images/button_background_normal.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/components/images/button_background_pressed.png b/examples/sensors/maze/components/images/button_background_pressed.png
deleted file mode 100644
index e0ba0e7a..00000000
--- a/examples/sensors/maze/components/images/button_background_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/content/00.png b/examples/sensors/maze/content/00.png
deleted file mode 100644
index 2522be5e..00000000
--- a/examples/sensors/maze/content/00.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/content/01.png b/examples/sensors/maze/content/01.png
deleted file mode 100644
index 6146b204..00000000
--- a/examples/sensors/maze/content/01.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/content/cheese.png b/examples/sensors/maze/content/cheese.png
deleted file mode 100644
index c737b9d6..00000000
--- a/examples/sensors/maze/content/cheese.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/content/cheeseeating.gif b/examples/sensors/maze/content/cheeseeating.gif
deleted file mode 100644
index 6b2cb47f..00000000
--- a/examples/sensors/maze/content/cheeseeating.gif
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/content/congratulations.gif b/examples/sensors/maze/content/congratulations.gif
deleted file mode 100644
index 70204176..00000000
--- a/examples/sensors/maze/content/congratulations.gif
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/content/mouse_down.gif b/examples/sensors/maze/content/mouse_down.gif
deleted file mode 100644
index 5491c18f..00000000
--- a/examples/sensors/maze/content/mouse_down.gif
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/content/start.png b/examples/sensors/maze/content/start.png
deleted file mode 100644
index 581b8c9b..00000000
--- a/examples/sensors/maze/content/start.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/maze/doc/src/maze.qdoc b/examples/sensors/maze/doc/src/maze.qdoc
deleted file mode 100644
index a6f132f9..00000000
--- a/examples/sensors/maze/doc/src/maze.qdoc
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example maze
- \title Qt Sensors - Maze QML Example
- \ingroup qtsensors-examples
- \image maze.png
-
- \section2 Maze in QML
- \brief The Maze example demonstrates the TiltSensor QML type.
-
-
- To write a QML application that will use the TiltSensor QML sensors type
- you need to do the following steps:
-
- To import the Qt Sensors QML types into your application, use the following
- import statement in your .qml file:
-
- \snippet maze/maze.qml 0
-
- Then, add the Sensor QML types into your qml file.
-
- In this example we use the TiltSensor:
-
- \snippet maze/maze.qml 1
-
- The mouse should move by a factor of the tilt value:
-
- \snippet maze/maze.qml 2
-
- The walk direction of the mouse takes into account some collision detection:
-
- \snippet maze/maze.qml 3
-
- The rotation of the mouse image is determined according to the angle that the mouse is moving.
-
- \snippet maze/Mouse.qml 0
-
-*/
-
diff --git a/examples/sensors/maze/lib.js b/examples/sensors/maze/lib.js
deleted file mode 100644
index 3bae6a86..00000000
--- a/examples/sensors/maze/lib.js
+++ /dev/null
@@ -1,264 +0,0 @@
-//global variables
-var labyrinth = null;
-var dimension = 24;
-var cellDimension = 13;
-var won;
-var objectArray = null;
-var sec = 0.0
-
-//Allocate labyrinth arrays and create labyrinth and way reflected in the labyrinth array
-function createLabyrinth()
-{
- won = false;
- //create the labyrinth matrix
- labyrinth = null;
- labyrinth = new Array(dimension);
- for (var x = 0; x < dimension; x++ ){
- labyrinth[x] = new Array(dimension);
- for (var y = 0; y < dimension; y++ ){
- labyrinth[x][y] = 0;
- }
- }
- createWay();
- createLab();
-}
-
-//Create a way where the mouse can reach the cheese
-function createWay()
-{
- //Create rnd way to have at least one solution
- //A way square is marked as a 2 in the labyrinth array
- var x = 0;
- var y = 0;
- var ox = x;
- var oy = y;
- labyrinth[0][0] = 2;
- while (x < dimension && y < dimension){
- var rnd = Math.floor(Math.random()*5);
- if (Math.floor(Math.random()*2) == 1){
- if (rnd == 0) x--;
- if (rnd >= 1) x++;
- if (x < 0) x++;
- if (x >= dimension){
- x = ox;
- break;
- }
- }
- else {
- if (rnd == 0) y--;
- if (rnd >= 1) y++;
- if (y < 0) y++;
- if (y >= dimension){
- y = oy;
- break;
- }
- }
-
- /*avoid to have [2]2|
- |2|2|*/
- if (x < (dimension - 1) && y < (dimension - 1)){
- if (labyrinth[x + 1][y] == 2
- && labyrinth[x][y + 1] == 2
- && labyrinth[x + 1][y + 1] == 2){
- y = oy;
- x = ox;
- continue;
- }
- }
- /*avoid to have |2[2]
- |2|2|*/
- if (x > 0 && y < (dimension - 1)){
- if (labyrinth[x - 1][y] == 2
- && labyrinth[x][y + 1] == 2
- && labyrinth[x - 1][y + 1] == 2){
- y = oy;
- x = ox;
- continue;
- }
- }
- /*avoid to have |2|2|
- [2]2|*/
- if (x < (dimension - 1) && y > 0){
- if (labyrinth[x + 1][y] == 2
- && labyrinth[x][y - 1] == 2
- && labyrinth[x + 1][y - 1] == 2){
- y = oy;
- x = ox;
- continue;
- }
- }
- /*avoid to have |2|2|
- |2[2]*/
- if (x > 0 && y > 0){
- if (labyrinth[x - 1][y] == 2
- && labyrinth[x][y - 1] == 2
- && labyrinth[x - 1][y - 1] == 2){
- y = oy;
- x = ox;
- continue;
- }
- }
-
- labyrinth[x][y] = 2;
- ox = x;
- oy = y;
- }
- //finish way
- while (x < (dimension - 1)){
- labyrinth[x][y] = 2;
- x++;
- }
- while (y < (dimension - 1)){
- labyrinth[x][y] = 2;
- y++;
- }
-}
-
-//Create the labyrinth with rnd values
-function createLab()
-{
- //A wall square is marked as a 1 in the labyrinth array
- //Not a wall square is marked as a 0 in the labyrinth array
- //The Cheese square is marked as a 3 in the labyrinth array
- //The start is marked as a -1 in the labyrinth array
- for (var x = 0; x < dimension; x++ ){
- var rnd = 0;
- for (var y = 0; y < dimension; y++){
- //But don't overwrite the way
- if (labyrinth[x][y] != 2){
- var rnd = Math.floor(Math.random()*2);
- var xy = 0;
- var xxy = 0;
- var xyy = 0;
- var xxyy = 0;
-
- if (x > 0 && y > 0){
- xy = labyrinth[x - 1][y - 1];
- if (xy == 2)
- xy = 0;
-
- xyy = labyrinth[x - 1][y];
- if (xyy == 2)
- xyy = 0;
-
- xxy = labyrinth[x][y - 1];
- if (xxy == 2)
- xxy = 0;
-
- xxyy = rnd;
- if (xxyy == 2)
- xxyy = 0;
-
- //avoid to have to many |0|1| or |1|0| [xy ][xxy ]
- // |1[0] |0[1] [xyy ][xxyy]
- if (xyy == xxy && xy == xxyy && xy != xxy){
- if (rnd == 1)
- rnd = 0;
- else rnd = 1;
- }
-
- //avoid to have to many |1|1| or |0|0|
- // |1[1] |0[0]
- if (xy == xxy && xxy == xxyy && xxyy == xyy){
- if (rnd == 1)
- rnd = 0;
- else rnd = 1;
- }
- }
- else if (x == 0 && y > 0){
- xy = labyrinth[x][y - 1];
- if (xy == 2)
- xy = 0;
-
- xyy = rnd;
- if (xyy == 2)
- xyy = 0;
-
- xxy = labyrinth[x + 1][y - 1];
- if (xxy == 2)
- xxy = 0;
-
- xxyy = labyrinth[x + 1][y];
- if (xxyy == 2)
- xxyy = 0;
-
- //avoid to have to many |1|1| or |0|0|
- // |1[1] |0[0]
- if (xy == xxy && xxy == xxyy && xxyy == xyy){
- if (rnd == 1)
- rnd = 0;
- else rnd = 1;
- }
-
- //avoid to have to many |0|1| or |1|0| [xy ][xxy ]
- // |1[0] |0[1] [xyy ][xxyy]
- if (xyy == xxy && xy == xxyy && xy != xxy){
- if (rnd == 1)
- rnd = 0;
- else rnd = 1;
- }
- }
- labyrinth[x][y] = rnd;
- }
-
- }
- }
- //set start and end
- labyrinth[0][0] = -1;
- labyrinth[0][1] = 0;
- labyrinth[1][0] = 0;
- labyrinth[1][1] = 0;
-
- labyrinth[dimension - 2][dimension - 2] = 0;
- labyrinth[dimension - 2][dimension - 1] = 0;
- labyrinth[dimension - 1][dimension - 2] = 0;
- labyrinth[dimension - 1][dimension - 1] = 3;
-}
-
-//Function that checks if the mouse can be moved in x and y
-function canMove(x, y)
-{
- //Check if movement is allowed
- var xcenter = x + (cellDimension / 2);
- var ycenter = y + (cellDimension / 2);
- //try to get the index
- var idx = Math.floor(xcenter / cellDimension);
- var idy = Math.floor(ycenter / cellDimension);
- var dx = xcenter - (idx * cellDimension + ( cellDimension / 2 ));
- var dy = ycenter - (idy * cellDimension + ( cellDimension / 2 ));
-
- if (dx > 0){
- if (labyrinth[idx][idy] == 1)
- return false;
- }
- if (dx < 0){
- if (labyrinth[idx][idy] == 1)
- return false;
- }
- if (dy > 0){
- if (labyrinth[idx][idy] == 1)
- return false;
- }
- if (dy < 0){
- if (labyrinth[idx][idy] == 1)
- return false;
- }
- //check if won
- if (idx == (dimension - 1) && idy == (dimension - 1))
- won = true;
- return true;
-}
-
-//Function that prints out the labyrith array values in the console
-function printLab()
-{
- //for debug purposes print out lab n console
- var iy = 0;
- for (var y = 0; y < dimension; y++ ){
- var line = "";
- for (var x = 0; x < dimension; x++ ){
- line += labyrinth[x][y];
- }
- console.log(line);
- }
-}
diff --git a/examples/sensors/maze/main.cpp b/examples/sensors/maze/main.cpp
deleted file mode 100644
index 2dbf1aa1..00000000
--- a/examples/sensors/maze/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(maze)
diff --git a/examples/sensors/maze/maze.pro b/examples/sensors/maze/maze.pro
deleted file mode 100644
index f15fa570..00000000
--- a/examples/sensors/maze/maze.pro
+++ /dev/null
@@ -1,19 +0,0 @@
-TEMPLATE = app
-TARGET = maze
-QT += quick sensors
-SOURCES = main.cpp
-
-OTHER_FILES = \
- components \
- $$files(*.qml) \
- $$files(*.js) \
- content \
- android/AndroidManifest.xml
-
-target.path = $$[QT_INSTALL_EXAMPLES]/sensors/maze
-INSTALLS += target
-
-RESOURCES += \
- maze.qrc
-
-ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
diff --git a/examples/sensors/maze/maze.qml b/examples/sensors/maze/maze.qml
deleted file mode 100644
index c28e970b..00000000
--- a/examples/sensors/maze/maze.qml
+++ /dev/null
@@ -1,251 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-/* Layout
- mainWnd
- /
-------------------------------/ gameRect
-| /
-|-----------------------------/
-||---------------------------|
-||||M| ||
-||| \ ||
-||| mouseCtrl ||
-||| ||
-||| ||
-||| Labyrinth ||
-||| ||
-||| ||
-||| cheeseSquare ||
-||| \ ||
-||| |C|||
-||---------------------------|
-|-----------------------------
-|
-|-----------------------------
-|| || |
-|-----------------------------
-| \ \
-| \ timePlayingLabel
-| newGameButton
-------------------------------
-
-*/
-//Import the declarative plugins
-import QtQuick
-import "components"
-
-//! [0]
-import QtSensors
-//! [0]
-
-//Import the javascript functions for this game
-import "lib.js" as Lib
-
-ApplicationWindow {
- id: mainWnd
- property bool gameRunning: false
-
- Component.onCompleted: {
- initializeMaze()
- newGame()
- }
-
- function initializeMaze() {
- Lib.objectArray = new Array(Lib.dimension * Lib.dimension);
- Lib.createLabyrinth();
- var idx = 0;
- var component = Qt.createComponent("LabyrinthSquare.qml");
- for (var y = 0; y < Lib.dimension; y++ ) {
- for (var x = 0; x < Lib.dimension; x++ ) {
- var square = component.createObject(gameRect);
- if (!square) {
- console.log("error loading labyrinth square: " + component.errorString())
- return
- }
- square.x = x * square.width;
- square.y = y * square.height;
- square.val = Lib.labyrinth[x][y];
- Lib.objectArray[idx] = square;
- idx++;
- }
- }
- }
-
- function newGame() {
- congratulation.visible = false;
-
- // Reset game time
- timePlayingLabel.text = "--";
- Lib.sec = 0.0;
-
- // Create new labyrinth
- Lib.createLabyrinth();
- // Update maze tiles to match the new labyrinth
- var idx = 0;
- for (var y = 0; y < Lib.dimension; y++ ) {
- for (var x = 0; x < Lib.dimension; x++ ) {
- Lib.objectArray[idx].val = Lib.labyrinth[x][y];
- Lib.objectArray[idx].updateImage();
- idx++;
- }
- }
- // Reset mouse position and start the game
- mouseCtrl.x = 0;
- mouseCtrl.y = 0;
- mainWnd.gameRunning = true;
- }
-
- function gameWon() {
- // Update the cheese square at the bottom right (win animation)
- Lib.objectArray[Lib.dimension * Lib.dimension - 1].val = 4
- Lib.objectArray[Lib.dimension * Lib.dimension - 1].updateImage()
- congratulation.visible = true;
- mainWnd.gameRunning = false;
- }
-
- Rectangle {
- id: gameRect
- x: (mainWnd.width - width) / 2
- y: 5
- width: Lib.dimension * Lib.cellDimension
- height: Lib.dimension * Lib.cellDimension
- color: "transparent"
- border.width: 2
- }
-
- Mouse {
- id: mouseCtrl
- }
-
- Congratulation {
- id: congratulation
- visible: false
- }
-
-//! [1]
- TiltSensor {
- id: tiltSensor
- active: true
- }
-//! [1]
-
- //Timer to read out the x and y rotation of the TiltSensor
- Timer {
- id: tiltTimer
- interval: 50
- repeat: true
- running: tiltSensor.active && mainWnd.gameRunning
-
- onTriggered: {
- // Update the maze unless game is already won
- if (Lib.won === true) {
- gameWon()
- return
- }
- Lib.sec += 0.05;
- timePlayingLabel.text = Math.floor(Lib.sec) + " seconds";
-
- //check if we can move the mouse
- var xval = -1;
- var yval = -1;
-
-//! [2]
- var xstep = 0;
- xstep = tiltSensor.reading.yRotation * 0.1 //acceleration
-
- var ystep = 0;
- ystep = tiltSensor.reading.xRotation * 0.1 //acceleration
-//! [2]
-//! [3]
- if (xstep < 1 && xstep > 0)
- xstep = 0
- else if (xstep > -1 && xstep < 0)
- xstep = 0
-
- if (ystep < 1 && ystep > 0)
- ystep = 0;
- else if (ystep > -1 && ystep < 0)
- ystep = 0;
-
- if ((xstep < 0 && mouseCtrl.x > 0
- && Lib.canMove(mouseCtrl.x + xstep,mouseCtrl.y))) {
- xval = mouseCtrl.x + xstep;
-
- } else if (xstep > 0 && mouseCtrl.x < (Lib.cellDimension * (Lib.dimension - 1))
- && Lib.canMove(mouseCtrl.x + xstep,mouseCtrl.y)) {
- xval = mouseCtrl.x + xstep;
- } else
- xval = mouseCtrl.x;
-
- if (ystep < 0 && mouseCtrl.y > 0
- && Lib.canMove(mouseCtrl.x, mouseCtrl.y + ystep)) {
- yval = mouseCtrl.y + ystep;
- } else if (ystep > 0 && (mouseCtrl.y < (Lib.cellDimension * (Lib.dimension - 1)))
- && Lib.canMove(mouseCtrl.x, mouseCtrl.y + ystep)) {
- yval = mouseCtrl.y + ystep;
- } else
- yval = mouseCtrl.y
- mouseCtrl.move(xval, yval);
-//! [3]
- }
- }
-
- //Button to start a new Game
- Button{
- id: newGameButton
- anchors.left: gameRect.left
- anchors.top: gameRect.bottom
- anchors.topMargin: 5
- height: 30
- width: 100
- text: qsTr("New game")
- onClicked: newGame()
- }
- Button{
- id: calibrateButton
- anchors.left: gameRect.left
- anchors.top: newGameButton.bottom
- anchors.topMargin: 5
- height: 30
- width: 100
- text: qsTr("Calibrate")
- onClicked: tiltSensor.calibrate();
- }
-
- Text {
- id: tiltSensorInfo
- visible: tiltSensor.active
- anchors.left: gameRect.left
- anchors.top: calibrateButton.bottom
- anchors.topMargin: 5
- text: qsTr("Tilt sensor ID: ") + tiltSensor.identifier
- }
-
- //Label to print out the game time
- Text{
- id: timePlayingLabel
- anchors.right: gameRect.right
- anchors.top: gameRect.bottom
- anchors.topMargin: 5
- }
-
- Rectangle {
- id: tiltSensorMissing
- visible: !tiltSensor.active
- anchors.fill: parent
- color: "#AACCCCCC" // slightly transparent
- Text {
- anchors.centerIn: parent
- text: qsTr("Tilt sensor\nnot found")
- font.pixelSize: 24
- font.bold: true
- color: "black"
- }
- MouseArea {
- // prevent interaction with the game
- anchors.fill: parent
- }
- }
-}
-
diff --git a/examples/sensors/maze/maze.qrc b/examples/sensors/maze/maze.qrc
deleted file mode 100644
index 10916193..00000000
--- a/examples/sensors/maze/maze.qrc
+++ /dev/null
@@ -1,21 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>Congratulation.qml</file>
- <file>LabyrinthSquare.qml</file>
- <file>lib.js</file>
- <file>maze.qml</file>
- <file>Mouse.qml</file>
- <file>components/ApplicationWindow.qml</file>
- <file>components/Button.qml</file>
- <file>components/images/button_background_disabled.png</file>
- <file>components/images/button_background_pressed.png</file>
- <file>components/images/button_background_normal.png</file>
- <file>content/00.png</file>
- <file>content/start.png</file>
- <file>content/mouse_down.gif</file>
- <file>content/congratulations.gif</file>
- <file>content/cheeseeating.gif</file>
- <file>content/cheese.png</file>
- <file>content/01.png</file>
- </qresource>
-</RCC>
diff --git a/examples/sensors/qmlqtsensors/CMakeLists.txt b/examples/sensors/qmlqtsensors/CMakeLists.txt
deleted file mode 100644
index 9c1146cf..00000000
--- a/examples/sensors/qmlqtsensors/CMakeLists.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(qmlqtsensors LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/qmlqtsensors")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick)
-
-qt_add_executable(qmlqtsensors
- main.cpp
-)
-
-set_target_properties(qmlqtsensors PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(qmlqtsensors PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Quick
-)
-
-# Resources:
-set(qmlqtsensors_resource_files
- "components/ApplicationWindow.qml"
- "components/Button.qml"
- "components/Divider.qml"
- "components/images/button_background_disabled.png"
- "components/images/button_background_normal.png"
- "components/images/button_background_pressed.png"
- "qmlqtsensors.qml"
-)
-
-qt6_add_resources(qmlqtsensors "qmlqtsensors"
- PREFIX
- "/"
- FILES
- ${qmlqtsensors_resource_files}
-)
-
-install(TARGETS qmlqtsensors
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/sensors/qmlqtsensors/components/ApplicationWindow.qml b/examples/sensors/qmlqtsensors/components/ApplicationWindow.qml
deleted file mode 100644
index a2e90655..00000000
--- a/examples/sensors/qmlqtsensors/components/ApplicationWindow.qml
+++ /dev/null
@@ -1,12 +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
-
-Rectangle {
- id: appWnd
- width: 320
- height: 480
- color: "#868482"
-}
diff --git a/examples/sensors/qmlqtsensors/components/Button.qml b/examples/sensors/qmlqtsensors/components/Button.qml
deleted file mode 100644
index 953424a4..00000000
--- a/examples/sensors/qmlqtsensors/components/Button.qml
+++ /dev/null
@@ -1,38 +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: 100
- property alias text: innerText.text
- signal clicked
-
- Image {
- id: backgroundImage
- anchors.fill: parent
- source: (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
- }
-
- Text {
- id: innerText
- anchors.centerIn: parent
- color: "white"
- font.bold: true
- }
-
- //Mouse area to react on click events
- MouseArea {
- anchors.fill: button
- onClicked: { button.clicked();}
- onPressed: {
- backgroundImage.source = "images/button_background_pressed.png" }
- onReleased: {
- backgroundImage.source = (button.enabled ? "images/button_background_normal.png" : "images/button_background_disabled.png")
- }
- }
-}
diff --git a/examples/sensors/qmlqtsensors/components/Divider.qml b/examples/sensors/qmlqtsensors/components/Divider.qml
deleted file mode 100644
index 4856d665..00000000
--- a/examples/sensors/qmlqtsensors/components/Divider.qml
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-
-Column {
- spacing: 5
- width: parent.width
- property alias label: textLabel.text
-
- Rectangle {
- border.width: 1
- height: 2
- width: parent.width
- anchors.margins: 20
- border.color: "#2d2b19"
- }
- Text {
- id: textLabel
- width: parent.width
- horizontalAlignment: Text.AlignHCenter
- font.bold: true
- }
-}
diff --git a/examples/sensors/qmlqtsensors/components/images/button_background_disabled.png b/examples/sensors/qmlqtsensors/components/images/button_background_disabled.png
deleted file mode 100644
index 62a00b9a..00000000
--- a/examples/sensors/qmlqtsensors/components/images/button_background_disabled.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/qmlqtsensors/components/images/button_background_normal.png b/examples/sensors/qmlqtsensors/components/images/button_background_normal.png
deleted file mode 100644
index 1fecad5b..00000000
--- a/examples/sensors/qmlqtsensors/components/images/button_background_normal.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/qmlqtsensors/components/images/button_background_pressed.png b/examples/sensors/qmlqtsensors/components/images/button_background_pressed.png
deleted file mode 100644
index e0ba0e7a..00000000
--- a/examples/sensors/qmlqtsensors/components/images/button_background_pressed.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc b/examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc
deleted file mode 100644
index 410fb2c1..00000000
--- a/examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example qmlqtsensors
- \title Qt Sensors - QML Example
- \ingroup qtsensors-examples
- \image qmlqtsensors.png
-
- \section2 Qt Sensors in QML
- \brief The QtSensors - QML example demonstrates the QML sensors types in the QtSensors import.
-
-
- To write a QML application that will use the QML sensors types in the QtSensors import you need to to the following steps:
-
- Import the QtSensors declarative plugin:
-
- \snippet qmlqtsensors/qmlqtsensors.qml 0
-
- Add the Sensor QML types into your qml file.
-
- In this example we use the TiltSensor:
-
- \snippet qmlqtsensors/qmlqtsensors.qml 1
-
- The Tilt-, AmbientLight- and the Proximity QML sensor types have the 'enabled' property in common.
- To start or stop the sensor set this property to true or false.
-
- \snippet qmlqtsensors/qmlqtsensors.qml 2
-
- Reading the data can be done for each sensor type like following:
-
- \l {TiltSensor} {TiltSensor}
-
- \snippet qmlqtsensors/qmlqtsensors.qml 3
- \snippet qmlqtsensors/qmlqtsensors.qml 4
-
- \l {AmbientLightSensor} {AmbientLightSensor}
-
- \snippet qmlqtsensors/qmlqtsensors.qml 5
-
- \l {ProximitySensor} {ProximitySensor}
-
- \snippet qmlqtsensors/qmlqtsensors.qml 6
-*/
-
diff --git a/examples/sensors/qmlqtsensors/main.cpp b/examples/sensors/qmlqtsensors/main.cpp
deleted file mode 100644
index 48705436..00000000
--- a/examples/sensors/qmlqtsensors/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(qmlqtsensors)
diff --git a/examples/sensors/qmlqtsensors/qmlqtsensors.pro b/examples/sensors/qmlqtsensors/qmlqtsensors.pro
deleted file mode 100644
index 4c8e83b3..00000000
--- a/examples/sensors/qmlqtsensors/qmlqtsensors.pro
+++ /dev/null
@@ -1,16 +0,0 @@
-TEMPLATE = app
-TARGET = qmlqtsensors
-QT += quick
-qtConfig(static):QT += sensors
-
-SOURCES = main.cpp
-
-RESOURCES += \
- qmlqtsensors.qrc
-
-OTHER_FILES = \
- $$files(*.qml) \
- components
-
-target.path = $$[QT_INSTALL_EXAMPLES]/sensors/qmlqtsensors
-INSTALLS += target
diff --git a/examples/sensors/qmlqtsensors/qmlqtsensors.qml b/examples/sensors/qmlqtsensors/qmlqtsensors.qml
deleted file mode 100644
index 43bf140a..00000000
--- a/examples/sensors/qmlqtsensors/qmlqtsensors.qml
+++ /dev/null
@@ -1,212 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-/* Layout
- mainWnd
- /
----------------------------------------------------------------------------------
-|--------------------------------------------------------------------------------
-|| labelTitle |
-|--------------------------------------------------------------------------------
-|-------------------------------------------------------------------------------- <---- tiltLine
-|--------------------------------------------------------------------------------
-|| labelTilt |
-|--------------------------------------------------------------------------------
-| / accuracyRect / speedRect
-|-------------------------------------------||----------------------------------|
-|| Accuracy <----- textAccuracy || Speed <-----textSpeed |
-|| value <- textAccuracyValue || value <- textSpeedValue |
-|| ----------------- ------------------ || --------------- ---------------- |
-|| | accuracyLower | | accuracyHigher | || | speedLower | | speedHigher | |
-|| ----------------- ------------------ || --------------- ---------------- |
-|------------------------------------------ ||----------------------------------|
-| -----------
-| |Calibrate| <------------------ calibrate
-| -----------
-| ---------
-| |Degree | <-------------------- useRadian X Rotation: 0 <------------------ xrottext
-| ---------
-| ---------
-| |Start | <-------------------- tiltStart Y Rotation: 0 <------------------ yrottext
-| ---------
-|-------------------------------------------------------------------------------- <---- ambientlightLine
-|--------------------------------------------------------------------------------
-|| labelAmbientLight |
-|--------------------------------------------------------------------------------
-| ---------
-| |Start | <-------------------- ablStart Ambient light: - <--------------- abltext
-| ---------
-|-------------------------------------------------------------------------------- <---- proximityLine
-|--------------------------------------------------------------------------------
-|| labelProximityLight |
-|--------------------------------------------------------------------------------
-| ---------
-| |Start | <-------------------- proxiStart Proximity: - <--------------- proxitext
-| ---------
-------------------------------------------------------------------------------
-*/
-
-//Import the declarative plugins
-import QtQuick
-import "components"
-
-//! [0]
-import QtSensors
-//! [0]
-
-ApplicationWindow {
-
- anchors.fill: parent
-
- // Sensor types used
- //! [1]
- TiltSensor {
- id: tilt
- active: false
- }
- //! [1]
-
- AmbientLightSensor {
- id: ambientlight
- active: false
- //! [5]
- onReadingChanged: {
- if (reading.lightLevel == AmbientLightReading.Dark)
- ambientlighttext.text = "Ambient light: Dark";
- else if (reading.lightLevel == AmbientLightReading.Twilight)
- ambientlighttext.text = "Ambient light: Twilight";
- else if (reading.lightLevel == AmbientLightReading.Light)
- ambientlighttext.text = "Ambient light: Light";
- else if (reading.lightLevel == AmbientLightReading.Bright)
- ambientlighttext.text = "Ambient light: Bright";
- else if (reading.lightLevel == AmbientLightReading.Sunny)
- ambientlighttext.text = "Ambient light: Sunny";
- else
- ambientlighttext.text = "Ambient light: Unknown";
- }
- //! [5]
- }
-
- ProximitySensor {
- id: proxi
- active: false
- }
-
- Column {
- spacing: 10
- anchors.fill: parent
- anchors.margins: 5
-
- Text {
- id: labelTitle
- width: parent.width
- horizontalAlignment: Text.AlignHCenter
- font.pixelSize: 30
- font.bold: true
- text: "QML QtSensors"
- }
-
- // Tilt region
- Divider { label: "TiltSensor" }
-
- Row {
- spacing: 20
- width: parent.width
- anchors.margins: 5
- Button {
- id: calibrate
- height: 30
- width: 80
- text: "Calibrate"
- onClicked: tilt.calibrate();
- }
- Text {
- id: xrottext
- height: 30
- verticalAlignment: Text.AlignVCenter
- //! [3]
- text: "X Rotation: " + (tilt.reading ? tilt.reading.xRotation.toFixed(2) + "°" : "Unknown")
- //! [3]
- }
- }
- Row {
- spacing: 20
- width: parent.width
- anchors.margins: 5
- Button {
- id: tiltStart
- height: 30
- width: 80
- text: tilt.active ? "Stop" : "Start"
- onClicked: {
- //! [2]
- tilt.active = (tiltStart.text === "Start");
- //! [2]
- }
- }
- Text {
- id: yrottext
- height: 30
- verticalAlignment: Text.AlignVCenter
- //! [4]
- text: "Y Rotation: " + (tilt.reading ? tilt.reading.yRotation.toFixed(2) + "°" : "Unknown")
- //! [4]
- }
- }
-
- Divider { label: "AmbientLightSensor" }
-
- Row {
- spacing: 20
- width: parent.width
- anchors.margins: 5
-
- Button{
- id: ambientlightStart
- height: 30
- width: 80
- text: ambientlight.active ? "Stop" : "Start"
- onClicked: {
- ambientlight.active = (ambientlightStart.text === "Start" ? true : false);
- }
- }
-
- Text {
- id: ambientlighttext
- height: 30
- verticalAlignment: Text.AlignVCenter
- text: "Ambient light: Unknown"
- }
- }
-
- // Proximity region
- Divider { label: "ProximitySensor" }
-
- Row {
- spacing: 20
- width: parent.width
- anchors.margins: 5
-
- Button {
- id: proxiStart
- height: 30
- width: 80
- text: proxi.active ? "Stop" : "Start"
-
- onClicked: {
- proxi.active = (proxiStart.text === "Start" ? true: false);
- }
- }
-
- Text {
- id: proxitext
- height: 30
- verticalAlignment: Text.AlignVCenter
- //! [6]
- text: "Proximity: " +
- (proxi.active ? (proxi.reading.near ? "Near" : "Far") : "Unknown")
- //! [6]
- }
- }
- }
-}
diff --git a/examples/sensors/qmlqtsensors/qmlqtsensors.qrc b/examples/sensors/qmlqtsensors/qmlqtsensors.qrc
deleted file mode 100644
index 4ba06dad..00000000
--- a/examples/sensors/qmlqtsensors/qmlqtsensors.qrc
+++ /dev/null
@@ -1,11 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>qmlqtsensors.qml</file>
- <file>components/ApplicationWindow.qml</file>
- <file>components/Button.qml</file>
- <file>components/images/button_background_disabled.png</file>
- <file>components/images/button_background_normal.png</file>
- <file>components/images/button_background_pressed.png</file>
- <file>components/Divider.qml</file>
- </qresource>
-</RCC>
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/sensor_explorer/CMakeLists.txt b/examples/sensors/sensor_explorer/CMakeLists.txt
deleted file mode 100644
index 33fc7ea8..00000000
--- a/examples/sensors/sensor_explorer/CMakeLists.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
-
-cmake_minimum_required(VERSION 3.16)
-project(sensor_explorer LANGUAGES CXX)
-
-set(CMAKE_AUTOMOC ON)
-
-if(NOT DEFINED INSTALL_EXAMPLESDIR)
- set(INSTALL_EXAMPLESDIR "examples")
-endif()
-
-set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/sensor_explorer")
-
-find_package(Qt6 REQUIRED COMPONENTS Qml Quick Sensors)
-
-qt_add_executable(sensor_explorer
- main.cpp
- sensormodels.cpp sensormodels.h
-)
-
-set_target_properties(sensor_explorer PROPERTIES
- WIN32_EXECUTABLE TRUE
- MACOSX_BUNDLE TRUE
-)
-
-target_link_libraries(sensor_explorer PUBLIC
- Qt::Qml
- Qt::Quick
- Qt::Sensors
-)
-
-qt_add_qml_module(sensor_explorer
- URI SensorModels
- VERSION 1.0
- QML_FILES sensor_explorer.qml
- NO_RESOURCE_TARGET_PATH
-)
-
-install(TARGETS sensor_explorer
- RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
- BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
- LIBRARY DESTINATION "${INSTALL_EXAMPLEDIR}"
-)
diff --git a/examples/sensors/sensor_explorer/doc/images/qtsensors-examples-sensor-explorer.png b/examples/sensors/sensor_explorer/doc/images/qtsensors-examples-sensor-explorer.png
deleted file mode 100644
index 830f9597..00000000
--- a/examples/sensors/sensor_explorer/doc/images/qtsensors-examples-sensor-explorer.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc b/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc
deleted file mode 100644
index f4d7c6bc..00000000
--- a/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
-
-/*!
- \example sensor_explorer
- \title Qt Sensors - Explorer QML Example
- \ingroup qtsensors-examples
- \brief Demonstrates how to read the meta-data of available sensors.
-
- \image qtsensors-examples-sensor-explorer.png
-
- The example is implemented as a typical model-view application. The
- models are written with C++ and exposed to QML, and the views are
- implemented as QML types in the QML application.
-
- \section1 Exposing and Importing the Models
-
- The QML models written in C++ are exposed in the project build files
- as a \c SensorModels QML module.
-
- \e CMake:
- \code
- qt_add_qml_module(sensor_explorer
- URI SensorModels
- VERSION 1.0
- )
- \endcode
-
- \e qmake:
- \code
- CONFIG += qmltypes
- QML_IMPORT_NAME = SensorModels
- QML_IMPORT_MAJOR_VERSION = 1
- \endcode
-
- The individual model elements are exposed as part of the model
- code by using the \c QML_ELEMENT macro as illustrated here:
- \snippet sensor_explorer/sensormodels.h 0
-
- To access the models in the QML application, the module is imported
- by the application QML:
- \snippet sensor_explorer/sensor_explorer.qml 0
-
- \section1 Populating the Model of Available Sensors
-
- The \c AvailableSensorsModel is a list model that provides information on
- available sensors on the device. The model is populated once at the
- element's construction time:
-
- \snippet sensor_explorer/sensormodels.cpp 0
-
- The model's \c data() function returns a pointer to the requested sensor
- object.
-
- \snippet sensor_explorer/sensormodels.cpp 1
-
- Since the sensor (QSensor) is a QObject, the QML is then able to directly
- access all metaproperties and -functions directly.
-
- \note It would be possible to refresh the sensor list later at will, but for
- the simplicity of the example such functionality is not exposed to QML.
-
- \section1 Populating the Model of Sensor Properties
-
- The \c SensorPropertyModel is a table model that provides individual
- sensor's property-value pairs as columns. The column \c 0 provides the
- property's name and the column \c 1 provides the property's value. The
- population of the properties is done by reading the metadata of the sensors.
- The model reads both the sensor's metadata as well as the sensor's reading's
- metadata. The code below illustrates the reading of the \c reading metadata:
-
- \snippet sensor_explorer/sensormodels.cpp 2
-
- This metadata access allows providing the model data for all sensors
- without prior compile-time understanding of their properties.
-
- Once the metadata is set, the code then subscribes to the
- QSensor::readingChanged() signal to detect sensor reading changes.
- Upon such changes (for example a rotation value changes), the model data
- is updated accordingly.
-
- \section1 Viewing the Models
-
- The QML application is based on two views. The first view shows the available
- sensors as a selectable list. The second view shows the selected sensor's
- properties and their values. The delegates for viewing the individual items
- are simplistic \e {rectangle and text} items.
-
- Binding the two views functionally together is done by binding the property
- model's \c sensor property to the current selection of the available sensors
- model:
-
- \snippet sensor_explorer/sensor_explorer.qml 1
-
- When the selected sensor changes, the \c sensor of the property model changes
- accordingly.
-
- The following snippet illustrates how the property view is implemented. For
- more details about QML models and views, please see
- \l{Models and Views in Qt Quick}.
-
- \snippet sensor_explorer/sensor_explorer.qml 3
-
- For clarity it should be mentioned that the \c display attribute used by
- the text element refers to the Qt::DisplayRole role of the model, which is
- provided by default by Qt models.
-
- \section1 Activating the Sensors
-
- The example has a button for activating and deactivating the currently
- selected sensor. The button is enabled only if a sensor is currently
- selected, as illustrated below.
-
- \snippet sensor_explorer/sensor_explorer.qml 2
-
- On clicking the button, the sensor's active property is toggled on/off.
-
-*/
diff --git a/examples/sensors/sensor_explorer/main.cpp b/examples/sensors/sensor_explorer/main.cpp
deleted file mode 100644
index 4eeaa147..00000000
--- a/examples/sensors/sensor_explorer/main.cpp
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtQml>
-#include <QtQuick/QQuickWindow>
-#include <QtGui/QGuiApplication>
-
-int main(int argc, char *argv[])
-{
- QGuiApplication app(argc, argv);
- QQmlApplicationEngine engine(QUrl("qrc:///sensor_explorer.qml"));
- QObject *topLevel = engine.rootObjects().value(0);
- QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
- if (!window) {
- qWarning("Error: Your root item has to be a Window.");
- return -1;
- }
- window->show();
- return app.exec();
-}
diff --git a/examples/sensors/sensor_explorer/qml.qrc b/examples/sensors/sensor_explorer/qml.qrc
deleted file mode 100644
index df6160ae..00000000
--- a/examples/sensors/sensor_explorer/qml.qrc
+++ /dev/null
@@ -1,5 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>sensor_explorer.qml</file>
- </qresource>
-</RCC>
diff --git a/examples/sensors/sensor_explorer/sensor_explorer.pro b/examples/sensors/sensor_explorer/sensor_explorer.pro
deleted file mode 100644
index a27681e2..00000000
--- a/examples/sensors/sensor_explorer/sensor_explorer.pro
+++ /dev/null
@@ -1,22 +0,0 @@
-TEMPLATE = app
-TARGET = sensor_explorer
-QT += qml quick sensors
-
-# Avoid going to release/debug subdirectory
-win32: DESTDIR = ./
-
-SOURCES = main.cpp sensormodels.cpp
-HEADERS = sensormodels.h
-
-CONFIG += qmltypes
-QML_IMPORT_NAME = SensorModels
-QML_IMPORT_MAJOR_VERSION = 1
-
-OTHER_FILES = \
- sensor_explorer.qml
-
-target.path = $$[QT_INSTALL_EXAMPLES]/sensors/sensor_explorer
-INSTALLS += target
-
-RESOURCES += \
- qml.qrc
diff --git a/examples/sensors/sensor_explorer/sensor_explorer.qml b/examples/sensors/sensor_explorer/sensor_explorer.qml
deleted file mode 100644
index 9fe59baa..00000000
--- a/examples/sensors/sensor_explorer/sensor_explorer.qml
+++ /dev/null
@@ -1,127 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Window
-import QtQuick.Controls
-import QtQuick.Layouts
-
-//! [0]
-import SensorModels
-//! [0]
-
-Window {
- id: window
- width: 400
- height: 600
-
- AvailableSensorsModel {
- id: availableSensorsModel
- }
-
- ColumnLayout {
-
- GroupBox {
- id: availableSensorsModelGroup
- title: qsTr("Available Sensors")
- Layout.preferredWidth: window.width - 4 // 4 = 2x2 margins
- Layout.preferredHeight: window.height * 0.4
- Layout.margins: 2
-
- ListView {
- id: sensorsView
- anchors.fill: parent
- currentIndex: -1 // no initial selection
- spacing: 1
- clip: true
- model: availableSensorsModel
- delegate: Item {
- id: sensorRow
- width: sensorsView.width
- height: 30
- property color rowColor: {
- if (sensorsView.currentIndex == index)
- return "lightsteelblue" // highlight
- return (index % 2 == 0) ? "#CCCCCC" : "#AAAAAA"
- }
- RowLayout {
- spacing: 1
- anchors.fill: parent
- Rectangle {
- color: sensorRow.rowColor
- Layout.preferredWidth: sensorRow.width * 0.8
- Layout.preferredHeight: sensorRow.height
- Text {
- anchors.centerIn: parent
- text: display.type + "::" + display.identifier
- }
- }
- Rectangle {
- color: sensorRow.rowColor
- Layout.preferredWidth: sensorRow.width * 0.2
- Layout.preferredHeight: sensorRow.height
- Text {
- anchors.centerIn: parent
- text: display.active ? qsTr("Active") : qsTr("Inactive")
- }
- }
- }
- MouseArea {
- anchors.fill: parent
- onClicked: sensorsView.currentIndex = index
- }
- }
- }
- }
-
- //! [1]
- SensorPropertyModel {
- id: propertyModel
- sensor: availableSensorsModel.get(sensorsView.currentIndex)
- }
- //! [1]
-
- //! [2]
- Button {
- id: activateButton
- Layout.preferredHeight: 30
- Layout.alignment: Qt.AlignCenter
- enabled: propertyModel.sensor
- text: !propertyModel.sensor ? qsTr("Select sensor")
- : (propertyModel.sensor.active ? qsTr("Deactivate sensor")
- : qsTr("Activate sensor"))
- onClicked: propertyModel.sensor.active = !propertyModel.sensor.active
- }
- //! [2]
-
- GroupBox {
- title: qsTr("Selected sensor's properties")
- Layout.preferredWidth: window.width - 4 // 4 = 2x2 margins
- Layout.preferredHeight: window.height * 0.55 - activateButton.height
- Layout.margins: 2
- enabled: sensorsView.currentIndex != -1
-
- //! [3]
- TableView {
- id: propertyView
- anchors.fill: parent
- model: propertyModel
- columnSpacing: 1
- rowSpacing: 1
- boundsMovement: Flickable.StopAtBounds
- clip: true
-
- delegate: Rectangle {
- implicitHeight: 30
- implicitWidth: propertyView.width * 0.5
- color: (model.row % 2 == 0) ? "#CCCCCC" : "#AAAAAA"
- Text {
- anchors.centerIn: parent
- text: display
- }
- }
- }
- //! [3]
- }
- }
-}
diff --git a/examples/sensors/sensor_explorer/sensormodels.cpp b/examples/sensors/sensor_explorer/sensormodels.cpp
deleted file mode 100644
index b0aa7189..00000000
--- a/examples/sensors/sensor_explorer/sensormodels.cpp
+++ /dev/null
@@ -1,191 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include "sensormodels.h"
-#include "qsensor.h"
-#include "qorientationsensor.h"
-#include <QtCore/QDebug>
-#include <qsensor.h>
-#include <QMetaObject>
-#include <QMetaProperty>
-
-QT_BEGIN_NAMESPACE
-
-QByteArray rangelistToByteArray(const qrangelist& list)
-{
- QStringList ranges;
- for (const qrange &r : list) {
- if (r.first == r.second)
- ranges << QString("%1 Hz").arg(r.first);
- else
- ranges << QString("%1-%2 Hz").arg(r.first).arg(r.second);
- }
- if (ranges.count() > 0)
- return ranges.join(", ").toLatin1();
- return "-";
-}
-
-QByteArray outputrangelistToByteArray(const qoutputrangelist& list)
-{
- QStringList ranges;
- for (const qoutputrange &r : list) {
- ranges << QString("(%1, %2) += %3").arg(r.minimum).arg(r.maximum).arg(r.accuracy);
- }
- if (ranges.count() > 0)
- return ranges.join(", ").toLatin1();
- return "-";
-}
-
-AvailableSensorsModel::AvailableSensorsModel(QObject* parent) : QAbstractListModel(parent)
-{
- // Some valuetypes do not convert nicely to presentable strings, add converters for them
- QMetaType::registerConverter<qrangelist, QByteArray>(rangelistToByteArray);
- QMetaType::registerConverter<qoutputrangelist, QByteArray>(outputrangelistToByteArray);
-
- // Populate the available sensors list
- loadSensors();
-}
-
-/*
- Load all available sensors and store them in a list.
-*/
-void AvailableSensorsModel::loadSensors()
-{
- //! [0]
- beginResetModel();
- m_availableSensors.clear();
-
- for (const QByteArray &type : QSensor::sensorTypes()) {
- for (const QByteArray &identifier : QSensor::sensorsForType(type)) {
- QSensor* sensor = new QSensor(type, this);
- sensor->setIdentifier(identifier);
- // Don't put in sensors we can't connect to
- if (!sensor->connectToBackend())
- continue;
- m_availableSensors.append(sensor);
- }
- }
- endResetModel();
- //! [0]
-}
-
-int AvailableSensorsModel::rowCount(const QModelIndex&) const
-{
- return m_availableSensors.count();
-}
-
-//! [1]
-QVariant AvailableSensorsModel::data(const QModelIndex &index, int role) const
-{
- if (role != Qt::DisplayRole)
- return QVariant();
- return QVariant::fromValue<QSensor*>(m_availableSensors.at(index.row()));
-}
-//! [1]
-
-QSensor* AvailableSensorsModel::get(int index) const
-{
- if (index < 0 || index >= m_availableSensors.count())
- return nullptr;
- return m_availableSensors[index];
-}
-
-// -- SensorPropertyModel
-
-static QSet<QByteArray> ignoredProperties = {"reading", "identifier", "active",
- "connectedToBackend", "busy"};
-
-SensorPropertyModel::SensorPropertyModel(QObject* parent) : QAbstractTableModel(parent)
-{
-}
-
-int SensorPropertyModel::rowCount(const QModelIndex&) const
-{
- if (!m_sensor)
- return 0;
- return m_values.count();
-}
-
-int SensorPropertyModel::columnCount(const QModelIndex&) const
-{
- return 2; // 2 = property name + value columns
-}
-
-QVariant SensorPropertyModel::data(const QModelIndex &index, int role) const
-{
- if (role != Qt::DisplayRole)
- return QVariant();
- return (index.column() == 0) ? std::get<0>(m_values.at(index.row()))
- : std::get<1>(m_values.at(index.row()));
-}
-
-void SensorPropertyModel::setSensor(QSensor *sensor)
-{
- if (m_sensor == sensor)
- return;
- if (m_sensor)
- m_sensor->disconnect(this);
- m_sensor = sensor;
-
- beginResetModel();
- m_values.clear();
- if (m_sensor) {
- // Use metobject to read the available properties. This allows the model to support all
- // available sensors without knowing their properties in advance / compile-time.
-
- // 1. Read properties of the 'reading' object if available
- //! [2]
- int firstProperty = QSensorReading::staticMetaObject.propertyOffset();
- QSensorReading *reading = m_sensor->reading();
- if (reading) {
- const QMetaObject *mo = reading->metaObject();
- for (int i = firstProperty; i < mo->propertyCount(); ++i) {
- QByteArray name = mo->property(i).name();
- m_values.append(std::tuple<QByteArray, QByteArray>
- (name, reading->property(name).toByteArray()));
- }
- }
- //! [2]
-
- // 2. Read properties of the 'sensor' object
- const QMetaObject *mo1 = m_sensor->metaObject();
- firstProperty = QSensorReading::staticMetaObject.propertyOffset();
- for (int i = firstProperty; i < mo1->propertyCount(); ++i) {
- QByteArray name = mo1->property(i).name();
- if (ignoredProperties.contains(name))
- continue;
- m_values.append(std::tuple<QByteArray, QByteArray>
- (name, m_sensor->property(name).toByteArray()));
- }
- QObject::connect(m_sensor, &QSensor::readingChanged,
- this, &SensorPropertyModel::onReadingChanged);
- }
- endResetModel();
- emit sensorChanged();
-}
-
-QSensor* SensorPropertyModel::sensor() const
-{
- return m_sensor;
-}
-
-void SensorPropertyModel::onReadingChanged()
-{
- QSensorReading *reading = m_sensor->reading();
- const QMetaObject *mo = reading->metaObject();
- int firstProperty = QSensorReading::staticMetaObject.propertyOffset();
-
- int valueMapIndex = 0;
- for (int i = firstProperty; i < mo->propertyCount(); ++i) {
- QByteArray name = mo->property(i).name();
- // Update the value and signal the change. Note: here we rely that the "reading"
- // properties are first on the m_values, and in same order as after the initial
- // population. This should be true as we access the static metabobject (dynamic
- // property changes shouldn't impact)
- m_values[valueMapIndex++] = std::tuple<QByteArray, QByteArray>
- (name, reading->property(name).toByteArray());
- }
- emit dataChanged(createIndex(0,1), createIndex(valueMapIndex,1), {Qt::DisplayRole});
-}
-
-QT_END_NAMESPACE
diff --git a/examples/sensors/sensor_explorer/sensormodels.h b/examples/sensors/sensor_explorer/sensormodels.h
deleted file mode 100644
index 02de2a8e..00000000
--- a/examples/sensors/sensor_explorer/sensormodels.h
+++ /dev/null
@@ -1,63 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#ifndef QSEONSOREXPLORER_H
-#define QSEONSOREXPLORER_H
-
-#include <QtSensors/qsensor.h>
-
-#include <QtQml/qqml.h>
-#include <QtCore/QAbstractListModel>
-#include <QtCore/QAbstractTableModel>
-
-QT_BEGIN_NAMESPACE
-
-//! [0]
-class AvailableSensorsModel: public QAbstractListModel
-{
- Q_OBJECT
- QML_ELEMENT
-//! [0]
-public:
- explicit AvailableSensorsModel(QObject* parent = nullptr);
- int rowCount(const QModelIndex & = QModelIndex()) const override;
- QVariant data(const QModelIndex &index, int role) const override;
- Q_INVOKABLE QSensor* get(int index) const;
-
-private:
- void loadSensors();
- QList<QSensor*> m_availableSensors;
-};
-
-class SensorPropertyModel: public QAbstractTableModel
-{
- Q_OBJECT
- Q_PROPERTY(QSensor* sensor READ sensor WRITE setSensor NOTIFY sensorChanged)
- QML_ELEMENT
-
-public:
- explicit SensorPropertyModel(QObject* parent = nullptr);
-
- int rowCount(const QModelIndex & = QModelIndex()) const override;
- int columnCount(const QModelIndex & = QModelIndex()) const override;
- QVariant data(const QModelIndex &index, int role) const override;
-
- void setSensor(QSensor* sensor);
- QSensor* sensor() const;
-
-signals:
- void sensorChanged();
-
-private slots:
- void onReadingChanged();
-
-private:
- QSensor* m_sensor = nullptr;
- // m_values is used to cache sensor property values to avoid
- // full metaobject iteration on every sensor reading change
- QList<std::tuple<QByteArray, QByteArray>> m_values;
-};
-
-QT_END_NAMESPACE
-
-#endif // QSEONSOREXPLORER_H
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
deleted file mode 100644
index 4d453cf2..00000000
--- a/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png
+++ /dev/null
Binary files differ
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>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
-&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
-p, li { white-space: pre-wrap; }
-&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;&quot;&gt;
-&lt;p style=&quot;-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;&quot;&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</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..d304cbd9 100644
--- a/examples/sensors/sensors.pro
+++ b/examples/sensors/sensors.pro
@@ -1,21 +1,5 @@
TEMPLATE = subdirs
-SUBDIRS += grue
-
-qtHaveModule(quick) {
- SUBDIRS += \
- maze \
- qmlqtsensors \
- sensor_explorer
- # qmlsensorgestures \
- # shakeit
-
- qtHaveModule(svg): SUBDIRS += \
- accelbubble
+qtHaveModule(quick): qtHaveModule(svg): {
+ SUBDIRS += sensorsshowcase
}
-
-# qtHaveModule(widgets): SUBDIRS += \
-# sensorgestures
-
-EXAMPLE_FILES += \
- stub.h
diff --git a/examples/sensors/sensorsshowcase/Accelerometer.qml b/examples/sensors/sensorsshowcase/Accelerometer.qml
new file mode 100644
index 00000000..a22e1404
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Accelerometer.qml
@@ -0,0 +1,70 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtQuick.Layouts
+import QtSensors
+
+Item {
+ id: root
+
+ required property int fontSize
+ required property int imageSize
+
+ //! [0]
+ Accelerometer {
+ id: accelerometer
+
+ property real x: 0
+ property real y: 0
+ property real z: 0
+
+ active: true
+ dataRate: 25
+
+ onReadingChanged: {
+ x = (reading as AccelerometerReading).x
+ y = (reading as AccelerometerReading).y
+ z = (reading as AccelerometerReading).z
+ imageTranslation.x = -x * 10
+ imageTranslation.y = y * 10
+ }
+ }
+ //! [0]
+ ColumnLayout {
+ id: layout
+
+ anchors.fill: parent
+ spacing: 10
+
+ Image {
+ id: image
+
+ Layout.alignment: Qt.AlignCenter
+ Layout.preferredHeight: root.imageSize
+ Layout.preferredWidth: root.imageSize
+ fillMode: Image.PreserveAspectFit
+ source: "images/qt_logo.png"
+
+ transform: [
+ Translate {
+ id: imageTranslation
+
+ x: 0
+ y: 0
+ }
+ ]
+ }
+
+ ProgressXYZBar {
+ Layout.fillWidth: true
+ fontSize: root.fontSize
+ xText: "X: " + accelerometer.x.toFixed(2)
+ xValue: 0.5 + (accelerometer.x / 100)
+ yText: "Y: " + accelerometer.y.toFixed(2)
+ yValue: 0.5 + (accelerometer.y / 100)
+ zText: "Z: " + accelerometer.z.toFixed(2)
+ zValue: 0.5 + (accelerometer.z / 100)
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/CMakeLists.txt b/examples/sensors/sensorsshowcase/CMakeLists.txt
index eb27f7ef..b949213a 100644
--- a/examples/sensors/sensorsshowcase/CMakeLists.txt
+++ b/examples/sensors/sensorsshowcase/CMakeLists.txt
@@ -1,18 +1,16 @@
-# Copyright (C) 2022 The Qt Company Ltd.
-# SPDX-License-Identifier: BSD-3-Clause
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
cmake_minimum_required(VERSION 3.16)
project(sensorsshowcase LANGUAGES CXX)
-set(CMAKE_AUTOMOC ON)
-
if(NOT DEFINED INSTALL_EXAMPLESDIR)
set(INSTALL_EXAMPLESDIR "examples")
endif()
set(INSTALL_EXAMPLEDIR "${INSTALL_EXAMPLESDIR}/sensors/sensorsshowcase")
-
-find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Sensors Svg)
+find_package(Qt6 REQUIRED COMPONENTS Core Gui Quick Svg Sensors)
+qt_standard_project_setup(REQUIRES 6.5)
qt_add_executable(sensorsshowcase
main.cpp
@@ -26,43 +24,47 @@ set_target_properties(sensorsshowcase PROPERTIES
if(ANDROID)
set_property(TARGET sensorsshowcase PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/android)
- endif()
-if(APPLE)
- if(IOS)
- set_property(TARGET sensorsshowcase PROPERTY
- MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
- )
- endif()
endif()
-target_link_libraries(sensorsshowcase PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Quick
- Qt::Sensors
- Qt::Svg
-)
+if(APPLE AND IOS)
+ set_property(TARGET sensorsshowcase PROPERTY
+ MACOSX_BUNDLE_INFO_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/Info.plist"
+ )
+else()
+ # default search path for the config file is "qrc:/"
+ qt_add_resources(sensorsshowcase "resources"
+ FILES qtquickcontrols2.conf)
+endif()
-# Resources:
-set(sensorsshowcase_resource_files
- "sensorsshowcase.qml"
- "accelerometer.qml"
- "proximity.qml"
- "compass.qml"
- "magnetometer.qml"
- "gyroscope.qml"
- "images/magnet.svg"
- "images/compass.svg"
- "images/qt_logo.png"
+qt_add_qml_module(sensorsshowcase
+ URI SensorShowcaseModule
+ VERSION 1.0
+ QML_FILES
+ "Main.qml"
+ "Accelerometer.qml"
+ "Compass.qml"
+ "Gyroscope.qml"
+ "Magnetometer.qml"
+ "Proximity.qml"
+ "ProgressXYZBar.qml"
+ RESOURCES
+ "images/compass.svg"
+ "images/magnet.svg"
+ "images/qt_logo.png"
+ SOURCES
+ sensorsupport.h
)
-qt6_add_resources(sensorsshowcase "sensorsshowcase"
- PREFIX
- "/"
- FILES
- ${sensorsshowcase_resource_files}
+target_link_libraries(sensorsshowcase
+ PRIVATE
+ Qt::Core
+ Qt::Gui
+ Qt::Quick
+ Qt::Svg
+ Qt::Sensors
)
+
install(TARGETS sensorsshowcase
RUNTIME DESTINATION "${INSTALL_EXAMPLEDIR}"
BUNDLE DESTINATION "${INSTALL_EXAMPLEDIR}"
diff --git a/examples/sensors/sensorsshowcase/Compass.qml b/examples/sensors/sensorsshowcase/Compass.qml
new file mode 100644
index 00000000..b4bc5ff1
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Compass.qml
@@ -0,0 +1,61 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtQuick.Layouts
+import QtSensors
+
+Item {
+ id: root
+
+ required property int fontSize
+ required property int imageSize
+ property alias isActive: compass.active
+
+ property real azimuth: 30
+
+ Compass {
+ id: compass
+ active: true
+ dataRate: 7
+ onReadingChanged: root.azimuth = -(reading as CompassReading).azimuth
+ }
+
+ ColumnLayout {
+ id: layout
+
+ anchors.fill: parent
+ spacing: 10
+
+ Image {
+ id: arrow
+
+ Layout.alignment: Qt.AlignHCenter
+ Layout.preferredWidth: root.imageSize * 1.25
+ Layout.fillHeight: true
+
+ source: "images/compass.svg"
+ fillMode: Image.PreserveAspectFit
+ rotation: root.azimuth
+ }
+
+ Rectangle {
+ id: separator
+
+ Layout.topMargin: 10
+ Layout.preferredWidth: parent.width * 0.75
+ Layout.preferredHeight: 1
+ Layout.alignment: Qt.AlignHCenter
+ color: "black"
+ }
+
+ Text {
+ id: info
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.topMargin: 10
+ text: "Azimuth: " + root.azimuth.toFixed(2) + "°"
+ font.pixelSize: root.fontSize
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/Gyroscope.qml b/examples/sensors/sensorsshowcase/Gyroscope.qml
new file mode 100644
index 00000000..9f0ffd2f
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Gyroscope.qml
@@ -0,0 +1,128 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+import QtSensors
+
+Item {
+ id: root
+
+ required property int fontSize
+ required property int imageSize
+
+ function resetRotations() : void
+ {
+ imageXRotation.angle = 0
+ imageYRotation.angle = 0
+ imageZRotation.angle = 0
+ }
+
+ //! [0]
+ Gyroscope {
+ id: gyroscope
+
+ property var lastTimeStamp: 0
+ property real x: 0
+ property real y: 0
+ property real z: 0
+
+ active: true
+ dataRate: 25
+
+ onReadingChanged: {
+ x = (reading as GyroscopeReading).x
+ y = (reading as GyroscopeReading).y
+ z = (reading as GyroscopeReading).z
+ let firstCall = false
+ if (lastTimeStamp == 0) {
+ firstCall = true
+ }
+ let timeSinceLast = reading.timestamp - lastTimeStamp
+ lastTimeStamp = reading.timestamp
+
+ //Skipping the initial time jump from 0
+ if (firstCall === true)
+ return
+ let normalizedX = x * (timeSinceLast / 1000000)
+ imageXRotation.angle += normalizedX
+ let normalizedY = y * (timeSinceLast / 1000000)
+ imageYRotation.angle -= normalizedY
+ let normalizedZ = z * (timeSinceLast / 1000000)
+ imageZRotation.angle += normalizedZ
+ }
+ }
+ //! [0]
+ ColumnLayout {
+ id: layout
+
+ anchors.fill: parent
+ spacing: 10
+
+ Image {
+ id: image
+
+ Layout.alignment: Qt.AlignHCenter
+ Layout.fillHeight: true
+ Layout.preferredWidth: root.imageSize
+ fillMode: Image.PreserveAspectFit
+ source: "images/qt_logo.png"
+
+ transform: [
+ Rotation {
+ id: imageXRotation
+
+ angle: 0
+ axis.x: 1
+ axis.y: 0
+ axis.z: 0
+ origin.x: layout.width / 2
+ origin.y: layout.height / 3
+ },
+ Rotation {
+ id: imageYRotation
+
+ angle: 0
+ axis.x: 0
+ axis.y: 1
+ axis.z: 0
+ origin.x: layout.width / 2
+ origin.y: layout.height / 3
+ },
+ Rotation {
+ id: imageZRotation
+
+ angle: 0
+ axis.x: 0
+ axis.y: 0
+ axis.z: 1
+ origin.x: layout.width / 2
+ origin.y: layout.height / 3
+ }
+ ]
+ }
+
+ ProgressXYZBar {
+ Layout.fillWidth: true
+ Layout.topMargin: 20
+ fontSize: root.fontSize
+ xText: "X: " + gyroscope.x.toFixed(2)
+ xValue: 0.5 + (gyroscope.x / 1000)
+ yText: "Y: " + gyroscope.y.toFixed(2)
+ yValue: 0.5 + (gyroscope.y / 1000)
+ zText: "Z: " + gyroscope.z.toFixed(2)
+ zValue: 0.5 + (gyroscope.z / 1000)
+ }
+
+ Button {
+ Layout.alignment: Qt.AlignHCenter
+ Layout.topMargin: 20
+ Layout.bottomMargin: 10
+ Layout.preferredWidth: parent.width / 2
+ Layout.preferredHeight: 60
+ onClicked: root.resetRotations()
+ text: "Reset rotation"
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/Magnetometer.qml b/examples/sensors/sensorsshowcase/Magnetometer.qml
new file mode 100644
index 00000000..551f8627
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Magnetometer.qml
@@ -0,0 +1,68 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtQuick.Layouts
+import QtSensors
+
+Item {
+ id: root
+
+ required property int fontSize
+ required property int imageSize
+
+ property real magnetRotation: 40
+ property real magnetometerX: 0
+ property real magnetometerY: 0
+ property real magnetometerZ: 0
+ property int barScaleFactor: 10000
+
+ //! [0]
+ Magnetometer {
+ id: magnetometer
+ active: true
+ dataRate: 25
+ onReadingChanged: {
+ root.magnetometerX = (reading as MagnetometerReading).x
+ root.magnetometerY = (reading as MagnetometerReading).y
+ root.magnetometerZ = (reading as MagnetometerReading).z
+ root.magnetRotation =
+ ((Math.atan2(root.magnetometerX, root.magnetometerY) / Math.PI) * 180)
+ }
+ }
+ //! [0]
+
+ ColumnLayout {
+ id: layout
+
+ anchors.fill: parent
+ spacing: 10
+
+ Image {
+ id: image
+
+ Layout.alignment: Qt.AlignHCenter
+ Layout.bottomMargin: 20
+ Layout.preferredWidth: root.imageSize * 0.9
+ Layout.preferredHeight: root.imageSize * 0.9
+
+ source: "images/magnet.svg"
+ fillMode: Image.PreserveAspectFit
+ rotation: root.magnetRotation
+ }
+
+ ProgressXYZBar {
+ Layout.fillWidth: true
+ fontSize: root.fontSize
+
+ xText: "X: " + root.magnetometerX.toFixed(9)
+ xValue: 0.5 + (root.magnetometerX * root.barScaleFactor)
+
+ yText: "Y: " + root.magnetometerY.toFixed(9)
+ yValue: 0.5 + (root.magnetometerY * root.barScaleFactor)
+
+ zText: "Z: " + root.magnetometerZ.toFixed(9)
+ zValue: 0.5 + (root.magnetometerZ * root.barScaleFactor)
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/Main.qml b/examples/sensors/sensorsshowcase/Main.qml
new file mode 100644
index 00000000..4587ba21
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Main.qml
@@ -0,0 +1,116 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
+
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+ApplicationWindow {
+ id: root
+
+ readonly property int defaultFontSize: 22
+ readonly property int imageSize: width / 2
+
+ width: 420
+ height: 760
+ visible: true
+ title: "Sensors Showcase"
+
+ header : ToolBar {
+ RowLayout {
+ anchors.fill: parent
+ anchors.leftMargin: 10
+ anchors.rightMargin: 10
+ ToolButton {
+ id: back
+ text: qsTr("Back")
+ font.pixelSize: root.defaultFontSize - 4
+ visible: stack.depth > 1
+ onClicked: {
+ stack.pop();
+ heading.text = root.title;
+ }
+ Layout.alignment: Qt.AlignLeft
+ }
+ Label {
+ id: heading
+ text: root.title
+ font.pixelSize: root.defaultFontSize
+ font.weight: Font.Medium
+ verticalAlignment: Qt.AlignVCenter
+ Layout.alignment: Qt.AlignCenter
+ Layout.preferredHeight: 55
+ }
+ Item {
+ visible: back.visible
+ Layout.preferredWidth: back.width
+ }
+ }
+ }
+
+ StackView {
+ id: stack
+
+ // Pushes the object and forwards the properties
+ function pusher(object : string) : void {
+ // Trim the suffix and set it as new heading
+ heading.text = object.split(".")[0]
+ return stack.push(object, {
+ fontSize: root.defaultFontSize,
+ imageSize: root.imageSize
+ })
+ }
+
+ anchors.fill: parent
+ anchors.margins: width / 12
+
+ initialItem: Item {
+ ColumnLayout {
+ id: initialItem
+
+ anchors.fill: parent
+ anchors.topMargin: 20
+ anchors.bottomMargin: 20
+ spacing: 5
+
+ component CustomButton: Button {
+ highlighted: true
+ font.pixelSize: root.defaultFontSize
+ font.letterSpacing: 1.5
+
+ Layout.alignment: Qt.AlignCenter
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ }
+
+ CustomButton {
+ text: "Accelerometer"
+ onClicked: stack.pusher("Accelerometer.qml")
+ enabled: SensorSupport.hasAccelerometer()
+ }
+ CustomButton {
+ text: "Proximity"
+ onClicked: stack.pusher("Proximity.qml")
+ enabled: SensorSupport.hasProximity()
+ }
+ CustomButton {
+ text: "Compass"
+ onClicked: stack.pusher("Compass.qml")
+ enabled: SensorSupport.hasCompass()
+ }
+ CustomButton {
+ text: "Magnetometer"
+ onClicked: stack.pusher("Magnetometer.qml")
+ enabled: SensorSupport.hasMagnetometer()
+ }
+ CustomButton {
+ text: "Gyroscope"
+ onClicked: stack.pusher("Gyroscope.qml")
+ enabled: SensorSupport.hasGyroscope()
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/sensors/sensorsshowcase/ProgressXYZBar.qml b/examples/sensors/sensorsshowcase/ProgressXYZBar.qml
new file mode 100644
index 00000000..be7bf7ae
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/ProgressXYZBar.qml
@@ -0,0 +1,45 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtQuick.Controls
+import QtQuick.Layouts
+
+ColumnLayout {
+ id: root
+ spacing: 0
+
+ required property int fontSize
+ property alias xText: xBar.text
+ property alias xValue: xBar.value
+ property alias yText: yBar.text
+ property alias yValue: yBar.value
+ property alias zText: zBar.text
+ property alias zValue: zBar.value
+
+ component NamedProgressBar: ColumnLayout {
+ property alias text: axes.text
+ property alias value: bar.value
+ Text {
+ id: axes
+ font.pixelSize: root.fontSize
+ Layout.fillWidth: true
+ }
+ ProgressBar {
+ id: bar
+ Layout.fillWidth: true
+ }
+ }
+
+ NamedProgressBar {
+ id: xBar
+ }
+
+ NamedProgressBar {
+ id: yBar
+ }
+
+ NamedProgressBar {
+ id: zBar
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/Proximity.qml b/examples/sensors/sensorsshowcase/Proximity.qml
new file mode 100644
index 00000000..41121983
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Proximity.qml
@@ -0,0 +1,55 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+pragma ComponentBehavior: Bound
+import QtQuick
+import QtQuick.Layouts
+import QtSensors
+
+Item {
+ id: root
+
+ required property int imageSize
+ required property int fontSize
+
+ property bool near: false
+
+ ProximitySensor {
+ id: proximity
+ onReadingChanged: root.near = (reading as ProximityReading).near
+ active: true
+ }
+
+ ColumnLayout {
+ id: layout
+
+ anchors.fill: parent
+ spacing: 10
+
+ Image {
+ id: image
+
+ Layout.alignment: Qt.AlignHCenter
+ Layout.preferredWidth: root.near ? root.imageSize : root.imageSize * 0.75
+ Layout.fillHeight: true
+
+ source: "images/qt_logo.png"
+ fillMode: Image.PreserveAspectFit
+ }
+
+ Rectangle {
+ id: separator
+ Layout.topMargin: 10
+ Layout.bottomMargin: 10
+ Layout.preferredWidth: parent.width * 0.75
+ Layout.preferredHeight: 1
+ Layout.alignment: Qt.AlignHCenter
+ color: "black"
+ }
+
+ Text {
+ Layout.fillHeight: true
+ font.pixelSize: root.fontSize
+ text: "Near: " + root.near
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/accelerometer.qml b/examples/sensors/sensorsshowcase/accelerometer.qml
deleted file mode 100644
index e4f6e39b..00000000
--- a/examples/sensors/sensorsshowcase/accelerometer.qml
+++ /dev/null
@@ -1,122 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtSensors
-
-Rectangle {
- id: root
- color: "dimgray"
-
- function resetRotations() {
- imageXRotation.angle = 0
- imageYRotation.angle = 0
- imageZRotation.angle = 0
- }
-
-//! [0]
- Accelerometer {
- id: accelerometer
- active: true
- dataRate: 25
-
- property real x: 0
- property real y: 0
- property real z: 0
-
- onReadingChanged: {
- x = reading.x
- y = reading.y
- z = reading.z
-
- imageTranslation.x = -reading.x * 10
- imageTranslation.y = reading.y * 10
- }
- }
-//! [0]
-
- ColumnLayout {
- anchors.fill: parent
- id: layout
-
- Text {
- Layout.topMargin: titleTopMargin
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- Layout.preferredHeight: textHeight
- color: "White"
- text: "Accelerometer"
- font.pixelSize: titleFontSize
- }
-
- Image {
- id: image
- Layout.alignment: Qt.AlignCenter
- Layout.fillHeight: true
- Layout.preferredWidth: root.width/2
- Layout.preferredHeight: root.height/3
- source: "qrc:/images/qt_logo.png"
- fillMode: Image.PreserveAspectFit
-
- transform: [
- Translate {
- id: imageTranslation
- x: 0
- y: 0
- }
- ]
- }
-
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "X: " + accelerometer.x.toFixed(2)
- font.pixelSize: textFontSize
- }
-
- ProgressBar {
- id: xbar
- value: 0.5 + (accelerometer.x / 100)
- Layout.preferredWidth: root.width
- }
-
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "Y: " + accelerometer.y.toFixed(2)
- font.pixelSize: textFontSize
- }
- ProgressBar {
- id: ybar
- value: 0.5 + (accelerometer.y / 100)
- Layout.preferredWidth: root.width
- }
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "Z: " + accelerometer.z.toFixed(2)
- font.pixelSize: textFontSize
- }
- ProgressBar {
- id: zbar
- value: 0.5 + (accelerometer.z / 100)
- Layout.preferredWidth: root.width
- }
- Button {
- Layout.alignment: Qt.AlignBottom
- Layout.preferredWidth: root.width
- Layout.preferredHeight: buttonHeight
- text:"Back"
- font.pixelSize: buttonFontSize
- onClicked:stack.pop()
- }
- }
-}
-
diff --git a/examples/sensors/sensorsshowcase/android/AndroidManifest.xml b/examples/sensors/sensorsshowcase/android/AndroidManifest.xml
index 3c152a90..359c0114 100644
--- a/examples/sensors/sensorsshowcase/android/AndroidManifest.xml
+++ b/examples/sensors/sensorsshowcase/android/AndroidManifest.xml
@@ -11,7 +11,6 @@
<!-- The comment below will be replaced with dependencies permissions upon deployment.
Remove the comment if you do not require these default features. -->
<!-- %%INSERT_FEATURES -->
-
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
@@ -22,26 +21,37 @@
android:extractNativeLibs="true"
android:hardwareAccelerated="true"
android:label="-- %%INSERT_APP_NAME%% --"
- android:requestLegacyExternalStorage="true">
+ android:requestLegacyExternalStorage="true"
+ android:allowNativeHeapPointerTagging="false"
+ android:allowBackup="true"
+ android:fullBackupOnly="false"
+ android:icon="@drawable/icon">
<activity
android:name="org.qtproject.qt.android.bindings.QtActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:label="-- %%INSERT_APP_NAME%% --"
android:launchMode="singleTop"
- android:screenOrientation="portrait">
+ android:screenOrientation="portrait"
+ android:exported="true">
<intent-filter>
- <action android:name="android.intent.action.MAIN"/>
- <category android:name="android.intent.category.LAUNCHER"/>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
+
<meta-data
android:name="android.app.lib_name"
android:value="-- %%INSERT_APP_LIB_NAME%% --" />
- <meta-data
- android:name="android.app.background_running"
- android:value="false" />
+
+ <meta-data android:name="android.app.arguments"
+ android:value="" />
+
<meta-data
android:name="android.app.extract_android_style"
android:value="minimal" />
+
+ <meta-data
+ android:name="android.app.background_running"
+ android:value="false" />
</activity>
</application>
</manifest>
diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-hdpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-hdpi/icon.png
new file mode 100644
index 00000000..5f61088b
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/android/res/drawable-hdpi/icon.png
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-ldpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-ldpi/icon.png
new file mode 100644
index 00000000..605497de
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/android/res/drawable-ldpi/icon.png
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-mdpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-mdpi/icon.png
new file mode 100644
index 00000000..3eb10832
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/android/res/drawable-mdpi/icon.png
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-xhdpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-xhdpi/icon.png
new file mode 100644
index 00000000..a9e39f88
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/android/res/drawable-xhdpi/icon.png
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-xxhdpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-xxhdpi/icon.png
new file mode 100644
index 00000000..b489d81e
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/android/res/drawable-xxhdpi/icon.png
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-xxxhdpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-xxxhdpi/icon.png
new file mode 100644
index 00000000..9443da63
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/android/res/drawable-xxxhdpi/icon.png
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/compass.qml b/examples/sensors/sensorsshowcase/compass.qml
deleted file mode 100644
index 65ea3543..00000000
--- a/examples/sensors/sensorsshowcase/compass.qml
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtSensors
-
-Rectangle {
- id: root
- color: "dimgray"
- property real azimuth: 30
- readonly property real buttonHeight: height/8
-
- Compass {
- id: compass
- active: true
- dataRate: 7
- onReadingChanged: {
- root.azimuth = -reading.azimuth
- }
- }
-
- ColumnLayout {
- anchors.fill: parent
- id: layout
-
- Text {
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- Layout.preferredHeight: titleHeight
- Layout.topMargin: titleTopMargin
- verticalAlignment: Text.AlignVCenter
- color: "White"
- text: "Compass"
- font.pixelSize: titleFontSize
- }
- Image {
- Layout.alignment: Qt.AlignCenter
- Layout.fillHeight: true
- Layout.preferredWidth: root.width
- Layout.preferredHeight: root.height
- id: arrow
- source: "qrc:/images/compass.svg"
- fillMode: Image.PreserveAspectFit
- rotation:root.azimuth
- }
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "Azimuth: " + root.azimuth.toFixed(2) + "°"
- font.pixelSize: textFontSize
- }
- Button {
- Layout.alignment: Qt.AlignBottom
- Layout.preferredWidth: root.width
- Layout.preferredHeight: buttonHeight
- text:"Back"
- font.pixelSize: buttonFontSize
- onClicked:stack.pop()
- }
- }
-}
diff --git a/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.png b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.png
deleted file mode 100644
index b26aa459..00000000
--- a/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.webp b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.webp
new file mode 100644
index 00000000..0ff45403
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.webp
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.png b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.png
deleted file mode 100644
index 838b39c9..00000000
--- a/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.webp b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.webp
new file mode 100644
index 00000000..b045b7ba
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.webp
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc b/examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc
index b2971f01..d3d31c34 100644
--- a/examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc
+++ b/examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc
@@ -1,13 +1,15 @@
-// Copyright (C) 2021 The Qt Company Ltd.
+// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example sensorsshowcase
- \title Qt Sensors - Sensors Showcase
+ \title Sensors Showcase
\brief The Sensors Showcase example demonstrates sensor usage with visual examples.
+ \meta tag {sensors,quick,mobile}
\ingroup qtsensors-examples
+ \examplecategory {Mobile}
- \image sensorsshowcase-mainview.png
+ \image sensorsshowcase-mainview.webp
\section1 Overview
@@ -17,9 +19,14 @@
\section1 Main Menu
- The main view shows the title with the name of the application and a button for each
- subview laid out evenly by a \c ColumnLayout. The navigation between the subviews
- and the main menu is managed by a \c StackView.
+ The main view shows the title with the name of the application and a button
+ for each subview laid out evenly by a \c ColumnLayout. A \c StackView
+ manages the navigation between the subviews and the main menu. The
+ application checks the availability of the sensors during startup and
+ disables the buttons for the sensors that are not available.
+
+ \note To simplify the example, the sensor availability is checked only once
+ during the startup.
\section1 Accelerometer View
@@ -29,7 +36,7 @@
Moving around the image happens in the accelerometer \c onReadingChanged method.
- \snippet sensorsshowcase/accelerometer.qml 0
+ \snippet sensorsshowcase/Accelerometer.qml 0
Whenever there is a new accelerometer value the image translation coordinates are
updated accordingly.
@@ -52,11 +59,11 @@
case of how the magnetometer readings can be used. Since the magnetometer provides
readings along all three axes, there is more freedom with how these readings can be used.
- \snippet sensorsshowcase/magnetometer.qml 0
+ \snippet sensorsshowcase/Magnetometer.qml 0
\section1 Gyroscope View
- \image sensorsshowcase-gyroscope.png
+ \image sensorsshowcase-gyroscope.webp
The gyroscope view also shows an image that is rotated around three axes with an amount
that is calculated from the gyroscope readings. Since the gyroscope provides relative
@@ -64,7 +71,7 @@
can vary, the time of the readings are stored and the rotational change is normalized
based on the time passed between reading updates.
- \snippet sensorsshowcase/gyroscope.qml 0
+ \snippet sensorsshowcase/Gyroscope.qml 0
By pressing the reset button the image rotation is reset to 0.
*/
diff --git a/examples/sensors/sensorsshowcase/gyroscope.qml b/examples/sensors/sensorsshowcase/gyroscope.qml
deleted file mode 100644
index 39252c0e..00000000
--- a/examples/sensors/sensorsshowcase/gyroscope.qml
+++ /dev/null
@@ -1,174 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtSensors
-
-Rectangle {
- id: root
- color: "dimgray"
-
- function resetRotations() {
- imageXRotation.angle = 0
- imageYRotation.angle = 0
- imageZRotation.angle = 0
- }
-
-//! [0]
- Gyroscope {
- id: gyroscope
- active: true
- dataRate: 25
-
- property variant lastTimeStamp: 0
-
- property real x: 0
- property real y: 0
- property real z: 0
-
- onReadingChanged: {
-
- x = reading.x
- y = reading.y
- z = reading.z
-
- var firstCall = false
- if (lastTimeStamp == 0) {
- firstCall = true
- }
-
- var timeSinceLast = reading.timestamp - lastTimeStamp
- lastTimeStamp = reading.timestamp
-
- //Skipping the initial time jump from 0
- if (firstCall === true) return
-
- var normalizedX = reading.x * (timeSinceLast/1000000)
- imageXRotation.angle += normalizedX
-
- var normalizedY = reading.y * (timeSinceLast/1000000)
- imageYRotation.angle -= normalizedY
-
- var normalizedZ = reading.z * (timeSinceLast/1000000)
- imageZRotation.angle += normalizedZ
- }
- }
-//! [0]
-
- ColumnLayout {
- anchors.fill: parent
- id: layout
-
- Text {
- Layout.topMargin: titleTopMargin
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- Layout.preferredHeight: textHeight
- color: "White"
- text: "Gyroscope"
- font.pixelSize: titleFontSize
- }
-
- Image {
- id: image
- Layout.alignment: Qt.AlignCenter
- Layout.fillHeight: true
- Layout.preferredWidth: root.height/3
- Layout.preferredHeight: root.height/3
- source: "qrc:/images/qt_logo.png"
- fillMode: Image.PreserveAspectFit
-
- transform: [
- Rotation {
- id: imageXRotation
- origin.x: layout.width/2
- origin.y: layout.height/3
- axis.x: 1
- axis.y: 0
- axis.z: 0
- angle: 0
- },
- Rotation {
- id: imageYRotation
- origin.x: layout.width/2
- origin.y: layout.height/3
- axis.x: 0
- axis.y: 1
- axis.z: 0
- angle: 0
- },
- Rotation {
- id: imageZRotation
- origin.x: layout.width/2
- origin.y: layout.height/3
- axis.x: 0
- axis.y: 0
- axis.z: 1
- angle: 0
- }
- ]
- }
-
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "X: " + gyroscope.x.toFixed(2)
- font.pixelSize: textFontSize
- }
-
- ProgressBar {
- id: xbar
- value: 0.5 + (gyroscope.x / 1000)
- Layout.preferredWidth: root.width
- }
-
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "Y: " + gyroscope.y.toFixed(2)
- font.pixelSize: textFontSize
- }
- ProgressBar {
- id: ybar
- value: 0.5 + (gyroscope.y / 1000)
- Layout.preferredWidth: root.width
- }
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "Z: " + gyroscope.z.toFixed(2)
- font.pixelSize: textFontSize
- }
- ProgressBar {
- id: zbar
- value: 0.5 + (gyroscope.z / 1000)
- Layout.preferredWidth: root.width
- }
- Button {
- Layout.alignment: Qt.AlignBottom
- Layout.preferredWidth: root.width
- Layout.preferredHeight: buttonHeight
- text:"Reset rotation"
- font.pixelSize: buttonFontSize
- onClicked: {
- resetRotations()
- }
- }
- Button {
- Layout.alignment: Qt.AlignBottom
- Layout.preferredWidth: root.width
- Layout.preferredHeight: buttonHeight
- text:"Back"
- font.pixelSize: buttonFontSize
- onClicked:stack.pop()
- }
- }
-}
-
diff --git a/examples/sensors/sensorsshowcase/images/qt_logo.png b/examples/sensors/sensorsshowcase/images/qt_logo.png
index 30c621c9..3a75e10c 100644
--- a/examples/sensors/sensorsshowcase/images/qt_logo.png
+++ b/examples/sensors/sensorsshowcase/images/qt_logo.png
Binary files differ
diff --git a/examples/sensors/sensorsshowcase/magnetometer.qml b/examples/sensors/sensorsshowcase/magnetometer.qml
deleted file mode 100644
index c40bb867..00000000
--- a/examples/sensors/sensorsshowcase/magnetometer.qml
+++ /dev/null
@@ -1,103 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtSensors
-
-Rectangle {
- id: root
- color: "dimgray"
-
- property real magnetRotation: 40
- property real magnetometerX: 0
- property real magnetometerY: 0
- property real magnetometerZ: 0
- property int barScaleFactor: 10000
-
-//! [0]
- Magnetometer {
- id: magnetometer
- active: true
- dataRate: 25
- onReadingChanged: {
- root.magnetometerX = reading.x
- root.magnetometerY = reading.y
- root.magnetometerZ = reading.z
- root.magnetRotation = ((Math.atan2(reading.x, reading.y) / Math.PI) * 180)
- }
- }
-//! [0]
-
- ColumnLayout {
- anchors.fill: parent
- id: layout
-
- Text {
- Layout.topMargin: titleTopMargin
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- Layout.preferredHeight: titleHeight
- verticalAlignment: Text.AlignVCenter
- color: "White"
- text: "Magnetometer"
- font.pixelSize: titleFontSize
- }
- Image {
- Layout.alignment: Qt.AlignCenter
- Layout.fillHeight: true
- Layout.preferredWidth: root.width / 2
- Layout.preferredHeight: root.height / 2
- source: "qrc:/images/magnet.svg"
- fillMode: Image.PreserveAspectFit
- rotation: magnetRotation
- }
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "X: " + root.magnetometerX.toFixed(9)
- font.pixelSize: textFontSize
- }
- ProgressBar {
- id: xbar
- value: 0.5 + (root.magnetometerX * barScaleFactor)
- Layout.preferredWidth: root.width
- }
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "Y: " + root.magnetometerY.toFixed(9)
- font.pixelSize: textFontSize
- }
- ProgressBar {
- id: ybar
- value: 0.5 + (root.magnetometerY * barScaleFactor)
- Layout.preferredWidth: root.width
- }
- Text {
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "Z: " + root.magnetometerZ.toFixed(9)
- font.pixelSize: textFontSize
- }
- ProgressBar {
- id: zbar
- value: 0.5 + (root.magnetometerZ * barScaleFactor)
- Layout.preferredWidth: root.width
- }
- Button {
- Layout.alignment: Qt.AlignBottom
- Layout.preferredWidth: root.width
- Layout.preferredHeight: buttonHeight
- text:"Back"
- font.pixelSize: buttonFontSize
- onClicked:stack.pop()
- }
- }
-}
diff --git a/examples/sensors/sensorsshowcase/main.cpp b/examples/sensors/sensorsshowcase/main.cpp
index 52e27a06..4a7bd285 100644
--- a/examples/sensors/sensorsshowcase/main.cpp
+++ b/examples/sensors/sensorsshowcase/main.cpp
@@ -1,14 +1,18 @@
-// Copyright (C) 2021 The Qt Company Ltd.
+// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-
-#include <QtGui/QGuiApplication>
-#include <QtQml/QQmlApplicationEngine>
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
int main(int argc, char *argv[])
{
QGuiApplication app(argc,argv);
- QQmlApplicationEngine engine(QUrl("qrc:///sensorsshowcase.qml"));
+ QGuiApplication::setOrganizationName("QtProject");
+ QGuiApplication::setApplicationName("Sensors Showcase");
+
+ QQmlApplicationEngine engine;
+ engine.loadFromModule("SensorShowcaseModule", "Main");
+ if (engine.rootObjects().isEmpty())
+ return -1;
return app.exec();
}
diff --git a/examples/sensors/sensorsshowcase/proximity.qml b/examples/sensors/sensorsshowcase/proximity.qml
deleted file mode 100644
index 7e4f6486..00000000
--- a/examples/sensors/sensorsshowcase/proximity.qml
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtSensors
-
-Rectangle {
- id: root
- color: "dimgray"
- property bool near: false
-
- ProximitySensor {
- id: proximity
- active: true
- onReadingChanged: {
- root.near = reading.near
- }
- }
-
- ColumnLayout {
- anchors.fill: parent
- id: layout
-
- Text {
- Layout.topMargin: titleTopMargin
- Layout.alignment: Qt.AlignHCenter | Qt.AlignVCenter
- Layout.preferredHeight: textHeight
- color: "White"
- text: "Proximity"
- font.pixelSize: titleFontSize
- }
- Image {
- Layout.alignment: Qt.AlignCenter
- Layout.fillHeight: true
- Layout.preferredWidth: root.near ? root.height/3 : root.height/4
- Layout.preferredHeight: root.near ? root.height/3 : root.height/4
- source: "qrc:/images/qt_logo.png"
- fillMode: Image.PreserveAspectFit
- }
- Text {
- visible: !proximity
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- font.pixelSize: textFontSize
- verticalAlignment: Text.AlignVCenter
- wrapMode: Text.WordWrap
- color: "White"
- text: "The proximity sensor is not available on this device!"
- }
- Text {
-// visible: typeof proximity.available !== 'undefined'
- Layout.preferredWidth: root.width
- Layout.preferredHeight: textHeight
- Layout.leftMargin: layout.spacing
- color: "White"
- text: "Near: " + root.near
- font.pixelSize: textFontSize
- }
- Button {
- Layout.alignment: Qt.AlignBottom
- Layout.preferredWidth: root.width
- Layout.preferredHeight: buttonHeight
- text:"Back"
- font.pixelSize: buttonFontSize
- onClicked:stack.pop()
- }
- }
-}
diff --git a/examples/sensors/sensorsshowcase/qmldir b/examples/sensors/sensorsshowcase/qmldir
new file mode 100644
index 00000000..76e61cdf
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/qmldir
@@ -0,0 +1,9 @@
+module SensorShowcaseModule
+prefer :/qt/qml/SensorShowcaseModule/
+Main 1.0 Main.qml
+Accelerometer 1.0 Accelerometer.qml
+Compass 1.0 Compass.qml
+Gyroscope 1.0 Gyroscope.qml
+Magnetometer 1.0 Magnetometer.qml
+Proximity 1.0 Proximity.qml
+ProgressXYZBar 1.0 ProgressXYZBar.qml
diff --git a/examples/sensors/sensorsshowcase/qtquickcontrols2.conf b/examples/sensors/sensorsshowcase/qtquickcontrols2.conf
new file mode 100644
index 00000000..76439328
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/qtquickcontrols2.conf
@@ -0,0 +1,6 @@
+[Controls]
+Style=Material
+
+[Material]
+Background=#eafcf3
+Accent=#28c878
diff --git a/examples/sensors/sensorsshowcase/sensorsshowcase.pro b/examples/sensors/sensorsshowcase/sensorsshowcase.pro
index f57733f5..cded9071 100644
--- a/examples/sensors/sensorsshowcase/sensorsshowcase.pro
+++ b/examples/sensors/sensorsshowcase/sensorsshowcase.pro
@@ -1,27 +1,46 @@
-TEMPLATE = app
-TARGET = sensorsshowcase
+# Copyright (C) 2023 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
QT += quick sensors svg
+
+TARGET = sensorsshowcase
+TEMPLATE = app
+
SOURCES = main.cpp
-RESOURCES += \
- sensorsshowcase.qrc
+qml_resources.files = \
+ qmldir \
+ Main.qml \
+ Accelerometer.qml \
+ Compass.qml \
+ Gyroscope.qml \
+ Magnetometer.qml \
+ Proximity.qml \
+ ProgressXYZBar.qml \
+ images/compass.svg \
+ images/magnet.svg \
+ images/qt_logo.png
-OTHER_FILES = \
- $$files(*.qml) \
- images \
- android/AndroidManifest.xml
+qml_resources.prefix = /qt/qml/SensorShowcaseModule
-target.path = $$[QT_INSTALL_EXAMPLES]/sensors/sensorsshowcase
-INSTALLS += target
+data_resources.files = \
+ qtquickcontrols2.conf
-ios {
-QMAKE_INFO_PLIST = Info.plist
+data_resources.prefix = /
+
+RESOURCES += \
+ qml_resources \
+ data_resources
-# manual plugin loading needed with older Qt
-# QTPLUGIN += qsvg qtsensors_ios qtsensors_generic
+android {
+ OTHER_FILES = android/AndroidManifest.xml
+ ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
}
-ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android
+ios {
+ QMAKE_INFO_PLIST = Info.plist
+ EXAMPLE_FILES += Info.plist
+}
-EXAMPLE_FILES += \
- Info.plist
+target.path = $$[QT_INSTALL_EXAMPLES]/sensors/sensorsshowcase
+INSTALLS += target
diff --git a/examples/sensors/sensorsshowcase/sensorsshowcase.qml b/examples/sensors/sensorsshowcase/sensorsshowcase.qml
deleted file mode 100644
index e0fbd944..00000000
--- a/examples/sensors/sensorsshowcase/sensorsshowcase.qml
+++ /dev/null
@@ -1,76 +0,0 @@
-// Copyright (C) 2021 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-import QtQuick
-import QtQuick.Controls
-import QtQuick.Layouts
-import QtSensors
-
-ApplicationWindow {
- title: "Sensors Showcase"
- id: mainWindow
- width: 540
- height: 1200
- visible: true
- color: "dimgray"
-
- property int titleHeight: height/7
- readonly property real buttonHeight: height/7
- property int textHeight: height/24
- readonly property int buttonFontSize: 30
- readonly property int textFontSize: 20
- readonly property int titleFontSize: 35
- readonly property int titleTopMargin: mainWindow.height/24
-
- StackView {
- id: stack
- anchors.fill: parent
- initialItem: ColumnLayout {
- width: stack.width
- Text {
- Layout.topMargin: mainWindow.height/12
- Layout.alignment: Qt.AlignCenter
- Layout.preferredHeight: titleHeight
- text: "Sensors Showcase"
- color: "White"
- font.pixelSize: titleFontSize
- }
-
- Button {
- Layout.fillHeight: true
- Layout.preferredWidth: stack.width
- text: "Accelerometer"
- font.pixelSize: buttonFontSize
- onClicked: stack.push("qrc:/accelerometer.qml")
- }
- Button {
- Layout.fillHeight: true
- Layout.preferredWidth: stack.width
- text: "Proximity"
- font.pixelSize: buttonFontSize
- onClicked: stack.push("qrc:/proximity.qml")
- }
- Button {
- Layout.fillHeight: true
- Layout.preferredWidth: stack.width
- text: "Compass"
- font.pixelSize: buttonFontSize
- onClicked: stack.push("qrc:/compass.qml")
- }
- Button {
- Layout.fillHeight: true
- Layout.preferredWidth: stack.width
- text: "Magnetometer"
- font.pixelSize: buttonFontSize
- onClicked: stack.push("qrc:/magnetometer.qml")
- }
- Button {
- Layout.fillHeight: true
- Layout.preferredWidth: stack.width
- text: "Gyroscope"
- font.pixelSize: buttonFontSize
- onClicked: stack.push("qrc:/gyroscope.qml")
- }
- }
- }
-}
diff --git a/examples/sensors/sensorsshowcase/sensorsshowcase.qrc b/examples/sensors/sensorsshowcase/sensorsshowcase.qrc
deleted file mode 100644
index e647c384..00000000
--- a/examples/sensors/sensorsshowcase/sensorsshowcase.qrc
+++ /dev/null
@@ -1,13 +0,0 @@
-<RCC>
- <qresource prefix="/">
- <file>sensorsshowcase.qml</file>
- <file>accelerometer.qml</file>
- <file>proximity.qml</file>
- <file>compass.qml</file>
- <file>magnetometer.qml</file>
- <file>gyroscope.qml</file>
- <file>images/magnet.svg</file>
- <file>images/compass.svg</file>
- <file>images/qt_logo.png</file>
- </qresource>
-</RCC>
diff --git a/examples/sensors/sensorsshowcase/sensorsupport.h b/examples/sensors/sensorsshowcase/sensorsupport.h
new file mode 100644
index 00000000..915157f8
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/sensorsupport.h
@@ -0,0 +1,41 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+#ifndef SENSORSUPPORT_H
+#define SENSORSUPPORT_H
+
+#include <QObject>
+#include <QtQmlIntegration>
+#include <QtSensors/QtSensors>
+
+class SensorSupport : public QObject
+{
+ Q_OBJECT
+ QML_ELEMENT
+ QML_SINGLETON
+ QML_UNCREATABLE("SensorSupport is a utility class")
+public:
+ explicit SensorSupport(QObject *parent = nullptr) : QObject(parent) { }
+
+ Q_INVOKABLE static bool hasAccelerometer()
+ {
+ return !QSensor::sensorsForType(QAccelerometer::sensorType).empty();
+ }
+ Q_INVOKABLE static bool hasCompass()
+ {
+ return !QSensor::sensorsForType(QCompass::sensorType).empty();
+ }
+ Q_INVOKABLE static bool hasGyroscope()
+ {
+ return !QSensor::sensorsForType(QGyroscope::sensorType).empty();
+ }
+ Q_INVOKABLE static bool hasMagnetometer()
+ {
+ return !QSensor::sensorsForType(QMagnetometer::sensorType).empty();
+ }
+ Q_INVOKABLE static bool hasProximity()
+ {
+ return !QSensor::sensorsForType(QProximitySensor::sensorType).empty();
+ }
+};
+
+#endif // SENSORSUPPORT_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
deleted file mode 100644
index 7d76cb65..00000000
--- a/examples/sensors/shakeit/audio/loopy2a_mono.wav
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/shakeit/audio/phone.wav b/examples/sensors/shakeit/audio/phone.wav
deleted file mode 100644
index 884e9ac2..00000000
--- a/examples/sensors/shakeit/audio/phone.wav
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/shakeit/content/triangle.png b/examples/sensors/shakeit/content/triangle.png
deleted file mode 100644
index f366537e..00000000
--- a/examples/sensors/shakeit/content/triangle.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/shakeit/content/triangle2.png b/examples/sensors/shakeit/content/triangle2.png
deleted file mode 100644
index 9318d5a3..00000000
--- a/examples/sensors/shakeit/content/triangle2.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/shakeit/content/triangle3.png b/examples/sensors/shakeit/content/triangle3.png
deleted file mode 100644
index 4cc5ccda..00000000
--- a/examples/sensors/shakeit/content/triangle3.png
+++ /dev/null
Binary files differ
diff --git a/examples/sensors/shakeit/doc/images/shakeit.png b/examples/sensors/shakeit/doc/images/shakeit.png
deleted file mode 100644
index 5ca1b58c..00000000
--- a/examples/sensors/shakeit/doc/images/shakeit.png
+++ /dev/null
Binary files differ
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>
diff --git a/examples/sensors/stub.h b/examples/sensors/stub.h
deleted file mode 100644
index 0bee2026..00000000
--- a/examples/sensors/stub.h
+++ /dev/null
@@ -1,15 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QGuiApplication>
-#include <QQuickView>
-#include <QLoggingCategory>
-
-#define SENSORS_EXAMPLE_MAIN(NAME) int main(int argc, char **argv) \
-{\
- QGuiApplication app(argc,argv);\
- QQuickView view;\
- view.setSource(QUrl("qrc:///" #NAME ".qml"));\
- view.show();\
- return app.exec();\
-}