Debian Codegraph @

src/imports/feedback/qdeclarativethemeeffect.cpp

raw symbols SCIP
1 /****************************************************************************
2 **
3 ** Copyright (C) 2017 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtFeedback module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 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.LGPL3 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-3.0.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 (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39
40 #include "qdeclarativethemeeffect_p.h"
41 /*!
42 \qmltype ThemeEffect
43 \brief The ThemeEffect element represents a themed feedback effect.
44 \ingroup qml-feedback-api
45
46 This element is used for playing feedback effects that follow the
47 system theme. The actual feedback might be haptic, audio or some other
48 method.
49
50 \snippet doc/src/snippets/declarative/declarative-feedback.qml Theme
51 */
52 QDeclarativeThemeEffect::QDeclarativeThemeEffect(QObject *parent)
53 : QObject(parent),
54 m_effect(QDeclarativeThemeEffect::Undefined)
55 {
56 }
57
58 /*!
59 \qmlproperty bool ThemeEffect::supported
60
61 This property is true if the system supports themed feedback effects.
62 */
63 bool QDeclarativeThemeEffect::effectSupported() {
64 return QFeedbackEffect::supportsThemeEffect();
65 }
66
67 /*!
68 \qmlproperty ThemeEffect ThemeEffect::effect
69
70 This property holds the specific themed effect type to play. It is one of:
71
72 \li Effect.Undefined - Undefined feedback. No feedback is given.
73 \li Effect.Press - Feedback for when the screen is pressed.
74 \li Effect.Release - Feedback for touch release.
75 \li Effect.PressWeak - A weak feedback for press.
76 \li Effect.ReleaseWeak - A weak feedback for release.
77 \li Effect.PressStrong - A strong feedback for press.
78 \li Effect.ReleaseStrong - A strong feedback for release.
79 \li Effect.DragStart - Feedback for when dragging starts.
80 \li Effect.DragDropInZone - Feedback for when dragging ends and touch is released inside a drop zone.
81 \li Effect.DragDropOutOfZone - Feedback for when dragging ends and touch is released outside a drop zone.
82 \li Effect.DragCrossBoundary - Feedback for when crossing a boundary while dragging.
83 \li Effect.Appear - Feedback for when an item is shown.
84 \li Effect.Disappear - Feedback for when an item item is closed.
85 \li Effect.Move - Feedback for dragging on screen.
86 \endlist
87
88 \sa QFeedbackEffect::Effect
89 */
90 void QDeclarativeThemeEffect::setEffect(QDeclarativeThemeEffect::Effect effect)
91 {
92 if (m_effect != effect) {
93 m_effect = effect;
94 emit effectChanged();
95 }
96 }
97
98 QDeclarativeThemeEffect::Effect QDeclarativeThemeEffect::effect() const
99 {
100 return m_effect;
101 }
102
103 /*!
104 \qmlmethod ThemeEffect::play()
105
106 Call this to play the themed effect.
107 */
108 void QDeclarativeThemeEffect::play()
109 {
110 QFeedbackEffect::playThemeEffect(static_cast<QFeedbackEffect::Effect>(m_effect));
111 }
112
113 /*!
114 \qmlmethod ThemeEffect::play(Effect)
115
116 Call this to play the themed effect passed as parameter.
117
118 */
119 void QDeclarativeThemeEffect::play(Effect effect)
120 {
121 QFeedbackEffect::playThemeEffect(static_cast<QFeedbackEffect::Effect>(effect));
122 }