summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Oberst <dennis.oberst@qt.io>2023-04-12 13:44:25 +0200
committerDennis Oberst <dennis.oberst@qt.io>2023-04-26 08:58:48 +0000
commitaec41a55ab717eac1e29b50952c9bf37341692f4 (patch)
tree9daa9cbd771b32b040062c77cdaf1485b70c6d89
parent080823ec04f111ff82ae2fcfd5e2b98c4f6a722e (diff)
downloadqtsensors-aec41a55ab717eac1e29b50952c9bf37341692f4.tar.gz
Example: revamp sensorsshowcase
Updated the example to align with the Qt6 Example-Guideline. https://wiki.qt.io/Qt6/Example-Guideline Pick-to: 6.5 Task-number: QTBUG-111254 Change-Id: I8d8028ab5351cd801c8ce5126b1ebe5f2d0f4e50 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
-rw-r--r--examples/sensors/sensorsshowcase/Accelerometer.qml88
-rw-r--r--examples/sensors/sensorsshowcase/CMakeLists.txt59
-rw-r--r--examples/sensors/sensorsshowcase/Compass.qml77
-rw-r--r--examples/sensors/sensorsshowcase/Gyroscope.qml143
-rw-r--r--examples/sensors/sensorsshowcase/Magnetometer.qml86
-rw-r--r--examples/sensors/sensorsshowcase/Main.qml88
-rw-r--r--examples/sensors/sensorsshowcase/ProgressXYZBar.qml45
-rw-r--r--examples/sensors/sensorsshowcase/Proximity.qml84
-rw-r--r--examples/sensors/sensorsshowcase/accelerometer.qml122
-rw-r--r--examples/sensors/sensorsshowcase/android/AndroidManifest.xml28
-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 -> 12500 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 -> 14162 bytes
-rw-r--r--examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc15
-rw-r--r--examples/sensors/sensorsshowcase/gyroscope.qml174
-rw-r--r--examples/sensors/sensorsshowcase/magnetometer.qml103
-rw-r--r--examples/sensors/sensorsshowcase/main.cpp15
-rw-r--r--examples/sensors/sensorsshowcase/proximity.qml71
-rw-r--r--examples/sensors/sensorsshowcase/qmldir9
-rw-r--r--examples/sensors/sensorsshowcase/qtquickcontrols2.conf10
-rw-r--r--examples/sensors/sensorsshowcase/sensorsshowcase.pro53
-rw-r--r--examples/sensors/sensorsshowcase/sensorsshowcase.qml76
-rw-r--r--examples/sensors/sensorsshowcase/sensorsshowcase.qrc13
25 files changed, 736 insertions, 687 deletions
diff --git a/examples/sensors/sensorsshowcase/Accelerometer.qml b/examples/sensors/sensorsshowcase/Accelerometer.qml
new file mode 100644
index 0000000..e7e810d
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Accelerometer.qml
@@ -0,0 +1,88 @@
+// 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
+
+ property alias headingFontSize: heading.font.pixelSize
+ required property StackView parentStack
+ 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
+
+ Text {
+ id: heading
+
+ Layout.fillWidth: true
+ horizontalAlignment: Text.AlignHCenter
+ text: "Accelerometer"
+ wrapMode: Text.Wrap
+ }
+
+ 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)
+ }
+
+ Button {
+ Layout.fillWidth: true
+ onClicked: root.parentStack.pop()
+ text: "Back"
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/CMakeLists.txt b/examples/sensors/sensorsshowcase/CMakeLists.txt
index eb27f7e..9805808 100644
--- a/examples/sensors/sensorsshowcase/CMakeLists.txt
+++ b/examples/sensors/sensorsshowcase/CMakeLists.txt
@@ -1,18 +1,16 @@
-# Copyright (C) 2022 The Qt Company Ltd.
+# Copyright (C) 2023 The Qt Company Ltd.
# SPDX-License-Identifier: 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,7 +24,7 @@ set_target_properties(sensorsshowcase PROPERTIES
if(ANDROID)
set_property(TARGET sensorsshowcase PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
${CMAKE_CURRENT_SOURCE_DIR}/android)
- endif()
+endif()
if(APPLE)
if(IOS)
set_property(TARGET sensorsshowcase PROPERTY
@@ -35,34 +33,37 @@ if(APPLE)
endif()
endif()
-target_link_libraries(sensorsshowcase PUBLIC
- Qt::Core
- Qt::Gui
- Qt::Quick
- Qt::Sensors
- Qt::Svg
-)
+# default search path for the config file is "qrc:/"
+qt_add_resources(sensorsshowcase "resources"
+ FILES qtquickcontrols2.conf)
-# 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"
)
-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 0000000..b3f0653
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Compass.qml
@@ -0,0 +1,77 @@
+// 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
+
+ property alias headingFontSize: heading.font.pixelSize
+ required property StackView parentStack
+ required property int fontSize
+ required property int imageSize
+
+ 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
+
+ Text {
+ id: heading
+ Layout.preferredWidth: parent.width
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.Wrap
+ text: "Compass"
+ }
+
+ 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
+ }
+
+ Button {
+ Layout.fillWidth: true
+ onClicked: root.parentStack.pop()
+ text: "Back"
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/Gyroscope.qml b/examples/sensors/sensorsshowcase/Gyroscope.qml
new file mode 100644
index 0000000..5835c5d
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Gyroscope.qml
@@ -0,0 +1,143 @@
+// 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
+
+ property alias headingFontSize: heading.font.pixelSize
+ required property StackView parentStack
+ 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
+
+ Text {
+ id: heading
+
+ Layout.fillWidth: true
+ horizontalAlignment: Text.AlignHCenter
+ text: "Gyroscope"
+ wrapMode: Text.Wrap
+ }
+
+ 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.bottomMargin: 10
+ Layout.topMargin: 10
+ onClicked: root.resetRotations()
+ text: "Reset rotation"
+ }
+
+ Button {
+ Layout.fillWidth: true
+ onClicked: root.parentStack.pop()
+ text: "Back"
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/Magnetometer.qml b/examples/sensors/sensorsshowcase/Magnetometer.qml
new file mode 100644
index 0000000..7940c76
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Magnetometer.qml
@@ -0,0 +1,86 @@
+// 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
+
+ property alias headingFontSize: heading.font.pixelSize
+ required property StackView parentStack
+ 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
+
+ Text {
+ id: heading
+ Layout.fillWidth: true
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.Wrap
+ text: "Magnetometer"
+ Layout.bottomMargin: 20
+ }
+
+ 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)
+ }
+
+ Button {
+ Layout.fillWidth: true
+ onClicked: root.parentStack.pop()
+ text: "Back"
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/Main.qml b/examples/sensors/sensorsshowcase/Main.qml
new file mode 100644
index 0000000..227e1cf
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Main.qml
@@ -0,0 +1,88 @@
+// 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 dynamicMargin: width / 12
+ readonly property int defaultFontSize: 20
+ readonly property int headingFontSize: 35
+ readonly property int imageSize: width / 2
+
+ width: 420
+ height: 760
+ visible: true
+ title: "Sensors Showcase"
+
+ StackView {
+ id: stack
+
+ // Pushes the object and forwards the properties
+ function pusher(object : string) : void
+ {
+ stack.push(object, {
+ parentStack: stack,
+ fontSize: root.defaultFontSize,
+ headingFontSize: root.headingFontSize,
+ imageSize: root.imageSize
+ })
+ }
+
+ anchors.fill: parent
+ anchors.margins: root.dynamicMargin
+
+ initialItem: Item {
+ ColumnLayout {
+ id: initialItem
+
+ anchors.bottomMargin: (root.width < root.height) ? 2 * root.dynamicMargin : 0
+ anchors.fill: parent
+ spacing: 5
+
+ Text {
+ Layout.bottomMargin: root.dynamicMargin
+ Layout.preferredWidth: parent.width
+ horizontalAlignment: Text.AlignHCenter
+ font.bold: true
+ font.pixelSize: root.headingFontSize
+ text: "Sensors Showcase"
+ wrapMode: Text.WordWrap
+ }
+
+ component CustomButton: Button {
+ Layout.alignment: Qt.AlignCenter
+ Layout.fillHeight: true
+ Layout.fillWidth: true
+ font.pixelSize: root.defaultFontSize
+ highlighted: true
+ }
+
+ CustomButton {
+ text: "Accelerometer"
+ onClicked: stack.pusher("Accelerometer.qml")
+ }
+ CustomButton {
+ text: "Proximity"
+ onClicked: stack.pusher("Proximity.qml")
+ }
+ CustomButton {
+ text: "Compass"
+ onClicked: stack.pusher("Compass.qml")
+ }
+ CustomButton {
+ text: "Magnetometer"
+ onClicked: stack.pusher("Magnetometer.qml")
+ }
+ CustomButton {
+ text: "Gyroscope"
+ onClicked: stack.pusher("Gyroscope.qml")
+ }
+ }
+ }
+ }
+
+}
diff --git a/examples/sensors/sensorsshowcase/ProgressXYZBar.qml b/examples/sensors/sensorsshowcase/ProgressXYZBar.qml
new file mode 100644
index 0000000..be7bf7a
--- /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 0000000..be1adfb
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/Proximity.qml
@@ -0,0 +1,84 @@
+// 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
+
+ property alias headingFontSize: heading.font.pixelSize
+ required property StackView parentStack
+ required property int imageSize
+ required property int fontSize
+
+ property bool near: false
+
+ ProximitySensor {
+ id: proximity
+ onReadingChanged: root.near = (reading as ProximityReading).near
+ }
+
+ ColumnLayout {
+ id: layout
+
+ anchors.fill: parent
+ spacing: 10
+
+ Text {
+ id: heading
+ Layout.preferredWidth: parent.width
+ horizontalAlignment: Text.AlignHCenter
+ wrapMode: Text.Wrap
+ text: "Proximity"
+ }
+
+ 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 {
+ id: error
+ visible: !proximity.active
+ Layout.preferredWidth: parent.width
+ horizontalAlignment: Text.AlignHCenter
+ text: "The proximity sensor is not available on this device!"
+ font.pixelSize: root.fontSize
+ font.bold: true
+ wrapMode: Text.Wrap
+ color: "red"
+ }
+
+ Text {
+ visible: proximity.active
+ Layout.fillHeight: true
+ font.pixelSize: root.fontSize
+ text: "Near: " + root.near
+ }
+
+ Button {
+ Layout.fillWidth: true
+ onClicked: root.parentStack.pop()
+ text: "Back"
+ }
+ }
+}
diff --git a/examples/sensors/sensorsshowcase/accelerometer.qml b/examples/sensors/sensorsshowcase/accelerometer.qml
deleted file mode 100644
index e4f6e39..0000000
--- 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 6ee010e..7e2f9a8 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"
@@ -23,6 +22,7 @@
android:hardwareAccelerated="true"
android:label="-- %%INSERT_APP_NAME%% --"
android:requestLegacyExternalStorage="true"
+ android:allowNativeHeapPointerTagging="false"
android:allowBackup="true"
android:fullBackupOnly="false">
<activity
@@ -33,18 +33,34 @@
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>
+
+ <provider
+ android:name="androidx.core.content.FileProvider"
+ android:authorities="${applicationId}.qtprovider"
+ android:exported="false"
+ android:grantUriPermissions="true">
+ <meta-data
+ android:name="android.support.FILE_PROVIDER_PATHS"
+ android:resource="@xml/qtprovider_paths" />
+ </provider>
</application>
</manifest>
diff --git a/examples/sensors/sensorsshowcase/compass.qml b/examples/sensors/sensorsshowcase/compass.qml
deleted file mode 100644
index 65ea354..0000000
--- 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 b26aa45..0000000
--- 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 0000000..3460852
--- /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 838b39c..0000000
--- 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 0000000..2bfa9ac
--- /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 b2971f0..43be13c 100644
--- a/examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc
+++ b/examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc
@@ -1,13 +1,14 @@
-// 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
- \image sensorsshowcase-mainview.png
+ \image sensorsshowcase-mainview.webp
\section1 Overview
@@ -29,7 +30,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 +53,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 +65,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 39252c0..0000000
--- 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/magnetometer.qml b/examples/sensors/sensorsshowcase/magnetometer.qml
deleted file mode 100644
index c40bb86..0000000
--- 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 52e27a0..bab9202 100644
--- a/examples/sensors/sensorsshowcase/main.cpp
+++ b/examples/sensors/sensorsshowcase/main.cpp
@@ -1,14 +1,19 @@
-// 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 <QtGui/qguiapplication.h>
+#include <QtQml/qqmlapplicationengine.h>
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 7e4f648..0000000
--- 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 0000000..76e61cd
--- /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 0000000..e2641ea
--- /dev/null
+++ b/examples/sensors/sensorsshowcase/qtquickcontrols2.conf
@@ -0,0 +1,10 @@
+[Controls]
+Style=Material
+
+[Universal]
+Background=Amber
+Accent=Orange
+
+[Material]
+Background=Orange
+Accent=DeepOrange
diff --git a/examples/sensors/sensorsshowcase/sensorsshowcase.pro b/examples/sensors/sensorsshowcase/sensorsshowcase.pro
index f57733f..4454e9c 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: 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 e0fbd94..0000000
--- 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 e647c38..0000000
--- 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>