aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqml.h
diff options
context:
space:
mode:
authorAntti Piira <apiira@blackberry.com>2013-10-28 16:17:36 -0700
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-09 22:46:47 +0100
commit7b75c3e63e7842c2667f58d43d44e21ff57ac0c8 (patch)
tree2aa1ade5d31c099170b65b8b618257bf330321dd /src/qml/qml/qqml.h
parentbed4d0de7e4bf57dd70e44be28eb361b4f4fe9e2 (diff)
Add a new variant of qmlRegisterSingletonType for QML singletons.
Adds a new public API to register a QML based singleton type from C++. This is the equivalent of the the qmlRegisterType, but for singletons. qmldir file is not needed for types registered through this function, but the type still needs to include the following pragma statement among the import statements: pragma Singleton Change-Id: Icb35b665fe2a8605667fe8ac575347be2a60490c Reviewed-by: Alan Alpert <aalpert@blackberry.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/qml/qml/qqml.h')
-rw-r--r--src/qml/qml/qqml.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/qml/qml/qqml.h b/src/qml/qml/qqml.h
index 6082fcda08..b6c6fe840d 100644
--- a/src/qml/qml/qqml.h
+++ b/src/qml/qml/qqml.h
@@ -485,6 +485,24 @@ inline int qmlRegisterSingletonType(const char *uri, int versionMajor, int versi
return QQmlPrivate::qmlregister(QQmlPrivate::SingletonRegistration, &api);
}
+inline int qmlRegisterSingletonType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName)
+{
+ if (url.isRelative()) {
+ // User input check must go here, because QQmlPrivate::qmlregister is also used internally for composite types
+ qWarning("qmlRegisterSingletonType requires absolute URLs.");
+ return 0;
+ }
+
+ QQmlPrivate::RegisterCompositeSingletonType type = {
+ url,
+ uri,
+ versionMajor,
+ versionMinor,
+ qmlName
+ };
+
+ return QQmlPrivate::qmlregister(QQmlPrivate::CompositeSingletonRegistration, &type);
+}
inline int qmlRegisterType(const QUrl &url, const char *uri, int versionMajor, int versionMinor, const char *qmlName)
{