From 90539274803dc3689bd418c1000ef40baed67efa Mon Sep 17 00:00:00 2001 From: end-4 <97237370+end-4@users.noreply.github.com> Date: Mon, 24 Nov 2025 22:45:54 +0100 Subject: [PATCH] wnotificationcenter: somewhat working calendar --- .../waffle/looks/WBorderlessButton.qml | 2 + .../ii/modules/waffle/looks/WButton.qml | 4 +- .../notificationCenter/CalendarHeader.qml | 2 +- .../notificationCenter/CalendarView.qml | 103 +++++++++++++++++- .../waffle/notificationCenter/FocusFooter.qml | 2 +- .../NotificationCenterContent.qml | 2 +- 6 files changed, 108 insertions(+), 7 deletions(-) diff --git a/dots/.config/quickshell/ii/modules/waffle/looks/WBorderlessButton.qml b/dots/.config/quickshell/ii/modules/waffle/looks/WBorderlessButton.qml index 0f0d99ad9..7f3546a6b 100644 --- a/dots/.config/quickshell/ii/modules/waffle/looks/WBorderlessButton.qml +++ b/dots/.config/quickshell/ii/modules/waffle/looks/WBorderlessButton.qml @@ -25,8 +25,10 @@ Button { return root.colBackground } } + property alias radius: background.radius background: Rectangle { + id: background radius: Looks.radius.medium color: root.color } diff --git a/dots/.config/quickshell/ii/modules/waffle/looks/WButton.qml b/dots/.config/quickshell/ii/modules/waffle/looks/WButton.qml index 69f255ad9..18fe0244b 100644 --- a/dots/.config/quickshell/ii/modules/waffle/looks/WButton.qml +++ b/dots/.config/quickshell/ii/modules/waffle/looks/WButton.qml @@ -23,7 +23,7 @@ Button { if (root.checked) { if (root.down) { return root.colBackgroundToggledActive; - } else if (root.hovered && !root.down) { + } else if (root.hovered) { return root.colBackgroundToggledHover; } else { return root.colBackgroundToggled; @@ -31,7 +31,7 @@ Button { } if (root.down) { return root.colBackgroundActive; - } else if (root.hovered && !root.down) { + } else if (root.hovered) { return root.colBackgroundHover; } else { return root.colBackground; diff --git a/dots/.config/quickshell/ii/modules/waffle/notificationCenter/CalendarHeader.qml b/dots/.config/quickshell/ii/modules/waffle/notificationCenter/CalendarHeader.qml index 79543846b..3e177f2fa 100644 --- a/dots/.config/quickshell/ii/modules/waffle/notificationCenter/CalendarHeader.qml +++ b/dots/.config/quickshell/ii/modules/waffle/notificationCenter/CalendarHeader.qml @@ -13,7 +13,7 @@ FooterRectangle { id: root property bool collapsed - implicitWidth: 334 + implicitWidth: 0 RowLayout { anchors { diff --git a/dots/.config/quickshell/ii/modules/waffle/notificationCenter/CalendarView.qml b/dots/.config/quickshell/ii/modules/waffle/notificationCenter/CalendarView.qml index 335cecf5a..07228590c 100644 --- a/dots/.config/quickshell/ii/modules/waffle/notificationCenter/CalendarView.qml +++ b/dots/.config/quickshell/ii/modules/waffle/notificationCenter/CalendarView.qml @@ -12,12 +12,111 @@ import qs.modules.waffle.looks BodyRectangle { id: root + // State property bool collapsed - implicitHeight: collapsed ? 0 : 400 // For now - implicitWidth: 334 + + // Sizes + property int _rowsPerMonth: 6 + property real viewHeight: (_rowsPerMonth * buttonSize) + ((_rowsPerMonth - 1) * buttonSpacing) + property real buttonSize: 40 + property real buttonSpacing: 2 + property real spacePerExtraRow: buttonSize + buttonSpacing + + implicitWidth: currentMonthGrid.implicitWidth + implicitHeight: collapsed ? 0 : viewHeight + opacity: implicitHeight > 0 ? 1 : 0 Behavior on implicitHeight { animation: Looks.transition.enter.createObject(this) } + // Month stuff + property real targetMonthDiff: 0 + property real monthDiff: targetMonthDiff + property int focusedMonthDiff: monthDiff // whole part of monthDiff + property int currentMonth: DateTime.clock.date.getMonth() + 1 // 0-indexed -> 1-indexed + property int currentYear: DateTime.clock.date.getFullYear() + + clip: true + property list monthGrids: [previousPreviousMonthGrid, previousMonthGrid, currentMonthGrid, nextMonthGrid, nextNextMonthGrid] + ColumnLayout { + spacing: 0 + y: { + const origin = - currentMonthGrid.y; + const diff = root.monthDiff * root.viewHeight; + return origin + (-diff % root.viewHeight); + } + DiffMonthGrid { + id: previousPreviousMonthGrid + monthDiff: root.focusedMonthDiff - 2 + } + DiffMonthGrid { + id: previousMonthGrid + monthDiff: root.focusedMonthDiff - 1 + } + DiffMonthGrid { + id: currentMonthGrid + monthDiff: root.focusedMonthDiff + } + DiffMonthGrid { + id: nextMonthGrid + monthDiff: root.focusedMonthDiff + 1 + } + DiffMonthGrid { + id: nextNextMonthGrid + monthDiff: root.focusedMonthDiff + 2 + } + } + + MouseArea { + anchors.fill: parent + onWheel: wheel => { + root.targetMonthDiff += wheel.angleDelta.y / 120 * -0.333333; // Reverse cuz scrolling down should advance + } + } + + Behavior on monthDiff { + animation: Looks.transition.enter.createObject(this) + } + + component DiffMonthGrid: MonthGrid { + id: monthGrid + required property int monthDiff + property int index: root.monthGrids.indexOf(this) + month: ((root.currentMonth - 1) + monthDiff) % 12 // 1-indexed -> 0-indexed + year: root.currentYear + Math.floor((root.currentMonth - 1 + monthDiff) / 12) + + spacing: root.buttonSpacing + // background: Rectangle { + // color: Qt.rgba(Math.abs(Math.sin(month * 12.9898)) % 1, Math.abs(Math.sin(month * 78.233)) % 1, Math.abs(Math.sin(month * 45.164)) % 1, 1) + // } + delegate: MonthDayButton {} + } + + component MonthDayButton: WButton { + id: monthDayButton + required property var model + opacity: model.month == parent.parent.month || model.today ? 1 : 0 + checked: model.today + implicitWidth: root.buttonSize + implicitHeight: root.buttonSize + radius: height / 2 + + required property int index + + contentItem: Item { + WText { + anchors.centerIn: parent + text: monthDayButton.model.day + color: { + if (monthDayButton.model.today) + return Looks.colors.accentFg; + if (monthDayButton.model.month == root.currentMonth - 1) + return Looks.colors.fg; + return Looks.colors.subfg; + } + font.pixelSize: Looks.font.pixelSize.large + } + } + } } diff --git a/dots/.config/quickshell/ii/modules/waffle/notificationCenter/FocusFooter.qml b/dots/.config/quickshell/ii/modules/waffle/notificationCenter/FocusFooter.qml index 95fc529c2..c66925d04 100644 --- a/dots/.config/quickshell/ii/modules/waffle/notificationCenter/FocusFooter.qml +++ b/dots/.config/quickshell/ii/modules/waffle/notificationCenter/FocusFooter.qml @@ -11,7 +11,7 @@ import qs.modules.waffle.looks FooterRectangle { Layout.fillWidth: true - implicitWidth: 334 + implicitWidth: 0 RowLayout { anchors { diff --git a/dots/.config/quickshell/ii/modules/waffle/notificationCenter/NotificationCenterContent.qml b/dots/.config/quickshell/ii/modules/waffle/notificationCenter/NotificationCenterContent.qml index 44ceef6ba..c2b97f6dc 100644 --- a/dots/.config/quickshell/ii/modules/waffle/notificationCenter/NotificationCenterContent.qml +++ b/dots/.config/quickshell/ii/modules/waffle/notificationCenter/NotificationCenterContent.qml @@ -40,7 +40,7 @@ WBarAttachedPanelContent { WPanelSeparator { visible: !root.collapsed } CalendarView { - Layout.fillWidth: true + // Layout.fillWidth: true Synchronizer on collapsed { property alias source: root.collapsed }