quickshell: show greyed adjacent-month days in the calendar grid
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
d6725f4d6d
commit
efb49deabd
1 changed files with 16 additions and 10 deletions
|
|
@ -6290,19 +6290,25 @@ in
|
|||
}
|
||||
|
||||
Grid {
|
||||
id: calGrid
|
||||
columns: 7
|
||||
spacing: 0
|
||||
// Offset of the 1st within its Mo-first week, and the
|
||||
// whole-week count that covers the month — so leading and
|
||||
// trailing cells only spill into the weeks that need them.
|
||||
property int startDay: (new Date(calPopup.viewYear, calPopup.viewMonth, 1).getDay() + 6) % 7
|
||||
property int daysInMonth: new Date(calPopup.viewYear, calPopup.viewMonth + 1, 0).getDate()
|
||||
Repeater {
|
||||
model: 42
|
||||
model: 7 * Math.ceil((calGrid.startDay + calGrid.daysInMonth) / 7)
|
||||
Rectangle {
|
||||
required property int index
|
||||
property int dayNum: {
|
||||
let first = new Date(calPopup.viewYear, calPopup.viewMonth, 1);
|
||||
let startDay = (first.getDay() + 6) % 7;
|
||||
return index - startDay + 1;
|
||||
}
|
||||
property int daysInMonth: new Date(calPopup.viewYear, calPopup.viewMonth + 1, 0).getDate()
|
||||
property bool isToday: dayNum === clockText.now.getDate()
|
||||
// Day-of-month offset; out-of-range values roll into
|
||||
// the adjacent month via the Date constructor.
|
||||
property int dayNum: index - calGrid.startDay + 1
|
||||
property date cellDate: new Date(calPopup.viewYear, calPopup.viewMonth, dayNum)
|
||||
property bool inMonth: dayNum >= 1 && dayNum <= calGrid.daysInMonth
|
||||
property bool isToday: inMonth
|
||||
&& dayNum === clockText.now.getDate()
|
||||
&& calPopup.viewMonth === clockText.now.getMonth()
|
||||
&& calPopup.viewYear === clockText.now.getFullYear()
|
||||
width: 32
|
||||
|
|
@ -6312,8 +6318,8 @@ in
|
|||
|
||||
SText {
|
||||
anchors.centerIn: parent
|
||||
text: parent.dayNum >= 1 && parent.dayNum <= parent.daysInMonth ? parent.dayNum.toString() : ""
|
||||
color: parent.isToday ? Theme.base05 : Theme.base04
|
||||
text: parent.cellDate.getDate().toString()
|
||||
color: parent.isToday ? Theme.base05 : (parent.inMonth ? Theme.base04 : Theme.base03)
|
||||
font.pixelSize: 13
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue