| 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 QtCore 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 | /*! | 
| 41 |     \class QPauseAnimation | 
| 42 |     \inmodule QtCore | 
| 43 |     \brief The QPauseAnimation class provides a pause for QSequentialAnimationGroup. | 
| 44 |     \since 4.6 | 
| 45 |     \ingroup animation | 
| 46 |  | 
| 47 |     If you wish to introduce a delay between animations in a | 
| 48 |     QSequentialAnimationGroup, you can insert a QPauseAnimation. This | 
| 49 |     class does not animate anything, but does not | 
| 50 |     \l{QAbstractAnimation::finished()}{finish} before a specified | 
| 51 |     number of milliseconds have elapsed from when it was started. You | 
| 52 |     specify the duration of the pause in the constructor. It can also | 
| 53 |     be set directly with setDuration(). | 
| 54 |  | 
| 55 |     It is not necessary to construct a QPauseAnimation yourself. | 
| 56 |     QSequentialAnimationGroup provides the convenience functions | 
| 57 |     \l{QSequentialAnimationGroup::}{addPause()} and | 
| 58 |     \l{QSequentialAnimationGroup::}{insertPause()}. These functions | 
| 59 |     simply take the number of milliseconds the pause should last. | 
| 60 |  | 
| 61 |     \sa QSequentialAnimationGroup | 
| 62 | */ | 
| 63 |  | 
| 64 | #include "qpauseanimation.h" | 
| 65 | #include "qabstractanimation_p.h" | 
| 66 |  | 
| 67 | QT_BEGIN_NAMESPACE | 
| 68 |  | 
| 69 | class QPauseAnimationPrivate : public QAbstractAnimationPrivate | 
| 70 | { | 
| 71 | public: | 
| 72 |     QPauseAnimationPrivate() : QAbstractAnimationPrivate(), duration(250) | 
| 73 |     { | 
| 74 |         isPause = true; | 
| 75 |     } | 
| 76 |  | 
| 77 |     int duration; | 
| 78 | }; | 
| 79 |  | 
| 80 | /*! | 
| 81 |     Constructs a QPauseAnimation. | 
| 82 |     \a parent is passed to QObject's constructor. | 
| 83 |     The default duration is 0. | 
| 84 | */ | 
| 85 |  | 
| 86 | QPauseAnimation::QPauseAnimation(QObject *parent) : QAbstractAnimation(*new QPauseAnimationPrivate, parent) | 
| 87 | { | 
| 88 | } | 
| 89 |  | 
| 90 | /*! | 
| 91 |     Constructs a QPauseAnimation. | 
| 92 |     \a msecs is the duration of the pause. | 
| 93 |     \a parent is passed to QObject's constructor. | 
| 94 | */ | 
| 95 |  | 
| 96 | QPauseAnimation::QPauseAnimation(int msecs, QObject *parent) : QAbstractAnimation(*new QPauseAnimationPrivate, parent) | 
| 97 | { | 
| 98 |     setDuration(msecs); | 
| 99 | } | 
| 100 |  | 
| 101 | /*! | 
| 102 |     Destroys the pause animation. | 
| 103 | */ | 
| 104 | QPauseAnimation::~QPauseAnimation() | 
| 105 | { | 
| 106 | } | 
| 107 |  | 
| 108 | /*! | 
| 109 |     \property QPauseAnimation::duration | 
| 110 |     \brief the duration of the pause. | 
| 111 |  | 
| 112 |     The duration of the pause. The duration should not be negative. | 
| 113 |     The default duration is 250 milliseconds. | 
| 114 | */ | 
| 115 | int QPauseAnimation::duration() const | 
| 116 | { | 
| 117 |     Q_D(const QPauseAnimation); | 
| 118 |     return d->duration; | 
| 119 | } | 
| 120 |  | 
| 121 | void QPauseAnimation::setDuration(int msecs) | 
| 122 | { | 
| 123 |     if (msecs < 0) { | 
| 124 |         qWarning(msg: "QPauseAnimation::setDuration: cannot set a negative duration" ); | 
| 125 |         return; | 
| 126 |     } | 
| 127 |     Q_D(QPauseAnimation); | 
| 128 |     d->duration = msecs; | 
| 129 | } | 
| 130 |  | 
| 131 | /*! | 
| 132 |     \reimp | 
| 133 |  */ | 
| 134 | bool QPauseAnimation::event(QEvent *e) | 
| 135 | { | 
| 136 |     return QAbstractAnimation::event(event: e); | 
| 137 | } | 
| 138 |  | 
| 139 | /*! | 
| 140 |     \reimp | 
| 141 |  */ | 
| 142 | void QPauseAnimation::updateCurrentTime(int) | 
| 143 | { | 
| 144 | } | 
| 145 |  | 
| 146 |  | 
| 147 | QT_END_NAMESPACE | 
| 148 |  | 
| 149 | #include "moc_qpauseanimation.cpp" | 
| 150 |  |