diff options
author | Robert Griebl <robert.griebl@qt.io> | 2022-05-23 19:05:50 +0200 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2022-05-31 00:26:57 +0200 |
commit | 33777a820f6fda597065cf77dc90aff34bbcc4f5 (patch) | |
tree | 6e90c7b21589fdf728ce34123cf3e182f7c32dd3 | |
parent | 9c62c010b911ca93a07b8d23e9cc3b4b56518af5 (diff) | |
download | qtapplicationmanager-33777a820f6fda597065cf77dc90aff34bbcc4f5.tar.gz |
Fix the qmltypes generation
* enums were not exported at all
* methods with pointer returns were not flagged correctly
* added an option to specify a prototype different from the C++ base
class
* added an option to specify how many super classes up the generator
is considering (used when the exported class is only a
implementation of a virtual base class)
Change-Id: I377c732362c34796e156067fd79ca0df772315d6
Fixes: QTBUG-103229
Task-number: QTBUG-103266
Reviewed-by: Bernd Weimer <bernd.weimer@qt.io>
-rw-r--r-- | qmltypes/QtApplicationManager/Application/plugins.qmltypes | 39 | ||||
-rw-r--r-- | qmltypes/QtApplicationManager/SystemUI/plugins.qmltypes | 38 | ||||
-rw-r--r-- | qmltypes/QtApplicationManager/plugins.qmltypes | 8 | ||||
-rw-r--r-- | src/intent-server-lib/intentmodel.h | 1 | ||||
-rw-r--r-- | src/launcher-lib/dbusapplicationinterface.h | 1 | ||||
-rw-r--r-- | src/manager-lib/applicationmodel.h | 1 | ||||
-rw-r--r-- | src/tools/dumpqmltypes/dumpqmltypes.cpp | 63 |
7 files changed, 121 insertions, 30 deletions
diff --git a/qmltypes/QtApplicationManager/Application/plugins.qmltypes b/qmltypes/QtApplicationManager/Application/plugins.qmltypes index 2caf0507..067171e5 100644 --- a/qmltypes/QtApplicationManager/Application/plugins.qmltypes +++ b/qmltypes/QtApplicationManager/Application/plugins.qmltypes @@ -7,7 +7,7 @@ import QtQuick.tooling 1.2 // appman-dumpqmltypes Module { - dependencies: [ "QtQuick.Window 2.2", "QtQuick 2.2" ] + dependencies: [ "QtQuick.Window 6.2", "QtQuick 6.2" ] Component { name: "IntentHandler" exports: [ "QtApplicationManager.Application/IntentHandler 2.0" ] @@ -49,14 +49,45 @@ Module { } } Component { - name: "DBusApplicationInterface" + name: "ApplicationInterface" exports: [ "QtApplicationManager.Application/ApplicationInterface 2.0" ] exportMetaObjectRevisions: [ 0 ] - prototype: "ApplicationInterface" + prototype: "QObject" isCreatable: false + Property { name: "applicationId"; type: "string"; isReadonly: true } + Property { name: "name"; type: "QVariantMap"; isReadonly: true } + Property { name: "icon"; type: "QUrl"; isReadonly: true } + Property { name: "version"; type: "string"; isReadonly: true } + Property { name: "systemProperties"; type: "QVariantMap"; isReadonly: true } + Property { name: "applicationProperties"; type: "QVariantMap"; isReadonly: true } + Signal { + name: "quit" + } + Signal { + name: "memoryLowWarning" + } + Signal { + name: "memoryCriticalWarning" + } + Signal { + name: "openDocument" + Parameter { name: "documentUrl"; type: "string"; } + Parameter { name: "mimeType"; type: "string"; } + } + Signal { + name: "interfaceCreated" + Parameter { name: "interfaceName"; type: "string"; } + } + Signal { + name: "slowAnimationsChanged" + Parameter { name: "isSlow"; type: "bool"; } + } + Method { + name: "finishedInitialization" + } Method { name: "createNotification" - type: "Notification*" + type: "Notification"; isPointer: true; } Method { name: "acknowledgeQuit" diff --git a/qmltypes/QtApplicationManager/SystemUI/plugins.qmltypes b/qmltypes/QtApplicationManager/SystemUI/plugins.qmltypes index 814d3c3f..8bc2df63 100644 --- a/qmltypes/QtApplicationManager/SystemUI/plugins.qmltypes +++ b/qmltypes/QtApplicationManager/SystemUI/plugins.qmltypes @@ -7,7 +7,7 @@ import QtQuick.tooling 1.2 // appman-dumpqmltypes Module { - dependencies: [ "QtQuick.Window 2.2", "QtQuick 2.2" ] + dependencies: [ "QtQuick.Window 6.2", "QtQuick 6.2" ] Component { name: "ProcessStatus" exports: [ "QtApplicationManager.SystemUI/ProcessStatus 2.0" ] @@ -50,7 +50,7 @@ Module { name: "IntentModel" exports: [ "QtApplicationManager.SystemUI/IntentModel 2.0" ] exportMetaObjectRevisions: [ 0 ] - prototype: "QSortFilterProxyModel" + prototype: "QObject" Property { name: "count"; type: "int"; isReadonly: true } Property { name: "filterFunction"; type: "QJSValue"; } Property { name: "sortFunction"; type: "QJSValue"; } @@ -98,6 +98,7 @@ Module { exportMetaObjectRevisions: [ 0 ] prototype: "QObject" isCreatable: false + Enum { name: "Visibility"; values: [ "Public", "Private" ] } Property { name: "intentId"; type: "string"; isReadonly: true } Property { name: "packageId"; type: "string"; isReadonly: true } Property { name: "applicationId"; type: "string"; isReadonly: true } @@ -142,38 +143,38 @@ Module { } Method { name: "intent" - type: "Intent*" + type: "Intent"; isPointer: true; Parameter { name: "index"; type: "int"; } } Method { name: "applicationIntent" - type: "Intent*" + type: "Intent"; isPointer: true; Parameter { name: "intentId"; type: "string"; } Parameter { name: "applicationId"; type: "string"; } Parameter { name: "parameters"; type: "QVariantMap"; } } Method { name: "applicationIntent" - type: "Intent*" + type: "Intent"; isPointer: true; Parameter { name: "intentId"; type: "string"; } Parameter { name: "applicationId"; type: "string"; } } Method { name: "packageIntent" - type: "Intent*" + type: "Intent"; isPointer: true; Parameter { name: "intentId"; type: "string"; } Parameter { name: "packageId"; type: "string"; } Parameter { name: "parameters"; type: "QVariantMap"; } } Method { name: "packageIntent" - type: "Intent*" + type: "Intent"; isPointer: true; Parameter { name: "intentId"; type: "string"; } Parameter { name: "packageId"; type: "string"; } } Method { name: "packageIntent" - type: "Intent*" + type: "Intent"; isPointer: true; Parameter { name: "intentId"; type: "string"; } Parameter { name: "packageId"; type: "string"; } Parameter { name: "applicationId"; type: "string"; } @@ -181,7 +182,7 @@ Module { } Method { name: "packageIntent" - type: "Intent*" + type: "Intent"; isPointer: true; Parameter { name: "intentId"; type: "string"; } Parameter { name: "packageId"; type: "string"; } Parameter { name: "applicationId"; type: "string"; } @@ -245,6 +246,7 @@ Module { exportMetaObjectRevisions: [ 0 ] prototype: "QObject" isCreatable: false + Enum { name: "ContentState"; values: [ "SurfaceWithContent", "SurfaceNoContent", "NoSurface" ] } Property { name: "size"; type: "QSize"; isReadonly: true } Property { name: "contentState"; type: "ContentState"; isReadonly: true } Property { name: "application"; type: "Application"; isPointer: true; isReadonly: true } @@ -348,7 +350,7 @@ Module { } Method { name: "window" - type: "Window*" + type: "Window"; isPointer: true; Parameter { name: "index"; type: "int"; } } Method { @@ -363,7 +365,7 @@ Module { } Method { name: "addExtension" - type: "QObject*" + type: "QObject"; isPointer: true; Parameter { name: "component"; type: "QQmlComponent"; isPointer: true; } } Method { @@ -379,12 +381,15 @@ Module { exportMetaObjectRevisions: [ 0 ] prototype: "QObject" isCreatable: false + Enum { name: "ExitStatus"; values: [ "NormalExit", "CrashExit", "ForcedExit" ] } + Enum { name: "RunState"; values: [ "NotRunning", "StartingUp", "Running", "ShuttingDown" ] } + Enum { name: "ProcessError"; values: [ "FailedToStart", "Crashed", "Timedout", "ReadError", "WriteError", "UnknownError" ] } } Component { name: "ApplicationModel" exports: [ "QtApplicationManager.SystemUI/ApplicationModel 2.0" ] exportMetaObjectRevisions: [ 0 ] - prototype: "QSortFilterProxyModel" + prototype: "QObject" Property { name: "count"; type: "int"; isReadonly: true } Property { name: "filterFunction"; type: "QJSValue"; } Property { name: "sortFunction"; type: "QJSValue"; } @@ -470,6 +475,7 @@ Module { exportMetaObjectRevisions: [ 0 ] prototype: "QObject" isCreatable: false + Enum { name: "State"; values: [ "Installed", "BeingInstalled", "BeingUpdated", "BeingDowngraded", "BeingRemoved" ] } Property { name: "id"; type: "string"; isReadonly: true } Property { name: "name"; type: "string"; isReadonly: true } Property { name: "names"; type: "QVariantMap"; isReadonly: true } @@ -679,12 +685,12 @@ Module { } Method { name: "package" - type: "Package*" + type: "Package"; isPointer: true; Parameter { name: "index"; type: "int"; } } Method { name: "package" - type: "Package*" + type: "Package"; isPointer: true; Parameter { name: "id"; type: "string"; } } Method { @@ -985,12 +991,12 @@ Module { } Method { name: "application" - type: "Application*" + type: "Application"; isPointer: true; Parameter { name: "index"; type: "int"; } } Method { name: "application" - type: "Application*" + type: "Application"; isPointer: true; Parameter { name: "id"; type: "string"; } } Method { diff --git a/qmltypes/QtApplicationManager/plugins.qmltypes b/qmltypes/QtApplicationManager/plugins.qmltypes index 28ad1058..2089cf4f 100644 --- a/qmltypes/QtApplicationManager/plugins.qmltypes +++ b/qmltypes/QtApplicationManager/plugins.qmltypes @@ -7,7 +7,7 @@ import QtQuick.tooling 1.2 // appman-dumpqmltypes Module { - dependencies: [ "QtQuick.Window 2.2", "QtQuick 2.2" ] + dependencies: [ "QtQuick.Window 6.2", "QtQuick 6.2" ] Component { name: "MonitorModel" exports: [ "QtApplicationManager/MonitorModel 2.0" ] @@ -139,6 +139,7 @@ Module { exportMetaObjectRevisions: [ 0 ] prototype: "QObject" isCreatable: false + Enum { name: "Direction"; values: [ "ToSystem", "ToApplication" ] } Property { name: "requestId"; type: "QUuid"; isReadonly: true } Property { name: "direction"; type: "Direction"; isReadonly: true } Property { name: "intentId"; type: "string"; isReadonly: true } @@ -171,13 +172,13 @@ Module { isSingleton: true Method { name: "sendIntentRequest" - type: "IntentClientRequest*" + type: "IntentClientRequest"; isPointer: true; Parameter { name: "intentId"; type: "string"; } Parameter { name: "parameters"; type: "QVariantMap"; } } Method { name: "sendIntentRequest" - type: "IntentClientRequest*" + type: "IntentClientRequest"; isPointer: true; Parameter { name: "intentId"; type: "string"; } Parameter { name: "applicationId"; type: "string"; } Parameter { name: "parameters"; type: "QVariantMap"; } @@ -188,6 +189,7 @@ Module { exports: [ "QtApplicationManager/Notification 2.0" ] exportMetaObjectRevisions: [ 0 ] prototype: "QObject" + Enum { name: "Priority"; values: [ "Low", "Normal", "Critical" ] } Property { name: "notificationId"; type: "uint"; isReadonly: true } Property { name: "visible"; type: "bool"; } Property { name: "summary"; type: "string"; } diff --git a/src/intent-server-lib/intentmodel.h b/src/intent-server-lib/intentmodel.h index 8f40d0ae..b402d078 100644 --- a/src/intent-server-lib/intentmodel.h +++ b/src/intent-server-lib/intentmodel.h @@ -45,6 +45,7 @@ class IntentModel : public QSortFilterProxyModel { Q_OBJECT Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/IntentModel 2.0") + Q_CLASSINFO("AM-QmlPrototype", "QObject") Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QJSValue filterFunction READ filterFunction WRITE setFilterFunction NOTIFY filterFunctionChanged) diff --git a/src/launcher-lib/dbusapplicationinterface.h b/src/launcher-lib/dbusapplicationinterface.h index 287a76ab..2dffc58f 100644 --- a/src/launcher-lib/dbusapplicationinterface.h +++ b/src/launcher-lib/dbusapplicationinterface.h @@ -53,6 +53,7 @@ class DBusApplicationInterface : public ApplicationInterface { Q_OBJECT Q_CLASSINFO("AM-QmlType", "QtApplicationManager.Application/ApplicationInterface 2.0 UNCREATABLE") + Q_CLASSINFO("AM-QmlVirtualSuperClasses", "1") public: explicit DBusApplicationInterface(const QString &dbusConnectionName, diff --git a/src/manager-lib/applicationmodel.h b/src/manager-lib/applicationmodel.h index 5a242101..3d7012f8 100644 --- a/src/manager-lib/applicationmodel.h +++ b/src/manager-lib/applicationmodel.h @@ -46,6 +46,7 @@ class ApplicationModel : public QSortFilterProxyModel { Q_OBJECT Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/ApplicationModel 2.0") + Q_CLASSINFO("AM-QmlPrototype", "QObject") Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QJSValue filterFunction READ filterFunction WRITE setFilterFunction NOTIFY filterFunctionChanged) diff --git a/src/tools/dumpqmltypes/dumpqmltypes.cpp b/src/tools/dumpqmltypes/dumpqmltypes.cpp index 46281070..ab0a9828 100644 --- a/src/tools/dumpqmltypes/dumpqmltypes.cpp +++ b/src/tools/dumpqmltypes/dumpqmltypes.cpp @@ -167,6 +167,28 @@ static QByteArray qmlTypeForMetaObect(const QMetaObject *mo, int level, bool ind if (type.isEmpty() || revMajor < 0 || revMinor < 0) throw Exception("Class %1 has an invalid AM-QmlType class info").arg(mo->className()); + // check the AM-QmlVirtualSuperClasses Q_CLASSINFO + // used to parse up to <n> super classes in addition to the current class and use the + // topmost one for naming (useful, if the actual type is a virtual base class) + int parseSuperClasses = 0; + int superIdx = mo->indexOfClassInfo("AM-QmlVirtualSuperClasses"); + if (superIdx >= mo->classInfoOffset()) { + parseSuperClasses = QByteArray(mo->classInfo(superIdx).value()).toInt(); + } + + const QMetaObject *supermo = mo; + for (int i = parseSuperClasses; i; --i) + supermo = supermo->superClass(); + + // parse the AM-QmlPrototype Q_CLASSINFO + // used to specify a different prototype than the actual C++ base class + // (useful, if the actual C++ base class should not be exposed to QML) + QByteArray prototype = stripNamespace(supermo->superClass()->className()); + int protoIdx = mo->indexOfClassInfo("AM-QmlPrototype"); + if (protoIdx >= mo->classInfoOffset()) { + prototype = mo->classInfo(protoIdx).value(); + } + QByteArray str; QByteArray indent1 = QByteArray(level * 4, ' '); QByteArray indent2 = QByteArray((level + 1) * 4, ' '); @@ -177,18 +199,41 @@ static QByteArray qmlTypeForMetaObect(const QMetaObject *mo, int level, bool ind str = str + "Component {\n" - + indent2 + "name: \"" + stripNamespace(mo->className()) + "\"\n" + + indent2 + "name: \"" + stripNamespace(supermo->className()) + "\"\n" + indent2 + "exports: [ \"" + type + " " + QByteArray::number(revMajor) + "." + QByteArray::number(revMinor) + "\" ]\n" + indent2 + "exportMetaObjectRevisions: [ 0 ]\n"; if (mo->superClass()) - str = str + indent2 + "prototype: \"" + stripNamespace(mo->superClass()->className()) + "\"\n"; + str = str + indent2 + "prototype: \"" + prototype + "\"\n"; if (isSingleton) str = str + indent2 + "isSingleton: true\n"; if (isUncreatable) str = str + indent2 + "isCreatable: false\n"; - for (int i = mo->propertyOffset(); i < mo->propertyCount(); ++i) { + + int propertyOffset = supermo->propertyOffset(); + int methodOffset = supermo->methodOffset(); + int enumeratorOffset = supermo->enumeratorOffset(); + + for (int i = enumeratorOffset; i < mo->enumeratorCount(); ++i) { + QMetaEnum e = mo->enumerator(i); + + QByteArray values; + for (int k = 0; k < e.keyCount(); ++k) { + if (k) + values.append(", "); + values.append('"'); + values.append(e.key(k)); + values.append('"'); + } + + str = str + + indent2 + + "Enum { name: \"" + e.enumName() + + "\"; values: [ " + values + " ] }\n"; + } + + for (int i = propertyOffset; i < mo->propertyCount(); ++i) { QMetaProperty p = mo->property(i); if (QByteArray(p.name()).startsWith('_')) // ignore "private" continue; @@ -204,7 +249,7 @@ static QByteArray qmlTypeForMetaObect(const QMetaObject *mo, int level, bool ind str = str + " }\n"; } - for (int i = mo->methodOffset(); i < mo->methodCount(); ++i) { + for (int i = methodOffset; i < mo->methodCount(); ++i) { QMetaMethod m = mo->method(i); if (m.name().startsWith('_')) // ignore "private" continue; @@ -223,8 +268,12 @@ static QByteArray qmlTypeForMetaObect(const QMetaObject *mo, int level, bool ind } str = str + indent2 + methodtype + " {\n" + indent3 + "name: \"" + m.name() + "\"\n"; - if (qstrcmp(m.typeName(), "void") != 0) - str = str + indent3 + "type: \"" + mapTypeName(m.typeName(), false) + "\"\n"; + if (qstrcmp(m.typeName(), "void") != 0) { + str = str + indent3 + "type: \"" + mapTypeName(m.typeName(), true) + "\""; + if (QByteArray(m.typeName()).endsWith('*')) + str += "; isPointer: true;"; + str += "\n"; + } for (int j = 0; j < m.parameterCount(); ++j) { str = str @@ -354,7 +403,7 @@ int main(int argc, char **argv) "// appman-dumpqmltypes\n" "\n" "Module {\n" - " dependencies: [ \"QtQuick.Window 2.${QT_MINOR_VERSION}\", \"QtQuick 2.${QT_MINOR_VERSION}\" ]\n"; + " dependencies: [ \"QtQuick.Window 6.${QT_MINOR_VERSION}\", \"QtQuick 6.${QT_MINOR_VERSION}\" ]\n"; const char *footer = "}\n"; typesOut << QByteArray(header).replace("${QT_MINOR_VERSION}", |