| 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 "qdeclarativethemeeffect_p.h" | 
| 38 | /*! | 
| 39 |     \qmltype ThemeEffect | 
| 40 |     \brief The ThemeEffect element represents a themed feedback effect. | 
| 41 |     \ingroup qml-feedback-api | 
| 42 |  | 
| 43 |     This element is used for playing feedback effects that follow the | 
| 44 |     system theme.  The actual feedback might be haptic, audio or some other | 
| 45 |     method. | 
| 46 |  | 
| 47 |     \snippet doc/src/snippets/declarative/declarative-feedback.qml Theme | 
| 48 | */ | 
| 49 | QDeclarativeThemeEffect::QDeclarativeThemeEffect(QObject *parent) | 
| 50 |     : QObject(parent), | 
| 51 |     m_effect(QDeclarativeThemeEffect::Undefined) | 
| 52 | { | 
| 53 | } | 
| 54 |  | 
| 55 | /*! | 
| 56 |     \qmlproperty bool ThemeEffect::supported | 
| 57 |  | 
| 58 |     This property is true if the system supports themed feedback effects. | 
| 59 | */ | 
| 60 | bool QDeclarativeThemeEffect::effectSupported() { | 
| 61 |     return QFeedbackEffect::supportsThemeEffect(); | 
| 62 | } | 
| 63 |  | 
| 64 | /*! | 
| 65 |     \qmlproperty ThemeEffect ThemeEffect::effect | 
| 66 |  | 
| 67 |     This property holds the specific themed effect type to play.  It is one of: | 
| 68 |  | 
| 69 |     \li Effect.Undefined - Undefined feedback. No feedback is given. | 
| 70 |     \li Effect.Press - Feedback for when the screen is pressed. | 
| 71 |     \li Effect.Release - Feedback for touch release. | 
| 72 |     \li Effect.PressWeak - A weak feedback for press. | 
| 73 |     \li Effect.ReleaseWeak - A weak feedback for release. | 
| 74 |     \li Effect.PressStrong - A strong feedback for press. | 
| 75 |     \li Effect.ReleaseStrong - A strong feedback for release. | 
| 76 |     \li Effect.DragStart - Feedback for when dragging starts. | 
| 77 |     \li Effect.DragDropInZone - Feedback for when dragging ends and touch is released inside a drop zone. | 
| 78 |     \li Effect.DragDropOutOfZone - Feedback for when dragging ends and touch is released outside a drop zone. | 
| 79 |     \li Effect.DragCrossBoundary - Feedback for when crossing a boundary while dragging. | 
| 80 |     \li Effect.Appear - Feedback for when an item is shown. | 
| 81 |     \li Effect.Disappear - Feedback for when an item item is closed. | 
| 82 |     \li Effect.Move - Feedback for dragging on screen. | 
| 83 |   \endlist | 
| 84 |  | 
| 85 |   \sa QFeedbackEffect::Effect | 
| 86 | */ | 
| 87 | void QDeclarativeThemeEffect::setEffect(QDeclarativeThemeEffect::Effect effect) | 
| 88 | { | 
| 89 |     if (m_effect != effect) { | 
| 90 |         m_effect = effect; | 
| 91 |         emit effectChanged(); | 
| 92 |     } | 
| 93 | } | 
| 94 |  | 
| 95 | QDeclarativeThemeEffect::Effect QDeclarativeThemeEffect::effect() const | 
| 96 | { | 
| 97 |     return m_effect; | 
| 98 | } | 
| 99 |  | 
| 100 | /*! | 
| 101 |     \qmlmethod ThemeEffect::play() | 
| 102 |  | 
| 103 |     Call this to play the themed effect. | 
| 104 | */ | 
| 105 | void QDeclarativeThemeEffect::play() | 
| 106 | { | 
| 107 |     QFeedbackEffect::playThemeEffect(effect: static_cast<QFeedbackEffect::Effect>(m_effect)); | 
| 108 | } | 
| 109 |  | 
| 110 | /*! | 
| 111 |     \qmlmethod ThemeEffect::play(Effect) | 
| 112 |  | 
| 113 |     Call this to play the themed effect passed as parameter. | 
| 114 |  | 
| 115 | */ | 
| 116 | void QDeclarativeThemeEffect::play(Effect effect) | 
| 117 | { | 
| 118 |     QFeedbackEffect::playThemeEffect(effect: static_cast<QFeedbackEffect::Effect>(effect)); | 
| 119 | } | 
| 120 |  |