summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
Diffstat (limited to 'modules')
-rw-r--r--modules/notifications/Notification.qml83
1 files changed, 48 insertions, 35 deletions
diff --git a/modules/notifications/Notification.qml b/modules/notifications/Notification.qml
index 1a520c8..6022e9d 100644
--- a/modules/notifications/Notification.qml
+++ b/modules/notifications/Notification.qml
@@ -413,53 +413,66 @@ StyledRect {
Anim {}
}
+ Action {
+ modelData: QtObject {
+ readonly property string text: qsTr("Close")
+ function invoke(): void {
+ root.modelData.notification.dismiss();
+ }
+ }
+ }
+
Repeater {
model: root.modelData.actions
- delegate: StyledRect {
- id: action
+ delegate: Component {
+ Action {}
+ }
+ }
+ }
+ }
- required property NotificationAction modelData
+ component Action: StyledRect {
+ id: action
- radius: Appearance.rounding.full
- color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3secondary : Colours.palette.m3surfaceContainerHigh
+ required property var modelData
- Layout.preferredWidth: actionText.width + Appearance.padding.normal * 2
- Layout.preferredHeight: actionText.height + Appearance.padding.small * 2
- implicitWidth: actionText.width + Appearance.padding.normal * 2
- implicitHeight: actionText.height + Appearance.padding.small * 2
+ radius: Appearance.rounding.full
+ color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3secondary : Colours.palette.m3surfaceContainerHigh
- StateLayer {
- radius: Appearance.rounding.full
- color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3onSecondary : Colours.palette.m3onSurface
+ Layout.preferredWidth: actionText.width + Appearance.padding.normal * 2
+ Layout.preferredHeight: actionText.height + Appearance.padding.small * 2
+ implicitWidth: actionText.width + Appearance.padding.normal * 2
+ implicitHeight: actionText.height + Appearance.padding.small * 2
- function onClicked(): void {
- action.modelData.invoke();
- }
- }
+ StateLayer {
+ radius: Appearance.rounding.full
+ color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3onSecondary : Colours.palette.m3onSurface
+
+ function onClicked(): void {
+ action.modelData.invoke();
+ }
+ }
- StyledText {
- id: actionText
+ StyledText {
+ id: actionText
- anchors.centerIn: parent
- text: actionTextMetrics.elidedText
- color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3onSecondary : Colours.palette.m3onSurfaceVariant
- font.pointSize: Appearance.font.size.small
- }
+ anchors.centerIn: parent
+ text: actionTextMetrics.elidedText
+ color: root.modelData.urgency === NotificationUrgency.Critical ? Colours.palette.m3onSecondary : Colours.palette.m3onSurfaceVariant
+ font.pointSize: Appearance.font.size.small
+ }
- TextMetrics {
- id: actionTextMetrics
+ TextMetrics {
+ id: actionTextMetrics
- text: modelData.text
- font.family: actionText.font.family
- font.pointSize: actionText.font.pointSize
- elide: Text.ElideRight
- elideWidth: {
- const numActions = root.modelData.actions.length;
- return (inner.width - actions.spacing * (numActions - 1)) / numActions - Appearance.padding.normal * 2;
- }
- }
- }
+ text: action.modelData.text
+ font.family: actionText.font.family
+ font.pointSize: actionText.font.pointSize
+ elide: Text.ElideRight
+ elideWidth: {
+ const numActions = root.modelData.actions.length + 1;
+ return (inner.width - actions.spacing * (numActions - 1)) / numActions - Appearance.padding.normal * 2;
}
}
}