summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativeloader.cpp
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-05-17 03:36:35 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-05-17 03:36:35 (GMT)
commitfd0b25da6997553bb95ea91bbdd509fa35711b9d (patch)
treecacaa230a8d8a1b7cc2ffee84d603a429194ebbb /src/declarative/graphicsitems/qdeclarativeloader.cpp
parente752dda20ae8b8e75de653371b6bd369d2966104 (diff)
downloadQt-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/graphicsitems/qdeclarativeloader.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp22
1 files changed, 20 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);