| 1 | // Copyright (C) 2022 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only |
| 3 | |
| 4 | #ifndef QSBINSPECTORHELPER_H |
| 5 | #define QSBINSPECTORHELPER_H |
| 6 | |
| 7 | #include <QObject> |
| 8 | #include <QVariantList> |
| 9 | #include <QtGui/private/qshader_p.h> |
| 10 | |
| 11 | // Model for common qsb information |
| 12 | struct QsbShaderData { |
| 13 | Q_GADGET |
| 14 | Q_PROPERTY(QString currentFile MEMBER m_currentFile) |
| 15 | Q_PROPERTY(QString stage MEMBER m_stage) |
| 16 | Q_PROPERTY(QString reflectionInfo MEMBER m_reflectionInfo) |
| 17 | Q_PROPERTY(int qsbVersion MEMBER m_qsbVersion) |
| 18 | Q_PROPERTY(int shaderCount MEMBER m_shaderCount) |
| 19 | Q_PROPERTY(int size MEMBER m_size) |
| 20 | public: |
| 21 | QString m_currentFile; |
| 22 | QString m_stage; |
| 23 | QString m_reflectionInfo; |
| 24 | int m_qsbVersion = 0; |
| 25 | int m_shaderCount = 0; |
| 26 | int m_size = 0; |
| 27 | }; |
| 28 | |
| 29 | // Model for shaders and their index in the qsb |
| 30 | struct ShaderSelectorData { |
| 31 | Q_GADGET |
| 32 | Q_PROPERTY(QString name MEMBER m_name) |
| 33 | Q_PROPERTY(int sourceIndex MEMBER m_sourceIndex) |
| 34 | public: |
| 35 | QString m_name; |
| 36 | int m_sourceIndex; |
| 37 | }; |
| 38 | |
| 39 | class QsbInspectorHelper : public QObject |
| 40 | { |
| 41 | Q_OBJECT |
| 42 | Q_PROPERTY(QsbShaderData shaderData READ shaderData NOTIFY shaderDataChanged) |
| 43 | Q_PROPERTY(QVariantList sourceSelectorModel READ sourceSelectorModel NOTIFY sourceSelectorModelChanged) |
| 44 | Q_PROPERTY(int currentSourceIndex READ currentSourceIndex WRITE setCurrentSourceIndex NOTIFY currentSourceIndexChanged) |
| 45 | Q_PROPERTY(QString currentSourceCode READ currentSourceCode NOTIFY currentSourceCodeChanged) |
| 46 | |
| 47 | public: |
| 48 | explicit QsbInspectorHelper(QObject *parent = nullptr); |
| 49 | |
| 50 | QsbShaderData shaderData() const; |
| 51 | QVariantList sourceSelectorModel() const; |
| 52 | int currentSourceIndex() const; |
| 53 | QString currentSourceCode() const; |
| 54 | |
| 55 | public Q_SLOTS: |
| 56 | bool loadQsb(const QString &filename); |
| 57 | void setCurrentSourceIndex(int index); |
| 58 | |
| 59 | Q_SIGNALS: |
| 60 | void shaderDataChanged(); |
| 61 | void sourceSelectorModelChanged(); |
| 62 | void currentSourceIndexChanged(); |
| 63 | void currentSourceCodeChanged(); |
| 64 | |
| 65 | private: |
| 66 | QsbShaderData m_shaderData; |
| 67 | QVariantList m_sourceSelectorModel; |
| 68 | int m_currentSourceIndex = -1; |
| 69 | QStringList m_sourceCodes; |
| 70 | }; |
| 71 | |
| 72 | Q_DECLARE_METATYPE(QsbShaderData); |
| 73 | |
| 74 | #endif // QSBINSPECTORHELPER_H |
| 75 | |