fixed virt-manager icon 'HOST'

This commit is contained in:
pika 2025-06-16 10:24:09 +02:00
parent 8be5689da0
commit ee3a12901e
2 changed files with 58 additions and 10 deletions

View file

@ -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