Add global holidays to calendar, fix volume mute display

This commit is contained in:
ly-sec 2025-07-19 16:22:10 +02:00
parent f55af1b68b
commit ba93df4a1f
5 changed files with 115 additions and 4 deletions

View file

@ -427,4 +427,4 @@ PanelWithOverlay {
offsetY: 0
}
}
}
}

View file

@ -5,6 +5,7 @@ import Quickshell
import qs.Components
import qs.Settings
import Quickshell.Wayland
import "root:/Helpers/Holidays.js" as Holidays
PanelWithOverlay {
id: calendarOverlay
@ -87,10 +88,38 @@ PanelWithOverlay {
month: Time.date.getMonth()
year: Time.date.getFullYear()
property var holidays: []
// Fetch holidays when calendar is opened or month/year changes
function updateHolidays() {
Holidays.getHolidaysForMonth(calendar.year, calendar.month, function(holidays) {
calendar.holidays = holidays;
});
}
onMonthChanged: updateHolidays()
onYearChanged: updateHolidays()
Component.onCompleted: updateHolidays()
// Optionally, update when the panel becomes visible
Connections {
target: calendarOverlay
function onVisibleChanged() {
if (calendarOverlay.visible) {
calendar.month = Time.date.getMonth();
calendar.year = Time.date.getFullYear();
calendar.updateHolidays();
}
}
}
delegate: Rectangle {
width: 32
height: 32
radius: 8
property var holidayInfo: calendar.holidays.filter(function(h) {
var d = new Date(h.date);
return d.getDate() === model.day && d.getMonth() === model.month && d.getFullYear() === model.year;
})
property bool isHoliday: holidayInfo.length > 0
color: {
if (model.today)
return Theme.accentPrimary;
@ -99,6 +128,19 @@ PanelWithOverlay {
return "transparent";
}
// Holiday dot indicator
Rectangle {
visible: isHoliday
width: 4; height: 4
radius: 4
color: Theme.accentTertiary
anchors.top: parent.top
anchors.right: parent.right
anchors.topMargin: 4
anchors.rightMargin: 4
z: 2
}
Text {
anchors.centerIn: parent
text: model.day
@ -113,6 +155,16 @@ PanelWithOverlay {
id: mouseArea2
anchors.fill: parent
hoverEnabled: true
onEntered: {
if (isHoliday) {
holidayTooltip.text = holidayInfo.map(function(h) {
return h.localName + (h.name !== h.localName ? " (" + h.name + ")" : "") + (h.global ? " [Global]" : "");
}).join(", ");
holidayTooltip.targetItem = parent;
holidayTooltip.tooltipVisible = true;
}
}
onExited: holidayTooltip.tooltipVisible = false
}
Behavior on color {
@ -120,6 +172,14 @@ PanelWithOverlay {
duration: 150
}
}
StyledTooltip {
id: holidayTooltip
text: ""
tooltipVisible: false
targetItem: undefined
delay: 100
}
}
}
}

View file

@ -14,7 +14,7 @@ Item {
PillIndicator {
id: pillIndicator
icon: volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up")
icon: shell && shell.defaultAudioSink && shell.defaultAudioSink.audio && shell.defaultAudioSink.audio.muted ? "volume_off" : (volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up"))
text: volume + "%"
pillColor: Theme.surfaceVariant
@ -36,7 +36,7 @@ Item {
if (shell && shell.volume !== volume) {
volume = shell.volume
pillIndicator.text = volume + "%"
pillIndicator.icon = volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up")
pillIndicator.icon = shell && shell.defaultAudioSink && shell.defaultAudioSink.audio && shell.defaultAudioSink.audio.muted ? "volume_off" : (volume === 0 ? "volume_off" : (volume < 30 ? "volume_down" : "volume_up"))
pillIndicator.show()
}
}