summaryrefslogtreecommitdiffstats
path: root/tools/qqem/qml/ExportEffectDialog.qml
blob: ad58bf08b823e6189fc66605a5cd3cf195bb6a71 (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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only

import QtQuick
import QtQuick.Layouts
import QtQuick.Controls
import QtQuick.Window
import QtQuick.Dialogs
import QtCore

CustomDialog {
    id: root

    property string defaultPath: "file:///" + effectManager.projectDirectory + "/export"
    title: qsTr("Export Effect")
    width: 540
    height: 580
    modal: true
    focus: true
    standardButtons: Dialog.Ok | Dialog.Cancel
    closePolicy: Popup.NoAutoClose

    onAboutToShow: {
        root.initializeDialog();
    }

    function initialName() {
        if (effectManager.exportFilename != "") {
            return effectManager.exportFilename;
        } else {
            // Returns project name, making sure first letter is uppercase
            var str = effectManager.projectName;
            str = str.charAt(0).toUpperCase() + str.slice(1);
            return str;
        }
    }

    function initialPath() {
        if (effectManager.exportDirectory != "")
            return effectManager.stripFileFromURL(effectManager.exportDirectory);
        else
            return effectManager.stripFileFromURL(defaultPath);
    }

    function initializeDialog() {
        nameTextEdit.text = initialName();
        pathTextEdit.text = initialPath();
        // Note: These must match with EffectManager ExportFlags
        qmlComponentCheckBox.checked = (effectManager.exportFlags & 1);
        qbsShadersCheckBox.checked = (effectManager.exportFlags & 2);
        plainShadersCheckBox.checked = (effectManager.exportFlags & 4);
        imagesCheckBox.checked = (effectManager.exportFlags & 8);
        qrcCheckBox.checked = (effectManager.exportFlags & 16);
    }

    function exportEffect() {
        var exportFlags = 0;
        // Note: These must match with EffectManager ExportFlags
        exportFlags += Number(qmlComponentCheckBox.checked) * 1;
        exportFlags += Number(qbsShadersCheckBox.checked) * 2;
        exportFlags += Number(plainShadersCheckBox.checked) * 4;
        exportFlags += Number(imagesCheckBox.checked) * 8;
        exportFlags += Number(qrcCheckBox.checked) * 16;
        var qsbVersionIndex = qsbVersionSelector.currentIndex;
        effectManager.exportEffect(pathTextEdit.text, nameTextEdit.text, exportFlags, qsbVersionIndex);
    }

    FolderDialog {
        id: projectPathDialog
        currentFolder: defaultPath
        onAccepted: {
            if (currentFolder) {
                // Remove file start
                var usedFolder = effectManager.stripFileFromURL(currentFolder.toString());
                pathTextEdit.text = usedFolder;
            }
        }
    }

    GridLayout {
        id: detailsArea
        width: parent.width
        columns: 3
        columnSpacing: 20
        Label {
            text: qsTr("Name:")
            font.bold: true
            font.pixelSize: 14
            color: mainView.foregroundColor2
        }
        CustomTextField {
            id: nameTextEdit
            Layout.columnSpan: 2
            Layout.fillWidth: true
        }
        Label {
            text: qsTr("Create in:")
            font.bold: true
            font.pixelSize: 14
            color: mainView.foregroundColor2
        }
        CustomTextField {
            id: pathTextEdit
            Layout.fillWidth: true
        }
        Button {
            Layout.preferredHeight: 40
            text: qsTr("Browse");
            onClicked: {
                projectPathDialog.open();
            }
        }
    }
    Row {
        id: qsbVersionArea
        width: parent.width
        anchors.top: detailsArea.bottom
        anchors.topMargin: 20
        spacing: 10
        Label {
            anchors.verticalCenter: parent.verticalCenter
            text: qsTr("QSB version:")
            font.bold: true
            font.pixelSize: 14
            color: mainView.foregroundColor2
        }
        ComboBox {
            id: qsbVersionSelector
            anchors.verticalCenter: parent.verticalCenter
            width: 200
            height: 40
            currentIndex: 1
            model: ["Latest", "Qt 6.5 compatibility", "Qt 6.4 compatibility"]
        }
    }
    Column {
        id: settingsArea
        width: parent.width
        anchors.top: qsbVersionArea.bottom
        anchors.topMargin: 20
        Label {
            text: qsTr("Exported files:")
            font.bold: true
            font.pixelSize: 14
            color: mainView.foregroundColor2
        }
        CheckBox {
            id: qmlComponentCheckBox
            text: "QML component"
            checked: true
        }
        CheckBox {
            id: qbsShadersCheckBox
            text: "Binary shaders (qsb)"
            checked: true
        }
        CheckBox {
            id: plainShadersCheckBox
            text: "Plain-text shaders"
            checked: true
        }
        CheckBox {
            id: imagesCheckBox
            text: "Images"
            checked: true
        }
        CheckBox {
            id: qrcCheckBox
            text: "Resource collection file (qrc)"
            checked: true
        }
    }
    onAccepted: {
        root.exportEffect();
    }
}