diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-05-17 03:36:35 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-05-17 03:36:35 (GMT) |
commit | fd0b25da6997553bb95ea91bbdd509fa35711b9d (patch) | |
tree | cacaa230a8d8a1b7cc2ffee84d603a429194ebbb /src/declarative | |
parent | e752dda20ae8b8e75de653371b6bd369d2966104 (diff) | |
download | Qt-fd0b25da6997553bb95ea91bbdd509fa35711b9d.zip Qt-fd0b25da6997553bb95ea91bbdd509fa35711b9d.tar.gz Qt-fd0b25da6997553bb95ea91bbdd509fa35711b9d.tar.bz2 |
Fix doc for status, add Image::onLoaded.
statusChanged is NOT emitted for local files, nor should it be (they
are loaded synchronously, so status is *initially* Ready). Add onLoaded
signal that *is* emitted.
Reviewed-by: Michael Brasser
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeloader.cpp | 22 | ||||
-rw-r--r-- | src/declarative/graphicsitems/qdeclarativeloader_p.h | 3 |
2 files changed, 23 insertions, 2 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp index 7edd53c..cbdfd87 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader.cpp +++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp @@ -321,6 +321,7 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() emit q->statusChanged(); emit q->progressChanged(); emit q->itemChanged(); + emit q->loaded(); } } @@ -341,10 +342,13 @@ void QDeclarativeLoaderPrivate::_q_sourceLoaded() of the following ways: \list \o Create a state, so that a state change occurs, e.g. State{name: 'loaded'; when: loader.status = Loader.Ready;} - \o Do something inside the onStatusChanged signal handler, e.g. Loader{id: loader; onStatusChanged: if(loader.status == Loader.Ready) console.log('Loaded');} + \o Do something inside the onLoaded signal handler, e.g. Loader{id: loader; onLoaded: console.log('Loaded');} \o Bind to the status variable somewhere, e.g. Text{text: if(loader.status!=Loader.Ready){'Not Loaded';}else{'Loaded';}} \endlist \sa progress + + Note that if the source is a local file, the status will initially be Ready (or Error). While + there will be no onStatusChanged signal in that case, the onLoaded will still be invoked. */ QDeclarativeLoader::Status QDeclarativeLoader::status() const @@ -360,6 +364,21 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const return d->source.isEmpty() ? Null : Error; } +void QDeclarativeLoader::componentComplete() +{ + if (status() == Ready) + emit loaded(); +} + + +/*! + \qmlsignal Loader::onLoaded() + + This handler is called when the \l status becomes Loader.Ready, or on successful + initial load. +*/ + + /*! \qmlproperty real Loader::progress @@ -382,7 +401,6 @@ qreal QDeclarativeLoader::progress() const return 0.0; } - void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged) { Q_Q(QDeclarativeLoader); diff --git a/src/declarative/graphicsitems/qdeclarativeloader_p.h b/src/declarative/graphicsitems/qdeclarativeloader_p.h index 49dfa11..ec7ffe9 100644 --- a/src/declarative/graphicsitems/qdeclarativeloader_p.h +++ b/src/declarative/graphicsitems/qdeclarativeloader_p.h @@ -84,11 +84,14 @@ Q_SIGNALS: void sourceChanged(); void statusChanged(); void progressChanged(); + void loaded(); protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); QVariant itemChange(GraphicsItemChange change, const QVariant &value); bool eventFilter(QObject *watched, QEvent *e); + void componentComplete(); + private: Q_DISABLE_COPY(QDeclarativeLoader) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeLoader) |