summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/sensors/CMakeLists.txt1
-rw-r--r--examples/sensors/grue/CMakeLists.txt69
-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/sensors.pro2
29 files changed, 0 insertions, 966 deletions
diff --git a/examples/sensors/CMakeLists.txt b/examples/sensors/CMakeLists.txt
index 7a0ee23a..ef323eff 100644
--- a/examples/sensors/CMakeLists.txt
+++ b/examples/sensors/CMakeLists.txt
@@ -2,7 +2,6 @@
# SPDX-License-Identifier: BSD-3-Clause
if(TARGET Qt::Quick)
- qt_internal_add_example(grue)
qt_internal_add_example(sensor_explorer)
if(TARGET Qt::Svg)
qt_internal_add_example(sensorsshowcase)
diff --git a/examples/sensors/grue/CMakeLists.txt b/examples/sensors/grue/CMakeLists.txt
deleted file mode 100644
index 16f9f4d5..00000000
--- a/examples/sensors/grue/CMakeLists.txt
+++ /dev/null
@@ -1,69 +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
- RESOURCE_PREFIX /
-)
-
-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/sensors.pro b/examples/sensors/sensors.pro
index 8f5f6c6f..984d7619 100644
--- a/examples/sensors/sensors.pro
+++ b/examples/sensors/sensors.pro
@@ -1,7 +1,5 @@
TEMPLATE = subdirs
-SUBDIRS += grue
-
qtHaveModule(quick) {
SUBDIRS += \
sensor_explorer