diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2009-11-17 02:35:53 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2009-11-17 02:35:53 (GMT) |
commit | f31522c3b01bb832d8ef3fa0eea7ec01f13424b2 (patch) | |
tree | 48ffd6929c78ad000b0cc157eae1476851854974 /src | |
parent | 39b2302dbed5fe510d71c1bde3864a79c1a4c9d0 (diff) | |
parent | 31d01e174c3a3a1bba2ec9bf40cdc22d4053d8ec (diff) | |
download | Qt-f31522c3b01bb832d8ef3fa0eea7ec01f13424b2.zip Qt-f31522c3b01bb832d8ef3fa0eea7ec01f13424b2.tar.gz Qt-f31522c3b01bb832d8ef3fa0eea7ec01f13424b2.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'src')
-rw-r--r-- | src/declarative/qml/qmlcompiler.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponent.h | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 75 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation.cpp | 50 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation_p.h | 2 | ||||
-rw-r--r-- | src/declarative/util/qmlanimation_p_p.h | 2 |
6 files changed, 71 insertions, 65 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp index 2cb44a3..9000339 100644 --- a/src/declarative/qml/qmlcompiler.cpp +++ b/src/declarative/qml/qmlcompiler.cpp @@ -2044,12 +2044,12 @@ bool QmlCompiler::checkDynamicMeta(QmlParser::Object *obj) if (prop.isDefaultProperty) { if (seenDefaultProperty) - COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Duplicate default property")); + COMPILE_EXCEPTION(&prop, qApp->translate("QmlCompiler","Duplicate default property")); seenDefaultProperty = true; } if (propNames.contains(prop.name)) - COMPILE_EXCEPTION(obj, qApp->translate("QmlCompiler","Duplicate property name")); + COMPILE_EXCEPTION(&prop, qApp->translate("QmlCompiler","Duplicate property name")); propNames.insert(prop.name); } diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h index 835bdc5..0abb58f 100644 --- a/src/declarative/qml/qmlcomponent.h +++ b/src/declarative/qml/qmlcomponent.h @@ -67,6 +67,9 @@ class Q_DECLARATIVE_EXPORT QmlComponent : public QObject Q_PROPERTY(bool isReady READ isReady NOTIFY statusChanged) Q_PROPERTY(bool isError READ isError NOTIFY statusChanged) Q_PROPERTY(bool isLoading READ isLoading NOTIFY statusChanged) + Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + Q_PROPERTY(QUrl url READ url CONSTANT) public: QmlComponent(QObject *parent = 0); diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index b9729ad..86472de 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -569,23 +569,23 @@ QmlContext *QmlEnginePrivate::getContext(QScriptContext *ctxt) QScriptValue QmlEnginePrivate::createComponent(QScriptContext *ctxt, QScriptEngine *engine) { - QmlComponent* c; - QmlEnginePrivate *activeEnginePriv = static_cast<QmlScriptEngine*>(engine)->p; QmlEngine* activeEngine = activeEnginePriv->q_func(); QmlContext* context = activeEnginePriv->getContext(ctxt); + Q_ASSERT(context); if(ctxt->argumentCount() != 1) { - c = new QmlComponent(activeEngine); + return engine->nullValue(); }else{ - QUrl url = QUrl(context->resolvedUrl(ctxt->argument(0).toString())); - if(!url.isValid()) - url = QUrl(ctxt->argument(0).toString()); - c = new QmlComponent(activeEngine, url, activeEngine); + QString arg = ctxt->argument(0).toString(); + if (arg.isEmpty()) + return engine->nullValue(); + QUrl url = QUrl(context->resolvedUrl(arg)); + QmlComponent *c = new QmlComponent(activeEngine, url, activeEngine); + c->setCreationContext(context); + return activeEnginePriv->objectClass->newQObject(c, qMetaTypeId<QmlComponent*>()); } - c->setCreationContext(context); - return engine->newQObject(c); } QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngine *engine) @@ -594,57 +594,64 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi static_cast<QmlScriptEngine*>(engine)->p; QmlEngine* activeEngine = activeEnginePriv->q_func(); - if(ctxt->argumentCount() < 2) + if(ctxt->argumentCount() < 2 || ctxt->argumentCount() > 3) return engine->nullValue(); + QmlContext* context = activeEnginePriv->getContext(ctxt); + Q_ASSERT(context); + QString qml = ctxt->argument(0).toString(); + if (qml.isEmpty()) + return engine->nullValue(); + QUrl url; if(ctxt->argumentCount() > 2) url = QUrl(ctxt->argument(2).toString()); + + if (url.isValid() && url.isRelative()) + url = context->resolvedUrl(url); + QObject *parentArg = activeEnginePriv->objectClass->toQObject(ctxt->argument(1)); - QmlContext *qmlCtxt = qmlContext(parentArg); - if(!parentArg || !qmlCtxt){ - //TODO: Could use a qmlInfo() like function for script functions - qWarning() << "createQmlObject called with invalid parent object"; + if(!parentArg) return engine->nullValue(); - } - if (url.isEmpty()) { - url = qmlCtxt->resolvedUrl(QUrl(QLatin1String("<Unknown File>"))); - } else { - url = qmlCtxt->resolvedUrl(url); - } QmlComponent component(activeEngine, qml.toUtf8(), url); if(component.isError()) { QList<QmlError> errors = component.errors(); - qWarning() <<"QmlEngine::createQmlObject():"; + qWarning().nospace() << "QmlEngine::createQmlObject():"; foreach (const QmlError &error, errors) - qWarning() << " " << error; + qWarning().nospace() << " " << error; + + return engine->nullValue(); + } + + if (!component.isReady()) { + qWarning().nospace() << "QmlEngine::createQmlObject(): Component is not ready"; return engine->nullValue(); } - QObject *obj = component.create(qmlCtxt); + QObject *obj = component.create(context); if(component.isError()) { QList<QmlError> errors = component.errors(); - qWarning() <<"QmlEngine::createQmlObject():"; + qWarning().nospace() << "QmlEngine::createQmlObject():"; foreach (const QmlError &error, errors) - qWarning() << " " << error; + qWarning().nospace() << " " << error; return engine->nullValue(); } - if(obj) { - obj->setParent(parentArg); - QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj); - QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parentArg); - if(gobj && gparent) - gobj->setParentItem(gparent); - return qmlScriptObject(obj, activeEngine); - } - return engine->nullValue(); + Q_ASSERT(obj); + + obj->setParent(parentArg); + QGraphicsObject* gobj = qobject_cast<QGraphicsObject*>(obj); + QGraphicsObject* gparent = qobject_cast<QGraphicsObject*>(parentArg); + if(gobj && gparent) + gobj->setParentItem(gparent); + + return qmlScriptObject(obj, activeEngine); } QScriptValue QmlEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index d78f0a1..780bc82 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE -QEasingCurve stringToCurve(const QString &curve) +static QEasingCurve stringToCurve(const QString &curve, QObject *obj) { QEasingCurve easingCurve; @@ -73,8 +73,7 @@ QEasingCurve stringToCurve(const QString &curve) if (hasParams) { QString easeName = curve.trimmed(); if (!easeName.endsWith(QLatin1Char(')'))) { - qWarning("QEasingCurve: Unmatched perenthesis in easing function '%s'", - qPrintable(curve)); + qmlInfo(obj) << obj->tr("Unmatched parenthesis in easing function \"%1\"").arg(curve); return easingCurve; } @@ -83,8 +82,8 @@ QEasingCurve stringToCurve(const QString &curve) easeName.mid(idx + 1, easeName.length() - 1 - idx - 1); normalizedCurve = easeName.left(idx); if (!normalizedCurve.startsWith(QLatin1String("ease"))) { - qWarning("QEasingCurve: Easing function '%s' must start with 'ease'", - qPrintable(curve)); + qmlInfo(obj) << obj->tr("Easing function \"%1\" must start with \"ease\"").arg(curve); + return easingCurve; } props = prop_str.split(QLatin1Char(',')); @@ -98,9 +97,8 @@ QEasingCurve stringToCurve(const QString &curve) int value = me.keyToValue(normalizedCurve.toUtf8().constData()); if (value < 0) { - qWarning("QEasingCurve: Unknown easing curve '%s'", - qPrintable(curve)); - value = 0; + qmlInfo(obj) << obj->tr("Unknown easing curve \"%1\"").arg(curve); + return easingCurve; } easingCurve.setType((QEasingCurve::Type)value); @@ -109,9 +107,8 @@ QEasingCurve stringToCurve(const QString &curve) int sep = str.indexOf(QLatin1Char(':')); if (sep == -1) { - qWarning("QEasingCurve: Improperly specified property in easing function '%s'", - qPrintable(curve)); - return easingCurve; + qmlInfo(obj) << obj->tr("Improperly specified parameter in easing function \"%1\"").arg(curve); + continue; } QString propName = str.left(sep).trimmed(); @@ -119,9 +116,8 @@ QEasingCurve stringToCurve(const QString &curve) qreal propValue = str.mid(sep + 1).trimmed().toDouble(&isOk); if (propName.isEmpty() || !isOk) { - qWarning("QEasingCurve: Improperly specified property in easing function '%s'", - qPrintable(curve)); - return easingCurve; + qmlInfo(obj) << obj->tr("Improperly specified parameter in easing function \"%1\"").arg(curve); + continue; } if (propName == QLatin1String("amplitude")) { @@ -130,10 +126,12 @@ QEasingCurve stringToCurve(const QString &curve) easingCurve.setPeriod(propValue); } else if (propName == QLatin1String("overshoot")) { easingCurve.setOvershoot(propValue); + } else { + qmlInfo(obj) << obj->tr("Unknown easing parameter \"%1\"").arg(propName); + continue; } } } - return easingCurve; } @@ -219,16 +217,14 @@ void QmlAbstractAnimationPrivate::commence() } } -//### make static? -QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str) +QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj) { - Q_Q(QmlAbstractAnimation); QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str); if (!prop.isValid()) { - qmlInfo(q) << QmlAbstractAnimation::tr("Cannot animate non-existant property \"%1\"").arg(str); + qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existant property \"%1\"").arg(str); return QmlMetaProperty(); } else if (!prop.isWritable()) { - qmlInfo(q) << QmlAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); + qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate read-only property \"%1\"").arg(str); return QmlMetaProperty(); } return prop; @@ -436,7 +432,7 @@ void QmlAbstractAnimation::setTarget(QObject *o) d->target = o; if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName); + d->userProperty = d->createProperty(d->target, d->propertyName, this); } else { d->userProperty.invalidate(); } @@ -458,7 +454,7 @@ void QmlAbstractAnimation::setProperty(const QString &n) d->propertyName = n; if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName); + d->userProperty = d->createProperty(d->target, d->propertyName, this); } else { d->userProperty.invalidate(); } @@ -652,7 +648,7 @@ int QmlPauseAnimation::duration() const void QmlPauseAnimation::setDuration(int duration) { if (duration < 0) { - qWarning("QmlPauseAnimation: Cannot set a duration of < 0"); + qmlInfo(this) << tr("Cannot set a duration of < 0"); return; } @@ -1029,7 +1025,7 @@ void QmlPropertyAction::transition(QmlStateActions &actions, if (hasTarget && d->value.isValid()) { Action myAction; - myAction.property = d->createProperty(target(), d->propertyName); + myAction.property = d->createProperty(target(), d->propertyName, this); if (myAction.property.isValid()) { myAction.toValue = d->value; data->actions << myAction; @@ -1630,7 +1626,7 @@ int QmlPropertyAnimation::duration() const void QmlPropertyAnimation::setDuration(int duration) { if (duration < 0) { - qWarning("QmlPropertyAnimation: Cannot set a duration of < 0"); + qmlInfo(this) << tr("Cannot set a duration of < 0"); return; } @@ -1872,7 +1868,7 @@ void QmlPropertyAnimation::setEasing(const QString &e) return; d->easing = e; - d->va->setEasingCurve(stringToCurve(d->easing)); + d->va->setEasingCurve(stringToCurve(d->easing, this)); emit easingChanged(e); } @@ -2114,7 +2110,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, //an explicit animation has been specified if (hasTarget && d->toIsDefined) { Action myAction; - myAction.property = d->createProperty(target(), d->propertyName); + myAction.property = d->createProperty(target(), d->propertyName, this); if (myAction.property.isValid()) { if (d->fromIsDefined) { d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index f126dee..87b6703 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -136,7 +136,7 @@ private Q_SLOTS: }; class QmlPauseAnimationPrivate; -class QmlPauseAnimation : public QmlAbstractAnimation +class Q_AUTOTEST_EXPORT QmlPauseAnimation : public QmlAbstractAnimation { Q_OBJECT Q_DECLARE_PRIVATE(QmlPauseAnimation) diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index e50415f..27c0cd7 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -208,7 +208,7 @@ public: QmlMetaProperty property; QmlAnimationGroup *group; - QmlMetaProperty createProperty(QObject *obj, const QString &str); + static QmlMetaProperty createProperty(QObject *obj, const QString &str, QObject *infoObj); }; class QmlPauseAnimationPrivate : public QmlAbstractAnimationPrivate |