1239 1239 required property
QtObject theme
1240 1240 required property
QtObject notificationService
1241 - property var state: notificationService
? Util.parseJson(notificationService.stateJson(), {
1243 - "notificationPanelContract": {
1247 - "notificationPanelContract": {
1241 + property var state: notificationService
? Util.parseJson(notificationService.stateJson(), {
"groups": [],
"dnd":
false,
"activeCount":
0})
: ({
"groups": [],
"dnd":
false,
"activeCount":
0})
1250 1242 readonly property
var groups: state.groups
|| []
1251 - readonly property
var panel: state.notificationPanelContract
|| ({
1255 - function roleColor(role) {
1257 - return "transparent";
1259 - if (role
=== "critical")
1260 - return theme.error;
1262 - if (role
=== "normal")
1263 - return theme.ui.accent;
1265 - return theme.ui.minor;
1268 - function runAction(notificationId, actionId) {
1244 + function runAction(id, actionId) {
1269 1245 if (notificationService)
1270 - state
= Util.parseJson(notificationService.runAction(notificationId, actionId), state);
1246 + state
= Util.parseJson(notificationService.runAction(id, actionId), state);
1274 1248 function toggleGroup(appName) {
1275 1249 if (notificationService)
1276 1250 state
= Util.parseJson(notificationService.toggleGroup(appName), state);
1280 - function dragNotification(notificationId, deltaX, rowWidth) {
1252 + function toggleDnd() {
1281 1253 if (notificationService)
1282 - state
= Util.parseJson(notificationService.dragNotification(notificationId, deltaX, rowWidth), state);
1254 + state
= Util.parseJson(notificationService.toggleDnd(), state);
1286 - function recordPointerEvent(kind, notificationId, x, y, deltaX) {
1287 - if (notificationService
&& typeof notificationService.recordPointerEvent
=== "function")
1288 - notificationService.recordPointerEvent(kind, notificationId, x, y, deltaX);
1256 + function clearAll() {
1257 + if (notificationService)
1258 + state
= Util.parseJson(notificationService.discardAllNotifications(), state);
1293 1262 width: parent
? parent.width
: 0 1265 + width: parent.width
1268 + anchors.left: parent.left
1269 + anchors.verticalCenter: parent.verticalCenter
1272 + text:
`Notifications${root.state.activeCount
? " · " + root.state.activeCount
: ""}
` 1275 + anchors.right: parent.right
1276 + anchors.verticalCenter: parent.verticalCenter
1279 + width: dndLabel.implicitWidth
+ 18 1282 + color: root.theme
? root.theme.withAlpha(root.state.dnd
? root.theme.ui.accent
: root.theme.ui.minor, root.state.dnd
? 0.3 : 0.12)
: "transparent" 1283 + NuguText {
id: dndLabel; anchors.centerIn: parent;
theme: root.theme;
variant:
"meta";
text: root.state.dnd
? "DND on" : "DND" }
1284 + MouseArea { anchors.fill: parent;
onClicked: root.toggleDnd() }
1287 + width: clearLabel.implicitWidth
+ 18 1290 + visible: (root.state.activeCount
|| 0)
> 0 1291 + color: clearArea.containsMouse
&& root.theme
? root.theme.withAlpha(root.theme.error,
0.24)
: (root.theme
? root.theme.withAlpha(root.theme.ui.minor,
0.12)
: "transparent")
1292 + NuguText {
id: clearLabel; anchors.centerIn: parent;
theme: root.theme;
variant:
"meta";
text:
"Clear all" }
1293 + MouseArea {
id: clearArea; anchors.fill: parent;
hoverEnabled:
true;
onClicked: root.clearAll() }
1299 + width: parent.width
1301 + visible: root.groups.length
=== 0 1303 + anchors.centerIn: parent
1305 + NuguText { anchors.horizontalCenter: parent.horizontalCenter;
theme: root.theme;
variant:
"title";
text:
"No notifications" }
1306 + NuguText { anchors.horizontalCenter: parent.horizontalCenter;
theme: root.theme;
variant:
"meta";
text:
"You're all caught up" }
1296 1311 model: root.groups
1298 - delegate: Rectangle {
1312 + delegate: Column {
1301 1314 required property
var modelData
1302 - property real
dragLastX:
0 1303 - property real
dragAccumX:
0 1305 1315 width: root.width
1306 - implicitHeight: groupColumn.implicitHeight
+ 16 1308 - color: root.theme
? root.theme.withAlpha(root.theme.ui.minor,
0.12)
: "transparent" 1310 - border.color: root.roleColor(modelData.urgency)
1316 - anchors.left: parent.left
1317 - anchors.right: parent.right
1318 - anchors.top: parent.top
1319 - anchors.margins:
8 1319 + width: parent.width
1320 + height: (groupDelegate.modelData.count
|| 0)
> 1 ? 22 : 0 1321 + visible: (groupDelegate.modelData.count
|| 0)
> 1 1323 - width: parent.width
1327 - objectName:
"appMediaSlot" 1331 - color: root.roleColor(groupCard.modelData.urgency)
1334 - anchors.centerIn: parent
1338 - text:
String(groupCard.modelData.appName
|| "?").slice(
0,
1)
1344 - width: parent.width
- 92 1349 - text: groupCard.modelData.appName
|| "unknown" 1350 - width: parent.width
1351 - elide:
Text.ElideRight
1357 - text:
`${groupCard.modelData.count
|| 0}
· ${groupCard.modelData.urgency
|| "normal"}
· ${groupCard.modelData.expandCollapseState
|| "collapsed"}
` 1358 - width: parent.width
1359 - elide:
Text.ElideRight
1365 - objectName:
"expandPill" 1369 - color: root.theme
? root.theme.withAlpha(root.theme.ui.accent,
0.22)
: "transparent" 1371 - border.color: root.theme
? root.theme.ui.accent
: "transparent" 1374 - anchors.centerIn: parent
1377 - text:
`${groupCard.modelData.count
|| 0}${groupCard.modelData.expanded
? "^" : "v"}
` 1381 - anchors.fill: parent
1382 - onClicked: root.toggleGroup(groupCard.modelData.appName
|| "")
1323 + anchors.left: parent.left
1324 + anchors.verticalCenter: parent.verticalCenter
1326 + NuguText {
theme: root.theme;
variant:
"meta";
text: groupDelegate.modelData.appName
|| "" }
1327 + NuguText {
theme: root.theme;
variant:
"meta";
text:
`· ${groupDelegate.modelData.count}
` }
1390 - model: groupCard.modelData.visibleNotifications
|| []
1392 - delegate: Rectangle {
1395 - required property
var modelData
1396 - property real
pressX:
0 1397 - property real
lastDragX:
0 1398 - property real
dragAccumX:
0 1400 - width: groupColumn.width
1401 - implicitHeight: notifColumn.implicitHeight
+ 12 1404 - color: root.theme
? root.theme.withAlpha(root.theme.ui.backdrop,
0.82)
: "transparent" 1406 - border.color: root.theme
? root.theme.ui.minor
: "transparent" 1410 - anchors.fill: parent
1411 - acceptedButtons:
Qt.LeftButton
| Qt.MiddleButton
1412 - drag.target: notifCard
1413 - drag.axis:
Drag.XAxis
1414 - onPressed: (event)
=> {
1415 - notifCard.pressX
= event.x;
1416 - notifCard.lastDragX
= event.x;
1417 - notifCard.dragAccumX
= 0;
1418 - root.recordPointerEvent(
"row-press", notifCard.modelData.id, event.x, event.y,
0);
1420 - onPositionChanged: (event)
=> {
1421 - if (pressed
&& pressedButtons
& Qt.LeftButton) {
1422 - notifCard.dragAccumX
= Math.
max(
0, notifCard.dragAccumX
+ event.x
- notifCard.lastDragX);
1423 - notifCard.lastDragX
= event.x;
1424 - notifCard.x
= notifCard.dragAccumX;
1425 - root.recordPointerEvent(
"row-drag", notifCard.modelData.id, event.x, event.y, notifCard.dragAccumX);
1428 - onClicked: (event)
=> {
1429 - if (event.button
=== Qt.MiddleButton)
1430 - root.runAction(notifCard.modelData.id,
"close");
1433 - onReleased: (event)
=> {
1434 - const dragged
= notifCard.x;
1435 - root.recordPointerEvent(
"row-release", notifCard.modelData.id, event.x, event.y, dragged);
1436 - root.dragNotification(notifCard.modelData.id, dragged,
Math.
max(
1, notifCard.width));
1444 - anchors.left: parent.left
1445 - anchors.right: parent.right
1446 - anchors.top: parent.top
1447 - anchors.margins:
6 1452 - text: notifCard.modelData.summary
|| "notification" 1453 - width: parent.width
1454 - elide:
Text.ElideRight
1460 - text: notifCard.modelData.body
|| "" 1461 - width: parent.width
1462 - elide:
Text.ElideRight
1466 - objectName:
"maskedHorizontalActionRail" 1467 - width: parent.width
1475 - model: notifCard.modelData.actionRows
|| []
1477 - delegate: Rectangle {
1480 - required property
var modelData
1483 - width:
Math.
max(
58, actionText.implicitWidth
+ 18)
1485 - color: root.theme
? root.theme.withAlpha(root.theme.ui.accent,
0.16)
: "transparent" 1487 - border.color: root.theme
? root.theme.ui.accent
: "transparent" 1492 - anchors.centerIn: parent
1495 - text: actionButton.modelData.label
|| actionButton.modelData.kind
|| "act" 1499 - anchors.fill: parent
1500 - onClicked: root.runAction(notifCard.modelData.id, actionButton.modelData.id)
1510 - anchors.left: parent.left
1511 - anchors.top: parent.top
1512 - anchors.bottom: parent.bottom
1514 - color: root.theme
? root.theme.withAlpha(root.theme.ui.backdrop,
0.72)
: "transparent" 1518 - anchors.right: parent.right
1519 - anchors.top: parent.top
1520 - anchors.bottom: parent.bottom
1522 - color: root.theme
? root.theme.withAlpha(root.theme.ui.backdrop,
0.72)
: "transparent" 1330 + anchors.right: parent.right
1331 + anchors.verticalCenter: parent.verticalCenter
1334 + text: groupDelegate.modelData.expanded
? "⌃" : "⌄" 1336 + MouseArea { anchors.fill: parent;
onClicked: root.toggleGroup(groupDelegate.modelData.appName
|| "") }
1536 - anchors.fill: parent
1538 - acceptedButtons:
Qt.LeftButton
1539 - propagateComposedEvents:
true 1540 - onPressed: (event)
=> {
1541 - groupCard.dragLastX
= event.x;
1542 - groupCard.dragAccumX
= 0;
1543 - const list
= groupCard.modelData.visibleNotifications
|| [];
1544 - root.recordPointerEvent(
"group-press", list.length
> 0 ? list[
0].id
: "", event.x, event.y,
0);
1545 - event.accepted
= false;
1547 - onPositionChanged: (event)
=> {
1548 - if (pressed
&& pressedButtons
& Qt.LeftButton) {
1549 - groupCard.dragAccumX
= Math.
max(
0, groupCard.dragAccumX
+ event.x
- groupCard.dragLastX);
1550 - groupCard.dragLastX
= event.x;
1551 - const list
= groupCard.modelData.visibleNotifications
|| [];
1552 - root.recordPointerEvent(
"group-drag", list.length
> 0 ? list[
0].id
: "", event.x, event.y, groupCard.dragAccumX);
1555 - onReleased: (event)
=> {
1556 - const list
= groupCard.modelData.visibleNotifications
|| [];
1557 - root.recordPointerEvent(
"group-release", list.length
> 0 ? list[
0].id
: "", event.x, event.y, groupCard.dragAccumX);
1558 - if (list.length
> 0 && groupCard.dragAccumX
> 0)
1559 - root.dragNotification(list[
0].id, groupCard.dragAccumX,
Math.
max(
1, groupCard.width
- 16));
1561 - event.accepted
= groupCard.dragAccumX
> 0;
1562 - groupCard.dragAccumX
= 0;
1564 - onClicked: (event)
=> {
1565 - return event.accepted
= false;
1340 + model: groupDelegate.modelData.visibleNotifications
|| []
1341 + delegate: NotificationCard {
1344 + onDismiss: (id)
=> root.runAction(id,
"close")
1345 + onInvokeAction: (id, actionId)
=> root.runAction(id, actionId)
1569 - Behavior on implicitHeight {
1571 - duration: root.theme
&& root.theme.lowPowerMode
? 0 : 180 1572 - easing.type:
Easing.OutCubic
1582 - visible: root.groups.length
=== 0 1585 - text:
"no notifications" 1590 1352 component
FailureShake:
Item {