From be357343ff911b6e83ebc7908270f6d3f93ce004 Mon Sep 17 00:00:00 2001 From: 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> Date: Tue, 21 Apr 2026 01:19:00 +1000 Subject: [PATCH] refactor: migrate notifications + sidebar to new font API --- modules/notifications/Notification.qml | 32 +++++++++++--------------- modules/sidebar/Notif.qml | 2 +- modules/sidebar/NotifDock.qml | 18 +++++---------- modules/sidebar/NotifGroup.qml | 8 +++---- 4 files changed, 25 insertions(+), 35 deletions(-) diff --git a/modules/notifications/Notification.qml b/modules/notifications/Notification.qml index 95c1a59e..a29c613e 100644 --- a/modules/notifications/Notification.qml +++ b/modules/notifications/Notification.qml @@ -174,14 +174,14 @@ StyledRect { asynchronous: true active: !root.hasAppIcon anchors.centerIn: parent - anchors.horizontalCenterOffset: -Tokens.font.size.large * 0.02 - anchors.verticalCenterOffset: Tokens.font.size.large * 0.02 + anchors.horizontalCenterOffset: -Tokens.font.body.large.pointSize * 0.02 + anchors.verticalCenterOffset: Tokens.font.body.large.pointSize * 0.02 sourceComponent: MaterialIcon { text: Icons.getNotifIcon(root.modelData.summary, root.modelData.urgency) color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3onError : root.modelData.urgency === NotificationUrgency.Low ? Colours.palette.m3onSurface : Colours.palette.m3onSecondaryContainer - font.pointSize: Tokens.font.size.large + font: Tokens.font.icon.large } } } @@ -234,7 +234,7 @@ StyledRect { text: appNameMetrics.elidedText maximumLineCount: 1 color: Colours.palette.m3onSurfaceVariant - font.pointSize: Tokens.font.size.small + font: Tokens.font.label.small opacity: root.expanded ? 1 : 0 @@ -247,8 +247,7 @@ StyledRect { id: appNameMetrics text: root.modelData.appName - font.family: appName.font.family - font.pointSize: appName.font.pointSize + font: appName.font elide: Text.ElideRight elideWidth: expandBtn.x - time.width - timeSep.width - summary.x - root.Tokens.spacing.small * 3 } @@ -298,8 +297,7 @@ StyledRect { id: summaryMetrics text: root.modelData.summary - font.family: summary.font.family - font.pointSize: summary.font.pointSize + font: summary.font elide: Text.ElideRight elideWidth: expandBtn.x - time.width - timeSep.width - summary.x - root.Tokens.spacing.small * 3 } @@ -313,7 +311,7 @@ StyledRect { text: "•" color: Colours.palette.m3onSurfaceVariant - font.pointSize: Tokens.font.size.small + font: Tokens.font.body.small states: State { name: "expanded" @@ -343,7 +341,7 @@ StyledRect { horizontalAlignment: Text.AlignLeft text: root.modelData.timeStr color: Colours.palette.m3onSurfaceVariant - font.pointSize: Tokens.font.size.small + font: Tokens.font.body.small } Item { @@ -368,7 +366,7 @@ StyledRect { animate: true text: root.expanded ? "expand_less" : "expand_more" - font.pointSize: Tokens.font.size.normal + font: Tokens.font.icon.medium } } @@ -384,7 +382,7 @@ StyledRect { textFormat: root.bodyTextFormat text: bodyPreviewMetrics.elidedText color: Colours.palette.m3onSurfaceVariant - font.pointSize: Tokens.font.size.small + font: Tokens.font.body.small opacity: root.expanded ? 0 : 1 @@ -397,8 +395,7 @@ StyledRect { id: bodyPreviewMetrics text: root.modelData.body - font.family: bodyPreview.font.family - font.pointSize: bodyPreview.font.pointSize + font: bodyPreview.font elide: Text.ElideRight elideWidth: bodyPreview.width } @@ -415,7 +412,7 @@ StyledRect { textFormat: root.bodyTextFormat text: root.modelData.body color: Colours.palette.m3onSurfaceVariant - font.pointSize: Tokens.font.size.small + font: Tokens.font.body.small wrapMode: Text.WrapAtWordBoundaryOrAnywhere height: text ? implicitHeight : 0 @@ -495,15 +492,14 @@ StyledRect { anchors.centerIn: parent text: actionTextMetrics.elidedText color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3onSecondary : Colours.palette.m3onSurfaceVariant - font.pointSize: Tokens.font.size.small + font: Tokens.font.label.small } TextMetrics { id: actionTextMetrics text: action.modelData.text - font.family: actionText.font.family - font.pointSize: actionText.font.pointSize + font: actionText.font elide: Text.ElideRight elideWidth: { const numActions = root.modelData.actions.length + 1; diff --git a/modules/sidebar/Notif.qml b/modules/sidebar/Notif.qml index 054ff61c..91df80b7 100644 --- a/modules/sidebar/Notif.qml +++ b/modules/sidebar/Notif.qml @@ -106,7 +106,7 @@ StyledRect { animate: true text: root.modelData?.timeStr ?? "" color: Colours.palette.m3outline - font.pointSize: Tokens.font.size.small + font: Tokens.font.body.small } } diff --git a/modules/sidebar/NotifDock.qml b/modules/sidebar/NotifDock.qml index 854fc91d..a5855985 100644 --- a/modules/sidebar/NotifDock.qml +++ b/modules/sidebar/NotifDock.qml @@ -43,9 +43,7 @@ Item { text: root.notifCount color: Colours.palette.m3outline - font.pointSize: Tokens.font.size.normal - font.family: Tokens.font.family.mono - font.weight: 500 + font: Tokens.font.mono.builders.medium.weight(500).build() Behavior on anchors.leftMargin { Anim {} @@ -66,9 +64,7 @@ Item { text: root.notifCount > 0 ? qsTr("notification%1").arg(root.notifCount === 1 ? "" : "s") : qsTr("Notifications") color: Colours.palette.m3outline - font.pointSize: Tokens.font.size.normal - font.family: Tokens.font.family.mono - font.weight: 500 + font: Tokens.font.mono.builders.medium.weight(500).build() elide: Text.ElideRight } } @@ -111,9 +107,7 @@ Item { Layout.alignment: Qt.AlignHCenter text: qsTr("No Notifications") color: Colours.palette.m3outlineVariant - font.pointSize: Tokens.font.size.large - font.family: Tokens.font.family.mono - font.weight: 500 + font: Tokens.font.mono.builders.large.weight(500).build() } } @@ -187,9 +181,9 @@ Item { id: clearBtn icon: "clear_all" - radius: Tokens.rounding.large - padding: Tokens.padding.medium - font.pointSize: Math.round(Tokens.font.size.large * 1.2) + radius: Tokens.rounding.normal + padding: Tokens.padding.normal + font: Tokens.font.icon.builders.large.size(Math.round(Tokens.font.icon.large.pointSize * 1.2)).build() onClicked: clearTimer.start() Elevation { diff --git a/modules/sidebar/NotifGroup.qml b/modules/sidebar/NotifGroup.qml index b1d61cad..a05de6ec 100644 --- a/modules/sidebar/NotifGroup.qml +++ b/modules/sidebar/NotifGroup.qml @@ -113,7 +113,7 @@ StyledRect { MaterialIcon { text: Icons.getNotifIcon(root.activeNotifs[0]?.summary, root.urgency) color: root.urgency === NotificationUrgency.Critical ? Colours.palette.m3onError : root.urgency === NotificationUrgency.Low ? Colours.palette.m3onSurface : Colours.palette.m3onSecondaryContainer - font.pointSize: Tokens.font.size.large + font: Tokens.font.icon.large } } @@ -174,7 +174,7 @@ StyledRect { Layout.fillWidth: true text: root.modelData color: Colours.palette.m3onSurfaceVariant - font.pointSize: Tokens.font.size.small + font: Tokens.font.title.small elide: Text.ElideRight } @@ -182,7 +182,7 @@ StyledRect { animate: true text: root.activeNotifs[0]?.timeStr ?? "" color: Colours.palette.m3outline - font.pointSize: Tokens.font.size.small + font: Tokens.font.title.small } StyledRect { @@ -210,7 +210,7 @@ StyledRect { animate: true text: root.notifCount color: root.urgency === NotificationUrgency.Critical ? Colours.palette.m3onError : Colours.palette.m3onSurface - font.pointSize: Tokens.font.size.small + font: Tokens.font.label.small } MaterialIcon {