mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 10:13:42 +00:00
first commit
This commit is contained in:
commit
3e7d8b4b70
43 changed files with 2681 additions and 0 deletions
98
src/qml/views/ListView.qml
Normal file
98
src/qml/views/ListView.qml
Normal file
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* 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
|
||||
|
||||
ColumnLayout {
|
||||
|
||||
QtObject {
|
||||
id: internal
|
||||
property string todayDate: Qt.formatDate(new Date(), 'yyyy-MM-dd')
|
||||
property string tomorrowDate: Qt.formatDate(new Date(new Date().setDate(new Date().getDate() + 1)), 'yyyy-MM-dd')
|
||||
}
|
||||
|
||||
Repeater {
|
||||
model: backend.tasks
|
||||
Rectangle {
|
||||
Layout.fillWidth: true
|
||||
Layout.preferredHeight: childrenRect.height
|
||||
id: task
|
||||
required property var modelData
|
||||
required property int index
|
||||
color: "transparent"
|
||||
|
||||
HoverHandler {
|
||||
acceptedDevices: PointerDevice.Mouse | PointerDevice.TouchPad
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
}
|
||||
|
||||
|
||||
ColumnLayout {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
|
||||
Component {
|
||||
id: dateForTasks
|
||||
AppText {
|
||||
topPadding: 32
|
||||
bottomPadding: 16
|
||||
text: task.modelData.date === internal.todayDate ? "Today"
|
||||
: task.modelData.date === internal.tomorrowDate ? "Tomorrow"
|
||||
: task.modelData.date
|
||||
color: task.modelData.date < internal.todayDate ? colorPalette.selected.palette.pink
|
||||
// : task.modelData.date === internal.todayDate ? colorPalette.selected.palette.sapphire
|
||||
: colorPalette.selected.text
|
||||
font.pointSize: 24
|
||||
}
|
||||
}
|
||||
|
||||
Loader {
|
||||
sourceComponent: task.modelData.shouldShowDate ? dateForTasks : undefined
|
||||
}
|
||||
|
||||
TaskItem {
|
||||
id: taskItem
|
||||
task: task.modelData
|
||||
}
|
||||
}
|
||||
|
||||
Menu {
|
||||
id: contextMenu
|
||||
MenuItem {
|
||||
text: "Edit"
|
||||
onClicked: {
|
||||
root.editTask(task.modelData, task.index)
|
||||
}
|
||||
}
|
||||
MenuItem {
|
||||
text: "Delete"
|
||||
onClicked: {
|
||||
backend.removeTodo(task.index)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
id: mouse
|
||||
anchors.fill: parent
|
||||
acceptedButtons: Qt.RightButton
|
||||
propagateComposedEvents: true
|
||||
onClicked: {
|
||||
contextMenu.popup()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Item {
|
||||
Layout.fillHeight: true
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue