1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtFeedback module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL3$
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 http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 3 as published by the Free Software
20** Foundation and appearing in the file LICENSE.LGPLv3 included in the
21** packaging of this file. Please review the following information to
22** ensure the GNU Lesser General Public License version 3 requirements
23** will be met: https://www.gnu.org/licenses/lgpl.html.
24**
25** GNU General Public License Usage
26** Alternatively, this file may be used under the terms of the GNU
27** General Public License version 2.0 or later as published by the Free
28** Software Foundation and appearing in the file LICENSE.GPL included in
29** the packaging of this file. Please review the following information to
30** ensure the GNU General Public License version 2.0 requirements will be
31** met: http://www.gnu.org/licenses/gpl-2.0.html.
32**
33** $QT_END_LICENSE$
34**
35****************************************************************************/
36
37#include "qdeclarativefeedbackactuator_p.h"
38
39/*!
40 \qmltype Actuator
41 \instantiates QFeedbackActuator
42 \brief The Actuator element represents a feedback actuator.
43 \ingroup qml-feedback-api
44
45 The Actuator class maps directly to the QFeedbackActuator C++ class, and
46 can be used with HapticsEffect elements.
47
48 There are several predefined enumerations and constants provided in this object:
49
50 1. Capability
51 \list
52 \li Envelope - Value specifying that the device can bound its intensity by an envelope.
53 \li Period - Value specifying that the device can play periodic effects.
54 \endlist
55
56 2. State
57 \list
58 \li Busy - The actuator is busy.
59 \li Ready - The actuator is ready to play an effect.
60 \li Unknown - The actuator is in an unknown state.
61 \endlist
62
63 \sa HapticsEffect, {QFeedbackActuator}
64*/
65QDeclarativeFeedbackActuator::QDeclarativeFeedbackActuator(QObject *parent)
66 :QObject(parent)
67{
68 d = new QFeedbackActuator(this);
69 connect(sender: d, SIGNAL(enabledChanged()), receiver: this, SIGNAL(enabledChanged()));
70}
71
72QDeclarativeFeedbackActuator::QDeclarativeFeedbackActuator(QObject *parent, QFeedbackActuator* actuator)
73 :QObject(parent)
74{
75 d = actuator;
76 connect(sender: d, SIGNAL(enabledChanged()), receiver: this, SIGNAL(enabledChanged()));
77}
78
79QFeedbackActuator* QDeclarativeFeedbackActuator::feedbackActuator() const
80{
81 return d;
82}
83
84/*!
85 \qmlproperty int Actuator::actuatorId
86 This property holds the id of the feedback actuator.
87 This property is read only.
88*/
89int QDeclarativeFeedbackActuator::actuatorId() const
90{
91 return d->id();
92}
93
94/*!
95 \qmlproperty bool Actuator::valid
96
97 This property is true if the actuator is valid.
98 This property is read only.
99*/
100bool QDeclarativeFeedbackActuator::isValid() const
101{
102 return d->isValid();
103}
104/*!
105 \qmlproperty string Actuator::name
106 This property holds the name of the feedback actuator.
107 This property is read only.
108*/
109QString QDeclarativeFeedbackActuator::name() const
110{
111 return d->name();
112}
113
114/*!
115 \qmlproperty enumeration Actuator::state
116 This property holds the state of the feedback actuator.
117 This property is read only.
118*/
119QDeclarativeFeedbackActuator::State QDeclarativeFeedbackActuator::state() const
120{
121 return static_cast<State>(d->state());
122}
123
124/*!
125 \qmlmethod bool Actuator::isCapabilitySupported(enumeration capability)
126 Returns if the actuator supports the supplied \a capability, available capabilities are:
127 \list
128 \li Envelope - Value specifying that the device can bound its intensity by an Envelope.
129 \li Period - Value specifying that the device can play periodic effects.
130 \endlist
131*/
132bool QDeclarativeFeedbackActuator::isCapabilitySupported(Capability capability) const
133{
134 return d->isCapabilitySupported(static_cast<QFeedbackActuator::Capability>(capability));
135}
136/*!
137 \qmlproperty bool Actuator::enabled
138 This property is true if the feedback actuator is enabled.
139*/
140
141bool QDeclarativeFeedbackActuator::isEnabled() const
142{
143 return d->isEnabled();
144}
145void QDeclarativeFeedbackActuator::setEnabled(bool v)
146{
147 d->setEnabled(v);
148}
149

source code of qtfeedback/src/imports/feedback/qdeclarativefeedbackactuator.cpp