mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-16 15:23:19 +00:00
Support multiple files
This commit is contained in:
parent
f8f49233dc
commit
689eea07a7
22 changed files with 528 additions and 131 deletions
52
src/qml/forms/FilesForm.qml
Normal file
52
src/qml/forms/FilesForm.qml
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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 Mirai
|
||||
|
||||
// WIP
|
||||
|
||||
ColumnLayout {
|
||||
id: form
|
||||
spacing: 6
|
||||
signal confirmed
|
||||
|
||||
function reset() {
|
||||
internal.paths = backend.files.map(file => {
|
||||
return {path: file.path, name: file.name}
|
||||
})
|
||||
}
|
||||
|
||||
QtObject {
|
||||
id: internal
|
||||
property var paths
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: internal.paths
|
||||
ColumnLayout {
|
||||
AppLineEdit {
|
||||
text: modelData.name
|
||||
}
|
||||
|
||||
AppLineEdit {
|
||||
text: modelData.path
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AppButton {
|
||||
text: "Save"
|
||||
onClicked: {
|
||||
backend.
|
||||
form.confirmed()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -21,11 +21,32 @@ ColumnLayout {
|
|||
newTodoContent.text = taskToEdit?.rawFormat ?? "- [ ] "
|
||||
newTodoDate.text = taskToEdit?.date ?? ""
|
||||
}
|
||||
|
||||
|
||||
AppText {
|
||||
text: "New task"
|
||||
text: "New/Edit task"
|
||||
}
|
||||
|
||||
AppComboBox {
|
||||
id: file
|
||||
textRole: "text"
|
||||
valueRole: "value"
|
||||
// Set the initial currentIndex to the value stored in the backend.
|
||||
Component.onCompleted: currentIndex = 0
|
||||
model: backend.files.map(file => (
|
||||
{ value: file.path, text: qsTr(file.name) }
|
||||
))
|
||||
onActivated: {
|
||||
console.log(currentValue)
|
||||
}
|
||||
}
|
||||
|
||||
DateField {
|
||||
id: newTodoDate
|
||||
text: taskToEdit?.date ?? ""
|
||||
textFieldComponent.placeholderText: "No date"
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
|
||||
AppLineEdit {
|
||||
id: newTodoContent
|
||||
Layout.fillWidth: true
|
||||
|
@ -39,17 +60,13 @@ ColumnLayout {
|
|||
if (taskToEdit && taskToEditIndex !== undefined) {
|
||||
backend.updateTodoFromRawFormat(taskToEditIndex, newTodoContent.text, newTodoDate.text)
|
||||
} else {
|
||||
backend.addTodoFromRawFormat(newTodoContent.text, newTodoDate.text)
|
||||
backend.addTodoFromRawFormat(
|
||||
file.currentValue,
|
||||
newTodoContent.text,
|
||||
newTodoDate.text
|
||||
)
|
||||
}
|
||||
form.confirmed()
|
||||
}
|
||||
}
|
||||
|
||||
DateField {
|
||||
id: newTodoDate
|
||||
text: taskToEdit?.date ?? ""
|
||||
textFieldComponent.placeholderText: "No date"
|
||||
Layout.fillWidth: true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue