aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltyperegistrar
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2020-04-07 11:50:39 +0200
committerUlf Hermann <ulf.hermann@qt.io>2020-04-28 11:46:03 +0200
commitc2de5643cd4f1b8d8b10e2bb62fdf95f12fdd9e3 (patch)
tree55cfa6610c91315d5ae6cbbf2c961fb2fbfcabd8 /src/qmltyperegistrar
parent1029b2b9f3d0ff88c0900fbfec2fac873aa6bcd4 (diff)
Register value types declaratively
For now this has the effect of adding them to the .qmltypes files. In the future, the registration shall actually add additional value types you can declare as properties in QML. Change-Id: Ifee5a8ec054f35cc7bd07eb992a136730be68da7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/qmltyperegistrar')
-rw-r--r--src/qmltyperegistrar/qmltypesclassdescription.cpp5
-rw-r--r--src/qmltyperegistrar/qmltypesclassdescription.h1
-rw-r--r--src/qmltyperegistrar/qmltypescreator.cpp5
3 files changed, 7 insertions, 4 deletions
diff --git a/src/qmltyperegistrar/qmltypesclassdescription.cpp b/src/qmltyperegistrar/qmltypesclassdescription.cpp
index 94f06a81ee..2214758f38 100644
--- a/src/qmltyperegistrar/qmltypesclassdescription.cpp
+++ b/src/qmltyperegistrar/qmltypesclassdescription.cpp
@@ -117,6 +117,9 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef,
else if (foreignName == QLatin1String("QML.Attached"))
collectAttached(foreignValue, types, foreign, defaultRevision);
}
+ } else {
+ // The foreign type does not have a meta object: We only override the name.
+ className = value;
}
} else if (name == QLatin1String("QML.Root")) {
isRootClass = true;
@@ -173,6 +176,8 @@ void QmlTypesClassDescription::collect(const QJsonObject *classDef,
revisions.erase(end, revisions.end());
resolvedClass = classDef;
+ if (className.isEmpty() && mode == TopLevel)
+ className = classDef->value(QLatin1String("qualifiedClassName")).toString();
// If it's not a QObject, it's not creatable
isCreatable = isCreatable && classDef->value(QLatin1String("object")).toBool();
diff --git a/src/qmltyperegistrar/qmltypesclassdescription.h b/src/qmltyperegistrar/qmltypesclassdescription.h
index abe68d42ed..ed4ba49592 100644
--- a/src/qmltyperegistrar/qmltypesclassdescription.h
+++ b/src/qmltyperegistrar/qmltypesclassdescription.h
@@ -39,6 +39,7 @@ struct QmlTypesClassDescription
{
const QJsonObject *resolvedClass = nullptr;
QString file;
+ QString className;
QString elementName;
QString defaultProp;
QString superClass;
diff --git a/src/qmltyperegistrar/qmltypescreator.cpp b/src/qmltyperegistrar/qmltypescreator.cpp
index 1bccbc36d8..a9885b03fa 100644
--- a/src/qmltyperegistrar/qmltypescreator.cpp
+++ b/src/qmltyperegistrar/qmltypescreator.cpp
@@ -48,10 +48,7 @@ void QmlTypesCreator::writeClassProperties(const QmlTypesClassDescription &colle
{
if (!collector.file.isEmpty())
m_qml.writeScriptBinding(QLatin1String("file"), enquote(collector.file));
- m_qml.writeScriptBinding(
- QLatin1String("name"),
- enquote(collector.resolvedClass->value(
- QLatin1String("qualifiedClassName")).toString()));
+ m_qml.writeScriptBinding(QLatin1String("name"), enquote(collector.className));
if (!collector.defaultProp.isEmpty())
m_qml.writeScriptBinding(QLatin1String("defaultProperty"), enquote(collector.defaultProp));