summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/utils/asset.h
blob: e779d4a7343f8c04395650a67cc47b7495b7068a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <QString>

namespace QmlDesigner {

class Asset
{
public:
    enum Type { Unknown,
                Image,
                MissingImage,
                FragmentShader,
                VertexShader,
                Font,
                Audio,
                Video,
                Texture3D,
                Effect };

    Asset(const QString &filePath);

    static const QStringList &supportedImageSuffixes();
    static const QStringList &supportedFragmentShaderSuffixes();
    static const QStringList &supportedVertexShaderSuffixes();
    static const QStringList &supportedShaderSuffixes();
    static const QStringList &supportedFontSuffixes();
    static const QStringList &supportedAudioSuffixes();
    static const QStringList &supportedVideoSuffixes();
    static const QStringList &supportedTexture3DSuffixes();
    static const QStringList &supportedEffectMakerSuffixes();
    static const QSet<QString> &supportedSuffixes();
    static bool isSupported(const QString &path);

    const QString suffix() const;
    const QString id() const;
    bool hasSuffix() const;

    Type type() const;
    bool isImage() const;
    bool isFragmentShader() const;
    bool isVertexShader() const;
    bool isShader() const;
    bool isFont() const;
    bool isAudio() const;
    bool isVideo() const;
    bool isTexture3D() const;
    bool isHdrFile() const;
    bool isKtxFile() const;
    bool isEffect() const;
    bool isSupported() const;
    bool isValidTextureSource();

private:
    void resolveType();

    QString m_filePath;
    QString m_suffix;
    Type m_type = Unknown;
};

} // namespace QmlDesigner