fixed virt-manager icon 'HOST'
This commit is contained in:
parent
8be5689da0
commit
ee3a12901e
2 changed files with 58 additions and 10 deletions
|
@ -7,7 +7,7 @@ Column {
|
||||||
id: root
|
id: root
|
||||||
|
|
||||||
spacing: Appearance.spacing.normal
|
spacing: Appearance.spacing.normal
|
||||||
width: 340
|
width: 280
|
||||||
|
|
||||||
property date currentDate: new Date()
|
property date currentDate: new Date()
|
||||||
property bool isCurrentMonth: true
|
property bool isCurrentMonth: true
|
||||||
|
@ -18,24 +18,68 @@ Column {
|
||||||
property bool isSelectingRange: false
|
property bool isSelectingRange: false
|
||||||
property string dateCalculation: ""
|
property string dateCalculation: ""
|
||||||
property bool hasSelection: false
|
property bool hasSelection: false
|
||||||
|
property bool hasValidSelection: root.selectedStartDate !== undefined
|
||||||
|
|
||||||
function calculateDays() {
|
function calculateDays() {
|
||||||
|
if (!root.selectedStartDate) return
|
||||||
|
|
||||||
if (root.selectedStartDate && root.selectedEndDate) {
|
if (root.selectedStartDate && root.selectedEndDate) {
|
||||||
const diffTime = Math.abs(root.selectedEndDate - root.selectedStartDate)
|
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"
|
root.dateCalculation = diffDays + " days"
|
||||||
} else if (root.selectedStartDate) {
|
} else {
|
||||||
const today = new Date()
|
const today = new Date()
|
||||||
const diffTime = Math.abs(root.selectedStartDate - today)
|
today.setHours(0, 0, 0, 0) // Normalize to start of day
|
||||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
|
const selectedDate = new Date(root.selectedStartDate)
|
||||||
root.dateCalculation = diffDays + " days"
|
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) {
|
function calculateDaysFromReference(referenceDate, targetDate) {
|
||||||
const diffTime = Math.abs(targetDate - referenceDate)
|
if (!referenceDate || !targetDate) return
|
||||||
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24))
|
|
||||||
root.dateCalculation = diffDays + " days"
|
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() {
|
function resetSelection() {
|
||||||
|
@ -178,6 +222,8 @@ Column {
|
||||||
id: monthView
|
id: monthView
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
anchors.margins: 12
|
anchors.margins: 12
|
||||||
|
anchors.rightMargin: 4 // 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
|
||||||
|
@ -304,6 +350,8 @@ Column {
|
||||||
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
acceptedButtons: Qt.LeftButton | Qt.RightButton
|
||||||
|
|
||||||
onClicked: function(mouse) {
|
onClicked: function(mouse) {
|
||||||
|
if (!modelData.date) return
|
||||||
|
|
||||||
if (mouse.button === Qt.RightButton) {
|
if (mouse.button === Qt.RightButton) {
|
||||||
root.selectedStartDate = modelData.date
|
root.selectedStartDate = modelData.date
|
||||||
root.hasSelection = true
|
root.hasSelection = true
|
||||||
|
|
|
@ -140,7 +140,7 @@ Singleton {
|
||||||
"2DGraphics": "photo_library",
|
"2DGraphics": "photo_library",
|
||||||
RasterGraphics: "photo_library",
|
RasterGraphics: "photo_library",
|
||||||
TV: "tv",
|
TV: "tv",
|
||||||
System: "host",
|
System: "desktop_windows",
|
||||||
Office: "content_paste"
|
Office: "content_paste"
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue