QmlObject::setQmlPath -> setSource

to be consistent with QQuickView
This commit is contained in:
Marco Martin 2013-02-19 19:25:55 +01:00
parent 08f9417c32
commit 31c442f39a
4 changed files with 17 additions and 17 deletions

View File

@ -51,7 +51,7 @@ public:
}
void errorPrint();
void execute(const QString &fileName);
void execute(const QUrl &source);
void scheduleExecutionEnd();
void minimumWidthChanged();
void minimumHeightChanged();
@ -63,7 +63,7 @@ public:
QmlObject *q;
QString qmlPath;
QUrl source;
QQmlEngine* engine;
QQmlIncubator incubator;
QQmlComponent* component;
@ -84,9 +84,9 @@ void QmlObjectPrivate::errorPrint()
kWarning() << component->url().toString() + '\n' + errorStr;
}
void QmlObjectPrivate::execute(const QString &fileName)
void QmlObjectPrivate::execute(const QUrl &source)
{
if (fileName.isEmpty()) {
if (source.isEmpty()) {
#ifndef NDEBUG
kDebug() << "File name empty!";
#endif
@ -103,7 +103,7 @@ void QmlObjectPrivate::execute(const QString &fileName)
//binds things like kconfig and icons
kdeclarative.setupBindings();
component->loadUrl(QUrl::fromLocalFile(fileName));
component->loadUrl(source);
if (delay) {
QTimer::singleShot(0, q, SLOT(scheduleExecutionEnd()));
@ -138,16 +138,16 @@ QmlObject::~QmlObject()
delete d;
}
void QmlObject::setQmlPath(const QString &path)
void QmlObject::setSource(const QUrl &source)
{
qDebug() << "Opening" << path;
d->qmlPath = path;
d->execute(path);
qDebug() << "Opening" << source;
d->source = source;
d->execute(source);
}
QString QmlObject::qmlPath() const
QUrl QmlObject::source() const
{
return d->qmlPath;
return d->source;
}
void QmlObject::setInitializationDelayed(const bool delay)

View File

@ -98,7 +98,7 @@ class QmlObject : public QObject
{
Q_OBJECT
Q_PROPERTY(QString qmlPath READ qmlPath WRITE setQmlPath)
Q_PROPERTY(QUrl source READ source WRITE setSource)
Q_PROPERTY(bool initializationDelayed READ isInitializationDelayed WRITE setInitializationDelayed)
Q_PROPERTY(QObject * rootObject READ rootObject)
@ -117,12 +117,12 @@ public:
*
* @param path the absolute path of a QML file
*/
void setQmlPath(const QString &path);
void setSource(const QUrl &source);
/**
* @return the absolute path of the current QML file
*/
QString qmlPath() const;
QUrl source() const;
/**
* Sets whether the execution of the QML file has to be delayed later in the event loop. It has to be called before setQmlPath().

View File

@ -99,7 +99,7 @@ void AppletInterface::init()
delete factory;
engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(m_appletScriptEngine->package()));
m_qmlObject->setQmlPath(m_appletScriptEngine->mainScript());
m_qmlObject->setSource(QUrl::fromLocalFile(m_appletScriptEngine->mainScript()));
if (!m_qmlObject->engine() || !m_qmlObject->engine()->rootContext() || !m_qmlObject->engine()->rootContext()->isValid() || m_qmlObject->mainComponent()->isError()) {
@ -109,7 +109,7 @@ void AppletInterface::init()
}
reason = i18n("Error loading QML file: %1", reason);
m_qmlObject->setQmlPath(applet()->containment()->corona()->package().filePath("ui", "AppletError.qml"));
m_qmlObject->setSource(QUrl::fromLocalFile(applet()->containment()->corona()->package().filePath("ui", "AppletError.qml")));
m_qmlObject->completeInitialization();

View File

@ -171,7 +171,7 @@ void ContainmentInterface::loadWallpaper()
pkg.setPath("org.kde.wallpaper.image");
m_wallpaperQmlObject = new QmlObject(this);
m_wallpaperQmlObject->setQmlPath(pkg.filePath("mainscript"));
m_wallpaperQmlObject->setSource(QUrl::fromLocalFile(pkg.filePath("mainscript")));
if (m_wallpaperQmlObject->mainComponent() &&
m_wallpaperQmlObject->rootObject() &&