Add compact clock again
This commit is contained in:
parent
2a1e7832d6
commit
b443c9f492
1 changed files with 35 additions and 20 deletions
|
|
@ -39,6 +39,17 @@ Rectangle {
|
||||||
|
|
||||||
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,7 +75,8 @@ 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:
|
||||||
|
// Hours
|
||||||
if (use12h) {
|
if (use12h) {
|
||||||
const hours = now.getHours()
|
const hours = now.getHours()
|
||||||
const displayHours = hours === 0 ? 12 : (hours > 12 ? hours - 12 : hours)
|
const displayHours = hours === 0 ? 12 : (hours > 12 ? hours - 12 : hours)
|
||||||
|
|
@ -72,7 +84,8 @@ Rectangle {
|
||||||
} else {
|
} else {
|
||||||
return now.getHours().toString().padStart(2, '0')
|
return now.getHours().toString().padStart(2, '0')
|
||||||
}
|
}
|
||||||
case 1: // Minutes
|
case 1:
|
||||||
|
// Minutes
|
||||||
return now.getMinutes().toString().padStart(2, '0')
|
return now.getMinutes().toString().padStart(2, '0')
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
|
|
@ -152,9 +165,11 @@ 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:
|
||||||
|
// Day
|
||||||
return now.getDate().toString().padStart(2, '0')
|
return now.getDate().toString().padStart(2, '0')
|
||||||
case 1: // Month
|
case 1:
|
||||||
|
// Month
|
||||||
return (now.getMonth() + 1).toString().padStart(2, '0')
|
return (now.getMonth() + 1).toString().padStart(2, '0')
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue