EffectMaker: Add save dialog

Change-Id: Ic538e6c8c9d3ac19bd8726b95d93a9b1f292a437
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2023-10-19 19:21:31 +03:00
parent 3d53bd6b80
commit 1d04d50c78
3 changed files with 98 additions and 4 deletions

View File

@@ -15,13 +15,19 @@ Item {
property int moveFromIdx: 0 property int moveFromIdx: 0
property int moveToIdx: 0 property int moveToIdx: 0
SaveDialog {
id: saveDialog
anchors.centerIn: parent
onAccepted: print("TODO: export and save effect files")
}
Column { Column {
id: col id: col
anchors.fill: parent anchors.fill: parent
spacing: 1 spacing: 1
EffectMakerTopBar { EffectMakerTopBar {
onSaveClicked: saveDialog.open()
} }
EffectMakerPreview { EffectMakerPreview {

View File

@@ -15,15 +15,15 @@ Rectangle {
height: StudioTheme.Values.toolbarHeight height: StudioTheme.Values.toolbarHeight
color: StudioTheme.Values.themeToolbarBackground color: StudioTheme.Values.themeToolbarBackground
signal saveClicked
HelperWidgets.Button { HelperWidgets.Button {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
x: 5 x: 5
text: qsTr("Save in Library") text: qsTr("Save in Library")
onClicked: { onClicked: root.saveClicked()
// TODO
}
} }
HelperWidgets.AbstractButton { HelperWidgets.AbstractButton {

View File

@@ -0,0 +1,88 @@
// 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
onOpened: {
nameText.text = ""
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: {
emptyText.opacity = nameText.text === "" ? 1 : 0
}
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 !== ""
onClicked: root.accept()
}
HelperWidgets.Button {
text: qsTr("Cancel")
onClicked: root.reject()
}
}
}
}