blob: 8bd48e1d6c43d8b120448286fa0371e8cb73c0b5 (
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
|
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
import QtQuick
import QtQuick.Controls
import HelperWidgets as HelperWidgets
import StudioControls as StudioControls
import StudioTheme as StudioTheme
import AssetsLibraryBackend
StudioControls.Dialog {
id: root
title: qsTr("Save Effect")
closePolicy: Popup.CloseOnEscape
modal: true
implicitWidth: 250
implicitHeight: 160
property string compositionName: ""
onOpened: {
nameText.text = compositionName //TODO: Generate unique name
emptyText.text = ""
nameText.forceActiveFocus()
}
contentItem: Item {
Column {
spacing: 2
Row {
id: row
Text {
text: qsTr("Effect name: ")
anchors.verticalCenter: parent.verticalCenter
color: StudioTheme.Values.themeTextColor
}
StudioControls.TextField {
id: nameText
actionIndicator.visible: false
translationIndicator.visible: false
onTextChanged: {
let errMsg = ""
if (/[^A-Za-z0-9_]+/.test(text))
errMsg = qsTr("Name contains invalid characters.")
else if (!/^[A-Z]/.test(text))
errMsg = qsTr("Name must start with a capital letter")
else if (text.length < 3)
errMsg = qsTr("Name must have at least 3 characters")
else if (/\s/.test(text))
errMsg = qsTr("Name cannot contain white space")
emptyText.text = errMsg
btnSave.enabled = errMsg.length === 0
}
Keys.onEnterPressed: btnSave.onClicked()
Keys.onReturnPressed: btnSave.onClicked()
Keys.onEscapePressed: root.reject()
}
}
Text {
id: emptyText
color: StudioTheme.Values.themeError
anchors.right: row.right
}
}
Row {
anchors.right: parent.right
anchors.bottom: parent.bottom
spacing: 2
HelperWidgets.Button {
id: btnSave
text: qsTr("Save")
enabled: nameText.text !== ""
onClicked: {
root.compositionName = nameText.text
root.accept() //TODO: Check if name is unique
}
}
HelperWidgets.Button {
text: qsTr("Cancel")
onClicked: root.reject()
}
}
}
}
|