diff options
author | Robert Griebl <robert.griebl@pelagicore.com> | 2018-12-19 17:43:42 +0100 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2019-01-16 13:52:57 +0000 |
commit | 1cbacf3a975366962a9c754ee1a4cc0c01f83a3f (patch) | |
tree | 9df8e7c256d765755f073867de9c2fe3b6febcbe | |
parent | 5a19cf42a430ac8eff0b6d315810bf624ad9ec6c (diff) |
Update the appman-dumptypes tool
- Added all the missing classes
- Split the generated types definition the same way we split the QML import
namespace earlier - otherwise QtCreator cannot use this information
Change-Id: I8259f7fe0598c54a75b125aac44f189177e7046b
Reviewed-by: Dominik Holland <dominik.holland@pelagicore.com>
24 files changed, 249 insertions, 126 deletions
diff --git a/src/common-lib/exception.cpp b/src/common-lib/exception.cpp index 728dea7f..11a54d89 100644 --- a/src/common-lib/exception.cpp +++ b/src/common-lib/exception.cpp @@ -52,6 +52,11 @@ Exception::Exception(const char *errorString) Q_DECL_NOEXCEPT , m_errorString(errorString ? qL1S(errorString) : QString()) { } +Exception::Exception(const QString &errorString) Q_DECL_NOEXCEPT + : m_errorCode(Error::System) + , m_errorString(errorString) +{ } + Exception::Exception(Error errorCode, const char *errorString) Q_DECL_NOEXCEPT : m_errorCode(errorCode) , m_errorString(errorString ? qL1S(errorString) : QString()) diff --git a/src/common-lib/exception.h b/src/common-lib/exception.h index e5184691..3dcdc03a 100644 --- a/src/common-lib/exception.h +++ b/src/common-lib/exception.h @@ -60,6 +60,7 @@ class Exception : public QException { public: explicit Exception(const char *errorString) Q_DECL_NOEXCEPT; + explicit Exception(const QString &errorString) Q_DECL_NOEXCEPT; explicit Exception(Error errorCode, const char *errorString = nullptr) Q_DECL_NOEXCEPT; explicit Exception(Error errorCode, const QString &errorString) Q_DECL_NOEXCEPT; explicit Exception(int _errno, const char *errorString) Q_DECL_NOEXCEPT; diff --git a/src/intent-client-lib/intentclient.h b/src/intent-client-lib/intentclient.h index 8eb633a0..6e1e7314 100644 --- a/src/intent-client-lib/intentclient.h +++ b/src/intent-client-lib/intentclient.h @@ -62,6 +62,7 @@ class IntentClientSystemInterface; class IntentClient : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager/IntentClient 2.0") public: ~IntentClient() override; diff --git a/src/intent-client-lib/intentclientrequest.h b/src/intent-client-lib/intentclientrequest.h index c9cc8d71..41e579d8 100644 --- a/src/intent-client-lib/intentclientrequest.h +++ b/src/intent-client-lib/intentclientrequest.h @@ -56,6 +56,8 @@ class IntentClient; class IntentClientRequest : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager/IntentRequest 2.0") + Q_PROPERTY(QUuid requestId READ requestId NOTIFY requestIdChanged) Q_PROPERTY(Direction direction READ direction CONSTANT) Q_PROPERTY(QString intentId READ intentId CONSTANT) diff --git a/src/intent-client-lib/intenthandler.h b/src/intent-client-lib/intenthandler.h index 3f1e822b..650ea539 100644 --- a/src/intent-client-lib/intenthandler.h +++ b/src/intent-client-lib/intenthandler.h @@ -57,6 +57,8 @@ class IntentClientRequest; class IntentHandler : public QObject, public QQmlParserStatus { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.Application/IntentHandler 2.0") + Q_INTERFACES(QQmlParserStatus) Q_PROPERTY(QStringList intentIds READ intentIds WRITE setIntentIds NOTIFY intentIdsChanged) diff --git a/src/intent-server-lib/intent.h b/src/intent-server-lib/intent.h index 2ed3ad68..f2c5901b 100644 --- a/src/intent-server-lib/intent.h +++ b/src/intent-server-lib/intent.h @@ -52,6 +52,8 @@ QT_BEGIN_NAMESPACE_AM class Intent { Q_GADGET + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/Intent 2.0") + Q_PROPERTY(bool valid READ (operator bool)) Q_PROPERTY(QString intentId READ intentId) Q_PROPERTY(QString applicationId READ applicationId) diff --git a/src/intent-server-lib/intentserver.cpp b/src/intent-server-lib/intentserver.cpp index eac17a44..62fdaa2f 100644 --- a/src/intent-server-lib/intentserver.cpp +++ b/src/intent-server-lib/intentserver.cpp @@ -109,8 +109,6 @@ IntentServer *IntentServer::createInstance(IntentServerSystemInterface *systemIn qmlRegisterUncreatableType<Intent>("QtApplicationManager.SystemUI", 2, 0, "Intent", qSL("Cannot create objects of type Intent")); - qmlRegisterUncreatableType<IntentServerRequest>("QtApplicationManager.SystemUI", 2, 0, "IntentServerRequest", - qSL("Cannot create objects of type IntentServerRequest")); qmlRegisterSingletonType<IntentServer>("QtApplicationManager.SystemUI", 2, 0, "IntentServer", [](QQmlEngine *, QJSEngine *) -> QObject * { QQmlEngine::setObjectOwnership(instance(), QQmlEngine::CppOwnership); diff --git a/src/intent-server-lib/intentserver.h b/src/intent-server-lib/intentserver.h index 04516195..3f43700a 100644 --- a/src/intent-server-lib/intentserver.h +++ b/src/intent-server-lib/intentserver.h @@ -64,6 +64,8 @@ typedef QVariantList IntentList; class IntentServer : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/IntentServer 2.0") + Q_PROPERTY(IntentList intentList READ intentList NOTIFY intentListChanged) public: diff --git a/src/manager-lib/amnamespace.h b/src/manager-lib/amnamespace.h index 53851d1f..ae13ef7f 100644 --- a/src/manager-lib/amnamespace.h +++ b/src/manager-lib/amnamespace.h @@ -51,10 +51,10 @@ QT_BEGIN_NAMESPACE_AM // enums when used as Q_PROPERTY types and accessed from QML class Am : public QObject { - //Q_GADGET Q_OBJECT -public: + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/Am 2.0") +public: // we cannot use QProcess enums directly, since some supported platforms might // not have QProcess available at all. // keep these enums in sync with those in containerinterface.h diff --git a/src/manager-lib/applicationipcinterface.h b/src/manager-lib/applicationipcinterface.h index 5cfe627d..3a1f8aad 100644 --- a/src/manager-lib/applicationipcinterface.h +++ b/src/manager-lib/applicationipcinterface.h @@ -43,6 +43,8 @@ #pragma once #include <QObject> +#include <QString> +#include <QVariant> #include <qqml.h> #if defined(QT_DBUS_LIB) # include <QDBusConnection> @@ -58,6 +60,8 @@ class IpcProxyObject; class ApplicationIPCInterface : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/ApplicationIPCInterface 2.0") + Q_PROPERTY(QObject *serviceObject READ serviceObject WRITE setServiceObject NOTIFY serviceObjectChanged) public: @@ -87,6 +91,30 @@ private: friend class ApplicationIPCManager; }; +class ApplicationIPCInterfaceAttached : public QObject +{ + Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/ApplicationIPCInterfaceAttached 2.0") + + Q_PROPERTY(QString sender READ sender) + Q_PROPERTY(QVariant receivers READ receivers WRITE setReceivers) + Q_PROPERTY(QVariant inProcessReceiversOnly READ inProcessReceiversOnly CONSTANT) + +public: + ApplicationIPCInterfaceAttached(QObject *object); + + QString sender() const; + QVariant receivers() const; + void setReceivers(const QVariant &receivers); + QVariant inProcessReceiversOnly() const; + +private: + bool resolveProxy() const; + + QObject *m_object; + mutable IpcProxyObject *m_proxy = nullptr; +}; + QT_END_NAMESPACE_AM QML_DECLARE_TYPEINFO(QT_PREPEND_NAMESPACE_AM(ApplicationIPCInterface), QML_HAS_ATTACHED_PROPERTIES) diff --git a/src/manager-lib/applicationipcinterface_p.h b/src/manager-lib/applicationipcinterface_p.h index cf64c5ba..e4828adb 100644 --- a/src/manager-lib/applicationipcinterface_p.h +++ b/src/manager-lib/applicationipcinterface_p.h @@ -129,29 +129,5 @@ private: IpcProxyObject *m_proxyObject; }; -class IpcProxyObject; - -class ApplicationIPCInterfaceAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString sender READ sender) - Q_PROPERTY(QVariant receivers READ receivers WRITE setReceivers) - Q_PROPERTY(QVariant inProcessReceiversOnly READ inProcessReceiversOnly CONSTANT) - -public: - ApplicationIPCInterfaceAttached(QObject *object); - - QString sender() const; - QVariant receivers() const; - void setReceivers(const QVariant &receivers); - QVariant inProcessReceiversOnly() const; - -private: - bool resolveProxy() const; - - QObject *m_object; - mutable IpcProxyObject *m_proxy = nullptr; -}; - QT_END_NAMESPACE_AM // We mean it. Dummy comment since syncqt needs this also for completely private Qt modules. diff --git a/src/manager-lib/applicationipcmanager.cpp b/src/manager-lib/applicationipcmanager.cpp index 345d84be..60f99950 100644 --- a/src/manager-lib/applicationipcmanager.cpp +++ b/src/manager-lib/applicationipcmanager.cpp @@ -82,7 +82,8 @@ ApplicationIPCManager *ApplicationIPCManager::createInstance() if (Q_UNLIKELY(s_instance)) qFatal("ApplicationIPCManager::createInstance() was called a second time."); - qmlRegisterType<ApplicationIPCInterfaceAttached>(); + qmlRegisterUncreatableType<ApplicationIPCInterfaceAttached>("QtApplicationManager.SystemUI", 2, 0, "ApplicationIPCInterfaceAttached", + "This type is only providing attached properties"); qmlRegisterType<ApplicationIPCInterface>("QtApplicationManager.SystemUI", 2, 0, "ApplicationIPCInterface"); qmlRegisterSingletonType<ApplicationIPCManager>("QtApplicationManager.SystemUI", 2, 0, "ApplicationIPCManager", &ApplicationIPCManager::instanceForQml); diff --git a/src/manager-lib/applicationmodel.h b/src/manager-lib/applicationmodel.h index 54d4f551..5cedb69a 100644 --- a/src/manager-lib/applicationmodel.h +++ b/src/manager-lib/applicationmodel.h @@ -55,6 +55,7 @@ class ApplicationModelPrivate; class ApplicationModel : public QSortFilterProxyModel { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/ApplicationModel 2.0") Q_PROPERTY(int count READ count NOTIFY countChanged) Q_PROPERTY(QJSValue filterFunction READ filterFunction WRITE setFilterFunction NOTIFY filterFunctionChanged) diff --git a/src/monitor-lib/cpustatus.h b/src/monitor-lib/cpustatus.h index 1c47632b..29308daf 100644 --- a/src/monitor-lib/cpustatus.h +++ b/src/monitor-lib/cpustatus.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE_AM class CpuStatus : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager/CpuStatus 2.0") Q_PROPERTY(qreal cpuLoad READ cpuLoad NOTIFY cpuLoadChanged) Q_PROPERTY(int cpuCores READ cpuCores CONSTANT) diff --git a/src/monitor-lib/frametimer.h b/src/monitor-lib/frametimer.h index 8942745b..65d1cee1 100644 --- a/src/monitor-lib/frametimer.h +++ b/src/monitor-lib/frametimer.h @@ -58,6 +58,7 @@ QT_BEGIN_NAMESPACE_AM class FrameTimer : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager/FrameTimer 2.0") Q_PROPERTY(qreal averageFps READ averageFps NOTIFY updated) Q_PROPERTY(qreal minimumFps READ minimumFps NOTIFY updated) diff --git a/src/monitor-lib/gpustatus.h b/src/monitor-lib/gpustatus.h index bb8eebd5..16f95077 100644 --- a/src/monitor-lib/gpustatus.h +++ b/src/monitor-lib/gpustatus.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE_AM class GpuStatus : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager/GpuStatus 2.0") Q_PROPERTY(qreal gpuLoad READ gpuLoad NOTIFY gpuLoadChanged) Q_PROPERTY(QStringList roleNames READ roleNames CONSTANT) diff --git a/src/monitor-lib/iostatus.h b/src/monitor-lib/iostatus.h index 15e9b9fb..5e5e5357 100644 --- a/src/monitor-lib/iostatus.h +++ b/src/monitor-lib/iostatus.h @@ -56,6 +56,7 @@ QT_BEGIN_NAMESPACE_AM class IoStatus : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager/IoStatus 2.0") Q_PROPERTY(QStringList deviceNames READ deviceNames WRITE setDeviceNames NOTIFY deviceNamesChanged) Q_PROPERTY(QVariantMap ioLoad READ ioLoad NOTIFY ioLoadChanged) diff --git a/src/monitor-lib/memorystatus.h b/src/monitor-lib/memorystatus.h index d398c5d4..cd712b9c 100644 --- a/src/monitor-lib/memorystatus.h +++ b/src/monitor-lib/memorystatus.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE_AM class MemoryStatus : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager/MemoryStatus 2.0") Q_PROPERTY(quint64 totalMemory READ totalMemory CONSTANT) Q_PROPERTY(quint64 memoryUsed READ memoryUsed NOTIFY memoryUsedChanged) diff --git a/src/monitor-lib/monitormodel.h b/src/monitor-lib/monitormodel.h index 496b8a6a..35fc4265 100644 --- a/src/monitor-lib/monitormodel.h +++ b/src/monitor-lib/monitormodel.h @@ -54,6 +54,7 @@ QT_BEGIN_NAMESPACE_AM class MonitorModel : public QAbstractListModel { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager/MonitorModel 2.0") Q_PROPERTY(QQmlListProperty<QObject> dataSources READ dataSources) Q_CLASSINFO("DefaultProperty", "dataSources") diff --git a/src/monitor-lib/processstatus.h b/src/monitor-lib/processstatus.h index e3af6577..b233aced 100644 --- a/src/monitor-lib/processstatus.h +++ b/src/monitor-lib/processstatus.h @@ -59,6 +59,7 @@ QT_BEGIN_NAMESPACE_AM class ProcessStatus : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/ProcessStatus 2.0") Q_PROPERTY(QString applicationId READ applicationId WRITE setApplicationId NOTIFY applicationIdChanged) Q_PROPERTY(qint64 processId READ processId NOTIFY processIdChanged) Q_PROPERTY(qreal cpuLoad READ cpuLoad NOTIFY cpuLoadChanged) diff --git a/src/tools/dumpqmltypes/dumpqmltypes.cpp b/src/tools/dumpqmltypes/dumpqmltypes.cpp index c12bc0ae..e767b7c2 100644 --- a/src/tools/dumpqmltypes/dumpqmltypes.cpp +++ b/src/tools/dumpqmltypes/dumpqmltypes.cpp @@ -29,6 +29,8 @@ #include <QtAppManInstaller/applicationinstaller.h> #include <QtAppManManager/applicationmanager.h> +#include <QtAppManManager/applicationmodel.h> +#include <QtAppManManager/amnamespace.h> #include <QtAppManManager/applicationipcmanager.h> #include <QtAppManManager/applicationipcinterface.h> #include <QtAppManManager/application.h> @@ -39,10 +41,25 @@ #include <QtAppManManager/notificationmanager.h> #include <QtAppManManager/qmlinprocessapplicationinterface.h> #include <QtAppManWindow/windowmanager.h> +#include <QtAppManWindow/window.h> +#include <QtAppManWindow/windowitem.h> #include <QtAppManLauncher/qmlapplicationinterface.h> #include <QtAppManLauncher/qmlapplicationinterfaceextension.h> #include <QtAppManLauncher/private/applicationmanagerwindow_p.h> +#include <QtAppManIntentServer/intent.h> +#include <QtAppManIntentServer/intentserver.h> +#include <QtAppManIntentClient/intentclient.h> +#include <QtAppManIntentClient/intentclientrequest.h> +#include <QtAppManIntentClient/intenthandler.h> +#include <QtAppManMonitor/cpustatus.h> +#include <QtAppManMonitor/gpustatus.h> +#include <QtAppManMonitor/memorystatus.h> +#include <QtAppManMonitor/iostatus.h> +#include <QtAppManMonitor/processstatus.h> +#include <QtAppManMonitor/frametimer.h> +#include <QtAppManMonitor/monitormodel.h> #include <QtAppManCommon/global.h> +#include <QtAppManCommon/exception.h> #include <QCoreApplication> #include <QCommandLineParser> @@ -51,6 +68,49 @@ QT_USE_NAMESPACE_AM +static const QVector<const QMetaObject *> all = { + // manager-lib + &ApplicationManager::staticMetaObject, + &ApplicationInstaller::staticMetaObject, + &NotificationManager::staticMetaObject, + &ApplicationIPCManager::staticMetaObject, + &AbstractApplication::staticMetaObject, + &AbstractRuntime::staticMetaObject, + &AbstractContainer::staticMetaObject, + &Notification::staticMetaObject, + &QmlApplicationInterface::staticMetaObject, + &QmlApplicationInterfaceExtension::staticMetaObject, + &ApplicationManagerWindow::staticMetaObject, + &ApplicationModel::staticMetaObject, + &Am::staticMetaObject, + &ApplicationIPCInterface::staticMetaObject, + &ApplicationIPCInterfaceAttached::staticMetaObject, + + // window-lib + &WindowManager::staticMetaObject, + &Window::staticMetaObject, + &WindowItem::staticMetaObject, + + // intent-client-lib + &IntentClient::staticMetaObject, + &IntentClientRequest::staticMetaObject, + &IntentHandler::staticMetaObject, + + // intent-server-lib + &IntentServer::staticMetaObject, + &Intent::staticMetaObject, + + // monitor-lib + &CpuStatus::staticMetaObject, + &GpuStatus::staticMetaObject, + &MemoryStatus::staticMetaObject, + &IoStatus::staticMetaObject, + &ProcessStatus::staticMetaObject, + &FrameTimer::staticMetaObject, + &MonitorModel::staticMetaObject +}; + + static QByteArray qmlTypeForMetaObect(const QMetaObject *mo, int level, bool indentFirstLine) { static auto stripNamespace = [](const QByteArray &identifier) -> QByteArray { @@ -83,17 +143,17 @@ static QByteArray qmlTypeForMetaObect(const QMetaObject *mo, int level, bool ind str = str + "Component {\n"; str = str - + indent2 - + "name: \"" - + stripNamespace(mo->className()) - + "\"\n"; + + indent2 + + "name: \"" + + stripNamespace(mo->className()) + + "\"\n"; if (mo->superClass()) { str = str - + indent2 - + "prototype: \"" - + stripNamespace(mo->superClass()->className()) - + "\"\n"; + + indent2 + + "prototype: \"" + + stripNamespace(mo->superClass()->className()) + + "\"\n"; } for (int i = mo->classInfoOffset(); i < mo->classInfoCount(); ++i) { @@ -111,9 +171,9 @@ static QByteArray qmlTypeForMetaObect(const QMetaObject *mo, int level, bool ind for (int i = mo->propertyOffset(); i < mo->propertyCount(); ++i) { QMetaProperty p = mo->property(i); str = str - + indent2 - + "Property { name: \"" + p.name() - + "\"; type: \"" + mapTypeName(p.typeName(), true) + "\";"; + + indent2 + + "Property { name: \"" + p.name() + + "\"; type: \"" + mapTypeName(p.typeName(), true) + "\";"; if (QByteArray(p.typeName()).endsWith('*')) str += " isPointer: true;"; if (!p.isWritable()) @@ -140,15 +200,15 @@ static QByteArray qmlTypeForMetaObect(const QMetaObject *mo, int level, bool ind } str = str - + indent2 - + methodtype + " {\n" + indent3 + "name: \"" + m.name() + "\"\n"; + + indent2 + + methodtype + " {\n" + indent3 + "name: \"" + m.name() + "\"\n"; if (qstrcmp(m.typeName(), "void") != 0) str = str + indent3 + "type: \"" + mapTypeName(m.typeName(), false) + "\"\n"; for (int j = 0; j < m.parameterCount(); ++j) { str = str - + indent3 + "Parameter { name: \"" - + m.parameterNames().at(j) + "\"; type: \"" + mapTypeName(m.parameterTypes().at(j), true) + "\";"; + + indent3 + "Parameter { name: \"" + + m.parameterNames().at(j) + "\"; type: \"" + mapTypeName(m.parameterTypes().at(j), true) + "\";"; if (m.parameterTypes().at(j).endsWith('*')) str += " isPointer: true;"; str = str + " }\n"; @@ -164,91 +224,123 @@ static QByteArray qmlTypeForMetaObect(const QMetaObject *mo, int level, bool ind int main(int argc, char **argv) { - QCoreApplication::setApplicationName(qSL("ApplicationManager qmltypes dumper")); - QCoreApplication::setOrganizationName(qSL("Luxoft Sweden AB")); - QCoreApplication::setOrganizationDomain(qSL("luxoft.com")); - QCoreApplication::setApplicationVersion(qSL(AM_VERSION)); - - QCoreApplication a(argc, argv); - Q_UNUSED(a) - QCommandLineParser clp; - - const char *desc = - "Luxoft ApplicationManager qmltypes dumper" - "\n\n" - "This tool is used to generate the qmltypes type information for all ApplicationManager\n" - "classes to get auto-completion in QtCreator.\n" - "Either install the resulting output as $QTDIR/qml/QtApplicationManager/plugins.qmltypes\n" - "or simply run this tool with the --install option.\n"; - - clp.setApplicationDescription(qL1S(desc)); - clp.addHelpOption(); - clp.addVersionOption(); - clp.addOption({ qSL("install"), qSL("directly install into the Qt directory.") }); - - if (!clp.parse(QCoreApplication::arguments())) { - fprintf(stderr, "%s\n", qPrintable(clp.errorText())); - return 1; - } - if (clp.isSet(qSL("version"))) - clp.showVersion(); - if (clp.isSet(qSL("help"))) - clp.showHelp(); - - QFile outFile; - - if (clp.isSet(qSL("install"))) { - QDir qmlDir = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); - if (!qmlDir.exists()) { - fprintf(stderr, "Qt's QML2 imports directory (%s) is missing.\n", - qPrintable(qmlDir.absolutePath())); - return 2; + try { + QCoreApplication::setApplicationName(qSL("ApplicationManager qmltypes dumper")); + QCoreApplication::setOrganizationName(qSL("Luxoft Sweden AB")); + QCoreApplication::setOrganizationDomain(qSL("luxoft.com")); + QCoreApplication::setApplicationVersion(qSL(AM_VERSION)); + + QCoreApplication a(argc, argv); + Q_UNUSED(a) + QCommandLineParser clp; + + const char *desc = + "Luxoft ApplicationManager qmltypes dumper" + "\n\n" + "This tool is used to generate the qmltypes type information for all ApplicationManager\n" + "classes to get auto-completion in QtCreator.\n" + "Either install the resulting output as $QTDIR/qml/QtApplicationManager/plugins.qmltypes\n" + "or simply run this tool with the --install option.\n"; + + clp.setApplicationDescription(qL1S(desc)); + clp.addHelpOption(); + clp.addVersionOption(); + clp.addOption({ qSL("install"), qSL("directly install into the Qt directory.") }); + clp.addPositionalArgument(qSL("destination"), qSL("Destination directory where the qmltypes information is created."), qSL("dir")); + + if (!clp.parse(QCoreApplication::arguments())) + throw Exception(clp.errorText()); + + if (clp.isSet(qSL("version"))) + clp.showVersion(); + if (clp.isSet(qSL("help"))) + clp.showHelp(); + + QDir outDir; + + if (clp.isSet(qSL("install")) && clp.positionalArguments().isEmpty()) { + outDir = QLibraryInfo::location(QLibraryInfo::Qml2ImportsPath); + if (!outDir.exists()) + throw Exception("Qt's QML2 imports directory (%1) is missing.") + .arg(outDir.absolutePath()); + } else if (clp.positionalArguments().count() == 1) { + outDir = clp.positionalArguments().first(); + if (!outDir.mkpath(qSL("."))) + throw Exception("Cannot create destination directory %1.").arg(outDir.absolutePath()); + } else { + throw Exception("You need to either specify a destination directory or run with --install."); } - outFile.setFileName(qmlDir.absoluteFilePath(qSL("QtApplicationManager/plugins.qmltypes"))); - if (!outFile.open(QFile::WriteOnly)) { - fprintf(stderr, "Failed to open %s for writing: %s\n", qPrintable(outFile.fileName()), - qPrintable(outFile.errorString())); - return 3; + + QMultiMap<QString, const QMetaObject *> imports; + QVector<QByteArray> sanityCheck; // check for copy&paste errors + + for (const auto &mo : all) { + bool foundType = false; + for (int i = mo->classInfoOffset(); (i < mo->classInfoCount()) && !foundType; ++i) { + QMetaClassInfo c = mo->classInfo(i); + if (qstrcmp(c.name(), "AM-QmlType") == 0) { + QByteArray type = c.value(); + QByteArray import = type.left(type.indexOf('/')); + + imports.insert(QString::fromLatin1(import), mo); + foundType = true; + + if (sanityCheck.contains(type)) + throw Exception("Q_CLASSINFO(\"AM-QmlType\", \"%1\") was found multiple times").arg(type); + sanityCheck << type; + } + } + if (!foundType) + throw Exception("Missing Q_CLASSINFO(\"AM-QmlType\", \"...\") on class %1").arg(mo->className()); } - } else { - outFile.open(stdout, QFile::WriteOnly); - } - QTextStream out(&outFile); - - const char *header = \ - "import QtQuick.tooling 1.2\n" - "\n" - "// This file describes the plugin-supplied types contained in the application-manager.\n" - "// It is used for QML tooling purposes only.\n" - "//\n" - "// This file was auto-generated by:\n" - "// appman-dumpqmltypes\n" - "\n" - "Module {\n" - " dependencies: []\n"; - const char *footer = "}\n"; - - out << header; - - QVector<const QMetaObject *> all; - all << &ApplicationManager::staticMetaObject - << &ApplicationInstaller::staticMetaObject - << &WindowManager::staticMetaObject - << &NotificationManager::staticMetaObject - << &ApplicationIPCManager::staticMetaObject - << &AbstractApplication::staticMetaObject - << &AbstractRuntime::staticMetaObject - << &AbstractContainer::staticMetaObject - << &Notification::staticMetaObject - << &QmlApplicationInterface::staticMetaObject - << &QmlApplicationInterfaceExtension::staticMetaObject - << &ApplicationManagerWindow::staticMetaObject; - - for (const auto &mo : qAsConst(all)) - out << qmlTypeForMetaObect(mo, 1, true); - - out << footer; + for (auto it = imports.keyBegin(); it != imports.keyEnd(); ++it) { + QString importPath = *it; + importPath.replace(qL1C('.'), qL1C('/')); + + QDir importDir = outDir; + if (!importDir.mkpath(importPath)) + throw Exception("Cannot create directory %1/%2").arg(importDir.absolutePath(), importPath); + if (!importDir.cd(importPath)) + throw Exception("Cannot cd into directory %1/%2").arg(importDir.absolutePath(), importPath); + + QFile qmldirFile(importDir.absoluteFilePath(qSL("qmldir"))); + if (!qmldirFile.open(QFile::WriteOnly)) + throw Exception(qmldirFile, "Failed to open for writing"); + QTextStream qmldirOut(&qmldirFile); + qmldirOut << "typeinfo plugins.qmltypes\n"; + qmldirFile.close(); + + QFile typesFile(importDir.absoluteFilePath(qSL("plugins.qmltypes"))); + if (!typesFile.open(QFile::WriteOnly)) + throw Exception(typesFile, "Failed to open for writing"); + QTextStream typesOut(&typesFile); + + const char *header = \ + "import QtQuick.tooling 1.2\n" + "\n" + "// This file describes the plugin-supplied types contained in the application-manager.\n" + "// It is used for QML tooling purposes only.\n" + "//\n" + "// This file was auto-generated by:\n" + "// appman-dumpqmltypes\n" + "\n" + "Module {\n" + " dependencies: []\n"; + const char *footer = "}\n"; + + typesOut << header; + + auto mos = imports.values(*it); + for (const auto &mo : qAsConst(mos)) + typesOut << qmlTypeForMetaObect(mo, 1, true); + + typesOut << footer; + } + } catch (const Exception &e) { + fprintf(stderr, "%s\n", qPrintable(e.errorString())); + return 1; + } return 0; } diff --git a/src/tools/dumpqmltypes/dumpqmltypes.pro b/src/tools/dumpqmltypes/dumpqmltypes.pro index 91f5cc14..147f383b 100644 --- a/src/tools/dumpqmltypes/dumpqmltypes.pro +++ b/src/tools/dumpqmltypes/dumpqmltypes.pro @@ -14,6 +14,9 @@ QT *= \ appman_notification-private \ appman_window-private \ appman_launcher-private \ + appman_intent_client-private \ + appman_intent_server-private \ + appman_monitor-private \ CONFIG *= console diff --git a/src/window-lib/window.h b/src/window-lib/window.h index 888ba7a5..a67338e6 100644 --- a/src/window-lib/window.h +++ b/src/window-lib/window.h @@ -62,6 +62,7 @@ class WindowItem; class Window : public QObject { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/Window 2.0") Q_PROPERTY(QSize size READ size NOTIFY sizeChanged) Q_PROPERTY(ContentState contentState READ contentState NOTIFY contentStateChanged) diff --git a/src/window-lib/windowitem.h b/src/window-lib/windowitem.h index 3bc72696..45bf9c71 100644 --- a/src/window-lib/windowitem.h +++ b/src/window-lib/windowitem.h @@ -61,6 +61,7 @@ class WaylandWindow; class WindowItem : public QQuickItem { Q_OBJECT + Q_CLASSINFO("AM-QmlType", "QtApplicationManager.SystemUI/WindowItem 2.0") Q_PROPERTY(Window* window READ window WRITE setWindow NOTIFY windowChanged) Q_PROPERTY(bool primary READ primary NOTIFY primaryChanged) |