1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the QtSensors module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29#include <QDebug>
30#include <QTimer>
31
32#include "qtemplaterecognizer.h"
33
34QTemplateGestureRecognizer::QTemplateGestureRecognizer(QObject *parent)
35 : QSensorGestureRecognizer(parent)
36{
37}
38
39QTemplateGestureRecognizer::~QTemplateGestureRecognizer()
40{
41
42}
43
44void QTemplateGestureRecognizer::create()
45{
46 connect(sender: &_timer,SIGNAL(timeout()),receiver: this,SLOT(timeout()));
47 _timer.setInterval(1000);
48}
49
50bool QTemplateGestureRecognizer::start()
51{
52 Q_EMIT detected(id());
53 _timer.start();
54 return _timer.isActive();
55}
56
57bool QTemplateGestureRecognizer::stop()
58{
59 _timer.stop();
60 return true;
61}
62
63
64bool QTemplateGestureRecognizer::isActive()
65{
66 return _timer.isActive();
67}
68
69QString QTemplateGestureRecognizer::id() const
70{
71 return QString("QtSensors.template");
72}
73
74void QTemplateGestureRecognizer::timeout()
75{
76 Q_EMIT detected(id());
77}
78
79
80QTemplateGestureRecognizer1::QTemplateGestureRecognizer1(QObject *parent)
81 : QSensorGestureRecognizer(parent)
82{
83}
84
85QTemplateGestureRecognizer1::~QTemplateGestureRecognizer1()
86{
87
88}
89
90void QTemplateGestureRecognizer1::create()
91{
92 connect(sender: &_timer,SIGNAL(timeout()),receiver: this,SLOT(timeout()));
93 _timer.setInterval(500);
94}
95
96bool QTemplateGestureRecognizer1::start()
97{
98 Q_EMIT detected(id());
99 _timer.start();
100 return _timer.isActive();
101}
102
103bool QTemplateGestureRecognizer1::stop()
104{
105 _timer.stop();
106 return true;
107}
108
109
110bool QTemplateGestureRecognizer1::isActive()
111{
112 return _timer.isActive();
113}
114
115QString QTemplateGestureRecognizer1::id() const
116{
117 return QString("QtSensors.template1");
118}
119
120void QTemplateGestureRecognizer1::timeout()
121{
122 Q_EMIT detected(id());
123}
124

source code of qtsensors/tests/auto/sensors2qmlapi/qtemplaterecognizer.cpp