Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickdelaybutton.cpp
Go to the documentation of this file.
1// Copyright (C) 2017 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
6
7#include <QtQuick/private/qquickanimation_p.h>
8#include <QtQuick/private/qquicktransition_p.h>
9#include <QtQuick/private/qquicktransitionmanager_p_p.h>
10
12
17
44
46{
47 Q_DECLARE_PUBLIC(QQuickDelayButton)
48
49public:
50 void beginTransition(qreal to);
51 void finishTransition();
52 void cancelTransition();
53
55
56 int delay = 300;
59 QScopedPointer<QQuickDelayTransitionManager> transitionManager;
60};
61
63{
64public:
66
68
69protected:
70 void finished() override;
71
72private:
73 QQuickDelayButton *m_button = nullptr;
74};
75
77{
79
80 QQmlProperty defaultTarget(m_button, QLatin1String("progress"));
81 QQmlListProperty<QQuickAbstractAnimation> animations = transition->animations();
82 const int count = animations.count(&animations);
83 for (int i = 0; i < count; ++i) {
84 QQuickAbstractAnimation *anim = animations.at(&animations, i);
85 anim->setDefaultTarget(defaultTarget);
86 }
87
88 QList<QQuickStateAction> actions;
89 actions << QQuickStateAction(m_button, QLatin1String("progress"), progress);
91}
92
94{
95 if (qFuzzyCompare(m_button->progress(), qreal(1.0)))
96 emit m_button->activated();
97}
98
100{
102 if (!transition) {
103 q->setProgress(to);
105 return;
106 }
107
110
112}
113
115{
117 if (qFuzzyCompare(progress, qreal(1.0)))
118 emit q->activated();
119}
120
126
132
142{
143 Q_D(const QQuickDelayButton);
144 return d->delay;
145}
146
148{
150 if (d->delay == delay)
151 return;
152
153 d->delay = delay;
155}
156
164{
165 Q_D(const QQuickDelayButton);
166 return d->progress;
167}
168
170{
172 if (qFuzzyCompare(d->progress, progress))
173 return;
174
175 d->progress = progress;
177}
178
186{
187 Q_D(const QQuickDelayButton);
188 return d->transition;
189}
190
192{
194 if (d->transition == transition)
195 return;
196
197 d->transition = transition;
199}
200
202{
204 switch (change) {
206 d->cancelTransition();
207 setProgress(d->checked ? 1.0 : 0.0);
208 break;
210 if (!d->checked)
211 d->beginTransition(d->pressed ? 1.0 : 0.0);
212 break;
213 default:
215 break;
216 }
217}
218
220{
222 setChecked(!d->checked && qFuzzyCompare(d->progress, qreal(1.0)));
223}
224
229
231
232#include "moc_qquickdelaybutton_p.cpp"
\reentrant
Definition qfont.h:22
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
The QQmlProperty class abstracts accessing properties on objects created from QML.
void setDefaultTarget(const QQmlProperty &)
void setChecked(bool checked)
void setCheckable(bool checkable)
virtual void buttonChange(ButtonChange change)
QScopedPointer< QQuickDelayTransitionManager > transitionManager
QPalette defaultPalette() const override
QQuickTransition * transition
void setTransition(QQuickTransition *transition)
void buttonChange(ButtonChange change) override
QQuickTransition * transition
QQuickDelayButton(QQuickItem *parent=nullptr)
QFont defaultFont() const override
void nextCheckState() override
void transitionChanged()
void setDelay(int delay)
void setProgress(qreal progress)
void transition(QQuickTransition *transition, qreal progress)
QQuickDelayTransitionManager(QQuickDelayButton *button)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
static QPalette palette(Scope scope)
static QFont font(Scope scope)
void transition(const QList< QQuickStateAction > &, QQuickTransition *transition, QObject *defaultTarget=nullptr)
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
QPushButton * button
[2]
Combined button and popup list for selecting options.
bool qFuzzyCompare(qfloat16 p1, qfloat16 p2) noexcept
Definition qfloat16.h:333
GLenum GLenum GLsizei count
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
void qmlExecuteDeferred(QObject *object)
Definition qqml.cpp:49
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define emit
double qreal
Definition qtypes.h:187