mirai/src/qml/forms/FilesForm.qml

80 lines
1.3 KiB
QML
Raw Normal View History

2024-04-14 14:11:41 +02:00
/*
* 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
2024-05-05 15:58:56 +02:00
import QtQuick.Dialogs
2024-04-14 14:11:41 +02:00
import Mirai
// WIP
ColumnLayout {
id: form
spacing: 6
2024-04-22 15:45:26 +02:00
signal confirmed(paths: var)
2024-04-14 14:11:41 +02:00
function reset() {
2024-04-22 15:45:26 +02:00
internal.paths = []
internal.paths = backend.files.map(file => file.path)
2024-04-14 14:11:41 +02:00
}
QtObject {
id: internal
property var paths
}
AppText {
text: "Files"
font.pixelSize: 32
}
Item {
Layout.preferredHeight: 32
}
2024-04-14 14:11:41 +02:00
Repeater {
model: internal.paths
ColumnLayout {
AppLineEdit {
2024-04-22 15:45:26 +02:00
text: modelData
onTextChanged: {
internal.paths[index] = text
}
2024-04-14 14:11:41 +02:00
}
2024-04-22 15:45:26 +02:00
}
}
2024-04-14 14:11:41 +02:00
AppButton {
text: "Add"
icon.source: "qrc:/qt/qml/Mirai/src/images/add.png"
icon.color: colorPalette.selected.palette.green
onClicked: {
fileDialog.open()
}
}
2024-05-05 15:58:56 +02:00
FileDialog {
id: fileDialog
onAccepted: {
console.log(selectedFile.toString())
internal.paths = [...internal.paths, selectedFile.toString().replace(/^file:\/\//, "")]
2024-05-05 15:58:56 +02:00
}
}
Item {
Layout.preferredHeight: 32
2024-04-14 14:11:41 +02:00
}
AppButton {
text: "Save"
onClicked: {
2024-04-22 15:45:26 +02:00
form.confirmed(internal.paths)
2024-04-14 14:11:41 +02:00
}
}
}