diff options
Diffstat (limited to 'examples')
148 files changed, 1210 insertions, 7342 deletions
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt new file mode 100644 index 00000000..1c5447e6 --- /dev/null +++ b/examples/CMakeLists.txt @@ -0,0 +1,8 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +qt_examples_build_begin(EXTERNAL_BUILD) + +add_subdirectory(sensors) + +qt_examples_build_end() diff --git a/examples/sensors/CMakeLists.txt b/examples/sensors/CMakeLists.txt new file mode 100644 index 00000000..bf1120c8 --- /dev/null +++ b/examples/sensors/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +if(TARGET Qt::Quick AND TARGET Qt::Svg) + qt_internal_add_example(sensorsshowcase) +endif() 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 f26179ff..00000000 --- a/examples/sensors/accelbubble/accelbubble.qml +++ /dev/null @@ -1,133 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -import QtQuick 2.1 -import QtQuick.Controls 1.0 - -//! [0] -import QtSensors 5.0 -//! [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.sqrt(x * x + z * z)) * mainWindow.radians_to_degrees; - } - function calcRoll(x,y,z) { - return -Math.atan2(x, Math.sqrt(y * y + z * 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 f3104443..00000000 --- a/examples/sensors/accelbubble/android/AndroidManifest.xml +++ /dev/null @@ -1,79 +0,0 @@ -<?xml version="1.0"?> -<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto"> - <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --"> - <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="portrait" android:launchMode="singleTop"> - <intent-filter> - <action android:name="android.intent.action.MAIN"/> - <category android:name="android.intent.category.LAUNCHER"/> - </intent-filter> - - <!-- Application arguments --> - <!-- meta-data android:name="android.app.arguments" android:value="arg1 arg2 arg3"/ --> - <!-- Application arguments --> - - <meta-data android:name="android.app.lib_name" android:value="-- %%INSERT_APP_LIB_NAME%% --"/> - <meta-data android:name="android.app.qt_sources_resource_id" android:resource="@array/qt_sources"/> - <meta-data android:name="android.app.repository" android:value="default"/> - <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/> - <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/> - <!-- Deploy Qt libs as part of package --> - <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/> - <meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/> - <meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/> - <!-- Run with local libs --> - <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/> - <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/> - <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/> - <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/> - <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/> - <!-- Used to specify custom system library path to run with local system libs --> - <!-- <meta-data android:name="android.app.system_libs_prefix" android:value="/system/lib/"/> --> - <!-- Messages maps --> - <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/> - <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/> - <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/> - <!-- Messages maps --> - - <!-- Splash screen --> - <!-- meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/ --> - <!-- meta-data android:name="android.app.splash_screen_sticky" android:value="true"/ --> - <!-- Splash screen --> - - <!-- Background running --> - <!-- Warning: changing this value to true may cause unexpected crashes if the - application still try to draw after - "applicationStateChanged(Qt::ApplicationSuspended)" - signal is sent! --> - <meta-data android:name="android.app.background_running" android:value="false"/> - <!-- Background running --> - - <!-- auto screen scale factor --> - <meta-data android:name="android.app.auto_screen_scale_factor" android:value="false"/> - <!-- auto screen scale factor --> - - <!-- extract android style --> - <!-- available android:values : - * full - useful QWidget & Quick Controls 1 apps - * minimal - useful for Quick Controls 2 apps, it is much faster than "full" - * none - useful for apps that don't use any of the above Qt modules - --> - <meta-data android:name="android.app.extract_android_style" android:value="full"/> - <!-- extract android style --> - </activity> - - <!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices --> - - </application> - - <uses-sdk android:minSdkVersion="16" android:targetSdkVersion="16"/> - <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/> - - <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application. - Remove the comment if you do not require these default permissions. --> - <!-- %%INSERT_PERMISSIONS --> - - <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application. - Remove the comment if you do not require these default features. --> - <!-- %%INSERT_FEATURES --> - -</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 Binary files differdeleted file mode 100644 index ad4cfc07..00000000 --- a/examples/sensors/accelbubble/doc/images/accelbubble.png +++ /dev/null diff --git a/examples/sensors/accelbubble/doc/src/accelbubble.qdoc b/examples/sensors/accelbubble/doc/src/accelbubble.qdoc deleted file mode 100644 index 02473575..00000000 --- a/examples/sensors/accelbubble/doc/src/accelbubble.qdoc +++ /dev/null @@ -1,56 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \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 e7ccc076..00000000 --- a/examples/sensors/accelbubble/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - - -#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/console_app/console_app.pro b/examples/sensors/grue/console_app/console_app.pro deleted file mode 100644 index 7b082d39..00000000 --- a/examples/sensors/grue/console_app/console_app.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = app -TARGET = detect_grue -CONFIG += console -CONFIG -= app_bundle -QT = core sensors - -DESTDIR = $$OUT_PWD/.. - -SOURCES = main.cpp - -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 29a629b5..00000000 --- a/examples/sensors/grue/console_app/main.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 Binary files differdeleted file mode 100644 index f4348271..00000000 --- a/examples/sensors/grue/doc/images/qtsensors-examples-grue.png +++ /dev/null diff --git a/examples/sensors/grue/doc/src/grue.qdoc b/examples/sensors/grue/doc/src/grue.qdoc deleted file mode 100644 index 146a8de0..00000000 --- a/examples/sensors/grue/doc/src/grue.qdoc +++ /dev/null @@ -1,153 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \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 Qt Sensors - Grue sensor example demonstrates all the steps from creating a new sensor to using it. - - The sensor definition is placed in a library where client apps can access it. The actual implementation - lives in a plugin. - - \list - \li \l{Grue Sensor Definition} - \li \l{Grue Sensor Implementation} - \endlist - - The sensor can now be used by a C++ application, even if the application does not have access to the - definition. - - \list - \li \l{Grue Sensor Console Application} - \endlist - - To make the sensor available to a QML application an import must be created. - - \list - \li \l{Grue Sensor QML Import} - \li \l{Grue Sensor QML Application} - \endlist - - \section1 Grue Sensor Definition - - The Grue sensor is defined in a library so that applications can use it. - The source code is available in the \c{grue/lib} subdirectory. - - First up is the sensor type. This is the interface for sensors that report - on your likelihood of being eaten by a Grue. Such sensors are very important - to adventurers, particularly if they are going into dark places as this is - where Grues live. - - The interface is a simple one. It provides only 1 piece of information, your - chance of being eaten. For the details on how this is property should be - interpreted please see the documentation in gruesensor.cpp. - - 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 a 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 be sure to call the - sensorStopped() or 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 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 the Grue Sensor - library. - - \section1 Grue Sensor QML Import - - The Grue sensor QML import exports the GrueSensor class as a QML type. - The source code is available in the \c{grue/import} subdirectory. - - This creates the \e {Grue 1.0} import. - - \section1 Grue Sensor QML Application - - The Grue sensor QML application demonstrates the use of GrueSensor QML type. - - The application consists of a single QML file and an image. It is built as an - exucutable with C++ code that runs the QML, but it can also be launched directly - using the \c qmlscene tool. - - You should build the top-level 'grue' project before trying to run - this example or it will not be able to find its dependencies. - - \code - qmlscene -I . grue.qml - \endcode - - Above, the \c{-I .} parameter adds the current directory as a module import - path to locate the Grue QML module. -*/ diff --git a/examples/sensors/grue/grue.png b/examples/sensors/grue/grue.png Binary files differdeleted file mode 100644 index 2727d393..00000000 --- a/examples/sensors/grue/grue.png +++ /dev/null diff --git a/examples/sensors/grue/grue.pro b/examples/sensors/grue/grue.pro deleted file mode 100644 index 7290cd34..00000000 --- a/examples/sensors/grue/grue.pro +++ /dev/null @@ -1,9 +0,0 @@ -TEMPLATE = subdirs - -SUBDIRS += lib plugin console_app - -qtHaveModule(quick): SUBDIRS += import qml.pro - -plugin.depends = lib -import.depends = lib - diff --git a/examples/sensors/grue/grue.qml b/examples/sensors/grue/grue.qml deleted file mode 100644 index 02b1bd0f..00000000 --- a/examples/sensors/grue/grue.qml +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -import QtSensors 5.0 -import Grue 1.0 - -Rectangle { - id: root - width: 320 - height: 480 - color: "black" - - property int percent: 0 - 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 - } - } - - GrueSensor { - 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.top: parent.top - anchors.topMargin: 0 - anchors.left: parent.left - anchors.right: parent.right - 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 Binary files differdeleted file mode 100644 index 2837ed7e..00000000 --- a/examples/sensors/grue/grue.xcf +++ /dev/null diff --git a/examples/sensors/grue/icon.xcf b/examples/sensors/grue/icon.xcf Binary files differdeleted file mode 100644 index 8416c49f..00000000 --- a/examples/sensors/grue/icon.xcf +++ /dev/null diff --git a/examples/sensors/grue/import/import.json b/examples/sensors/grue/import/import.json deleted file mode 100644 index 0967ef42..00000000 --- a/examples/sensors/grue/import/import.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/sensors/grue/import/import.pro b/examples/sensors/grue/import/import.pro deleted file mode 100644 index 17d7713e..00000000 --- a/examples/sensors/grue/import/import.pro +++ /dev/null @@ -1,37 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin - -TARGET = $$qtLibraryTarget(declarative_grue) - -macos: DESTDIR = ../grue_app.app/Contents/MacOS/Grue -else: DESTDIR = ../Grue - -QT = core gui qml sensors - -include(../lib/lib.pri) - -# Shared gruesensor library will be installed in parent directory. -# Define rpath so that this plugin will know where to look for it. -unix:!mac: QMAKE_LFLAGS += -Wl,-rpath,\\\$\$ORIGIN/.. -macos: QMAKE_RPATHDIR += @loader_path/../../Frameworks - -SOURCES = main.cpp - -DESTPATH=$$[QT_INSTALL_EXAMPLES]/sensors/grue/Grue - -target.path=$$DESTPATH -INSTALLS += target - -CONFIG += install_ok # Do not cargo-cult this! - -qmldir.files=$$PWD/qmldir -qmldir.path=$$DESTPATH -INSTALLS += qmldir - -OTHER_FILES += \ - import.json qmldir - -# Copy the qmldir file to the same folder as the plugin binary -cpqmldir.files = $$PWD/qmldir -cpqmldir.path = $$DESTDIR -COPIES += cpqmldir diff --git a/examples/sensors/grue/import/main.cpp b/examples/sensors/grue/import/main.cpp deleted file mode 100644 index 4827af48..00000000 --- a/examples/sensors/grue/import/main.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtQml/qqmlextensionplugin.h> -#include <QtQml/qqml.h> - -#include <gruesensor.h> -#include <QDebug> - -#ifdef BUNDLED_PLUGIN -#include <QPluginLoader> -#include <QSensorPluginInterface> -#endif - -QT_BEGIN_NAMESPACE - -class GrueSensorQmlImport : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "import.json") -public: - void registerTypes(const char *uri) override - { - char const * const package = "Grue"; - if (QLatin1String(uri) != QLatin1String(package)) return; - int major; - int minor; - - // Register the 1.0 interfaces - major = 1; - minor = 0; - // @uri Grue - qmlRegisterType <GrueSensor >(package, major, minor, "GrueSensor"); - qmlRegisterUncreatableType<GrueSensorReading>(package, major, minor, "GrueSensorReading", QLatin1String("Cannot create GrueSensorReading")); - } - -#ifdef BUNDLED_PLUGIN - GrueSensorQmlImport() - { - // For now, this is getting called after Sensors has loaded - // Ensure that a change later does not break this by forcing - // sensors to load now - (void)QSensor::sensorTypes(); - - // Load the bundled sensor plugin - QPluginLoader loader(QString::fromLocal8Bit(BUNDLED_PLUGIN)); - QObject *instance = loader.instance(); - m_changes = qobject_cast<QSensorChangesInterface*>(instance); - if (m_changes) { - QSensor *sensor = new QSensor(QByteArray(), this); - connect(sensor, SIGNAL(availableSensorsChanged()), this, SLOT(sensorsChanged())); - m_changes->sensorsChanged(); - } - QSensorPluginInterface *plugin = qobject_cast<QSensorPluginInterface*>(instance); - if (plugin) { - plugin->registerSensors(); - } - } - -private slots: - void sensorsChanged() - { - m_changes->sensorsChanged(); - } - -private: - QSensorChangesInterface *m_changes; -#endif -}; - -QT_END_NAMESPACE - -#include "main.moc" - -/* - \omit - \qmltype GrueSensor - \instantiates GrueSensor - \inherits Sensor - \inqmlmodule Grue - \brief The GrueSensor type reports on your chance of being eaten by a Grue. - - The GrueSensor type reports on your chance of being eaten by a Grue. - - This type wraps the GrueSensor class. Please see the documentation for - GrueSensor for details. - \endomit -*/ - -/* - \omit - \qmltype GrueSensorReading - \instantiates GrueSensorReading - \inherits SensorReading - \inqmlmodule Grue - \brief The GrueSensorReading type holds the most recent GrueSensor reading. - - The GrueSensorReading type holds the most recent GrueSensor reading. - - This type wraps the GrueSensorReading class. Please see the documentation for - GrueSensorReading for details. - - This type cannot be directly created. - \endomit -*/ - -/* - \omit - \qmlproperty qreal Grue1::GrueSensorReading::chanceOfBeingEaten - Please see GrueSensorReading::chanceOfBeingEaten for information about this property. - \endomit -*/ diff --git a/examples/sensors/grue/import/qmldir b/examples/sensors/grue/import/qmldir deleted file mode 100644 index 529b9093..00000000 --- a/examples/sensors/grue/import/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module Grue -plugin declarative_grue diff --git a/examples/sensors/grue/lib/gruesensor.cpp b/examples/sensors/grue/lib/gruesensor.cpp deleted file mode 100644 index 1de2f4e8..00000000 --- a/examples/sensors/grue/lib/gruesensor.cpp +++ /dev/null @@ -1,159 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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::type("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/lib/gruesensor.h b/examples/sensors/grue/lib/gruesensor.h deleted file mode 100644 index 90379939..00000000 --- a/examples/sensors/grue/lib/gruesensor.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRUESENSOR_H -#define GRUESENSOR_H - -#include <qsensor.h> - -class GrueSensorReadingPrivate; - -#if defined(QT_BUILD_GRUE_LIB) -# define Q_GRUE_EXPORT Q_DECL_EXPORT -#else -# define Q_GRUE_EXPORT Q_DECL_IMPORT -#endif - -class Q_GRUE_EXPORT 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 Q_GRUE_EXPORT GrueFilter : public QSensorFilter -{ -public: - virtual bool filter(GrueSensorReading *reading) = 0; -private: - bool filter(QSensorReading *reading) override { return filter(static_cast<GrueSensorReading*>(reading)); } -}; - -class Q_GRUE_EXPORT GrueSensor : public QSensor -{ - Q_OBJECT - Q_PROPERTY(GrueSensorReading* reading READ reading) -public: - explicit GrueSensor(QObject *parent = 0) : QSensor(GrueSensor::type, parent) {} - virtual ~GrueSensor() {} - GrueSensorReading *reading() const { return static_cast<GrueSensorReading*>(QSensor::reading()); } - static char const * const type; -}; -// end generated code - -#endif diff --git a/examples/sensors/grue/lib/gruesensor_p.h b/examples/sensors/grue/lib/gruesensor_p.h deleted file mode 100644 index 0216d06b..00000000 --- a/examples/sensors/grue/lib/gruesensor_p.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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/lib/lib.pri b/examples/sensors/grue/lib/lib.pri deleted file mode 100644 index 0e3da252..00000000 --- a/examples/sensors/grue/lib/lib.pri +++ /dev/null @@ -1,6 +0,0 @@ -INCLUDEPATH += $$PWD - -macos: LIBS += -L$$OUT_PWD/../grue_app.app/Contents/Frameworks -else: LIBS += -L$$OUT_PWD/.. - -LIBS += -lgruesensor diff --git a/examples/sensors/grue/lib/lib.pro b/examples/sensors/grue/lib/lib.pro deleted file mode 100644 index cc10e5c4..00000000 --- a/examples/sensors/grue/lib/lib.pro +++ /dev/null @@ -1,20 +0,0 @@ -TEMPLATE = lib -TARGET = gruesensor - -macos: DESTDIR = ../grue_app.app/Contents/Frameworks -else: DESTDIR = $$OUT_PWD/.. - -macos: QMAKE_SONAME_PREFIX = @rpath - -DEFINES *= QT_BUILD_GRUE_LIB -QT = core sensors - -HEADERS += gruesensor.h \ - gruesensor_p.h - -SOURCES += gruesensor.cpp - -target.path=$$[QT_INSTALL_EXAMPLES]/sensors/grue -INSTALLS += target - -CONFIG += install_ok # Do not cargo-cult this! diff --git a/examples/sensors/grue/main.cpp b/examples/sensors/grue/main.cpp deleted file mode 100644 index 499a3432..00000000 --- a/examples/sensors/grue/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "../stub.h" -SENSORS_EXAMPLE_MAIN(grue) diff --git a/examples/sensors/grue/plugin/gruesensorimpl.cpp b/examples/sensors/grue/plugin/gruesensorimpl.cpp deleted file mode 100644 index d8012b54..00000000 --- a/examples/sensors/grue/plugin/gruesensorimpl.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 0847ed9c..00000000 --- a/examples/sensors/grue/plugin/gruesensorimpl.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef GRUESENSORIMPL_H -#define GRUESENSORIMPL_H - -#include <qsensorbackend.h> -#include "gruesensor.h" -#include <qambientlightsensor.h> -#include <QTime> - -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; - QTime 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 4c5da15d..00000000 --- a/examples/sensors/grue/plugin/main.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 - { - qDebug() << "loaded the grue plugin"; - } - - void sensorsChanged() override - { - if (!QSensor::defaultSensorForType(QAmbientLightSensor::type).isEmpty()) { - // There is a light sensor available. Register the backend - if (!QSensorManager::isBackendRegistered(GrueSensor::type, gruesensorimpl::id)) - QSensorManager::registerBackend(GrueSensor::type, gruesensorimpl::id, this); - } else { - if (QSensorManager::isBackendRegistered(GrueSensor::type, gruesensorimpl::id)) - QSensorManager::unregisterBackend(GrueSensor::type, 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 e198140d..00000000 --- a/examples/sensors/grue/plugin/plugin.pro +++ /dev/null @@ -1,30 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin -TARGET = $$qtLibraryTarget(qtsensors_grue) -PLUGIN_TYPE = sensors - -QT = core sensors - -macos: DESTDIR = ../grue_app.app/Contents/MacOS/$$PLUGIN_TYPE -else: DESTDIR = ../$$PLUGIN_TYPE - -include(../lib/lib.pri) - -# Shared gruesensor library will be installed in parent directory. -# Define rpath so that this plugin will know where to look for it. -unix:!mac: QMAKE_LFLAGS += -Wl,-rpath,\\\$\$ORIGIN/.. - -HEADERS += gruesensorimpl.h - -SOURCES += gruesensorimpl.cpp \ - main.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 3293c4f2..00000000 --- a/examples/sensors/grue/qml.pro +++ /dev/null @@ -1,22 +0,0 @@ -TEMPLATE = app -TARGET = grue_app -QT += quick - -# Avoid going to release/debug subdirectory -win32: DESTDIR = ./ - -SOURCES = main.cpp - -RESOURCES += \ - qml.qrc - -OTHER_FILES = \ - $$files(*.qml) \ - grue.png - -target.path = $$[QT_INSTALL_EXAMPLES]/sensors/grue -INSTALLS += target - -EXAMPLE_FILES += \ - grue.xcf \ - icon.xcf diff --git a/examples/sensors/grue/qml.qrc b/examples/sensors/grue/qml.qrc deleted file mode 100644 index 55b269b9..00000000 --- a/examples/sensors/grue/qml.qrc +++ /dev/null @@ -1,6 +0,0 @@ -<RCC> - <qresource prefix="/"> - <file>grue.qml</file> - <file>grue.png</file> - </qresource> -</RCC> diff --git a/examples/sensors/maze/Congratulation.qml b/examples/sensors/maze/Congratulation.qml deleted file mode 100644 index 3288e3a3..00000000 --- a/examples/sensors/maze/Congratulation.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 - -//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/LabyrinthSquare.qml b/examples/sensors/maze/LabyrinthSquare.qml deleted file mode 100644 index dab6d7ca..00000000 --- a/examples/sensors/maze/LabyrinthSquare.qml +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 - -//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 cf839910..00000000 --- a/examples/sensors/maze/Mouse.qml +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 - -//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 de787fad..00000000 --- a/examples/sensors/maze/android/AndroidManifest.xml +++ /dev/null @@ -1,56 +0,0 @@ -<?xml version="1.0"?> -<manifest package="org.qtproject.example" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="1.0" android:versionCode="1" android:installLocation="auto"> - <application android:hardwareAccelerated="true" android:name="org.qtproject.qt5.android.bindings.QtApplication" android:label="-- %%INSERT_APP_NAME%% --"> - <activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|locale|fontScale|keyboard|keyboardHidden|navigation" android:name="org.qtproject.qt5.android.bindings.QtActivity" android:label="-- %%INSERT_APP_NAME%% --" android:screenOrientation="portrait" android:launchMode="singleTop"> - <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.qt_sources_resource_id" android:resource="@array/qt_sources"/> - <meta-data android:name="android.app.repository" android:value="default"/> - <meta-data android:name="android.app.qt_libs_resource_id" android:resource="@array/qt_libs"/> - <meta-data android:name="android.app.bundled_libs_resource_id" android:resource="@array/bundled_libs"/> - <!-- Deploy Qt libs as part of package --> - <meta-data android:name="android.app.bundle_local_qt_libs" android:value="-- %%BUNDLE_LOCAL_QT_LIBS%% --"/> - <meta-data android:name="android.app.bundled_in_lib_resource_id" android:resource="@array/bundled_in_lib"/> - <meta-data android:name="android.app.bundled_in_assets_resource_id" android:resource="@array/bundled_in_assets"/> - <!-- Run with local libs --> - <meta-data android:name="android.app.use_local_qt_libs" android:value="-- %%USE_LOCAL_QT_LIBS%% --"/> - <meta-data android:name="android.app.libs_prefix" android:value="/data/local/tmp/qt/"/> - <meta-data android:name="android.app.load_local_libs" android:value="-- %%INSERT_LOCAL_LIBS%% --"/> - <meta-data android:name="android.app.load_local_jars" android:value="-- %%INSERT_LOCAL_JARS%% --"/> - <meta-data android:name="android.app.static_init_classes" android:value="-- %%INSERT_INIT_CLASSES%% --"/> - <!-- Messages maps --> - <meta-data android:value="@string/ministro_not_found_msg" android:name="android.app.ministro_not_found_msg"/> - <meta-data android:value="@string/ministro_needed_msg" android:name="android.app.ministro_needed_msg"/> - <meta-data android:value="@string/fatal_error_msg" android:name="android.app.fatal_error_msg"/> - <!-- Messages maps --> - - <!-- Splash screen --> - <!-- - <meta-data android:name="android.app.splash_screen_drawable" android:resource="@drawable/logo"/> - --> - <!-- Splash screen --> - - <!-- Background running --> - <!-- Warning: changing this value to true may cause unexpected crashes if the - application still try to draw after - "applicationStateChanged(Qt::ApplicationSuspended)" - signal is sent! --> - <meta-data android:name="android.app.background_running" android:value="false"/> - <!-- Background running --> - </activity> - </application> - <uses-sdk android:minSdkVersion="9" android:targetSdkVersion="14"/> - <supports-screens android:largeScreens="true" android:normalScreens="true" android:anyDensity="true" android:smallScreens="true"/> - - <!-- The following comment will be replaced upon deployment with default permissions based on the dependencies of the application. - Remove the comment if you do not require these default permissions. --> - <!-- %%INSERT_PERMISSIONS --> - - <!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application. - Remove the comment if you do not require these default features. --> - <!-- %%INSERT_FEATURES --> - -</manifest> diff --git a/examples/sensors/maze/components/ApplicationWindow.qml b/examples/sensors/maze/components/ApplicationWindow.qml deleted file mode 100644 index 5a1c9f67..00000000 --- a/examples/sensors/maze/components/ApplicationWindow.qml +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 - -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 c7a05251..00000000 --- a/examples/sensors/maze/components/Button.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 - -//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 Binary files differdeleted file mode 100644 index 62a00b9a..00000000 --- a/examples/sensors/maze/components/images/button_background_disabled.png +++ /dev/null diff --git a/examples/sensors/maze/components/images/button_background_normal.png b/examples/sensors/maze/components/images/button_background_normal.png Binary files differdeleted file mode 100644 index 1fecad5b..00000000 --- a/examples/sensors/maze/components/images/button_background_normal.png +++ /dev/null diff --git a/examples/sensors/maze/components/images/button_background_pressed.png b/examples/sensors/maze/components/images/button_background_pressed.png Binary files differdeleted file mode 100644 index e0ba0e7a..00000000 --- a/examples/sensors/maze/components/images/button_background_pressed.png +++ /dev/null diff --git a/examples/sensors/maze/content/00.png b/examples/sensors/maze/content/00.png Binary files differdeleted file mode 100644 index 2522be5e..00000000 --- a/examples/sensors/maze/content/00.png +++ /dev/null diff --git a/examples/sensors/maze/content/01.png b/examples/sensors/maze/content/01.png Binary files differdeleted file mode 100644 index 6146b204..00000000 --- a/examples/sensors/maze/content/01.png +++ /dev/null diff --git a/examples/sensors/maze/content/cheese.png b/examples/sensors/maze/content/cheese.png Binary files differdeleted file mode 100644 index c737b9d6..00000000 --- a/examples/sensors/maze/content/cheese.png +++ /dev/null diff --git a/examples/sensors/maze/content/cheeseeating.gif b/examples/sensors/maze/content/cheeseeating.gif Binary files differdeleted file mode 100644 index 6b2cb47f..00000000 --- a/examples/sensors/maze/content/cheeseeating.gif +++ /dev/null diff --git a/examples/sensors/maze/content/congratulations.gif b/examples/sensors/maze/content/congratulations.gif Binary files differdeleted file mode 100644 index 70204176..00000000 --- a/examples/sensors/maze/content/congratulations.gif +++ /dev/null diff --git a/examples/sensors/maze/content/mouse_down.gif b/examples/sensors/maze/content/mouse_down.gif Binary files differdeleted file mode 100644 index 5491c18f..00000000 --- a/examples/sensors/maze/content/mouse_down.gif +++ /dev/null diff --git a/examples/sensors/maze/content/start.png b/examples/sensors/maze/content/start.png Binary files differdeleted file mode 100644 index 581b8c9b..00000000 --- a/examples/sensors/maze/content/start.png +++ /dev/null diff --git a/examples/sensors/maze/doc/src/maze.qdoc b/examples/sensors/maze/doc/src/maze.qdoc deleted file mode 100644 index 2cc69644..00000000 --- a/examples/sensors/maze/doc/src/maze.qdoc +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \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: - - Import the QtSensors 5.x declarative plugin: - - \snippet maze/maze.qml 0 - - Add the Sensor QML types into your qml file. - - In this example we use the TiltSensor with values based in degrees and an accuracy of 5 degree: - - \snippet maze/maze.qml 1 - - Starting the sensor can be done by setting the 'enabled' property to true: - - \snippet maze/maze.qml 2 - - The mouse should move by a factor of the tilt value: - - \snippet maze/maze.qml 3 - - The walk direction of the mouse takes into account some collision detection: - - \snippet maze/maze.qml 4 - - 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 2c3dd56e..00000000 --- a/examples/sensors/maze/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 05ac9559..00000000 --- a/examples/sensors/maze/maze.qml +++ /dev/null @@ -1,299 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* Layout - mainWnd - / -------------------------------/ gameRect -| / -|-----------------------------/ -||---------------------------| -||||M| || -||| \ || -||| mouseCtrl || -||| || -||| || -||| Labyrinth || -||| || -||| || -||| cheeseSquare || -||| \ || -||| |C||| -||---------------------------| -|----------------------------- -| -|----------------------------- -|| || | -|----------------------------- -| \ \ -| \ timePlayingLabel -| newGameButton ------------------------------- - -*/ -//Import the declarative plugins -import QtQuick 2.0 -import "components" - -//! [0] -import QtSensors 5.0 -//! [0] - -//Import the javascript functions for this game -import "lib.js" as Lib - -ApplicationWindow { - id: mainWnd - - property Mouse mouseCtrl; - property LabyrinthSquare cheeseSquare; - property Congratulation congratulation; - - 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 - - //timer for starting the labyrinth game - Timer { - id: startTimer - interval: 50; running: true; repeat: false - onTriggered: { - - //reset game time - timePlayingLabel.text = "--"; - Lib.sec = 0.0; - Lib.createLabyrinth(); - - //create labyrinth elements (only at the first time) - var needloadcomponent = false; - if (Lib.objectArray === null) { - needloadcomponent = true; - Lib.objectArray = new Array(Lib.dimension * Lib.dimension); - } - var idx = 0; - for (var y = 0; y < Lib.dimension; y++ ) { - for (var x = 0; x < Lib.dimension; x++ ) { - var component = null; - - //create labyrinth components (only at the first time) - if (needloadcomponent) { - component = Qt.createComponent("LabyrinthSquare.qml"); - if (component.status == Component.Ready) { - var square = component.createObject(parent); - square.x = x * square.width; - square.y = y * square.height; - square.val = Lib.labyrinth[x][y]; - square.updateImage(); - Lib.objectArray[idx] = square; - if (x == (Lib.dimension - 1) && y == (Lib.dimension - 1)) { - cheeseSquare = square; - var component1 = Qt.createComponent("Congratulation.qml"); - if (component1.status == Component.Ready) { - congratulation = component1.createObject(parent); - congratulation.visible = false; - } - } - } - } - else{ - Lib.objectArray[idx].val = Lib.labyrinth[x][y]; - Lib.objectArray[idx].updateImage(); - if (x == (Lib.dimension - 1) && y == (Lib.dimension - 1)) { - cheeseSquare = Lib.objectArray[idx]; - congratulation.visible = false; - } - } - idx++; - } - } - - //Lib.printLab(); //this is for debug. Labyrinth will be printed out in the console - - //Create the mouse control (only at the first time) - if (mouseCtrl === null) { - var component = Qt.createComponent("Mouse.qml"); - if (component.status == Component.Ready) { - mouseCtrl = component.createObject(parent); - } - } - mouseCtrl.x = 0; - mouseCtrl.y = 0; - newGameButton.enabled = true; - - //Start the Tilt reader timer - tiltTimer.running = true; - } - } - } - -//! [1] - TiltSensor { - id: tiltSensor - active: true - } -//! [1] - - //Timer to read out the x and y rotation of the TiltSensor - Timer { - id: tiltTimer - interval: 50; running: false; repeat: true - -//! [2] - onTriggered: { - if (!tiltSensor.enabled) - tiltSensor.active = true; -//! [2] - - if (mouseCtrl === null) - return; - - //check if already solved - if (Lib.won !== true) { - Lib.sec += 0.05; - timePlayingLabel.text = Math.floor(Lib.sec) + " seconds"; - - //check if we can move the mouse - var xval = -1; - var yval = -1; - -//! [3] - var xstep = 0; - xstep = tiltSensor.reading.yRotation * 0.1 //acceleration - - var ystep = 0; - ystep = tiltSensor.reading.xRotation * 0.1 //acceleration -//! [3] -//! [4] - 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); -//! [4] - - } else { - //game won, stop the tilt meter - mainWnd.cheeseSquare.val = 4; - mainWnd.cheeseSquare.updateImage(); - mainWnd.congratulation.visible = true; - newGameButton.enabled = true; - tiltTimer.running = false; - } - } - } - - - //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: "new game" - enabled: false; - onClicked: { - newGameButton.enabled = false; - startTimer.start(); - } - } - Button{ - id: calibrateButton - anchors.left: gameRect.left - anchors.top: newGameButton.bottom - anchors.topMargin: 5 - height: 30 - width: 100 - text: "calibrate" - onClicked: { - tiltSensor.calibrate(); - } - } - - //Label to print out the game time - Text{ - id: timePlayingLabel - anchors.right: gameRect.right - anchors.top: gameRect.bottom - anchors.topMargin: 5 - } -} - 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/components/ApplicationWindow.qml b/examples/sensors/qmlqtsensors/components/ApplicationWindow.qml deleted file mode 100644 index 54d837b2..00000000 --- a/examples/sensors/qmlqtsensors/components/ApplicationWindow.qml +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 - -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 c7a05251..00000000 --- a/examples/sensors/qmlqtsensors/components/Button.qml +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 - -//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 68d78ae9..00000000 --- a/examples/sensors/qmlqtsensors/components/Divider.qml +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 - -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 Binary files differdeleted file mode 100644 index 62a00b9a..00000000 --- a/examples/sensors/qmlqtsensors/components/images/button_background_disabled.png +++ /dev/null diff --git a/examples/sensors/qmlqtsensors/components/images/button_background_normal.png b/examples/sensors/qmlqtsensors/components/images/button_background_normal.png Binary files differdeleted file mode 100644 index 1fecad5b..00000000 --- a/examples/sensors/qmlqtsensors/components/images/button_background_normal.png +++ /dev/null diff --git a/examples/sensors/qmlqtsensors/components/images/button_background_pressed.png b/examples/sensors/qmlqtsensors/components/images/button_background_pressed.png Binary files differdeleted file mode 100644 index e0ba0e7a..00000000 --- a/examples/sensors/qmlqtsensors/components/images/button_background_pressed.png +++ /dev/null diff --git a/examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc b/examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc deleted file mode 100644 index ce32cea2..00000000 --- a/examples/sensors/qmlqtsensors/doc/src/qmlqtsensors.qdoc +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \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 5 import. - - - To write a QML application that will use the QML sensors types in the QtSensors 5 import you need to to the following steps: - - Import the QtSensors 5.x 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 3615d892..00000000 --- a/examples/sensors/qmlqtsensors/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 6add64dc..00000000 --- a/examples/sensors/qmlqtsensors/qmlqtsensors.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = app -TARGET = qmlqtsensors -QT += quick -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 456c0140..00000000 --- a/examples/sensors/qmlqtsensors/qmlqtsensors.qml +++ /dev/null @@ -1,257 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/* 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 2.0 -import "components" - -//! [0] -import QtSensors 5.0 -//! [0] - -ApplicationWindow { - - // 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 56430f1b..00000000 --- a/examples/sensors/qmlsensorgestures/Button.qml +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 - -//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/GestureList.qml b/examples/sensors/qmlsensorgestures/GestureList.qml deleted file mode 100644 index 8ee1f6ed..00000000 --- a/examples/sensors/qmlsensorgestures/GestureList.qml +++ /dev/null @@ -1,146 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 -import QtSensors 5.0 - -/* 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 eaa46cd8..00000000 --- a/examples/sensors/qmlsensorgestures/GestureView.qml +++ /dev/null @@ -1,162 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 - -//! [0] -import QtSensors 5.0 -//! [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 3ba53546..00000000 --- a/examples/sensors/qmlsensorgestures/GesturesView.qml +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 -import QtSensors 5.0 - -/* 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 5bdd39f9..00000000 --- a/examples/sensors/qmlsensorgestures/doc/src/qmlsensorgestures.qdoc +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \example qmlsensorgestures - \title Qt Sensors - SensorGesture QML Type example - \ingroup qtsensors-examples - - \brief Demonstrates the use of SensorGesture QML type. - - \section1 Overview - To write a QML application that will use the gesture plugin, following - steps are needed: - - Import the QtSensors 5.x module: - - \snippet qmlsensorgestures/GestureView.qml 0 - - Add the SensorGesture QML type into your qml file. - - \snippet qmlsensorgestures/GestureView.qml 1 - - Each SensorGesture QML type contains a property called gestures. This example - uses an alias \c gestureId for this property. - - \snippet qmlsensorgestures/GestureView.qml 2 - - Then, the gesture or gestures to use can be specified using the alias: - - \snippet qmlsensorgestures/qmlsensorgestures.qml 3 - \dots 12 - \snippet qmlsensorgestures/qmlsensorgestures.qml 4 - - A list of all available gestures is accessible through the - \c availableGestures property: - - \snippet qmlsensorgestures/GestureList.qml 4 - \codeline - \snippet qmlsensorgestures/GestureList.qml 5 - \dots 12 - \snippet qmlsensorgestures/GestureList.qml 6 - - \sa {Qt Sensors - ShakeIt QML Example}, {Qt Sensor Gestures} -*/ diff --git a/examples/sensors/qmlsensorgestures/main.cpp b/examples/sensors/qmlsensorgestures/main.cpp deleted file mode 100644 index 646da4ed..00000000 --- a/examples/sensors/qmlsensorgestures/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "../stub.h" -SENSORS_EXAMPLE_MAIN(qmlsensorgestures) 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 eeeb354f..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 1b756328..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/qcountergestureplugin.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 11ffbb94..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 4a0212ab..00000000 --- a/examples/sensors/qmlsensorgestures/plugin/qcounterrecognizer.h +++ /dev/null @@ -1,80 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 6191f322..00000000 --- a/examples/sensors/qmlsensorgestures/qml.pro +++ /dev/null @@ -1,13 +0,0 @@ -TEMPLATE = app -TARGET = qmlsensorgestures -QT += quick -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 02d9e0cf..00000000 --- a/examples/sensors/qmlsensorgestures/qmlsensorgestures.qml +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//Import the declarative plugins -import QtQuick 2.0 -import QtSensors 5.0 - -/* 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/doc/images/qtsensors-examples-explorer.png b/examples/sensors/sensor_explorer/doc/images/qtsensors-examples-explorer.png Binary files differdeleted file mode 100644 index 888fc3c6..00000000 --- a/examples/sensors/sensor_explorer/doc/images/qtsensors-examples-explorer.png +++ /dev/null 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 367711b1..00000000 --- a/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc +++ /dev/null @@ -1,104 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \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-explorer.png - - This example is divided into two parts: - - \list - \li A \l{Sensor Explorer QML Import}{C++ plugin} that provides QML - alternatives for \c QSensorExplorer, \c QPropertyInfo and - \c QSensorItem C++ classes. - \li A \l{Sensor Explorer QML Application}{QML Application} that uses - the QML types to read the sensor meta-data and present it. - \endlist - - This example is built as an executable with C++ code that runs the QML, - but it can also be launched directly using the \c qmlscene tool. You - should build the top-level \e sensor_explorer project before trying to - run this example or it will not be able to find its dependencies. - - \code - qmlscene -I . sensor_explorer.qml - \endcode - - Above, the -I . parameter adds the current directory as a module import - path to locate the Explorer QML module. - - \section1 Sensor Explorer QML Import - - The Sensor Explorer QML import defines the \e Explorer QML module, - exporting \c QSensorExplorer, \c QPropertyInfo and \c QSensorItem C++ - classes as QML types. The source code is available in the - \c sensor_explorer/import subdirectory. - - \section1 Sensor Explorer QML Application - - To write a QML application that will use the QML types exposed by the - Explorer module, following steps are needed: - - Import the Explorer 1.0 declarative plugin: - - \snippet sensor_explorer/sensor_explorer.qml 0 - - Create a SensorExplorer QML item: - - \snippet sensor_explorer/sensor_explorer.qml 1 - - You can retrieve a list of all available sensors using - \c SensorExplorer.availableSensors: - - \snippet sensor_explorer/sensor_explorer.qml 2 - - The example uses the returned list as a model to populate a view of - available sensors. - - To retrieve the properties of a sensor, use \c SensorItem.properties: - - \snippet sensor_explorer/sensor_explorer.qml 3 - - The property list is used as a model for another view that displays the - property names and values. - - It is possible to edit the values of certain sensor properties. Selecting - a writable property value will open an editor. \c SensorExplorer QML - type allows you to pass a new value for a sensor property value as - follows: - - \snippet sensor_explorer/sensor_explorer.qml 4 - - Starting and stopping a sensor can be done by setting the - \c SensorItem.start property: - - \snippet sensor_explorer/sensor_explorer.qml 5 -*/ diff --git a/examples/sensors/sensor_explorer/import/explorer.cpp b/examples/sensors/sensor_explorer/import/explorer.cpp deleted file mode 100644 index 4773ee18..00000000 --- a/examples/sensors/sensor_explorer/import/explorer.cpp +++ /dev/null @@ -1,152 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "explorer.h" -#include <QtCore/QDebug> -#include <qsensor.h> -#include <QMetaObject> -#include <QMetaProperty> - -QT_BEGIN_NAMESPACE - -/* - \class QSensorExplorer - \brief The QSensorExplorer type provides an easy access for reading all avalaible sensors installed on the system. -*/ - -/* - Construct a QSensorExplorer object with parent \a parent -*/ -QSensorExplorer::QSensorExplorer(QObject* parent) - : QObject(parent) - , _selectedSensorItem(0) -{ - loadSensors(); -} - -/* - Destructor of a QSensorExplorer -*/ -QSensorExplorer::~QSensorExplorer() -{ -} - -/* - Load all available sensors and store it in a list. -*/ -void QSensorExplorer::loadSensors() -{ - //! [0] - _availableSensors.clear(); - - foreach (const QByteArray &type, QSensor::sensorTypes()) { - qDebug() << "Found type" << type; - foreach (const QByteArray &identifier, QSensor::sensorsForType(type)) { - qDebug() << "Found identifier" << identifier; - // Don't put in sensors we can't connect to - QSensor* sensor = new QSensor(type, this); - sensor->setIdentifier(identifier); - if (!sensor->connectToBackend()) { - qDebug() << "Couldn't connect to" << identifier; - continue; - } - - qDebug() << "Adding identifier" << identifier; - _availableSensors.append(new QSensorItem(sensor, this)); - } - } - emit availableSensorsChanged(); - //! [0] -} - -/* - \fn QSensorExplorer::availableSensorsChanged() - Notifies the client if the list of the available sensors was changed -*/ - -/* - \property QSensorExplorer::availableSensors - Returns a list of all available sensor. -*/ -QQmlListProperty<QSensorItem> QSensorExplorer::availableSensors() -{ - return QQmlListProperty<QSensorItem>(this,_availableSensors); -} - -/* - \fn QSensorExplorer::selectedSensorItemChanged() - Notifies the client if the selected sensor has been changed -*/ - -/* - \property QSensorExplorer::selectedSensorItem - Returns the current selected sensor item. -*/ -QSensorItem* QSensorExplorer::selectedSensorItem() -{ - return _selectedSensorItem; -} - -/* - \fn QSensorExplorer::setSelectedSensorItem(QSensorItem* selitem) - Sets the QSensorItem \a selitem as the current selected QSensorItem. -*/ -void QSensorExplorer::setSelectedSensorItem(QSensorItem* selitem) -{ - if (selitem && _selectedSensorItem != selitem) { - if (_selectedSensorItem) - _selectedSensorItem->unSelect(); - _selectedSensorItem = selitem; - _selectedSensorItem->select(); - emit selectedSensorItemChanged(); - } -} - -QT_END_NAMESPACE diff --git a/examples/sensors/sensor_explorer/import/explorer.h b/examples/sensors/sensor_explorer/import/explorer.h deleted file mode 100644 index 2e583f81..00000000 --- a/examples/sensors/sensor_explorer/import/explorer.h +++ /dev/null @@ -1,88 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSEONSOREXPLORER_H -#define QSEONSOREXPLORER_H - -#include <QtQml/QtQml> -#include <QtQml/QQmlListProperty> -#include "sensoritem.h" - -QT_BEGIN_NAMESPACE - -class QSensorExplorer : public QObject -{ - Q_OBJECT - Q_PROPERTY(QQmlListProperty<QSensorItem> availableSensors READ availableSensors NOTIFY availableSensorsChanged) - Q_PROPERTY(QSensorItem* selectedSensorItem READ selectedSensorItem WRITE setSelectedSensorItem NOTIFY selectedSensorItemChanged) -public: - QSensorExplorer(QObject* parent = 0); - virtual ~QSensorExplorer(); - -private: - QQmlListProperty<QSensorItem> availableSensors(); - void loadSensors(); - void setSelectedSensorItem(QSensorItem* selitem); - QSensorItem* selectedSensorItem(); - -Q_SIGNALS: - void availableSensorsChanged(); - void selectedSensorItemChanged(); - -private: - QList<QSensorItem*> _availableSensors; - QSensorItem* _selectedSensorItem; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensorExplorer) - -#endif // QSEONSOREXPLORER_H diff --git a/examples/sensors/sensor_explorer/import/import.json b/examples/sensors/sensor_explorer/import/import.json deleted file mode 100644 index 0967ef42..00000000 --- a/examples/sensors/sensor_explorer/import/import.json +++ /dev/null @@ -1 +0,0 @@ -{} diff --git a/examples/sensors/sensor_explorer/import/import.pro b/examples/sensors/sensor_explorer/import/import.pro deleted file mode 100644 index 49a437e8..00000000 --- a/examples/sensors/sensor_explorer/import/import.pro +++ /dev/null @@ -1,37 +0,0 @@ -TEMPLATE = lib -CONFIG += plugin - -TARGET = $$qtLibraryTarget(declarative_explorer) - -macos: DESTDIR = ../sensor_explorer.app/Contents/MacOS/Explorer -else: DESTDIR = ../Explorer - -QT += qml sensors - -SOURCES = \ - main.cpp \ - explorer.cpp \ - sensoritem.cpp \ - propertyinfo.cpp - -HEADERS = \ - explorer.h \ - sensoritem.h \ - propertyinfo.h - -DESTPATH=$$[QT_INSTALL_EXAMPLES]/sensors/sensor_explorer/Explorer - -target.path=$$DESTPATH -qmldir.files=$$PWD/qmldir -qmldir.path=$$DESTPATH -INSTALLS += target qmldir - -CONFIG += install_ok # Do not cargo-cult this! - -OTHER_FILES += \ - import.json qmldir - -# Copy the qmldir file to the same folder as the plugin binary -cpqmldir.files = $$PWD/qmldir -cpqmldir.path = $$DESTDIR -COPIES += cpqmldir diff --git a/examples/sensors/sensor_explorer/import/main.cpp b/examples/sensors/sensor_explorer/import/main.cpp deleted file mode 100644 index b43ea339..00000000 --- a/examples/sensors/sensor_explorer/import/main.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtQml/QQmlExtensionPlugin> -#include <QtQml/QtQml> -#include "explorer.h" -#include <QtCore/QDebug> - -QT_BEGIN_NAMESPACE - -class SensorExplorerDeclarativeModule : public QQmlExtensionPlugin -{ - Q_OBJECT - Q_PLUGIN_METADATA(IID QQmlExtensionInterface_iid FILE "import.json") -public: - void registerTypes(const char *uri) override - { - Q_ASSERT(QLatin1String(uri) == QLatin1String("Explorer")); - // @uri Explorer - qmlRegisterType<QSensorExplorer>(uri, 1, 0, "SensorExplorer"); - qmlRegisterType<QSensorItem>(uri, 1, 0, "SensorItem"); - qmlRegisterType<QPropertyInfo>(uri, 1, 0, "PropertyInfo"); - } -}; - -QT_END_NAMESPACE - -#include "main.moc" diff --git a/examples/sensors/sensor_explorer/import/propertyinfo.cpp b/examples/sensors/sensor_explorer/import/propertyinfo.cpp deleted file mode 100644 index 4704a6a1..00000000 --- a/examples/sensors/sensor_explorer/import/propertyinfo.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensoritem.h" -#include <QtCore/QDebug> -#include <QtSensors> - -QT_BEGIN_NAMESPACE - -/* - \class QPropertyInfo - \brief The QPropertyInfo type provides an easy access for reading and writing the property values. -*/ - -/* - Construct a QPropertyInfo object with parent \a parent -*/ -QPropertyInfo::QPropertyInfo(QObject* parent) - : QObject(parent) - , _index(0) - , _isWriteable(false) - , _name("") - , _typeName("") - , _value("") -{} - -/* - Construct a QPropertyInfo object with parent \a parent, property name \a name, property index \a index, - property write access \a writeable, property type \a typeName and property value \a value -*/ -QPropertyInfo::QPropertyInfo(const QString& name, int index, bool writeable, const QString& typeName, const QString& value, QObject* parent) - : QObject(parent) - , _index(index) - , _isWriteable(writeable) - , _name(name) - , _typeName(typeName) - , _value(value) -{} - -/* - \property QPropertyInfo::name - Returns the name of the property -*/ -QString QPropertyInfo::name() -{ - return _name; -} - -/* - \property QPropertyInfo::typeName - Returns the type of the property -*/ -QString QPropertyInfo::typeName() -{ - return _typeName; -} - -/* - \property QPropertyInfo::value - Returns the current value of the property -*/ -QString QPropertyInfo::value() -{ - return _value; -} - -/* - \fn void QPropertyInfo::valueChanged() - Signal that notifies the client if the property value was changed. -*/ - -/* - \fn QPropertyInfo::setValue(const QString& value) - Sets the value \a value of the property -*/ -void QPropertyInfo::setValue(const QString& value) -{ - if (value != _value){ - _value = value; - emit valueChanged(); - } -} - -/* - \fn QPropertyInfo::index() - Returns the meta-data index of the property -*/ -int QPropertyInfo::index() -{ - return _index; -} - -/* - \property QPropertyInfo::isWriteable - Returns true if the property is writeable false if property is read only -*/ -bool QPropertyInfo::isWriteable() -{ - return _isWriteable; -} - -QT_END_NAMESPACE diff --git a/examples/sensors/sensor_explorer/import/propertyinfo.h b/examples/sensors/sensor_explorer/import/propertyinfo.h deleted file mode 100644 index 53b194a3..00000000 --- a/examples/sensors/sensor_explorer/import/propertyinfo.h +++ /dev/null @@ -1,92 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QPROPERTYINFO_H -#define QPROPERTYINFO_H - -#include <QtQml/QtQml> -#include <QtCore/QString> - -QT_BEGIN_NAMESPACE - -class QPropertyInfo : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name CONSTANT) - Q_PROPERTY(QString typeName READ typeName CONSTANT) - Q_PROPERTY(QString value READ value NOTIFY valueChanged) - Q_PROPERTY(bool isWriteable READ isWriteable CONSTANT) - -public: - QPropertyInfo(QObject* parent = 0); - QPropertyInfo(const QString& name, int index, bool writeable, const QString& typeName, const QString& value, QObject* parent=0); - QString name(); - QString typeName(); - QString value(); - void setValue(const QString& value); - int index(); - bool isWriteable(); - -Q_SIGNALS: - void valueChanged(); - -private: - int _index; - bool _isWriteable; - QString _name; - QString _typeName; - QString _value; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QPropertyInfo) - -#endif // QPROPERTYINFO_H diff --git a/examples/sensors/sensor_explorer/import/qmldir b/examples/sensors/sensor_explorer/import/qmldir deleted file mode 100644 index 31c037fa..00000000 --- a/examples/sensors/sensor_explorer/import/qmldir +++ /dev/null @@ -1,2 +0,0 @@ -module Explorer -plugin declarative_explorer diff --git a/examples/sensors/sensor_explorer/import/sensoritem.cpp b/examples/sensors/sensor_explorer/import/sensoritem.cpp deleted file mode 100644 index 88b5fa7c..00000000 --- a/examples/sensors/sensor_explorer/import/sensoritem.cpp +++ /dev/null @@ -1,331 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "sensoritem.h" -#include <QtCore/QDebug> -#include <QtSensors> - -QT_BEGIN_NAMESPACE - -/* - \class QSensorItem - \brief The QSensorItem type provides information about the metadata from a sensors installed on the system. -*/ - -/* - Construct a QSensorItem object with parent \a parent -*/ -QSensorItem::QSensorItem(QObject* parent) - : QObject(parent) - , _qsensor(0) -{ -} - -/* - Construct a QSensorItem object with QSensor \a sensor and parent \a parent -*/ -QSensorItem::QSensorItem(QSensor* sensor, QObject* parent) - : QObject(parent) - , _qsensor(sensor) -{ -} - -/* - Destructor of a QSensorItem -*/ -QSensorItem::~QSensorItem() -{ -} - -/* - \fn QSensorItem::startChanged() - Notifies the client if the sensors has changed its start active status -*/ - -/* - \property QSensorItem::start - This property starts or stops the sensor -*/ -bool QSensorItem::start() -{ - return (_qsensor ? _qsensor->isActive() : false); -} - -void QSensorItem::setStart(bool run) -{ - if (_qsensor) - _qsensor->setActive(run); -} - -/* - \property QSensorItem::id - Returns the sensor id of the sensor item -*/ -QString QSensorItem::id() -{ - return (_qsensor ? _qsensor->identifier() : ""); -} - -/* - Set the new value \a val to the QPropertyInfo object \a property -*/ -void QSensorItem::changePropertyValue(QPropertyInfo* property, const QString& val) -{ - if (_qsensor && _sensorProperties.contains(property)){ - if ( _qsensor->setProperty(property->name().toLatin1().constData(), QVariant(val))) - updateSensorPropertyValues(); - else - qWarning() << "new property value couldn't be set"; - } -} - -/* - Reading the metadata and activates the sensor. -*/ -void QSensorItem::select() -{ - if (_sensorProperties.isEmpty()) { - // Probe the reading using Qt's meta-object facilities - //Read properties from reader - QSensorReading *reading = _qsensor->reading(); - const QMetaObject *mo = reading->metaObject(); - int firstProperty = QSensorReading::staticMetaObject.propertyOffset(); - - for (int i = firstProperty; i < mo->propertyCount(); ++i) { - QString typeName = QLatin1String(mo->property(i).typeName()); - int crap = typeName.lastIndexOf("::"); - if (crap != -1) - typeName = typeName.mid(crap + 2); - - QPropertyInfo* pi = new QPropertyInfo(mo->property(i).name() - , i - , isWriteable(mo->property(i).name()) - , typeName - , "-" - , this); - _readerProperties.append(pi); - } - - //Read properties from sensor - const QMetaObject *mo1 = _qsensor->metaObject(); - firstProperty = QSensorReading::staticMetaObject.propertyOffset(); - - for (int i = firstProperty; i < mo1->propertyCount(); ++i) { - QString propertyname = mo1->property(i).name(); - if (ignoreProperty(propertyname)) - continue; - - QString typeName = QLatin1String(mo1->property(i).typeName()); - int crap = typeName.lastIndexOf("::"); - if (crap != -1) - typeName = typeName.mid(crap + 2); - - QPropertyInfo* pi = new QPropertyInfo(propertyname - , i - , isWriteable(propertyname) - , typeName - , "-" - , this); - _sensorProperties.append(pi); - } - updateSensorPropertyValues(); - connect(_qsensor, SIGNAL(readingChanged()), this, SLOT(sensorReadingChanged())); - } - connect(_qsensor, SIGNAL(activeChanged()), SIGNAL(startChanged())); -} - -/* - Unselect the sensor by stopping the sensor. -*/ -void QSensorItem::unSelect() -{ - _qsensor->stop(); - disconnect(_qsensor, SIGNAL(activeChanged()), this , SIGNAL(startChanged())); -} - -/* - Updates the property values from QSensor -*/ -void QSensorItem::updateSensorPropertyValues() -{ - if (_qsensor){ - const QMetaObject *mo = _qsensor->metaObject(); - for (int i = 0; i < _sensorProperties.count(); i++){ - QVariant val = mo->property(_sensorProperties[i]->index()).read(_qsensor); - _sensorProperties[i]->setValue(convertValue(_sensorProperties[i]->typeName(), val)); - } - } -} - -/* - \fn QSensorItem::propertiesChanged() - Notifies the client if the list of the properties was changed -*/ - -/* - Updates the property values from the QSensorReader -*/ -void QSensorItem::sensorReadingChanged() -{ - QSensorReading *reading = _qsensor->reading(); - const QMetaObject *mo = reading->metaObject(); - for (int i = 0; i < _readerProperties.count(); i++){ - QVariant val = mo->property(_readerProperties[i]->index()).read(reading); - _readerProperties[i]->setValue(convertValue(_readerProperties[i]->typeName(), val)); - } -} - -/* - Returns true if the property with the name \a propertyname should be ignored -*/ -bool QSensorItem::ignoreProperty(const QString& propertyname) -{ - if (propertyname == "reading" || - propertyname == "active" || - propertyname == "identifier" || - propertyname == "connectedToBackend" || - propertyname == "busy") - return true; - - return false; -} - -/* - Returns true if the property with the name \a propertyname is writeable -*/ -bool QSensorItem::isWriteable(const QString& propertyname) -{ - if (_qsensor){ - const QMetaObject *mo = _qsensor->metaObject(); - int propertyindex = mo->indexOfProperty(propertyname.toLocal8Bit().constData()); - if (propertyindex >= 0){ - QMetaProperty prop = mo->property(propertyindex); - return prop.isWritable(); - } - else { - QSensorReading *reading = _qsensor->reading(); - const QMetaObject *moreader = reading->metaObject(); - propertyindex = moreader->indexOfProperty(propertyname.toLocal8Bit().constData()); - if (propertyindex >= 0){ - QMetaProperty prop = mo->property(propertyindex); - return prop.isWritable(); - } - } - } - - return false; -} - -/* - Convert the variant \a val dependent on the type \a type and returns the converted value as a QString -*/ -QString QSensorItem::convertValue(const QString& type, const QVariant& val) -{ - if (type == "LightLevel"){ - switch (val.toInt()) { - case 1: return "Dark"; - case 2: return "Twilight"; - case 3: return "Light"; - case 4: return "Bright"; - case 5: return "Sunny"; - default: return "Undefined"; - } - } - else if (type == "Orientation"){ - switch (val.toInt()) { - case 1: return "TopUp"; - case 2: return "TopDown"; - case 3: return "LeftUp"; - case 4: return "RightUp"; - case 5: return "FaceUp"; - case 6: return "FaceDown"; - default: return "Undefined"; - } - } - else if (type == "qrangelist"){ - qrangelist rangelist = val.value<qrangelist>(); - QStringList ranges; - foreach (const qrange &r, rangelist) { - 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(", "); - return "-"; - } - else if (type == "qoutputrangelist") { - qoutputrangelist rangelist = val.value<qoutputrangelist>(); - QStringList ranges; - foreach (const qoutputrange &r, rangelist) { - ranges << QString("(%1, %2) += %3").arg(r.minimum).arg(r.maximum).arg(r.accuracy); - } - if (ranges.count() > 0) - return ranges.join(", "); - return "-"; - } - - return val.toString(); -} - -/* - \property QSensorItem::properties - Returns a list of all properties from the sensor -*/ -QQmlListProperty<QPropertyInfo> QSensorItem::properties() -{ - _properties.clear(); - _properties.append(_sensorProperties); - _properties.append(_readerProperties); - return QQmlListProperty<QPropertyInfo> (this, _properties); -} - -QT_END_NAMESPACE diff --git a/examples/sensors/sensor_explorer/import/sensoritem.h b/examples/sensors/sensor_explorer/import/sensoritem.h deleted file mode 100644 index f67b6bda..00000000 --- a/examples/sensors/sensor_explorer/import/sensoritem.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QSENSORITEM_H -#define QSENSORITEM_H - -#include <QtQml/QtQml> -#include <QtCore/QString> -#include "propertyinfo.h" - -QT_BEGIN_NAMESPACE - -class QSensor; -class QSensorItem : public QObject -{ - Q_OBJECT - Q_PROPERTY(bool start READ start WRITE setStart NOTIFY startChanged) - Q_PROPERTY(QString id READ id CONSTANT) - Q_PROPERTY(QQmlListProperty<QPropertyInfo> properties READ properties NOTIFY propertiesChanged) -public: - QSensorItem(QObject* parent = 0); - QSensorItem(QSensor* sensor, QObject* parent = 0); - virtual ~QSensorItem(); - -public slots: - void select(); - void unSelect(); - void changePropertyValue(QPropertyInfo* property, const QString& val); - -private slots: - void sensorReadingChanged(); - -private: - QString id(); - bool start(); - void setStart(bool run); - QQmlListProperty<QPropertyInfo> properties(); - QString convertValue(const QString& type, const QVariant& val); - bool isWriteable(const QString& propertyname); - bool ignoreProperty(const QString& propertyname); - void updateSensorPropertyValues(); - -Q_SIGNALS: - void propertiesChanged(); - void startChanged(); - -private: - QSensor* _qsensor; - QList<QPropertyInfo*> _properties; - QList<QPropertyInfo*> _readerProperties; - QList<QPropertyInfo*> _sensorProperties; -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QSensorItem) - -#endif // QSENSORITEM_H diff --git a/examples/sensors/sensor_explorer/main.cpp b/examples/sensors/sensor_explorer/main.cpp deleted file mode 100644 index bb0a3b17..00000000 --- a/examples/sensors/sensor_explorer/main.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QtQml> -#include <QtQuick/QQuickWindow> - -#ifndef QT_NO_WIDGETS -#include <QtWidgets/QApplication> -#define Application QApplication -#else -#include <QtGui/QGuiApplication> -#define Application QGuiApplication -#endif - -int main(int argc, char *argv[]) -{ - Application 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.pro b/examples/sensors/sensor_explorer/qml.pro deleted file mode 100644 index 1407d5b2..00000000 --- a/examples/sensors/sensor_explorer/qml.pro +++ /dev/null @@ -1,21 +0,0 @@ -TEMPLATE = app -TARGET = sensor_explorer -QT += qml quick - -qtHaveModule(widgets) { - QT += widgets -} - -# Avoid going to release/debug subdirectory -win32: DESTDIR = ./ - -SOURCES = main.cpp - -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/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 85ba45ef..00000000 --- a/examples/sensors/sensor_explorer/sensor_explorer.pro +++ /dev/null @@ -1,6 +0,0 @@ -TEMPLATE = subdirs -CONFIG += ordered - -SUBDIRS = \ - import \ - qml.pro diff --git a/examples/sensors/sensor_explorer/sensor_explorer.qml b/examples/sensors/sensor_explorer/sensor_explorer.qml deleted file mode 100644 index 365842d9..00000000 --- a/examples/sensors/sensor_explorer/sensor_explorer.qml +++ /dev/null @@ -1,224 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.1 -import QtQuick.Window 2.1 -import QtQuick.Controls 1.0 - -//! [0] -import Explorer 1.0 -//! [0] - -Window { - id: window - width: 320 - height: 480 - minimumWidth: 320 - minimumHeight: 480 - - //! [1] - SensorExplorer { - id: explorer - } - //! [1] - - Column { - anchors.fill: parent - anchors.margins: 8 - spacing: 8 - - GroupBox { - title: qsTr("Available Sensors") - width: parent.width - height: window.height * 0.4 - - TableView { - id: sensorList - anchors.fill: parent - //! [2] - model: explorer.availableSensors - //! [2] - - TableViewColumn { role: "id"; title: qsTr("ID"); width: sensorList.width * 0.7 } - TableViewColumn { role: "start"; title: qsTr("Running"); width: sensorList.width * 0.3 - 5 } - - onClicked: { - explorer.selectedSensorItem = explorer.availableSensors[row] - //! [3] - propertyList.model = explorer.selectedSensorItem.properties - //! [3] - button.update() - } - } - - Button { - id: button - anchors.margins: 4 - anchors.horizontalCenter: parent.horizontalCenter - anchors.top: sensorList.bottom - text: qsTr("Start") - enabled: explorer.selectedSensorItem !== null - - function update() { - text = (explorer.selectedSensorItem !== null ? - (explorer.selectedSensorItem.start === true ? - qsTr("Stop") : qsTr("Start")) : qsTr("Start")) - } - - onClicked: { - if (explorer.selectedSensorItem !== null) { - //! [5] - if (text === "Start") { - explorer.selectedSensorItem.start = true; - text = "Stop"; - } - else { - explorer.selectedSensorItem.start = false; - text = "Start"; - } - //! [5] - } - } - } - - } - - GroupBox { - title: qsTr("Properties") - width: parent.width - height: window.height * 0.55 - - enabled: explorer.selectedSensorItem != null - - TableView { - id: propertyList - property PropertyInfo selectedItem: null - - anchors.fill: parent - TableViewColumn { role: "name"; title: qsTr("Name"); width: propertyList.width * 0.5 } - TableViewColumn { role: "value"; title: qsTr("Value"); width: propertyList.width * 0.5 - 5 } - - onClicked: { - selectedItem = model[row] - } - - itemDelegate: { - if (selectedItem && selectedItem.isWriteable) - return editableDelegate; - return readOnlyDelegate; - } - - Component { - id: readOnlyDelegate - Item { - Text { - width: parent.width - anchors.margins: 4 - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - elide: styleData.elideMode - text: styleData.value - color: propertyList.model[styleData.row].isWriteable ? - styleData.textColor : Qt.lighter(styleData.textColor) - } - } - } - - Component { - id: editableDelegate - Item { - Text { - width: parent.width - anchors.margins: 4 - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - elide: styleData.elideMode - text: styleData.value - color: styleData.textColor - visible: !styleData.selected || styleData.column === 0 - } - Loader { // Initialize text editor lazily to improve performance - id: loaderEditor - anchors.margins: 4 - anchors.left: parent.left - anchors.verticalCenter: parent.verticalCenter - Connections { - target: loaderEditor.item - onAccepted: { - //! [4] - explorer.selectedSensorItem.changePropertyValue(propertyList.selectedItem, loaderEditor.item.text); - //! [4] - } - } - - // Load the editor for selected 'Value' cell - sourceComponent: (styleData.selected && styleData.column === 1) ? editor : null - - Component { - id: editor - TextInput { - id: textinput - color: styleData.textColor - text: styleData.value - MouseArea { - id: mouseArea - anchors.fill: parent - hoverEnabled: true - onClicked: textinput.forceActiveFocus() - } - } - } - } - } - } - } - } - } -} diff --git a/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png b/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png Binary files differdeleted file mode 100644 index 4d453cf2..00000000 --- a/examples/sensors/sensorgestures/doc/images/sensorgesturecpp.png +++ /dev/null diff --git a/examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc b/examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc deleted file mode 100644 index 8178cc5a..00000000 --- a/examples/sensors/sensorgestures/doc/src/sensorgestures.qdoc +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \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 660c8416..00000000 --- a/examples/sensors/sensorgestures/main.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 54d1399d..00000000 --- a/examples/sensors/sensorgestures/mainwindow.cpp +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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; - - Q_FOREACH (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 cc74e52a..00000000 --- a/examples/sensors/sensorgestures/mainwindow.h +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef MAINWINDOW_H -#define MAINWINDOW_H - -#include <QtWidgets/QMainWindow> -#include <qsensorgesture.h> -QT_BEGIN_NAMESPACE -namespace Ui { - class MainWindow; -} - -class MainWindow : public QMainWindow -{ - Q_OBJECT - -public: - explicit MainWindow(QWidget *parent = 0); - ~MainWindow(); - -private: - Ui::MainWindow *ui; - QMap <QString, QSensorGesture *> recognizerMap; - -private slots: - void detectedShake(const QString&); - void onShake(); - - void on_pushButton_clicked(); - - void on_startPushButton_clicked(); - void on_stopPushButton_clicked(); -}; - - -QT_END_NAMESPACE - -#endif // MAINWINDOW_H diff --git a/examples/sensors/sensorgestures/mainwindow.ui b/examples/sensors/sensorgestures/mainwindow.ui deleted file mode 100644 index baccf98c..00000000 --- a/examples/sensors/sensorgestures/mainwindow.ui +++ /dev/null @@ -1,84 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<ui version="4.0"> - <class>MainWindow</class> - <widget class="QMainWindow" name="MainWindow"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>423</width> - <height>474</height> - </rect> - </property> - <property name="windowTitle"> - <string>MainWindow</string> - </property> - <widget class="QWidget" name="centralWidget"> - <layout class="QGridLayout" name="gridLayout"> - <item row="0" column="0" colspan="2"> - <widget class="QTreeWidget" name="treeWidget"> - <column> - <property name="text"> - <string>Gesture Recognizer Id</string> - </property> - </column> - </widget> - </item> - <item row="1" column="0"> - <widget class="QPushButton" name="startPushButton"> - <property name="text"> - <string>Start</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QPushButton" name="stopPushButton"> - <property name="text"> - <string>Stop</string> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QTextEdit" name="textEdit"> - <property name="html"> - <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'Lucida Grande'; font-size:13pt; font-weight:400; font-style:normal;"> -<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'Sans Serif'; font-size:9pt;"></p></body></html></string> - </property> - </widget> - </item> - <item row="3" column="0"> - <widget class="QPushButton" name="pushButton"> - <property name="text"> - <string>Clear</string> - </property> - </widget> - </item> - </layout> - </widget> - <widget class="QMenuBar" name="menuBar"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>423</width> - <height>22</height> - </rect> - </property> - </widget> - <widget class="QToolBar" name="mainToolBar"> - <attribute name="toolBarArea"> - <enum>TopToolBarArea</enum> - </attribute> - <attribute name="toolBarBreak"> - <bool>false</bool> - </attribute> - </widget> - <widget class="QStatusBar" name="statusBar"/> - </widget> - <layoutdefault spacing="6" margin="11"/> - <resources/> - <connections/> -</ui> diff --git a/examples/sensors/sensorgestures/sensorgestures.pro b/examples/sensors/sensorgestures/sensorgestures.pro deleted file mode 100644 index e692a53c..00000000 --- a/examples/sensors/sensorgestures/sensorgestures.pro +++ /dev/null @@ -1,14 +0,0 @@ -TEMPLATE = app -TARGET = gesture -QT += sensors widgets -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 be51a62c..d304cbd9 100644 --- a/examples/sensors/sensors.pro +++ b/examples/sensors/sensors.pro @@ -1,21 +1,5 @@ TEMPLATE = subdirs -SUBDIRS += grue - -qtHaveModule(quick) { - SUBDIRS += \ - maze \ - qmlsensorgestures \ - qmlqtsensors \ - sensor_explorer \ - 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 new file mode 100644 index 00000000..b949213a --- /dev/null +++ b/examples/sensors/sensorsshowcase/CMakeLists.txt @@ -0,0 +1,72 @@ +# 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) + +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 Svg Sensors) +qt_standard_project_setup(REQUIRES 6.5) + +qt_add_executable(sensorsshowcase + main.cpp +) + +set_target_properties(sensorsshowcase PROPERTIES + WIN32_EXECUTABLE TRUE + MACOSX_BUNDLE TRUE +) + +if(ANDROID) + set_property(TARGET sensorsshowcase PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR + ${CMAKE_CURRENT_SOURCE_DIR}/android) +endif() + +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() + +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 +) + +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}" + LIBRARY 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/accelbubble/Info.plist b/examples/sensors/sensorsshowcase/Info.plist index 90725455..61d01e5a 100644 --- a/examples/sensors/accelbubble/Info.plist +++ b/examples/sensors/sensorsshowcase/Info.plist @@ -3,15 +3,15 @@ <plist version="1.0"> <dict> <key>CFBundleDisplayName</key> - <string>accelbubble</string> + <string>sensorsshowcase</string> <key>CFBundleExecutable</key> - <string>accelbubble</string> + <string>sensorsshowcase</string> <key>CFBundleGetInfoString</key> <string>Created by Qt/QMake</string> <key>CFBundleIdentifier</key> - <string>com.digia.accelbubble</string> + <string>com.qt.sensorsshowcase</string> <key>CFBundleName</key> - <string>accelbubble</string> + <string>sensorsshowcase</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> @@ -22,8 +22,6 @@ <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> 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/android/AndroidManifest.xml b/examples/sensors/sensorsshowcase/android/AndroidManifest.xml new file mode 100644 index 00000000..359c0114 --- /dev/null +++ b/examples/sensors/sensorsshowcase/android/AndroidManifest.xml @@ -0,0 +1,57 @@ +<?xml version="1.0"?> +<manifest xmlns:android="http://schemas.android.com/apk/res/android" + package="org.qtproject.example.sensorsshowcase" + 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" + 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:exported="true"> + <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.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 Binary files differnew file mode 100644 index 00000000..5f61088b --- /dev/null +++ b/examples/sensors/sensorsshowcase/android/res/drawable-hdpi/icon.png diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-ldpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-ldpi/icon.png Binary files differnew file mode 100644 index 00000000..605497de --- /dev/null +++ b/examples/sensors/sensorsshowcase/android/res/drawable-ldpi/icon.png diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-mdpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-mdpi/icon.png Binary files differnew file mode 100644 index 00000000..3eb10832 --- /dev/null +++ b/examples/sensors/sensorsshowcase/android/res/drawable-mdpi/icon.png diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-xhdpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-xhdpi/icon.png Binary files differnew file mode 100644 index 00000000..a9e39f88 --- /dev/null +++ b/examples/sensors/sensorsshowcase/android/res/drawable-xhdpi/icon.png diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-xxhdpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-xxhdpi/icon.png Binary files differnew file mode 100644 index 00000000..b489d81e --- /dev/null +++ b/examples/sensors/sensorsshowcase/android/res/drawable-xxhdpi/icon.png diff --git a/examples/sensors/sensorsshowcase/android/res/drawable-xxxhdpi/icon.png b/examples/sensors/sensorsshowcase/android/res/drawable-xxxhdpi/icon.png Binary files differnew file mode 100644 index 00000000..9443da63 --- /dev/null +++ b/examples/sensors/sensorsshowcase/android/res/drawable-xxxhdpi/icon.png diff --git a/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.webp b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.webp Binary files differnew file mode 100644 index 00000000..0ff45403 --- /dev/null +++ b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-gyroscope.webp diff --git a/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.webp b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.webp Binary files differnew file mode 100644 index 00000000..b045b7ba --- /dev/null +++ b/examples/sensors/sensorsshowcase/doc/images/sensorsshowcase-mainview.webp diff --git a/examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc b/examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc new file mode 100644 index 00000000..d3d31c34 --- /dev/null +++ b/examples/sensors/sensorsshowcase/doc/src/sensorsshowcase.qdoc @@ -0,0 +1,78 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only + +/*! + \example sensorsshowcase + \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.webp + + \section1 Overview + + On startup, the application shows a menu with buttons for the subviews for each sensor. + The sensor views instantiate the given sensor, display the sensor's values as numbers, + and also visualize them with a simple graphical representation. + + \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. 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 + + The accelerometer view shows the current device acceleration values and moves around + an image with an amount that is opposite of the device acceleration giving the image + an inertia effect that is proportional with the movement of the device. + + Moving around the image happens in the accelerometer \c onReadingChanged method. + + \snippet sensorsshowcase/Accelerometer.qml 0 + + Whenever there is a new accelerometer value the image translation coordinates are + updated accordingly. + + \section1 Proximity View + + The proximity view shows an image that is enlarged whenever the proximity sensor of + the device is covered. + + \section1 Compass View + + The compass view shows a compass image that is rotated according to the Compass sensor + reading value making the compass turn towards north. + + \section1 Magnetometer View + + The magnetometer view displays a magnet image that is rotated around an amount that is + decided by the rotation angle of the vector given by the x and y magnetometer values. + This results in general in the same rotation as the compass gives, demonstrating one use + 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 + + \section1 Gyroscope View + + \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 + rotational change around the three spatial axes and the time between reading updates + 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 + + By pressing the reset button the image rotation is reset to 0. +*/ + diff --git a/examples/sensors/sensorsshowcase/images/compass.svg b/examples/sensors/sensorsshowcase/images/compass.svg new file mode 100644 index 00000000..009e6ffd --- /dev/null +++ b/examples/sensors/sensorsshowcase/images/compass.svg @@ -0,0 +1,222 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="123.29776mm" + height="123.29776mm" + viewBox="0 0 123.29776 123.29776" + version="1.1" + id="svg5" + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + sodipodi:docname="compass.svg" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview7" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:document-units="mm" + showgrid="false" + showborder="true" + inkscape:zoom="1.5554293" + inkscape:cx="118.61677" + inkscape:cy="123.76005" + inkscape:window-width="2560" + inkscape:window-height="1377" + inkscape:window-x="1912" + inkscape:window-y="72" + inkscape:window-maximized="1" + inkscape:current-layer="layer1" + lock-margins="true" + fit-margin-top="15" + fit-margin-left="15" + fit-margin-right="15" + fit-margin-bottom="15" /> + <defs + id="defs2" /> + <g + inkscape:groupmode="layer" + id="layer2" + inkscape:label="Layer 2" + style="display:inline" + transform="translate(7.215891,-13.196477)"> + <path + sodipodi:type="star" + style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:1.88976;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path2691" + inkscape:flatsided="false" + sodipodi:sides="4" + sodipodi:cx="131.1535" + sodipodi:cy="547.11584" + sodipodi:r1="75.011292" + sodipodi:r2="15.353019" + sodipodi:arg1="0.77933767" + sodipodi:arg2="1.5647358" + inkscape:rounded="0" + inkscape:randomized="0" + d="m 184.51497,599.83441 -53.26842,-37.36583 -52.811613,38.00874 37.365833,-53.26843 -38.008738,-52.81161 53.268428,37.36583 52.81161,-38.00874 -37.36583,53.26843 z" + transform="matrix(0.45357635,0,0,0.48302392,-5.0551384,-189.42468)" /> + <circle + style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path25062" + cx="54.432987" + cy="74.84536" + r="30" /> + <circle + style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.579683;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="circle25206" + cx="54.432987" + cy="74.84536" + r="34.780952" /> + </g> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + style="display:inline" + transform="translate(7.215891,-13.196477)"> + <path + sodipodi:type="star" + style="fill:none;stroke:#000000;stroke-width:1.88976;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path846" + inkscape:flatsided="false" + sodipodi:sides="4" + sodipodi:cx="205.73099" + sodipodi:cy="282.8801" + sodipodi:r1="176.15717" + sodipodi:r2="35.231434" + sodipodi:arg1="1.5707963" + sodipodi:arg2="2.3561945" + inkscape:rounded="0" + inkscape:randomized="0" + d="M 205.73099,459.03726 180.8186,307.79248 29.573822,282.8801 180.8186,257.96771 l 24.91238,-151.24478 24.91239,151.24478 151.24478,24.91238 -151.24478,24.91239 z" + transform="scale(0.26458333)" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 54.432988,28.237108 2e-6,93.216502" + id="path991" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="m 7.8247403,74.845359 93.2164997,-3e-6" + id="path993" /> + <path + style="fill:none;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 47.841587,68.253956 C 61.024391,81.436759 61.024391,81.436759 61.024391,81.436759" + id="path995" /> + <path + style="fill:#ff0000;stroke:#000000;stroke-width:0.264583px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + d="M 61.024391,68.253956 47.841587,81.436759" + id="path997" /> + <path + style="fill:#ff0000;stroke:#000000;stroke-width:0.607473;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 193.43534,269.62014 c -6.2322,-6.23407 -11.33698,-11.55089 -11.34397,-11.81517 -0.007,-0.26428 5.0921,-31.50414 11.33128,-69.4219 l 11.34397,-68.9414 0.0816,40.4123 c 0.0449,22.22675 0.0449,58.56721 0,80.75656 l -0.0816,40.34427 z" + id="path1073" + transform="scale(0.26458333)" /> + <path + style="fill:#aa0000;stroke:#000000;stroke-width:0.607473;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 206.57191,200.26456 c 0.0205,-44.46429 0.0937,-80.62717 0.16276,-80.36197 0.27012,1.03808 22.62323,137.13728 22.62323,137.74386 0,0.42036 -3.98335,4.62794 -11.41164,12.05401 l -11.41164,11.40825 z" + id="path1186" + transform="scale(0.26458333)" /> + <path + style="fill:#0000ff;stroke:#000000;stroke-width:0.607473;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 206.57191,365.49565 -0.0373,-80.84415 11.41164,11.40825 c 7.42829,7.42607 11.41164,11.63365 11.41164,12.05401 0,0.60657 -22.35311,136.70578 -22.62323,137.74386 -0.069,0.2652 -0.14225,-35.89769 -0.16276,-80.36197 z" + id="path1336" + transform="scale(0.26458333)" /> + <path + style="fill:#0000aa;fill-opacity:1;stroke:#000000;stroke-width:0.607473;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="M 193.41121,377.30741 C 187.17832,339.428 182.08439,308.218 182.09137,307.95187 c 0.007,-0.26613 5.14794,-5.61759 11.42434,-11.89212 l 11.41164,-11.40825 v 80.76379 c 0,44.42008 -0.0413,80.76378 -0.0918,80.76378 -0.0505,0 -5.19144,-30.99224 -11.42433,-68.87166 z" + id="path1412" + transform="scale(0.26458333)" /> + <path + style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.607473;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 41.628379,282.04372 c 0.2652,-0.0654 31.724078,-5.25942 69.908621,-11.5423 l 69.42643,-11.4234 11.57959,11.57959 11.57958,11.57958 -81.4882,-0.0373 c -44.818513,-0.0205 -81.271221,-0.0908 -81.006021,-0.15619 z" + id="path2360" + transform="scale(0.26458333)" /> + <path + style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.607473;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 111.38404,295.24525 c -37.746813,-6.24278 -68.992206,-11.41247 -69.434206,-11.48821 -0.442001,-0.0757 35.865552,-0.15937 80.683446,-0.18586 l 81.48708,-0.0482 -11.56902,11.57237 c -6.36296,6.3648 -11.78675,11.55617 -12.05287,11.53638 -0.26612,-0.0198 -31.36762,-5.14373 -69.11443,-11.38651 z" + id="path2436" + transform="scale(0.26458333)" /> + <path + style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.607473;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 218.92415,270.65241 11.58478,-11.58478 69.42124,11.42566 c 38.18168,6.28411 69.63822,11.48048 69.90342,11.54749 0.2652,0.067 -36.18751,0.13862 -81.00602,0.15913 l -81.4882,0.0373 z" + id="path2475" + transform="scale(0.26458333)" /> + <path + style="fill:none;fill-opacity:1;stroke:#000000;stroke-width:0.607473;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 218.91063,295.09538 -11.56902,-11.57237 81.48708,0.0373 c 44.81789,0.0205 81.2701,0.0921 81.0049,0.15913 -0.42568,0.10756 -139.03687,22.94832 -139.26393,22.94832 -0.0495,0 -5.29607,-5.20757 -11.65903,-11.57237 z" + id="path2514" + transform="scale(0.26458333)" /> + <path + style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.21495;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 51.111292,281.19388 c 0.5304,-0.13818 29.895283,-5.01467 65.255298,-10.83664 l 64.29093,-10.5854 10.92713,10.91122 10.92713,10.91123 -76.18242,-0.0746 c -41.900341,-0.041 -75.748469,-0.18764 -75.218068,-0.32583 z" + id="path2999" + transform="scale(0.26458333)" /> + <path + style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1.21495;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + d="m 219.88208,295.10818 -10.92236,-10.94226 76.17766,0.0508 c 41.89771,0.0279 75.88835,0.15784 75.53475,0.28872 -0.3536,0.13088 -28.99521,4.88871 -63.64802,10.57296 -34.65281,5.68424 -63.72839,10.47833 -64.61239,10.65353 -1.3859,0.27467 -3.11163,-1.18855 -12.52964,-10.62371 z" + id="path3075" + transform="scale(0.26458333)" /> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583" + x="48.989689" + y="16.670103" + id="text6475"><tspan + sodipodi:role="line" + id="tspan6473" + style="stroke-width:0.264583" + x="48.989689" + y="16.670103"></tspan></text> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583" + x="50.474586" + y="25.95421" + id="text29322"><tspan + sodipodi:role="line" + id="tspan29320" + style="stroke-width:0.264583" + x="50.474586" + y="25.95421">N</tspan></text> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583" + x="51.019772" + y="131.41812" + id="text33982"><tspan + sodipodi:role="line" + id="tspan33980" + style="stroke-width:0.264583" + x="51.019772" + y="131.41812">S</tspan></text> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583" + x="104.54184" + y="78.702988" + id="text37802"><tspan + sodipodi:role="line" + id="tspan37800" + style="stroke-width:0.264583" + x="104.54184" + y="78.702988">E</tspan></text> + <text + xml:space="preserve" + style="font-style:normal;font-weight:normal;font-size:10.5833px;line-height:1.25;font-family:sans-serif;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.264583" + x="-4.1540327" + y="78.702988" + id="text39852"><tspan + sodipodi:role="line" + id="tspan39850" + style="stroke-width:0.264583" + x="-4.1540327" + y="78.702988">W</tspan></text> + </g> +</svg> diff --git a/examples/sensors/sensorsshowcase/images/magnet.svg b/examples/sensors/sensorsshowcase/images/magnet.svg new file mode 100644 index 00000000..21d9f46b --- /dev/null +++ b/examples/sensors/sensorsshowcase/images/magnet.svg @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + width="152.6804mm" + height="186.70102mm" + viewBox="0 0 152.6804 186.70102" + version="1.1" + id="svg22292" + sodipodi:docname="magnet.svg" + inkscape:version="1.1.1 (3bf5ae0d25, 2021-09-20)" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns="http://www.w3.org/2000/svg" + xmlns:svg="http://www.w3.org/2000/svg"> + <sodipodi:namedview + id="namedview22294" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageshadow="2" + inkscape:pageopacity="0.0" + inkscape:pagecheckerboard="0" + inkscape:document-units="mm" + showgrid="false" + inkscape:zoom="3.1108586" + inkscape:cx="384.62051" + inkscape:cy="214.24953" + inkscape:window-width="2560" + inkscape:window-height="1377" + inkscape:window-x="1912" + inkscape:window-y="72" + inkscape:window-maximized="1" + inkscape:current-layer="layer1" /> + <defs + id="defs22289" /> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0.34020391,-51.711357)"> + <path + style="fill:none;stroke:#0000ff;stroke-width:40;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path22661" + sodipodi:type="arc" + sodipodi:cx="76.206184" + sodipodi:cy="162.27835" + sodipodi:rx="56.134018" + sodipodi:ry="56.134018" + sodipodi:start="1.5707963" + sodipodi:end="3.1415927" + sodipodi:arc-type="arc" + d="M 76.206184,218.41237 A 56.134018,56.134018 0 0 1 36.513439,201.9711 56.134018,56.134018 0 0 1 20.072166,162.27835" + sodipodi:open="true" /> + <rect + style="fill:#cccccc;fill-opacity:1;stroke:none;stroke-width:0.814709;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect22976" + width="39.829895" + height="50.35051" + x="0.17010537" + y="51.711357" /> + <path + style="fill:#ff0000;stroke:#ff0000;stroke-width:40;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="path23734" + sodipodi:type="arc" + sodipodi:cx="-76.206184" + sodipodi:cy="162.27835" + sodipodi:rx="56.134018" + sodipodi:ry="56.134018" + sodipodi:start="1.5707963" + sodipodi:end="3.1415927" + sodipodi:arc-type="arc" + d="M -76.206184,218.41237 A 56.134018,56.134018 0 0 1 -115.89893,201.9711 56.134018,56.134018 0 0 1 -132.3402,162.27835" + sodipodi:open="true" + transform="scale(-1,1)" /> + <rect + style="fill:#cccccc;fill-opacity:1;stroke:none;stroke-width:0.816447;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect24456" + width="40" + height="50.35051" + x="112.26804" + y="51.711357" /> + <rect + style="fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:1.00283;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect24480" + width="40" + height="60.340206" + x="112.26804" + y="102.06187" /> + <rect + style="fill:#0000ff;fill-opacity:1;stroke:none;stroke-width:1.00563;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" + id="rect24580" + width="39.829895" + height="60.93557" + x="0.17010537" + y="102.06187" /> + </g> +</svg> diff --git a/examples/sensors/sensorsshowcase/images/qt_logo.png b/examples/sensors/sensorsshowcase/images/qt_logo.png Binary files differnew file mode 100644 index 00000000..3a75e10c --- /dev/null +++ b/examples/sensors/sensorsshowcase/images/qt_logo.png diff --git a/examples/sensors/sensorsshowcase/main.cpp b/examples/sensors/sensorsshowcase/main.cpp new file mode 100644 index 00000000..4a7bd285 --- /dev/null +++ b/examples/sensors/sensorsshowcase/main.cpp @@ -0,0 +1,18 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause +#include <QGuiApplication> +#include <QQmlApplicationEngine> + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc,argv); + 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/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 new file mode 100644 index 00000000..cded9071 --- /dev/null +++ b/examples/sensors/sensorsshowcase/sensorsshowcase.pro @@ -0,0 +1,46 @@ +# 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 + +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 + +qml_resources.prefix = /qt/qml/SensorShowcaseModule + +data_resources.files = \ + qtquickcontrols2.conf + +data_resources.prefix = / + +RESOURCES += \ + qml_resources \ + data_resources + +android { + OTHER_FILES = android/AndroidManifest.xml + ANDROID_PACKAGE_SOURCE_DIR = $$PWD/android +} + +ios { + QMAKE_INFO_PLIST = Info.plist + EXAMPLE_FILES += Info.plist +} + +target.path = $$[QT_INSTALL_EXAMPLES]/sensors/sensorsshowcase +INSTALLS += target 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/audio/loopy2a_mono.wav b/examples/sensors/shakeit/audio/loopy2a_mono.wav Binary files differdeleted file mode 100644 index 7d76cb65..00000000 --- a/examples/sensors/shakeit/audio/loopy2a_mono.wav +++ /dev/null diff --git a/examples/sensors/shakeit/audio/phone.wav b/examples/sensors/shakeit/audio/phone.wav Binary files differdeleted file mode 100644 index 884e9ac2..00000000 --- a/examples/sensors/shakeit/audio/phone.wav +++ /dev/null diff --git a/examples/sensors/shakeit/content/triangle.png b/examples/sensors/shakeit/content/triangle.png Binary files differdeleted file mode 100644 index f366537e..00000000 --- a/examples/sensors/shakeit/content/triangle.png +++ /dev/null diff --git a/examples/sensors/shakeit/content/triangle2.png b/examples/sensors/shakeit/content/triangle2.png Binary files differdeleted file mode 100644 index 9318d5a3..00000000 --- a/examples/sensors/shakeit/content/triangle2.png +++ /dev/null diff --git a/examples/sensors/shakeit/content/triangle3.png b/examples/sensors/shakeit/content/triangle3.png Binary files differdeleted file mode 100644 index 4cc5ccda..00000000 --- a/examples/sensors/shakeit/content/triangle3.png +++ /dev/null diff --git a/examples/sensors/shakeit/doc/images/shakeit.png b/examples/sensors/shakeit/doc/images/shakeit.png Binary files differdeleted file mode 100644 index 5ca1b58c..00000000 --- a/examples/sensors/shakeit/doc/images/shakeit.png +++ /dev/null diff --git a/examples/sensors/shakeit/doc/src/shakeit.qdoc b/examples/sensors/shakeit/doc/src/shakeit.qdoc deleted file mode 100644 index 6a42388b..00000000 --- a/examples/sensors/shakeit/doc/src/shakeit.qdoc +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: https://www.gnu.org/licenses/fdl-1.3.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! - \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 44b1f278..00000000 --- a/examples/sensors/shakeit/main.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#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 00eb1ab3..00000000 --- a/examples/sensors/shakeit/shakeit.pro +++ /dev/null @@ -1,15 +0,0 @@ -TEMPLATE = app -TARGET = shakeit -QT += quick -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 b5d5b499..00000000 --- a/examples/sensors/shakeit/shakeit.qml +++ /dev/null @@ -1,334 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -import QtQuick 2.0 -//! [0] -import QtSensors 5.0 -//! [0] -import QtMultimedia 5.0 - - - -Rectangle { - id: window - width: 320 - height: 480 - - state: "default" - - Audio { - id :phone - source: "audio/phone.wav" //mono - } - Audio { - id :loopy2a_mono - source: "audio/loopy2a_mono.wav" //mono - } - - 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); - } - PropertyChanges { target: triangle2; rotation: 0; - x: parent.width / 2 - (triangle1.width + triangle2.width / 2) - y: parent.height / 2 + (triangle2.height / 2); - } - PropertyChanges { target: triangle3; rotation: 0; - x: parent.width / 2 + (triangle1.width / 2) - y: parent.height / 2 + (triangle3.height / 2); - } - }, - 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 - } - } - ] - - - 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" } - } - } - ] - -//! [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 = "default" - loopy2a_mono.play(); - timer.start() - } - if (gesture == "pickup") { - window.state = "default" - phone.play() - 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 3f198bb1..00000000 --- a/examples/sensors/stub.h +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtSensors module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** BSD License Usage -** Alternatively, you may use this file under the terms of the BSD license -** as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of The Qt Company Ltd nor the names of its -** contributors may be used to endorse or promote products derived -** from this software without specific prior written permission. -** -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include <QGuiApplication> -#include <QQuickView> - -#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();\ -} |