Add compact clock again
This commit is contained in:
parent
2a1e7832d6
commit
b443c9f492
1 changed files with 35 additions and 20 deletions
|
|
@ -33,12 +33,23 @@ Rectangle {
|
||||||
readonly property bool use12h: widgetSettings.use12HourClock !== undefined ? widgetSettings.use12HourClock : widgetMetadata.use12HourClock
|
readonly property bool use12h: widgetSettings.use12HourClock !== undefined ? widgetSettings.use12HourClock : widgetMetadata.use12HourClock
|
||||||
readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth !== undefined ? widgetSettings.reverseDayMonth : widgetMetadata.reverseDayMonth
|
readonly property bool reverseDayMonth: widgetSettings.reverseDayMonth !== undefined ? widgetSettings.reverseDayMonth : widgetMetadata.reverseDayMonth
|
||||||
readonly property string displayFormat: widgetSettings.displayFormat !== undefined ? widgetSettings.displayFormat : widgetMetadata.displayFormat
|
readonly property string displayFormat: widgetSettings.displayFormat !== undefined ? widgetSettings.displayFormat : widgetMetadata.displayFormat
|
||||||
|
|
||||||
// Use compact mode for vertical bars
|
// Use compact mode for vertical bars
|
||||||
readonly property bool useCompactMode: barPosition === "left" || barPosition === "right"
|
readonly property bool useCompactMode: barPosition === "left" || barPosition === "right"
|
||||||
|
|
||||||
implicitWidth: useCompactMode ? Math.round(Style.capsuleHeight * scaling) : Math.round(layout.implicitWidth + Style.marginM * 2 * scaling)
|
implicitWidth: useCompactMode ? Math.round(Style.capsuleHeight * scaling) : Math.round(layout.implicitWidth + Style.marginM * 2 * scaling)
|
||||||
implicitHeight: useCompactMode ? Math.round(Style.capsuleHeight * 2.5 * scaling) : Math.round(Style.capsuleHeight * scaling)
|
implicitHeight: useCompactMode ? Math.round(Style.capsuleHeight * 2.5 * scaling) : Math.round(Style.capsuleHeight * scaling)
|
||||||
|
|
||||||
|
// React to bar position changes
|
||||||
|
Connections {
|
||||||
|
target: BarService
|
||||||
|
function onBarPositionChanged(newPosition) {
|
||||||
|
root.barPosition = newPosition
|
||||||
|
// Force re-evaluation of implicitWidth and implicitHeight
|
||||||
|
root.implicitWidth = Qt.binding(() => useCompactMode ? Math.round(Style.capsuleHeight * scaling) : Math.round(layout.implicitWidth + Style.marginM * 2 * scaling))
|
||||||
|
root.implicitHeight = Qt.binding(() => useCompactMode ? Math.round(Style.capsuleHeight * 2.5 * scaling) : Math.round(Style.capsuleHeight * scaling))
|
||||||
|
}
|
||||||
|
}
|
||||||
radius: Math.round(Style.radiusS * scaling)
|
radius: Math.round(Style.radiusS * scaling)
|
||||||
color: Color.mSurfaceVariant
|
color: Color.mSurfaceVariant
|
||||||
|
|
||||||
|
|
@ -64,18 +75,20 @@ Rectangle {
|
||||||
if (useCompactMode) {
|
if (useCompactMode) {
|
||||||
// Compact mode: time section (first 2 lines)
|
// Compact mode: time section (first 2 lines)
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: // Hours
|
case 0:
|
||||||
if (use12h) {
|
// Hours
|
||||||
const hours = now.getHours()
|
if (use12h) {
|
||||||
const displayHours = hours === 0 ? 12 : (hours > 12 ? hours - 12 : hours)
|
const hours = now.getHours()
|
||||||
return displayHours.toString().padStart(2, '0')
|
const displayHours = hours === 0 ? 12 : (hours > 12 ? hours - 12 : hours)
|
||||||
} else {
|
return displayHours.toString().padStart(2, '0')
|
||||||
return now.getHours().toString().padStart(2, '0')
|
} else {
|
||||||
}
|
return now.getHours().toString().padStart(2, '0')
|
||||||
case 1: // Minutes
|
}
|
||||||
return now.getMinutes().toString().padStart(2, '0')
|
case 1:
|
||||||
default:
|
// Minutes
|
||||||
return ""
|
return now.getMinutes().toString().padStart(2, '0')
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Normal mode: single line with time
|
// Normal mode: single line with time
|
||||||
|
|
@ -152,12 +165,14 @@ Rectangle {
|
||||||
if (useCompactMode) {
|
if (useCompactMode) {
|
||||||
// Compact mode: date section (last 2 lines)
|
// Compact mode: date section (last 2 lines)
|
||||||
switch (index) {
|
switch (index) {
|
||||||
case 0: // Day
|
case 0:
|
||||||
return now.getDate().toString().padStart(2, '0')
|
// Day
|
||||||
case 1: // Month
|
return now.getDate().toString().padStart(2, '0')
|
||||||
return (now.getMonth() + 1).toString().padStart(2, '0')
|
case 1:
|
||||||
default:
|
// Month
|
||||||
return ""
|
return (now.getMonth() + 1).toString().padStart(2, '0')
|
||||||
|
default:
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
|
@ -215,4 +230,4 @@ Rectangle {
|
||||||
PanelService.getPanel("calendarPanel")?.toggle(this)
|
PanelService.getPanel("calendarPanel")?.toggle(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue