This commit is contained in:
pika 2025-06-16 12:00:46 +02:00
parent ee3a12901e
commit 9c3a3e06b2
2 changed files with 43 additions and 48 deletions

View file

@ -24,62 +24,41 @@ Column {
if (!root.selectedStartDate) return if (!root.selectedStartDate) return
if (root.selectedStartDate && root.selectedEndDate) { if (root.selectedStartDate && root.selectedEndDate) {
const diffTime = Math.abs(root.selectedEndDate - root.selectedStartDate) // For range selection, just count the days between dates
const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24)) const start = new Date(root.selectedStartDate.getFullYear(), root.selectedStartDate.getMonth(), root.selectedStartDate.getDate())
root.dateCalculation = diffDays + " days" const end = new Date(root.selectedEndDate.getFullYear(), root.selectedEndDate.getMonth(), root.selectedEndDate.getDate())
const diffDays = Math.round((end - start) / (1000 * 60 * 60 * 24))
root.dateCalculation = Math.abs(diffDays) + " days"
} else { } else {
const today = new Date() // For single date selection, compare with today
today.setHours(0, 0, 0, 0) // Normalize to start of day const today = new Date(new Date().getFullYear(), new Date().getMonth(), new Date().getDate())
const selectedDate = new Date(root.selectedStartDate) const selected = new Date(root.selectedStartDate.getFullYear(), root.selectedStartDate.getMonth(), root.selectedStartDate.getDate())
selectedDate.setHours(0, 0, 0, 0) // Normalize to start of day const diffDays = Math.round((selected - today) / (1000 * 60 * 60 * 24))
const diffTime = selectedDate - today if (diffDays === 0) {
const direction = diffTime > 0 ? "until" : "since" root.dateCalculation = "0 days"
let diffDays = Math.floor(Math.abs(diffTime) / (1000 * 60 * 60 * 24)) } else if (diffDays > 0) {
root.dateCalculation = diffDays + " days until"
// For future dates, ensure we start at 1
if (direction === "until") {
// If it's the same day, show 0 days
if (diffDays === 0) {
root.dateCalculation = "0 days"
return
}
// For next day and beyond, add 1
diffDays += 1
} else { } else {
diffDays = Math.max(1, diffDays - 1) root.dateCalculation = Math.abs(diffDays) + " days since"
} }
root.dateCalculation = diffDays + " days " + direction
} }
} }
function calculateDaysFromReference(referenceDate, targetDate) { function calculateDaysFromReference(referenceDate, targetDate) {
if (!referenceDate || !targetDate) return if (!referenceDate || !targetDate) return
const refDate = new Date(referenceDate) const ref = new Date(referenceDate.getFullYear(), referenceDate.getMonth(), referenceDate.getDate())
refDate.setHours(0, 0, 0, 0) // Normalize to start of day const target = new Date(targetDate.getFullYear(), targetDate.getMonth(), targetDate.getDate())
const targDate = new Date(targetDate) const diffDays = Math.round((target - ref) / (1000 * 60 * 60 * 24))
targDate.setHours(0, 0, 0, 0) // Normalize to start of day
const diffTime = targDate - refDate if (diffDays === 0) {
const direction = diffTime > 0 ? "until" : "since" root.dateCalculation = "0 days"
let diffDays = Math.floor(Math.abs(diffTime) / (1000 * 60 * 60 * 24)) } else if (diffDays > 0) {
root.dateCalculation = diffDays + " days until"
// For future dates, ensure we start at 1
if (direction === "until") {
// If it's the same day, show 0 days
if (diffDays === 0) {
root.dateCalculation = "0 days"
return
}
// For next day and beyond, add 1
diffDays += 1
} else { } else {
diffDays = Math.max(1, diffDays - 1) root.dateCalculation = Math.abs(diffDays) + " days since"
} }
root.dateCalculation = diffDays + " days " + direction
} }
function resetSelection() { function resetSelection() {
@ -222,8 +201,7 @@ Column {
id: monthView id: monthView
anchors.fill: parent anchors.fill: parent
anchors.margins: 12 anchors.margins: 12
anchors.rightMargin: 4 // Reduced right margin anchors.rightMargin: 0 // Reduced right margin
anchors.bottomMargin: 16 // Keep the bottom margin
orientation: ListView.Horizontal orientation: ListView.Horizontal
snapMode: ListView.SnapOneItem snapMode: ListView.SnapOneItem
highlightRangeMode: ListView.StrictlyEnforceRange highlightRangeMode: ListView.StrictlyEnforceRange
@ -259,9 +237,23 @@ Column {
model: 12 // Show all months model: 12 // Show all months
currentIndex: new Date().getMonth() currentIndex: new Date().getMonth()
// Ensure current month is active when calendar opens
Component.onCompleted: {
currentIndex = new Date().getMonth()
}
delegate: Grid { delegate: Grid {
width: monthView.width width: monthView.width
height: monthView.height height: monthView.height
opacity: monthView.currentIndex === index ? 1 : 0.2 // Dim non-current months
Behavior on opacity {
NumberAnimation {
duration: Appearance.anim.durations.normal
easing.type: Easing.BezierSpline
easing.bezierCurve: Appearance.anim.curves.standard
}
}
columns: 7 columns: 7
spacing: Appearance.spacing.small spacing: Appearance.spacing.small

View file

@ -102,7 +102,10 @@ Singleton {
"395": "snowing" "395": "snowing"
}) })
readonly property var desktopEntrySubs: ({}) readonly property var desktopEntrySubs: ({
"zen-browser": "firefox",
"nvim": "terminal"
})
readonly property var categoryIcons: ({ readonly property var categoryIcons: ({
WebBrowser: "web", WebBrowser: "web",