1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2019 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of Qt Quick 3D. 7 ** 8 ** $QT_BEGIN_LICENSE:GPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU 19 ** General Public License version 3 or (at your option) any later version 20 ** approved by the KDE Free Qt Foundation. The licenses are as published by 21 ** the Free Software Foundation and appearing in the file LICENSE.GPL3 22 ** included in the packaging of this file. Please review the following 23 ** information to ensure the GNU General Public License requirements will 24 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 25 ** 26 ** $QT_END_LICENSE$ 27 ** 28 ****************************************************************************/ 29 30 #ifndef UIPIMPORTER_H 31 #define UIPIMPORTER_H 32 33 #include <QtQuick3DAssetImport/private/qssgassetimporter_p.h> 34 35 #include <QtCore/QTextStream> 36 37 #include "uipparser.h" 38 #include "uiaparser.h" 39 40 QT_BEGIN_NAMESPACE 41 42 class UipPresentation; 43 class ReferencedMaterial; 44 class ComponentNode; 45 class AliasNode; 46 class UipImporter : public QSSGAssetImporter 47 { 48 public: 49 UipImporter(); 50 51 const QString name() const override; 52 const QStringList inputExtensions() const override; 53 const QString outputExtension() const override; 54 const QString type() const override; 55 const QString typeDescription() const override; 56 const QVariantMap importOptions() const override; 57 const QString import(const QString &sourceFile, const QDir &savePath, const QVariantMap &options, QStringList *generatedFiles) override; 58 59 private: 60 QString processUipPresentation(UipPresentation *presentation, const QString &ouputFilePath); 61 void processNode(GraphObject *object, QTextStream &output, int tabLevel, bool isInRootLevel = false, bool processSiblings = true); 62 void checkForResourceFiles(GraphObject *object); 63 void generateMaterialComponent(GraphObject *object); 64 void generateAliasComponent(GraphObject *reference); 65 void generateAnimationTimeLine(QTextStream &output, int tabLevel, UipPresentation *presentation = nullptr, ComponentNode *component = nullptr); 66 void generateStatesFromSlides(Slide *masterSlide, QTextStream &output, int tabLevel); 67 void generateComponent(GraphObject *component); 68 void writeHeader(QTextStream &output, bool isRootLevel = false); 69 void generateApplicationComponent(const QString &initialPresentationComponent, const QSize &size); 70 void generateQmlComponent(const QString componentName, const QString componentSource); 71 void processOptions(const QVariantMap &options); 72 bool checkBooleanOption(const QString &optionName, const QJsonObject &options); 73 double getRealOption(const QString &optionName, const QJsonObject &options); 74 75 QVector<QString> m_resourcesList; 76 UiaParser m_uiaParser; 77 UipParser m_uipParser; 78 UipPresentation *m_presentation; 79 80 QString m_sourceFile; 81 QDir m_exportPath; 82 QVariantMap m_options; 83 QStringList m_generatedFiles; 84 85 // per presentation 86 QVector <ReferencedMaterial *> m_referencedMaterials; 87 QVector <AliasNode *> m_aliasNodes; 88 QVector <ComponentNode *> m_componentNodes; 89 QVector<QDir> m_qmlDirs; 90 bool m_hasQMLSubPresentations = false; 91 92 // options 93 bool m_createProjectWrapper = false; 94 bool m_createIndividualLayers = false; 95 float m_fps = 60.f; 96 }; 97 98 QT_END_NAMESPACE 99 100 #endif // UIPIMPORTER_H 101