summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/components/createtexture.h
blob: d02eacc1eed2ee05281f269c5b05225fc4960f0d (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
// 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 <modelnode.h>

namespace QmlDesigner {

class AbstractView;

enum class AddTextureMode { Image, Texture, LightProbe };

class CreateTexture
{
public:
    CreateTexture(AbstractView *view, bool importFiles = false);
    void execute(const QString &filePath, AddTextureMode mode, int sceneId);
    ModelNode resolveSceneEnv(int sceneId);
    void assignTextureAsLightProbe(const ModelNode &texture, int sceneId);

private:
    bool addFileToProject(const QString &filePath);
    ModelNode createTextureFromImage(const QString &assetPath, AddTextureMode mode);

private:
    AbstractView *m_view = nullptr;
    bool m_importFile = false;
};

class CreateTextures : public CreateTexture
{
public:
    using CreateTexture::CreateTexture;
    void execute(const QStringList &filePaths, AddTextureMode mode, int sceneId)
    {
        for (const QString &path : filePaths)
            CreateTexture::execute(path, mode, sceneId);
    }
};

}