From ee3a12901e88d873e95a344cb3bbc07ebe29aba0 Mon Sep 17 00:00:00 2001 From: pika Date: Mon, 16 Jun 2025 10:24:09 +0200 Subject: [PATCH] fixed virt-manager icon 'HOST' --- modules/bar/popouts/Calendar.qml | 66 +++++++++++++++++++++++++++----- utils/Icons.qml | 2 +- 2 files changed, 58 insertions(+), 10 deletions(-) diff --git a/modules/bar/popouts/Calendar.qml b/modules/bar/popouts/Calendar.qml index 47fcfff..e4278a0 100644 --- a/modules/bar/popouts/Calendar.qml +++ b/modules/bar/popouts/Calendar.qml @@ -7,7 +7,7 @@ Column { id: root spacing: Appearance.spacing.normal - width: 340 + width: 280 property date currentDate: new Date() property bool isCurrentMonth: true @@ -18,24 +18,68 @@ Column { property bool isSelectingRange: false property string dateCalculation: "" property bool hasSelection: false + property bool hasValidSelection: root.selectedStartDate !== undefined function calculateDays() { + if (!root.selectedStartDate) return + if (root.selectedStartDate && root.selectedEndDate) { const diffTime = Math.abs(root.selectedEndDate - root.selectedStartDate) - const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) + const diffDays = Math.floor(diffTime / (1000 * 60 * 60 * 24)) root.dateCalculation = diffDays + " days" - } else if (root.selectedStartDate) { + } else { const today = new Date() - const diffTime = Math.abs(root.selectedStartDate - today) - const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) - root.dateCalculation = diffDays + " days" + today.setHours(0, 0, 0, 0) // Normalize to start of day + const selectedDate = new Date(root.selectedStartDate) + selectedDate.setHours(0, 0, 0, 0) // Normalize to start of day + + const diffTime = selectedDate - today + const direction = diffTime > 0 ? "until" : "since" + let diffDays = Math.floor(Math.abs(diffTime) / (1000 * 60 * 60 * 24)) + + // 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 { + diffDays = Math.max(1, diffDays - 1) + } + + root.dateCalculation = diffDays + " days " + direction } } function calculateDaysFromReference(referenceDate, targetDate) { - const diffTime = Math.abs(targetDate - referenceDate) - const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24)) - root.dateCalculation = diffDays + " days" + if (!referenceDate || !targetDate) return + + const refDate = new Date(referenceDate) + refDate.setHours(0, 0, 0, 0) // Normalize to start of day + const targDate = new Date(targetDate) + targDate.setHours(0, 0, 0, 0) // Normalize to start of day + + const diffTime = targDate - refDate + const direction = diffTime > 0 ? "until" : "since" + let diffDays = Math.floor(Math.abs(diffTime) / (1000 * 60 * 60 * 24)) + + // 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 { + diffDays = Math.max(1, diffDays - 1) + } + + root.dateCalculation = diffDays + " days " + direction } function resetSelection() { @@ -178,6 +222,8 @@ Column { id: monthView anchors.fill: parent anchors.margins: 12 + anchors.rightMargin: 4 // Reduced right margin + anchors.bottomMargin: 16 // Keep the bottom margin orientation: ListView.Horizontal snapMode: ListView.SnapOneItem highlightRangeMode: ListView.StrictlyEnforceRange @@ -304,6 +350,8 @@ Column { acceptedButtons: Qt.LeftButton | Qt.RightButton onClicked: function(mouse) { + if (!modelData.date) return + if (mouse.button === Qt.RightButton) { root.selectedStartDate = modelData.date root.hasSelection = true diff --git a/utils/Icons.qml b/utils/Icons.qml index 41ecbfa..1af7d69 100644 --- a/utils/Icons.qml +++ b/utils/Icons.qml @@ -140,7 +140,7 @@ Singleton { "2DGraphics": "photo_library", RasterGraphics: "photo_library", TV: "tv", - System: "host", + System: "desktop_windows", Office: "content_paste" })