summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2009-07-21 07:00:45 (GMT)
committerMichael Brasser <michael.brasser@nokia.com>2009-07-21 07:00:45 (GMT)
commit8db694cb38e1f7f5096db96fcc1f168b13e643a4 (patch)
tree994c34bc6a0d39d697067f331547ee6a20877a8f
parentae8e2b626a9acc0cdaed8dbc3fb4c2a3b13d19f4 (diff)
parent4dc3189aea1c619828abdf87e553587c656ede63 (diff)
downloadQt-8db694cb38e1f7f5096db96fcc1f168b13e643a4.zip
Qt-8db694cb38e1f7f5096db96fcc1f168b13e643a4.tar.gz
Qt-8db694cb38e1f7f5096db96fcc1f168b13e643a4.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/declarative/samegame/content/SpinBlock.qml2
-rw-r--r--demos/declarative/samegame/content/samegame.js6
-rw-r--r--examples/declarative/dynamic/dynamic.js4
-rw-r--r--src/declarative/extra/qfxanimatedimageitem.cpp45
-rw-r--r--src/declarative/extra/qfxanimatedimageitem.h6
-rw-r--r--src/declarative/extra/qfxanimatedimageitem_p.h3
-rw-r--r--src/declarative/qml/qml.pri3
-rw-r--r--src/declarative/qml/qmlbindablecomponent.cpp104
-rw-r--r--src/declarative/qml/qmlbindablecomponent.h91
-rw-r--r--src/declarative/qml/qmlbindablecomponent_p.h77
-rw-r--r--src/declarative/qml/qmlcomponent.cpp17
-rw-r--r--src/declarative/qml/qmlcomponent.h9
-rw-r--r--src/declarative/qml/qmlengine.cpp12
13 files changed, 342 insertions, 37 deletions
diff --git a/demos/declarative/samegame/content/SpinBlock.qml b/demos/declarative/samegame/content/SpinBlock.qml
index 42276d0..2597bfb 100644
--- a/demos/declarative/samegame/content/SpinBlock.qml
+++ b/demos/declarative/samegame/content/SpinBlock.qml
@@ -15,7 +15,7 @@ Item { id:block
} else {
"pics/gnome/greenStone.gif";
}
- playing: selected
+ paused: !selected
}
opacity: 0
y: targetY
diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js
index 1814031..b1b2c50 100644
--- a/demos/declarative/samegame/content/samegame.js
+++ b/demos/declarative/samegame/content/samegame.js
@@ -49,7 +49,7 @@ function initBoard()
var fillFound;
var floodBoard;
-var lastHoveredIdx = -1
+var lastHoveredIdx = -2
function handleHover(x,y, btn)
{
xIdx = Math.floor(x/tileSize);
@@ -201,7 +201,7 @@ var waitTop = -1;
function finishCreatingBlock(xIdx,yIdx){
//TODO: Doc that the 'x', 'y' that were here are hidden properties from the calling QFxItem
- if(component.isReady()){
+ if(component.isReady){
if(xIdx == undefined){
//Called without arguments, create a previously stored (xIdx,yIdx)
if(waitTop == -1)
@@ -226,7 +226,7 @@ function finishCreatingBlock(xIdx,yIdx){
dynamicObject.spawned = true;
board[index(xIdx,yIdx)] = dynamicObject;
return true;
- }else if(component.isError()){
+ }else if(component.isError){
print("error creating block");
print(component.errorsString());
}else{
diff --git a/examples/declarative/dynamic/dynamic.js b/examples/declarative/dynamic/dynamic.js
index 13317df..8f1e138 100644
--- a/examples/declarative/dynamic/dynamic.js
+++ b/examples/declarative/dynamic/dynamic.js
@@ -28,10 +28,10 @@ function instantCreateWithComponent() {//Like create, but assumes instant readyn
}
function finishCreation(){
- if(component.isReady() && dynamicObject == null){
+ if(component.isReady && dynamicObject == null){
dynamicObject = component.createObject();
dynamicObject.parent = targetItem;
- }else if(component.isError()){
+ }else if(component.isError){
dynamicObject = null;
print("error creating component");
print(component.errorsString());
diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp
index 5516a00..4c74f6f 100644
--- a/src/declarative/extra/qfxanimatedimageitem.cpp
+++ b/src/declarative/extra/qfxanimatedimageitem.cpp
@@ -96,6 +96,30 @@ QFxAnimatedImageItem::~QFxAnimatedImageItem()
}
/*!
+ \qmlproperty bool AnimatedImage::paused
+ This property holds whether the animated image is paused or not
+
+ Defaults to false, and can be set to true when you want to pause.
+*/
+bool QFxAnimatedImageItem::isPaused() const
+{
+ Q_D(const QFxAnimatedImageItem);
+ if(!d->_movie)
+ return false;
+ return d->_movie->state()==QMovie::Paused;
+}
+
+void QFxAnimatedImageItem::setPaused(bool pause)
+{
+ Q_D(QFxAnimatedImageItem);
+ if(pause == d->paused)
+ return;
+ d->paused = pause;
+ if(!d->_movie)
+ return;
+ d->_movie->setPaused(pause);
+}
+/*!
\qmlproperty bool AnimatedImage::playing
This property holds whether the animated image is playing or not
@@ -106,7 +130,7 @@ bool QFxAnimatedImageItem::isPlaying() const
Q_D(const QFxAnimatedImageItem);
if (!d->_movie)
return false;
- return d->_movie->state()==QMovie::Running;
+ return d->_movie->state()!=QMovie::NotRunning;
}
void QFxAnimatedImageItem::setPlaying(bool play)
@@ -120,7 +144,7 @@ void QFxAnimatedImageItem::setPlaying(bool play)
if (play)
d->_movie->start();
else
- d->_movie->setPaused(true);
+ d->_movie->stop();
}
/*!
@@ -197,7 +221,7 @@ void QFxAnimatedImageItem::movieRequestFinished()
return;
}
connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)),
- this, SIGNAL(playingChanged()));
+ this, SLOT(playingStatusChanged()));
connect(d->_movie, SIGNAL(frameChanged(int)),
this, SLOT(movieUpdate()));
d->_movie->setCacheMode(QMovie::CacheAll);
@@ -205,6 +229,8 @@ void QFxAnimatedImageItem::movieRequestFinished()
d->_movie->start();
else
d->_movie->jumpToFrame(0);
+ if(d->paused)
+ d->_movie->setPaused(true);
setPixmap(d->_movie->currentPixmap());
}
@@ -215,4 +241,17 @@ void QFxAnimatedImageItem::movieUpdate()
emit frameChanged();
}
+void QFxAnimatedImageItem::playingStatusChanged()
+{
+ Q_D(QFxAnimatedImageItem);
+ if((d->_movie->state() != QMovie::NotRunning) != d->playing){
+ d->playing = (d->_movie->state() != QMovie::NotRunning);
+ emit playingChanged();
+ }
+ if((d->_movie->state() == QMovie::Paused) != d->paused){
+ d->playing = (d->_movie->state() == QMovie::Paused);
+ emit pausedChanged();
+ }
+}
+
QT_END_NAMESPACE
diff --git a/src/declarative/extra/qfxanimatedimageitem.h b/src/declarative/extra/qfxanimatedimageitem.h
index 720d187..2d531ee 100644
--- a/src/declarative/extra/qfxanimatedimageitem.h
+++ b/src/declarative/extra/qfxanimatedimageitem.h
@@ -58,6 +58,7 @@ class Q_DECLARATIVE_EXPORT QFxAnimatedImageItem : public QFxImage
Q_OBJECT
Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged)
+ Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged)
Q_PROPERTY(int frameCount READ frameCount)
public:
@@ -67,6 +68,9 @@ public:
bool isPlaying() const;
void setPlaying(bool play);
+ bool isPaused() const;
+ void setPaused(bool pause);
+
int currentFrame() const;
void setCurrentFrame(int frame);
@@ -77,11 +81,13 @@ public:
Q_SIGNALS:
void playingChanged();
+ void pausedChanged();
void frameChanged();
private Q_SLOTS:
void movieUpdate();
void movieRequestFinished();
+ void playingStatusChanged();
protected:
QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent);
diff --git a/src/declarative/extra/qfxanimatedimageitem_p.h b/src/declarative/extra/qfxanimatedimageitem_p.h
index d743ba4..859f869 100644
--- a/src/declarative/extra/qfxanimatedimageitem_p.h
+++ b/src/declarative/extra/qfxanimatedimageitem_p.h
@@ -65,11 +65,12 @@ class QFxAnimatedImageItemPrivate : public QFxImagePrivate
public:
QFxAnimatedImageItemPrivate()
- : playing(true), _movie(0)
+ : playing(true), paused(false), _movie(0)
{
}
bool playing;
+ bool paused;
QMovie *_movie;
};
diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri
index b3fa063..b71ca1f 100644
--- a/src/declarative/qml/qml.pri
+++ b/src/declarative/qml/qml.pri
@@ -5,6 +5,7 @@ SOURCES += qml/qmlparser.cpp \
qml/qmlexpression.cpp \
qml/qmlbinding.cpp \
qml/qmlmetaproperty.cpp \
+ qml/qmlbindablecomponent.cpp \
qml/qmlcomponent.cpp \
qml/qmlcontext.cpp \
qml/qmlcustomparser.cpp \
@@ -36,6 +37,8 @@ HEADERS += qml/qmlparser_p.h \
qml/qmlbinding.h \
qml/qmlbinding_p.h \
qml/qmlmetaproperty.h \
+ qml/qmlbindablecomponent.h \
+ qml/qmlbindablecomponent_p.h \
qml/qmlcomponent.h \
qml/qmlcomponent_p.h \
qml/qmlcustomparser_p.h \
diff --git a/src/declarative/qml/qmlbindablecomponent.cpp b/src/declarative/qml/qmlbindablecomponent.cpp
new file mode 100644
index 0000000..ed9924a
--- /dev/null
+++ b/src/declarative/qml/qmlbindablecomponent.cpp
@@ -0,0 +1,104 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmlbindablecomponent.h"
+#include "qmlbindablecomponent_p.h"
+#include "qmlcomponent.h"
+
+QT_BEGIN_NAMESPACE
+QmlBindableComponent::QmlBindableComponent(QmlEngine *engine, QObject *parent)
+ : QmlComponent(*(new QmlBindableComponentPrivate), parent)
+{
+ Q_D(QmlBindableComponent);
+ d->engine = engine;
+ connect(this, SIGNAL(statusChanged(QmlComponent::Status)),
+ this, SLOT(statusChange(QmlComponent::Status)));
+}
+
+QmlBindableComponent::QmlBindableComponent(QmlEngine *engine, const QUrl &url, QObject *parent)
+ : QmlComponent(*(new QmlBindableComponentPrivate), parent)
+{
+ Q_D(QmlBindableComponent);
+ d->engine = engine;
+ loadUrl(url);
+ connect(this, SIGNAL(statusChanged(QmlComponent::Status)),
+ this, SLOT(statusChange(QmlComponent::Status)));
+}
+
+void QmlBindableComponent::setContext(QmlContext* c)
+{
+ Q_D(QmlBindableComponent);
+ d->ctxt =c;
+}
+/*!
+ Create a script object instance from this component. Returns a null
+ script object if creation failed. It will create the instance in the
+ same context that it was created it. QmlBindableComponent is only
+ meant to be created from with script - C++ developers should just use
+ QmlComponent directly.
+
+ Similar to QmlComponent::create(), but creates an object suitable
+ for usage within scripts.
+*/
+QScriptValue QmlBindableComponent::createObject()
+{
+ Q_D(QmlBindableComponent);
+ QObject* ret = create(d->ctxt);
+ return QmlEngine::qmlScriptObject(ret, d->engine);
+}
+
+void QmlBindableComponent::statusChange(QmlComponent::Status newStatus)
+{
+ Q_D(QmlBindableComponent);
+ if(newStatus == d->prevStatus)
+ return;
+ if(newStatus == QmlComponent::Null || d->prevStatus == QmlComponent::Null)
+ emit isNullChanged();
+ if(newStatus == QmlComponent::Ready || d->prevStatus == QmlComponent::Ready)
+ emit isReadyChanged();
+ if(newStatus == QmlComponent::Loading || d->prevStatus == QmlComponent::Loading)
+ emit isLoadingChanged();
+ if(newStatus == QmlComponent::Error || d->prevStatus == QmlComponent::Error)
+ emit isErrorChanged();
+ d->prevStatus = newStatus;
+}
+
+QT_END_NAMESPACE
diff --git a/src/declarative/qml/qmlbindablecomponent.h b/src/declarative/qml/qmlbindablecomponent.h
new file mode 100644
index 0000000..2b3e0ce
--- /dev/null
+++ b/src/declarative/qml/qmlbindablecomponent.h
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLBINDABLECOMPONENT_H
+#define QMLBINDABLECOMPONENT_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qstring.h>
+#include <QtDeclarative/qfxglobal.h>
+#include <QtDeclarative/qml.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <QtDeclarative/qmlerror.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Declarative)
+
+class QmlBindableComponentPrivate;
+class QmlEngine;
+class QmlContext;
+class Q_DECLARATIVE_EXPORT QmlBindableComponent : public QmlComponent
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QmlBindableComponent)
+ friend class QmlEngine;
+public:
+ QmlBindableComponent(QmlEngine *, const QUrl &url, QObject *parent = 0);
+ QmlBindableComponent(QmlEngine *, QObject *parent=0);
+ Q_PROPERTY(bool isNull READ isNull NOTIFY isNullChanged);
+ Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged);
+ Q_PROPERTY(bool isError READ isError NOTIFY isErrorChanged);
+ Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged);
+
+ Q_INVOKABLE QScriptValue createObject();
+
+ void setContext(QmlContext* c);
+Q_SIGNALS:
+ void isNullChanged();
+ void isErrorChanged();
+ void isReadyChanged();
+ void isLoadingChanged();
+private slots:
+ void statusChange(QmlComponent::Status newStatus);
+};
+
+QT_END_NAMESPACE
+
+QML_DECLARE_TYPE(QmlBindableComponent)
+
+QT_END_HEADER
+#endif
diff --git a/src/declarative/qml/qmlbindablecomponent_p.h b/src/declarative/qml/qmlbindablecomponent_p.h
new file mode 100644
index 0000000..79335df
--- /dev/null
+++ b/src/declarative/qml/qmlbindablecomponent_p.h
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: Qt Software Information (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain
+** additional rights. These rights are described in the Nokia Qt LGPL
+** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
+** package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at qt-sales@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMLBINDABLECOMPONENT_P_H
+#define QMLBINDABLECOMPONENT_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "qmlcomponent.h"
+#include "qmlbindablecomponent.h"
+#include "qmlcomponent_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QmlContext;
+class QmlBindableComponentPrivate : public QmlComponentPrivate
+{
+ Q_DECLARE_PUBLIC(QmlBindableComponent)
+public:
+ QmlBindableComponentPrivate() : QmlComponentPrivate(),
+ prevStatus(QmlBindableComponent::Null), ctxt(0)
+ { }
+
+ QmlComponent::Status prevStatus;
+ QmlContext* ctxt;
+};
+
+QT_END_NAMESPACE
+
+#endif
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index 4e39d7f..0fdba64 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -431,23 +431,6 @@ QmlComponent::QmlComponent(QmlComponentPrivate &dd, QObject *parent)
{
}
-/*!
- Create a script object instance from this component. Returns a null
- script object if creation failed. It will create the instance in the
- engine's \l {QmlEngine::rootContext()}{root context}.
-
- Similar to QmlComponent::create(), but creates an object suitable
- for usage within scripts.
-*/
-QScriptValue QmlComponent::createObject()
-{
- Q_D(QmlComponent);
- QObject* ret = create();
- if(ret)
- return QmlEngine::qmlScriptObject(ret, d->engine);
- else
- return d->engine->scriptEngine()->nullValue();
-}
/*!
Create an object instance from this component. Returns 0 if creation
diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h
index 9c712df..45b26eb 100644
--- a/src/declarative/qml/qmlcomponent.h
+++ b/src/declarative/qml/qmlcomponent.h
@@ -77,17 +77,16 @@ public:
enum Status { Null, Ready, Loading, Error };
Status status() const;
- Q_INVOKABLE bool isNull() const;
- Q_INVOKABLE bool isReady() const;
- Q_INVOKABLE bool isError() const;
- Q_INVOKABLE bool isLoading() const;
+ bool isNull() const;
+ bool isReady() const;
+ bool isError() const;
+ bool isLoading() const;
QList<QmlError> errors() const;
Q_INVOKABLE QString errorsString() const;
QUrl url() const;
- Q_INVOKABLE QScriptValue createObject();
virtual QObject *create(QmlContext *context = 0);
virtual QObject *beginCreate(QmlContext *);
virtual void completeCreate();
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 8b21290..c4b3c0d 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -71,6 +71,7 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qdir.h>
#include <qmlcomponent.h>
+#include <qmlbindablecomponent.h>
#include "private/qmlmetaproperty_p.h"
#include <private/qmlbinding_p.h>
#include <private/qmlvme_p.h>
@@ -583,19 +584,20 @@ QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine)
*/
QScriptValue QmlEngine::createComponent(QScriptContext *ctxt, QScriptEngine *engine)
{
- QmlComponent* c;
+ QmlBindableComponent* c;
QmlEngine* activeEngine = qobject_cast<QmlEngine*>(
engine->globalObject().property(QLatin1String("qmlEngine")).toQObject());
+ QmlContext* context =activeEngine->d_func()->currentExpression->context();
if(ctxt->argumentCount() != 1 || !activeEngine){
- c = new QmlComponent(activeEngine);
+ c = new QmlBindableComponent(activeEngine);
}else{
- QUrl url = QUrl(activeEngine->d_func()->currentExpression->context()
- ->resolvedUrl(ctxt->argument(0).toString()));
+ QUrl url = QUrl(context->resolvedUrl(ctxt->argument(0).toString()));
if(!url.isValid()){
url = QUrl(ctxt->argument(0).toString());
}
- c = new QmlComponent(activeEngine, url, activeEngine);
+ c = new QmlBindableComponent(activeEngine, url, activeEngine);
}
+ c->setContext(context);
return engine->newQObject(c);
}