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 "qdeclarativefileeffect_p.h" |
38 | /*! |
39 | \internal |
40 | \qmltype FileEffect |
41 | \brief The FileEffect element represents feedback data stored in a file. |
42 | \ingroup qml-feedback-api |
43 | \inherits FeedbackEffect |
44 | |
45 | \snippet doc/src/snippets/declarative/declarative-feedback.qml File Effect |
46 | |
47 | \sa HapticsEffect, {QFeedbackActuator} |
48 | */ |
49 | QDeclarativeFileEffect::QDeclarativeFileEffect(QObject *parent) |
50 | : QDeclarativeFeedbackEffect(parent) |
51 | { |
52 | d = new QFeedbackFileEffect(this); |
53 | setFeedbackEffect(d); |
54 | } |
55 | |
56 | /*! |
57 | \qmlproperty bool FileEffect::loaded |
58 | |
59 | This property is true if this feedback effect is loaded. |
60 | */ |
61 | bool QDeclarativeFileEffect::isLoaded() const |
62 | { |
63 | return d->isLoaded(); |
64 | } |
65 | void QDeclarativeFileEffect::setLoaded(bool v) |
66 | { |
67 | if (v != d->isLoaded()) { |
68 | d->setLoaded(v); |
69 | emit loadedChanged(); |
70 | } |
71 | } |
72 | |
73 | /*! |
74 | \qmlproperty url FileEffect::source |
75 | |
76 | This property stores the URL for the feedback data. |
77 | */ |
78 | QUrl QDeclarativeFileEffect::source() const |
79 | { |
80 | return d->source(); |
81 | } |
82 | void QDeclarativeFileEffect::setSource(const QUrl & url) |
83 | { |
84 | if (url != d->source()) { |
85 | d->setSource(url); |
86 | emit sourceChanged(); |
87 | } |
88 | } |
89 | |
90 | /*! |
91 | \qmlproperty list<string> FileEffect::supportedMimeTypes |
92 | |
93 | This property holds the MIME types supported for playing effects from a file. |
94 | */ |
95 | QStringList QDeclarativeFileEffect::supportedMimeTypes() |
96 | { |
97 | return d->supportedMimeTypes(); |
98 | } |
99 | |
100 | /*! |
101 | \qmlmethod FileEffect::load() |
102 | |
103 | Makes sure that the file associated with the feedback object is loaded. |
104 | \sa QFeedbackFileEffect::load() |
105 | */ |
106 | void QDeclarativeFileEffect::load() |
107 | { |
108 | if (!isLoaded()) { |
109 | d->load(); |
110 | emit loadedChanged(); |
111 | } |
112 | } |
113 | |
114 | /*! |
115 | \qmlmethod FileEffect::unload() |
116 | |
117 | Makes sure that the file associated with the feedback object is unloaded. |
118 | \sa QFeedbackFileEffect::unload() |
119 | */ |
120 | void QDeclarativeFileEffect::unload() |
121 | { |
122 | if (isLoaded()) { |
123 | d->unload(); |
124 | emit loadedChanged(); |
125 | } |
126 | } |
127 | |