QmlObject::setQmlPath -> setSource
to be consistent with QQuickView
This commit is contained in:
parent
08f9417c32
commit
31c442f39a
@ -51,7 +51,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void errorPrint();
|
void errorPrint();
|
||||||
void execute(const QString &fileName);
|
void execute(const QUrl &source);
|
||||||
void scheduleExecutionEnd();
|
void scheduleExecutionEnd();
|
||||||
void minimumWidthChanged();
|
void minimumWidthChanged();
|
||||||
void minimumHeightChanged();
|
void minimumHeightChanged();
|
||||||
@ -63,7 +63,7 @@ public:
|
|||||||
|
|
||||||
QmlObject *q;
|
QmlObject *q;
|
||||||
|
|
||||||
QString qmlPath;
|
QUrl source;
|
||||||
QQmlEngine* engine;
|
QQmlEngine* engine;
|
||||||
QQmlIncubator incubator;
|
QQmlIncubator incubator;
|
||||||
QQmlComponent* component;
|
QQmlComponent* component;
|
||||||
@ -84,9 +84,9 @@ void QmlObjectPrivate::errorPrint()
|
|||||||
kWarning() << component->url().toString() + '\n' + errorStr;
|
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
|
#ifndef NDEBUG
|
||||||
kDebug() << "File name empty!";
|
kDebug() << "File name empty!";
|
||||||
#endif
|
#endif
|
||||||
@ -103,7 +103,7 @@ void QmlObjectPrivate::execute(const QString &fileName)
|
|||||||
//binds things like kconfig and icons
|
//binds things like kconfig and icons
|
||||||
kdeclarative.setupBindings();
|
kdeclarative.setupBindings();
|
||||||
|
|
||||||
component->loadUrl(QUrl::fromLocalFile(fileName));
|
component->loadUrl(source);
|
||||||
|
|
||||||
if (delay) {
|
if (delay) {
|
||||||
QTimer::singleShot(0, q, SLOT(scheduleExecutionEnd()));
|
QTimer::singleShot(0, q, SLOT(scheduleExecutionEnd()));
|
||||||
@ -138,16 +138,16 @@ QmlObject::~QmlObject()
|
|||||||
delete d;
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlObject::setQmlPath(const QString &path)
|
void QmlObject::setSource(const QUrl &source)
|
||||||
{
|
{
|
||||||
qDebug() << "Opening" << path;
|
qDebug() << "Opening" << source;
|
||||||
d->qmlPath = path;
|
d->source = source;
|
||||||
d->execute(path);
|
d->execute(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QmlObject::qmlPath() const
|
QUrl QmlObject::source() const
|
||||||
{
|
{
|
||||||
return d->qmlPath;
|
return d->source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QmlObject::setInitializationDelayed(const bool delay)
|
void QmlObject::setInitializationDelayed(const bool delay)
|
||||||
|
@ -98,7 +98,7 @@ class QmlObject : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
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(bool initializationDelayed READ isInitializationDelayed WRITE setInitializationDelayed)
|
||||||
Q_PROPERTY(QObject * rootObject READ rootObject)
|
Q_PROPERTY(QObject * rootObject READ rootObject)
|
||||||
|
|
||||||
@ -117,12 +117,12 @@ public:
|
|||||||
*
|
*
|
||||||
* @param path the absolute path of a QML file
|
* @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
|
* @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().
|
* Sets whether the execution of the QML file has to be delayed later in the event loop. It has to be called before setQmlPath().
|
||||||
|
@ -99,7 +99,7 @@ void AppletInterface::init()
|
|||||||
delete factory;
|
delete factory;
|
||||||
engine->setNetworkAccessManagerFactory(new PackageAccessManagerFactory(m_appletScriptEngine->package()));
|
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()) {
|
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);
|
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();
|
m_qmlObject->completeInitialization();
|
||||||
|
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ void ContainmentInterface::loadWallpaper()
|
|||||||
pkg.setPath("org.kde.wallpaper.image");
|
pkg.setPath("org.kde.wallpaper.image");
|
||||||
|
|
||||||
m_wallpaperQmlObject = new QmlObject(this);
|
m_wallpaperQmlObject = new QmlObject(this);
|
||||||
m_wallpaperQmlObject->setQmlPath(pkg.filePath("mainscript"));
|
m_wallpaperQmlObject->setSource(QUrl::fromLocalFile(pkg.filePath("mainscript")));
|
||||||
|
|
||||||
if (m_wallpaperQmlObject->mainComponent() &&
|
if (m_wallpaperQmlObject->mainComponent() &&
|
||||||
m_wallpaperQmlObject->rootObject() &&
|
m_wallpaperQmlObject->rootObject() &&
|
||||||
|
Loading…
Reference in New Issue
Block a user