summaryrefslogtreecommitdiff
path: root/share/qtcreator/qmldesigner/materialBrowserQmlSource/TextureBrowserContextMenu.qml
blob: 658b7e7a5126acb3aa4e47c606d15fcad3c43098 (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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

import QtQuick
import HelperWidgets
import StudioControls as StudioControls
import StudioTheme as StudioTheme

StudioControls.Menu {
    id: root

    property var targetTexture: null
    property int copiedTextureInternalId: -1

    function popupMenu(targetTexture = null)
    {
        this.targetTexture = targetTexture
        materialBrowserTexturesModel.updateSceneEnvState()
        materialBrowserTexturesModel.updateModelSelectionState()
        popup()
    }

    closePolicy: StudioControls.Menu.CloseOnEscape | StudioControls.Menu.CloseOnPressOutside

    StudioControls.MenuItem {
        text: qsTr("Apply to selected model")
        enabled: root.targetTexture && materialBrowserTexturesModel.hasSingleModelSelection
        onTriggered: materialBrowserTexturesModel.applyToSelectedModel(root.targetTexture.textureInternalId)
    }

    StudioControls.MenuItem {
        text: qsTr("Apply to selected material")
        enabled: root.targetTexture && materialBrowserModel.selectedIndex >= 0
        onTriggered: materialBrowserTexturesModel.applyToSelectedMaterial(root.targetTexture.textureInternalId)
    }

    StudioControls.MenuItem {
        text: qsTr("Apply as light probe")
        enabled: root.targetTexture && materialBrowserTexturesModel.hasSceneEnv
        onTriggered: materialBrowserTexturesModel.applyAsLightProbe(root.targetTexture.textureInternalId)
    }

    StudioControls.MenuSeparator {}

    StudioControls.MenuItem {
        text: qsTr("Duplicate")
        enabled: root.targetTexture
        onTriggered: materialBrowserTexturesModel.duplicateTexture(materialBrowserTexturesModel.selectedIndex)
    }

    StudioControls.MenuItem {
        text: qsTr("Delete")
        enabled: root.targetTexture
        onTriggered: materialBrowserTexturesModel.deleteTexture(materialBrowserTexturesModel.selectedIndex)
    }

    StudioControls.MenuSeparator {}

    StudioControls.MenuItem {
        text: qsTr("Create New Texture")
        onTriggered: materialBrowserTexturesModel.addNewTexture()
    }
}