summaryrefslogtreecommitdiffstats
path: root/src/declarative
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative')
-rw-r--r--src/declarative/qml/qmlcompiler.cpp10
-rw-r--r--src/declarative/qml/qmlengine.cpp12
2 files changed, 15 insertions, 7 deletions
diff --git a/src/declarative/qml/qmlcompiler.cpp b/src/declarative/qml/qmlcompiler.cpp
index 764699e..070add7 100644
--- a/src/declarative/qml/qmlcompiler.cpp
+++ b/src/declarative/qml/qmlcompiler.cpp
@@ -1235,13 +1235,9 @@ bool QmlCompiler::buildProperty(QmlParser::Property *prop,
// default property or to sub-objects (which are always in binding
// sub-contexts)
COMPILE_CHECK(buildIdProperty(prop, obj));
- if (prop->type == QVariant::String){
- if(!prop->values.at(0)->value.isString()){
- //Need to convert to string to assign to the QString id property
- prop->values.at(0)->value = Variant(prop->values.at(0)->value.asString());
- }
+ if (prop->type == QVariant::String &&
+ prop->values.at(0)->value.isString())
COMPILE_CHECK(buildPropertyAssignment(prop, obj, ctxt));
- }
} else if (isAttachedPropertyName(prop->name)) {
@@ -1702,7 +1698,7 @@ bool QmlCompiler::buildListProperty(QmlParser::Property *prop,
// children: [ Item {}, Item {} ]
// }
//
-// We allow assigning multiple values to single value properties
+// We allow assignming multiple values to single value properties
bool QmlCompiler::buildPropertyAssignment(QmlParser::Property *prop,
QmlParser::Object *obj,
const BindingContext &ctxt)
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index fbd9cf1..de88241 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -55,6 +55,7 @@
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QNetworkAccessManager>
+#include <QDesktopServices>
#include <QTimer>
#include <QList>
#include <QPair>
@@ -96,6 +97,14 @@ struct StaticQtMetaObject : public QObject
{ return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
};
+QScriptValue desktopOpenUrl(QScriptContext *ctxt, QScriptEngine *e)
+{
+ if(!ctxt->argumentCount())
+ return e->newVariant(QVariant(false));
+ bool ret = QDesktopServices::openUrl(QUrl(ctxt->argument(0).toString()));
+ return e->newVariant(QVariant(ret));
+}
+
QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
: rootContext(0), currentBindContext(0), currentExpression(0),
isDebugging(false), contextClass(0), objectClass(0), valueTypeClass(0),
@@ -104,6 +113,9 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
{
QScriptValue qtObject =
scriptEngine.newQMetaObject(StaticQtMetaObject::get());
+ QScriptValue desktopObject = scriptEngine.newObject();
+ desktopObject.setProperty(QLatin1String("openUrl"),scriptEngine.newFunction(desktopOpenUrl, 1));
+ qtObject.setProperty(QLatin1String("DesktopServices"), desktopObject);
scriptEngine.globalObject().setProperty(QLatin1String("Qt"), qtObject);
qtObject.setProperty(QLatin1String("rgba"), scriptEngine.newFunction(QmlEnginePrivate::rgba, 4));
qtObject.setProperty(QLatin1String("hsla"), scriptEngine.newFunction(QmlEnginePrivate::hsla, 4));