summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-09-07 06:42:21 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-09-07 06:42:21 (GMT)
commit8252ee3f13f9d8043153e3bbd337f951ffaf49bf (patch)
tree5c26c24327df67a2d04ad5c1fef1c26d0112e8cb
parentdb2b45ec980708fe507b224e82d48bbbbf7a542d (diff)
parentcdc50db23a89721f793ef353fb4d64b0631456c0 (diff)
downloadQt-8252ee3f13f9d8043153e3bbd337f951ffaf49bf.zip
Qt-8252ee3f13f9d8043153e3bbd337f951ffaf49bf.tar.gz
Qt-8252ee3f13f9d8043153e3bbd337f951ffaf49bf.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--doc/src/declarative/extending.qdoc2
-rw-r--r--src/declarative/QmlChanges.txt1
-rw-r--r--src/declarative/fx/qfxitem.cpp11
-rw-r--r--src/declarative/fx/qfxloader.cpp65
-rw-r--r--src/declarative/fx/qfxloader.h13
-rw-r--r--src/declarative/qml/qmlcomponent.cpp23
-rw-r--r--src/declarative/qml/qmlcomponent.h3
-rw-r--r--src/declarative/qml/qmlcomponent_p.h4
-rw-r--r--src/declarative/qml/qmlcompositetypedata_p.h2
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp17
-rw-r--r--src/declarative/qml/qmlcompositetypemanager_p.h1
-rw-r--r--src/declarative/qml/qmlengine.cpp4
-rw-r--r--tools/qmlviewer/qmlviewer.cpp31
13 files changed, 165 insertions, 12 deletions
diff --git a/doc/src/declarative/extending.qdoc b/doc/src/declarative/extending.qdoc
index 3235435..2d0dc34 100644
--- a/doc/src/declarative/extending.qdoc
+++ b/doc/src/declarative/extending.qdoc
@@ -369,7 +369,7 @@ The QML snippet shown above associates the evaluation of a ECMAScript expression
with the emission of a Qt signal.
All Qt signals on a registered class become available as special "signal
-propeties" within QML to which the user can assign a single ECMAScript
+properties" within QML to which the user can assign a single ECMAScript
expression. The signal property's name is a transformed version of the Qt
signal name: "on" is prepended, and the first letter of the signal name upper
cased. For example, the signal used in the example above has the following
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt
index 8247a35..e63eb8b 100644
--- a/src/declarative/QmlChanges.txt
+++ b/src/declarative/QmlChanges.txt
@@ -65,6 +65,7 @@ MouseRegion: add "hoverEnabled" property
MouseRegion: add "pressedButtons" property
Timer: add start() and stop() slots
WebView: add newWindowComponent and newWindowParent properties
+Loader: add status() and progress() properties
Deletions:
Column/VerticalPositioner: lost "margins" property
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp
index 9f3e301..5363148 100644
--- a/src/declarative/fx/qfxitem.cpp
+++ b/src/declarative/fx/qfxitem.cpp
@@ -336,6 +336,7 @@ public:
virtual void keyReleased(QKeyEvent *event);
virtual void inputMethodEvent(QInputMethodEvent *event);
virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+ virtual void componentComplete();
private:
QFxItemKeyFilter *m_next;
@@ -377,6 +378,11 @@ QVariant QFxItemKeyFilter::inputMethodQuery(Qt::InputMethodQuery query) const
return QVariant();
}
+void QFxItemKeyFilter::componentComplete()
+{
+ if (m_next) m_next->componentComplete();
+}
+
class QFxKeyNavigationAttachedPrivate : public QObjectPrivate
{
public:
@@ -912,11 +918,10 @@ public:
QFxItem *item;
};
-class QFxKeysAttached : public QObject, public QFxItemKeyFilter, public QmlParserStatus
+class QFxKeysAttached : public QObject, public QFxItemKeyFilter
{
Q_OBJECT
Q_DECLARE_PRIVATE(QFxKeysAttached)
- Q_INTERFACES(QmlParserStatus)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(QList<QFxItem *> *forwardTo READ forwardTo)
@@ -2496,6 +2501,8 @@ void QFxItem::componentComplete()
d->_anchors->componentComplete();
d->_anchors->d_func()->updateOnComplete();
}
+ if (d->keyHandler)
+ d->keyHandler->componentComplete();
}
QmlStateGroup *QFxItemPrivate::states()
diff --git a/src/declarative/fx/qfxloader.cpp b/src/declarative/fx/qfxloader.cpp
index 95ddae3..869a5b0 100644
--- a/src/declarative/fx/qfxloader.cpp
+++ b/src/declarative/fx/qfxloader.cpp
@@ -111,9 +111,12 @@ void QFxLoader::setSource(const QUrl &url)
d->source = url;
d->item = 0;
+ emit itemChanged();
if (d->source.isEmpty()) {
emit sourceChanged();
+ emit statusChanged();
+ emit progressChanged();
return;
}
@@ -122,14 +125,22 @@ void QFxLoader::setSource(const QUrl &url)
(*iter)->setOpacity(1.);
d->item = (*iter);
emit sourceChanged();
+ emit statusChanged();
+ emit progressChanged();
+ emit itemChanged();
} else {
d->qmlcomp =
new QmlComponent(qmlEngine(this), d->source, this);
- if (!d->qmlcomp->isLoading())
+ if (!d->qmlcomp->isLoading()) {
d->_q_sourceLoaded();
- else
+ } else {
connect(d->qmlcomp, SIGNAL(statusChanged(QmlComponent::Status)),
this, SLOT(_q_sourceLoaded()));
+ connect(d->qmlcomp, SIGNAL(progressChanged(qreal)),
+ this, SIGNAL(progressChanged()));
+ emit statusChanged();
+ emit progressChanged();
+ }
}
}
@@ -146,6 +157,8 @@ void QFxLoaderPrivate::_q_sourceLoaded()
delete qmlcomp;
qmlcomp = 0;
emit q->sourceChanged();
+ emit q->statusChanged();
+ emit q->progressChanged();
return;
}
QObject *obj = qmlcomp->create(ctxt);
@@ -163,10 +176,58 @@ void QFxLoaderPrivate::_q_sourceLoaded()
delete qmlcomp;
qmlcomp = 0;
emit q->sourceChanged();
+ emit q->statusChanged();
+ emit q->progressChanged();
+ emit q->itemChanged();
}
}
/*!
+ \qmlproperty enum Loader::status
+
+ This property holds the status of QML loading. It can be one of:
+ \list
+ \o Null - no QML source has been set
+ \o Ready - the QML source has been loaded
+ \o Loading - the QML source is currently being loaded
+ \o Error - an error occurred while loading the QML source
+ \endlist
+
+ \sa progress
+*/
+
+/*!
+ \qmlproperty real Loader::progress
+
+ This property holds the progress of QML data loading, from 0.0 (nothing loaded)
+ to 1.0 (finished).
+
+ \sa status
+*/
+QFxLoader::Status QFxLoader::status() const
+{
+ Q_D(const QFxLoader);
+
+ if (d->qmlcomp)
+ return static_cast<QFxLoader::Status>(d->qmlcomp->status());
+
+ if (d->item)
+ return Ready;
+
+ return d->source.isEmpty() ? Null : Error;
+}
+
+qreal QFxLoader::progress() const
+{
+ Q_D(const QFxLoader);
+
+ if (d->qmlcomp)
+ return d->qmlcomp->progress();
+
+ return d->item ? 1.0 : 0.0;
+}
+
+/*!
\qmlproperty Item Loader::item
This property holds the top-level item created from source.
*/
diff --git a/src/declarative/fx/qfxloader.h b/src/declarative/fx/qfxloader.h
index 8c555c6..132c8f4 100644
--- a/src/declarative/fx/qfxloader.h
+++ b/src/declarative/fx/qfxloader.h
@@ -54,12 +54,14 @@ class QFxLoaderPrivate;
class Q_DECLARATIVE_EXPORT QFxLoader : public QFxItem
{
Q_OBJECT
+ Q_ENUMS(Status)
Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged)
- Q_PROPERTY(QFxItem *item READ item) //### NOTIFY itemChanged
+ Q_PROPERTY(QFxItem *item READ item NOTIFY itemChanged)
+ Q_PROPERTY(Status status READ status NOTIFY statusChanged)
+ Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged)
//### sourceItem
//### sourceComponent
- //### status, progress
//### resizeMode { NoResize, SizeLoaderToItem (default), SizeItemToLoader }
public:
@@ -69,10 +71,17 @@ public:
QUrl source() const;
void setSource(const QUrl &);
+ enum Status { Null, Ready, Loading, Error };
+ Status status() const;
+ qreal progress() const;
+
QFxItem *item() const;
Q_SIGNALS:
+ void itemChanged();
void sourceChanged();
+ void statusChanged();
+ void progressChanged();
private:
Q_DISABLE_COPY(QFxLoader)
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index e897cce..f291ac0 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -121,6 +121,14 @@ void QmlComponentPrivate::typeDataReady()
emit q->statusChanged(q->status());
}
+void QmlComponentPrivate::updateProgress(qreal p)
+{
+ Q_Q(QmlComponent);
+
+ progress = p;
+ emit q->progressChanged(p);
+}
+
void QmlComponentPrivate::fromTypeData(QmlCompositeTypeData *data)
{
url = data->imports.baseUrl();
@@ -238,6 +246,12 @@ bool QmlComponent::isLoading() const
return status() == Loading;
}
+qreal QmlComponent::progress() const
+{
+ Q_D(const QmlComponent);
+ return d->progress;
+}
+
/*!
\fn void QmlComponent::statusChanged(QmlComponent::Status status)
@@ -343,7 +357,9 @@ void QmlComponent::setData(const QByteArray &data, const QUrl &url)
}
+ d->progress = 1.0;
emit statusChanged(status());
+ emit progressChanged(d->progress);
}
/*!
@@ -364,17 +380,16 @@ void QmlComponent::loadUrl(const QUrl &url)
QmlEnginePrivate::get(d->engine)->typeManager.get(d->url);
if (data->status == QmlCompositeTypeData::Waiting) {
-
d->typeData = data;
d->typeData->addWaiter(d);
-
+ d->progress = data->progress;
} else {
-
d->fromTypeData(data);
-
+ d->progress = 1.0;
}
emit statusChanged(status());
+ emit progressChanged(d->progress);
}
/*!
diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h
index 60b7ccd..af250e5 100644
--- a/src/declarative/qml/qmlcomponent.h
+++ b/src/declarative/qml/qmlcomponent.h
@@ -84,6 +84,8 @@ public:
QList<QmlError> errors() const;
+ qreal progress() const;
+
QUrl url() const;
virtual QObject *create(QmlContext *context = 0);
@@ -95,6 +97,7 @@ public:
Q_SIGNALS:
void statusChanged(QmlComponent::Status);
+ void progressChanged(qreal);
protected:
QmlComponent(QmlComponentPrivate &dd, QObject* parent);
diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h
index 4b459c2..2b25b78 100644
--- a/src/declarative/qml/qmlcomponent_p.h
+++ b/src/declarative/qml/qmlcomponent_p.h
@@ -74,15 +74,17 @@ class QmlComponentPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QmlComponent)
public:
- QmlComponentPrivate() : typeData(0), start(-1), count(-1), cc(0), completePending(false), engine(0) {}
+ QmlComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), completePending(false), engine(0) {}
QmlCompositeTypeData *typeData;
void typeDataReady();
+ void updateProgress(qreal);
void fromTypeData(QmlCompositeTypeData *data);
QList<QmlError> errors;
QUrl url;
+ qreal progress;
int start;
int count;
diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h
index 54933c4..044b4ca 100644
--- a/src/declarative/qml/qmlcompositetypedata_p.h
+++ b/src/declarative/qml/qmlcompositetypedata_p.h
@@ -108,6 +108,8 @@ struct QmlCompositeTypeData : public QmlRefCount
void addWaiter(QmlComponentPrivate *p);
void remWaiter(QmlComponentPrivate *p);
+ qreal progress;
+
private:
friend class QmlCompositeTypeManager;
friend class QmlCompiler;
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
index 4f16bc4..bcfbcc8 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -242,9 +242,26 @@ void QmlCompositeTypeManager::loadSource(QmlCompositeTypeData *unit)
engine->networkAccessManager()->get(QNetworkRequest(url));
QObject::connect(reply, SIGNAL(finished()),
this, SLOT(replyFinished()));
+ QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
}
}
+void QmlCompositeTypeManager::requestProgress(qint64 received, qint64 total)
+{
+ if (total <= 0)
+ return;
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+
+ QmlCompositeTypeData *unit = components.value(reply->url().toString());
+ Q_ASSERT(unit);
+
+ unit->progress = qreal(received)/total;
+
+ foreach (QmlComponentPrivate *comp, unit->waiters)
+ comp->updateProgress(unit->progress);
+}
+
void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit,
const QByteArray &data,
const QUrl &url)
diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h
index 1b28044..41cbe80 100644
--- a/src/declarative/qml/qmlcompositetypemanager_p.h
+++ b/src/declarative/qml/qmlcompositetypemanager_p.h
@@ -88,6 +88,7 @@ public:
private Q_SLOTS:
void replyFinished();
+ void requestProgress(qint64 received, qint64 total);
private:
void loadSource(QmlCompositeTypeData *);
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 6d3506c..e3d4840 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -1509,6 +1509,10 @@ public:
if (s) {
if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return))
return true;
+ if (s->urls.count() == 1 && !s->isBuiltin[0] && !s->isLibrary[0] && url_return) {
+ *url_return = QUrl(s->urls[0]+"/").resolved(QUrl(QLatin1String(unqualifiedtype + ".qml")));
+ return true;
+ }
}
if (url_return) {
*url_return = base.resolved(QUrl(QLatin1String(type + ".qml")));
diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp
index 3ae9a97..1c0f496 100644
--- a/tools/qmlviewer/qmlviewer.cpp
+++ b/tools/qmlviewer/qmlviewer.cpp
@@ -23,6 +23,8 @@
#include <private/qabstractanimation_p.h>
#include "deviceskin.h"
+#include <QSettings>
+#include <QNetworkCookieJar>
#include <QNetworkDiskCache>
#include <QNetworkAccessManager>
#include <QSignalMapper>
@@ -208,6 +210,34 @@ public:
}
};
+class PersistentCookieJar : public QNetworkCookieJar {
+public:
+ PersistentCookieJar(QObject *parent) : QNetworkCookieJar(parent) { load(); }
+ ~PersistentCookieJar() { save(); }
+
+private:
+ void save()
+ {
+ QList<QNetworkCookie> list = allCookies();
+ QByteArray data;
+ foreach (QNetworkCookie cookie, list) {
+ if (!cookie.isSessionCookie()) {
+ data.append(cookie.toRawForm());
+ data.append("\n");
+ }
+ }
+ QSettings settings("Nokia", "QtQmlViewer");
+ settings.setValue("Cookies",data);
+ }
+
+ void load()
+ {
+ QSettings settings("Nokia", "QtQmlViewer");
+ QByteArray data = settings.value("Cookies").toByteArray();
+ setAllCookies(QNetworkCookie::parseCookies(data));
+ }
+};
+
QString QmlViewer::getVideoFileName()
{
QString title = convertAvailable || ffmpegAvailable ? tr("Save Video File") : tr("Save PNG Frames");
@@ -271,6 +301,7 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags)
layout->addWidget(canvas);
setupProxy();
+ canvas->engine()->networkAccessManager()->setCookieJar(new PersistentCookieJar(this));
connect(&autoStartTimer, SIGNAL(triggered()), this, SLOT(autoStartRecording()));
connect(&autoStopTimer, SIGNAL(triggered()), this, SLOT(autoStopRecording()));