This commit is contained in:
pika 2025-06-16 12:49:33 +02:00
parent fded02f5b2
commit d711bc59e9

View file

@ -86,29 +86,72 @@ Column {
anchors.leftMargin: 12 anchors.leftMargin: 12
spacing: Appearance.spacing.normal spacing: Appearance.spacing.normal
// Today's date // Show dates in chronological order
StyledText {
text: Qt.formatDateTime(new Date(), "dd MMM yyyy")
font.pointSize: Appearance.font.size.small
font.family: Appearance.font.family.mono
}
// Arrow and selected date (when applicable)
Row { Row {
visible: root.hasSelection
spacing: Appearance.spacing.small spacing: Appearance.spacing.small
StyledText { StyledText {
text: "→" text: {
font.pointSize: Appearance.font.size.small if (!root.hasSelection) return Qt.formatDateTime(new Date(), "dd MMM yyyy")
color: Colours.palette.m3onSurfaceVariant
} const today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate())
const selected = new Date(root.selectedStartDate.getFullYear(), root.selectedStartDate.getMonth(), root.selectedStartDate.getDate())
StyledText { const diffDays = Math.round((selected - today) / (1000 * 60 * 60 * 24))
text: Qt.formatDateTime(root.selectedStartDate, "dd MMM yyyy")
// For past dates, show selected date first
if (diffDays < 0) {
return Qt.formatDateTime(root.selectedStartDate, "dd MMM yyyy")
}
// For future dates, show today first
return Qt.formatDateTime(new Date(), "dd MMM yyyy")
}
font.pointSize: Appearance.font.size.small font.pointSize: Appearance.font.size.small
font.family: Appearance.font.family.mono font.family: Appearance.font.family.mono
color: Colours.palette.m3primary color: {
if (!root.hasSelection) return Colours.palette.m3onSurface
const today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate())
const selected = new Date(root.selectedStartDate.getFullYear(), root.selectedStartDate.getMonth(), root.selectedStartDate.getDate())
const diffDays = Math.round((selected - today) / (1000 * 60 * 60 * 24))
return diffDays < 0 ? Colours.palette.m3primary : Colours.palette.m3onSurface
}
}
// Arrow and second date (when applicable)
Row {
visible: root.hasSelection
spacing: Appearance.spacing.small
StyledText {
text: "→"
font.pointSize: Appearance.font.size.small
color: Colours.palette.m3onSurfaceVariant
}
StyledText {
text: {
if (!root.hasSelection) return ""
const today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate())
const selected = new Date(root.selectedStartDate.getFullYear(), root.selectedStartDate.getMonth(), root.selectedStartDate.getDate())
const diffDays = Math.round((selected - today) / (1000 * 60 * 60 * 24))
// For past dates, show today second
if (diffDays < 0) {
return Qt.formatDateTime(new Date(), "dd MMM yyyy")
}
// For future dates, show selected date second
return Qt.formatDateTime(root.selectedStartDate, "dd MMM yyyy")
}
font.pointSize: Appearance.font.size.small
font.family: Appearance.font.family.mono
color: {
if (!root.hasSelection) return Colours.palette.m3onSurface
const today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate())
const selected = new Date(root.selectedStartDate.getFullYear(), root.selectedStartDate.getMonth(), root.selectedStartDate.getDate())
const diffDays = Math.round((selected - today) / (1000 * 60 * 60 * 24))
return diffDays < 0 ? Colours.palette.m3onSurface : Colours.palette.m3primary
}
}
} }
} }
} }