mirai/src/qml/forms/FilesForm.qml

79 lines
1.3 KiB
QML

/*
* Mirai. Copyright (C) 2024 Vyn
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
*/
import QtQuick
import QtQuick.Window
import QtQuick.Controls
import QtQuick.Layouts
import QtQuick.Dialogs
import Mirai
// WIP
ColumnLayout {
id: form
spacing: 6
signal confirmed(paths: var)
function reset() {
internal.paths = []
internal.paths = backend.files.map(file => file.path)
}
QtObject {
id: internal
property var paths
}
AppText {
text: "Files"
font.pixelSize: 32
}
Item {
Layout.preferredHeight: 32
}
Repeater {
model: internal.paths
ColumnLayout {
AppLineEdit {
text: modelData
onTextChanged: {
internal.paths[index] = text
}
}
}
}
AppButton {
text: "Add"
icon.source: "qrc:/qt/qml/Mirai/src/images/add.png"
icon.color: colorPalette.selected.palette.green
onClicked: {
fileDialog.open()
}
}
FileDialog {
id: fileDialog
onAccepted: {
console.log(selectedFile.toString())
internal.paths = [...internal.paths, selectedFile.toString().replace(/^file:\/\//, "")]
}
}
Item {
Layout.preferredHeight: 32
}
AppButton {
text: "Save"
onClicked: {
form.confirmed(internal.paths)
}
}
}