summaryrefslogtreecommitdiffstats
path: root/examples/sensors/grue/console_app/main.cpp
diff options
context:
space:
mode:
authorJuha Vuolle <juha.vuolle@qt.io>2023-02-17 12:59:11 +0200
committerJuha Vuolle <juha.vuolle@qt.io>2023-02-22 08:37:56 +0200
commit20373cfd4019c66884fb63a4316b1c60ede089ca (patch)
treee84f5e64d7a52d88672e97a9f854276366eadd87 /examples/sensors/grue/console_app/main.cpp
parent849519a842cf34527f4532837dcf84ec6bb28108 (diff)
Remove sensors grue example
The primary purpose of the grue example is to demonstrate how to create new sensors. However, while a nice implementation, it doesn't achieve this purpose particularly well, and is all in all an overly complex construct given the straightforward purpose (for instance causing build and deployment challenges). Instead it should be replaced with a tutorial-like step-by-step guide on how to add new sensors. The item to track this: QTBUG-111251 Task-number: QTBUG-110939 Pick-to: 6.5 Change-Id: If353fd019483ad3d608f16d90820c09e676f1df1 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'examples/sensors/grue/console_app/main.cpp')
-rw-r--r--examples/sensors/grue/console_app/main.cpp52
1 files changed, 0 insertions, 52 deletions
diff --git a/examples/sensors/grue/console_app/main.cpp b/examples/sensors/grue/console_app/main.cpp
deleted file mode 100644
index 7de66334..00000000
--- a/examples/sensors/grue/console_app/main.cpp
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (C) 2017 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
-
-#include <QtCore>
-#include <qsensor.h>
-
-class Filter : public QSensorFilter
-{
- int lastPercent;
-public:
- Filter()
- : QSensorFilter()
- , lastPercent(0)
- {
- }
-
- bool filter(QSensorReading *reading) override
- {
- int percent = reading->property("chanceOfBeingEaten").value<int>();
- if (percent == 0) {
- qDebug() << "It is light. You are safe from Grues.";
- } else if (lastPercent == 0) {
- qDebug() << "It is dark. You are likely to be eaten by a Grue.";
- }
- if (percent == 100) {
- qDebug() << "You have been eaten by a Grue!";
- QCoreApplication::instance()->quit();
- } else if (percent)
- qDebug() << "Your chance of being eaten by a Grue:" << percent << "percent.";
- lastPercent = percent;
- return false;
- }
-};
-
-int main(int argc, char **argv)
-{
- QCoreApplication app(argc, argv);
-
- QSensor sensor("GrueSensor");
-
- Filter filter;
- sensor.addFilter(&filter);
- sensor.start();
-
- if (!sensor.isActive()) {
- qWarning("The Grue sensor didn't start. You're on your own!");
- return 1;
- }
-
- return app.exec();
-}
-