mirai/src/qml/TaskItem.qml

46 lines
1.2 KiB
QML
Raw Normal View History

2024-04-10 16:53:18 +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.Layouts
import Mirai
RowLayout {
2024-04-11 14:08:09 +02:00
id: control
2024-04-10 16:53:18 +02:00
property taskItem task
2024-04-11 14:08:09 +02:00
function getFormatedText() {
if (task?.time && task.time != "") {
2024-08-11 16:46:44 +02:00
return `<font color=\"${colorPalette.selected.textPlaceholder}\">${task.time} \></font> ${task.text}`
2024-04-11 14:08:09 +02:00
}
return task.text
}
2024-04-10 16:53:18 +02:00
AppCheckbox {
id: checkbox
2024-04-11 14:08:09 +02:00
text: control.getFormatedText()
2024-04-10 16:53:18 +02:00
checked: task.state === 'DONE'
2024-08-09 21:12:35 +02:00
textComponent.font.pointSize: 14
textComponent.color: task.date < internal.todayDate ? colorPalette.selected.red
2024-04-10 16:53:18 +02:00
// : task.date === internal.todayDate ? colorPalette.selected.palette.sapphire
: colorPalette.selected.text
onClicked: {
backend.updateTodo(index, modelData.state === 'DONE' ? "TODO" : "DONE", modelData.text, modelData.date)
}
}
2024-04-11 13:29:40 +02:00
Repeater {
model: task.tags
Tag {
Layout.alignment: Qt.AlignVCenter
text: modelData
backgroundColor: colorPalette.selected.fieldBackground
2024-08-09 21:12:35 +02:00
textColor: colorPalette.selected.accent
2024-04-11 13:29:40 +02:00
}
}
2024-04-10 16:53:18 +02:00
}