1 | // Copyright (C) 2019 The Qt Company Ltd. |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
3 | |
4 | #ifndef QSSGASSETIMPORTMANAGER_H |
5 | #define QSSGASSETIMPORTMANAGER_H |
6 | |
7 | // |
8 | // W A R N I N G |
9 | // ------------- |
10 | // |
11 | // This file is not part of the Qt API. It exists purely as an |
12 | // implementation detail. This header file may change from version to |
13 | // version without notice, or even be removed. |
14 | // |
15 | // We mean it. |
16 | // |
17 | |
18 | #include <QtQuick3DAssetImport/private/qtquick3dassetimportglobal_p.h> |
19 | |
20 | #include <QtCore/QObject> |
21 | #include <QtCore/QVector> |
22 | #include <QtCore/QMap> |
23 | #include <QtCore/QDir> |
24 | #include <QtCore/QString> |
25 | #include <QtCore/QList> |
26 | #include <QtCore/qjsonobject.h> |
27 | |
28 | QT_BEGIN_NAMESPACE |
29 | |
30 | class QSSGAssetImporter; |
31 | class QQuick3DNode; |
32 | namespace QSSGSceneDesc { struct Scene; } |
33 | |
34 | struct QSSGAssetImporterPluginInfo |
35 | { |
36 | QString name; |
37 | QStringList inputExtensions; |
38 | QString outputExtension; |
39 | QString type; |
40 | QJsonObject importOptions; |
41 | QString typeDescription; |
42 | }; |
43 | |
44 | class Q_QUICK3DASSETIMPORT_EXPORT QSSGAssetImportManager : public QObject |
45 | { |
46 | Q_OBJECT |
47 | public: |
48 | explicit QSSGAssetImportManager(QObject *parent = nullptr); |
49 | ~QSSGAssetImportManager(); |
50 | |
51 | enum class ImportState : quint8 |
52 | { |
53 | Success, |
54 | IoError, |
55 | Unsupported |
56 | }; |
57 | |
58 | using PluginOptionMaps = QHash<QString, QJsonObject>; |
59 | |
60 | // ### Temp API |
61 | ImportState importFile(const QString &filename, |
62 | const QDir &outputPath, |
63 | QString *error = nullptr); |
64 | ImportState importFile(const QString &filename, |
65 | const QDir &outputPath, |
66 | const QJsonObject &options = QJsonObject(), |
67 | QString *error = nullptr); |
68 | ImportState importFile(const QUrl &url, |
69 | QSSGSceneDesc::Scene &scene, |
70 | QString *error = nullptr); |
71 | ImportState importFile(const QUrl &url, |
72 | QSSGSceneDesc::Scene &scene, |
73 | const QJsonObject &options = QJsonObject(), |
74 | QString *error = nullptr); |
75 | QJsonObject getOptionsForFile(const QString &filename); |
76 | PluginOptionMaps getAllOptions() const; |
77 | QHash<QString, QStringList> getSupportedExtensions() const; |
78 | QList<QSSGAssetImporterPluginInfo> getImporterPluginInfos() const; |
79 | |
80 | private: |
81 | QVector<QSSGAssetImporter *> m_assetImporters; |
82 | QMap<QString, QSSGAssetImporter *> m_extensionsMap; |
83 | }; |
84 | |
85 | QT_END_NAMESPACE |
86 | |
87 | #endif // QSSGASSETIMPORTMANAGER_H |
88 | |