2023-10-19 19:21:31 +03:00
|
|
|
// 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
|
|
|
|
|
|
2023-11-08 16:12:35 +02:00
|
|
|
property string compositionName: null
|
|
|
|
|
|
2023-10-19 19:21:31 +03:00
|
|
|
onOpened: {
|
2023-11-08 16:12:35 +02:00
|
|
|
nameText.text = "" //TODO: Generate unique name
|
2023-10-19 19:21:31 +03:00
|
|
|
emptyText.opacity = 0
|
|
|
|
|
nameText.forceActiveFocus()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelperWidgets.RegExpValidator {
|
|
|
|
|
id: validator
|
|
|
|
|
regExp: /^(\w[^*/><?\\|:]*)$/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
contentItem: 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
|
|
|
|
|
validator: validator
|
|
|
|
|
|
|
|
|
|
onTextChanged: {
|
2023-11-08 16:12:35 +02:00
|
|
|
let validator = /^[A-Z]\w{2,}[A-Za-z0-9_]*$/
|
|
|
|
|
emptyText.visible = text.length > 0 && !validator.test(text)
|
|
|
|
|
btnSave.enabled = !emptyText.visible
|
2023-10-19 19:21:31 +03:00
|
|
|
}
|
|
|
|
|
Keys.onEnterPressed: btnSave.onClicked()
|
|
|
|
|
Keys.onReturnPressed: btnSave.onClicked()
|
|
|
|
|
Keys.onEscapePressed: root.reject()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Text {
|
|
|
|
|
id: emptyText
|
|
|
|
|
|
|
|
|
|
text: qsTr("Effect name cannot be empty.")
|
|
|
|
|
color: StudioTheme.Values.themeError
|
|
|
|
|
anchors.right: row.right
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item { // spacer
|
|
|
|
|
width: 1
|
|
|
|
|
height: 20
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Row {
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
|
|
|
|
|
HelperWidgets.Button {
|
|
|
|
|
id: btnSave
|
|
|
|
|
|
|
|
|
|
text: qsTr("Save")
|
|
|
|
|
enabled: nameText.text !== ""
|
2023-11-08 16:12:35 +02:00
|
|
|
onClicked: {
|
|
|
|
|
root.compositionName = nameText.text
|
|
|
|
|
root.accept() //TODO: Check if name is unique
|
|
|
|
|
}
|
2023-10-19 19:21:31 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
HelperWidgets.Button {
|
|
|
|
|
text: qsTr("Cancel")
|
|
|
|
|
onClicked: root.reject()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|