7#include <QtGui/qguiapplication.h>
8#include <QtQml/qqmlinfo.h>
9#include <QtQml/qqmlfile.h>
10#include <QtQml/qqmlengine.h>
11#include <QtGui/qmovie.h>
12#if QT_CONFIG(qml_network)
13#include <QtNetwork/qnetworkrequest.h>
14#include <QtNetwork/qnetworkreply.h>
141#if QT_CONFIG(qml_network)
143 d->reply->deleteLater();
168 if (pause ==
d->paused)
174 d->movie->setPaused(pause);
207 if (play ==
d->playing)
234 return d->presetCurrentFrame;
235 return d->movie->currentFrameNumber();
242 d->presetCurrentFrame =
frame;
245 d->movie->jumpToFrame(
frame);
253 return d->movie->frameCount();
288#if QT_CONFIG(qml_network)
290 d->reply->deleteLater();
297 d->setMovie(
nullptr);
309 if (
d->url.isEmpty()) {
322 const qreal targetDevicePixelRatio = (
window() ?
window()->effectiveDevicePixelRatio() :
qApp->devicePixelRatio());
323 d->devicePixelRatio = 1.0;
335 movieRequestFinished();
337#if QT_CONFIG(qml_network)
343 d->reply =
qmlEngine(
this)->networkAccessManager()->get(req);
351void QQuickAnimatedImage::movieRequestFinished()
355#if QT_CONFIG(qml_network)
360 if (!
d->movie || !
d->movie->isValid()) {
362 qmlWarning(
this) <<
"Error Reading Animated Image File "
364 d->setMovie(
nullptr);
384 d->movie->setSpeed(
qRound(
d->speed * 100.0));
388 bool pausedAtStart =
d->paused;
389 if (
d->movie &&
d->playing)
391 if (
d->movie && pausedAtStart)
392 d->movie->setPaused(
true);
393 if (
d->movie && (
d->paused || !
d->playing)) {
394 d->movie->jumpToFrame(
d->presetCurrentFrame);
395 d->presetCurrentFrame = 0;
413void QQuickAnimatedImage::movieUpdate()
421 d->setPixmap(*
d->infoForCurrentFrame(
qmlEngine(
this)));
422 emit QQuickImageBase::currentFrameChanged();
426void QQuickAnimatedImage::playingStatusChanged()
440void QQuickAnimatedImage::onCacheChanged()
465 const int oldFrameCount =
q->frameCount();
478 if (oldFrameCount !=
q->frameCount())
479 emit q->frameCountChanged();
484#include "moc_qquickanimatedimage_p.cpp"
iterator insert(const Key &key, const T &value)
T value(const Key &key, const T &defaultValue=T()) const
bool contains(const Key &key) const
QImage currentImage() const
Returns the current frame as a QImage.
int currentFrameNumber() const
Returns the sequence number of the current frame.
QString fileName() const
Returns the name of the file that QMovie reads image data from.
void stateChanged(QMovie::MovieState state)
This signal is emitted every time the state of the movie changes.
void frameChanged(int frameNumber)
void setScaledSize(const QSize &size)
void finished()
This signal is emitted when the reply has finished processing.
The QNetworkRequest class holds a request to be sent with QNetworkAccessManager.
@ HttpPipeliningAllowedAttribute
void setAttribute(Attribute code, const QVariant &value)
Sets the attribute associated with code code to be value value.
static bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *member)
\threadsafe
void deleteLater()
\threadsafe
The QQmlContext class defines a context within a QML engine.
The QQmlEngine class provides an environment for instantiating QML components.
static QString urlToLocalFileOrQrc(const QString &)
If url is a local file returns a path suitable for passing to QFile.
void setMovie(QMovie *movie)
QQuickPixmap * infoForCurrentFrame(QQmlEngine *engine)
QMap< int, QQuickPixmap * > frameMap
void setPaused(bool pause)
void currentFrameChanged()
void setSpeed(qreal speed)
void componentComplete() override
Invoked after the root component that caused this instantiation has completed construction.
void setSource(const QUrl &) override
bool isPlaying() const
\qmlproperty bool QtQuick::AnimatedImage::playing This property holds whether the animated image is p...
void setCurrentFrame(int frame) override
QQuickAnimatedImage(QQuickItem *parent=nullptr)
\qmltype AnimatedImage \instantiates QQuickAnimatedImage \inqmlmodule QtQuick \inherits Image
void setPlaying(bool play)
bool isPaused() const
\qmlproperty bool QtQuick::AnimatedImage::paused This property holds whether the animated image is pa...
static void resolve2xLocalFile(const QUrl &url, qreal targetDevicePixelRatio, QUrl *sourceUrl, qreal *sourceDevicePixelRatio)
void sourceChanged(const QUrl &)
The QQuickImageProviderOptions class provides options for QQuickImageProviderWithOptions image reques...
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
void componentComplete() override
\reimp Derived classes should call the base class method before adding their own actions to perform a...
bool isComponentComplete() const
Returns true if construction of the QML component is complete; otherwise returns false.
static bool isCached(const QUrl &url, const QRect &requestRegion, const QSize &requestSize, const int frame, const QQuickImageProviderOptions &options)
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
bool isEmpty() const
Returns true if the URL has no data; otherwise returns false.
void setUrl(const QString &url, ParsingMode mode=TolerantMode)
Parses url and sets this object to that value.
qDeleteAll(list.begin(), list.end())
Combined button and popup list for selecting options.
int qRound(qfloat16 d) noexcept
GLdouble GLdouble GLdouble GLdouble q
QQmlEngine * qmlEngine(const QObject *obj)
QQmlContext * qmlContext(const QObject *obj)
Q_QML_EXPORT QQmlInfo qmlWarning(const QObject *me)
static QUrl resolvedUrl(const QUrl &url, const QQmlRefPointer< QQmlContextData > &context)
QUrl url("example.com")
[constructor-url-reference]
connect(quitButton, &QPushButton::clicked, &app, &QCoreApplication::quit, Qt::QueuedConnection)
char * toString(const MyType &t)
[31]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent