mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-08-07 14:08:29 -04:00
fix(notifications): handle sound-name hint
This commit is contained in:
@@ -18,6 +18,17 @@ Item {
|
|||||||
|
|
||||||
readonly property bool _descriptionIsHtml: /<[a-z][^>]*>/i.test((eventData && eventData.description) || "")
|
readonly property bool _descriptionIsHtml: /<[a-z][^>]*>/i.test((eventData && eventData.description) || "")
|
||||||
|
|
||||||
|
// _locationUrl returns the location when it is nothing but a URL so the
|
||||||
|
// row can open it; links inside a street address surface as meetingUrl.
|
||||||
|
function _locationUrl() {
|
||||||
|
const loc = ((eventData && eventData.location) || "").trim();
|
||||||
|
if (/^https?:\/\/\S+$/i.test(loc))
|
||||||
|
return loc;
|
||||||
|
if (/^www\.\S+$/i.test(loc))
|
||||||
|
return "https://" + loc;
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
function _styleAnchors(html) {
|
function _styleAnchors(html) {
|
||||||
return html.replace(/<a\s([^>]*)>/gi, (m, attrs) => {
|
return html.replace(/<a\s([^>]*)>/gi, (m, attrs) => {
|
||||||
const cleaned = attrs.replace(/style="[^"]*"/gi, "");
|
const cleaned = attrs.replace(/style="[^"]*"/gi, "");
|
||||||
@@ -214,7 +225,7 @@ Item {
|
|||||||
DankIcon {
|
DankIcon {
|
||||||
name: "place"
|
name: "place"
|
||||||
size: 14
|
size: 14
|
||||||
color: Theme.surfaceVariantText
|
color: root._locationUrl() !== "" ? Theme.primary : Theme.surfaceVariantText
|
||||||
anchors.top: parent.top
|
anchors.top: parent.top
|
||||||
anchors.topMargin: 2
|
anchors.topMargin: 2
|
||||||
}
|
}
|
||||||
@@ -223,10 +234,48 @@ Item {
|
|||||||
width: parent.width - 14 - Theme.spacingXS
|
width: parent.width - 14 - Theme.spacingXS
|
||||||
text: root.eventData ? root.eventData.location : ""
|
text: root.eventData ? root.eventData.location : ""
|
||||||
font.pixelSize: Theme.fontSizeSmall
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
color: Theme.surfaceVariantText
|
color: root._locationUrl() !== "" ? Theme.primary : Theme.surfaceVariantText
|
||||||
wrapMode: Text.Wrap
|
wrapMode: Text.Wrap
|
||||||
maximumLineCount: 2
|
maximumLineCount: 2
|
||||||
elide: Text.ElideRight
|
elide: Text.ElideRight
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
enabled: root._locationUrl() !== ""
|
||||||
|
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
||||||
|
onClicked: Qt.openUrlExternally(root._locationUrl())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Row {
|
||||||
|
width: parent.width
|
||||||
|
spacing: Theme.spacingXS
|
||||||
|
visible: root.eventData && root.eventData.meetingUrl
|
||||||
|
|
||||||
|
DankIcon {
|
||||||
|
name: "videocam"
|
||||||
|
size: 14
|
||||||
|
color: Theme.primary
|
||||||
|
anchors.top: parent.top
|
||||||
|
anchors.topMargin: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
StyledText {
|
||||||
|
width: parent.width - 14 - Theme.spacingXS
|
||||||
|
text: I18n.tr("Join video call")
|
||||||
|
font.pixelSize: Theme.fontSizeSmall
|
||||||
|
color: Theme.primary
|
||||||
|
elide: Text.ElideRight
|
||||||
|
|
||||||
|
MouseArea {
|
||||||
|
anchors.fill: parent
|
||||||
|
cursorShape: Qt.PointingHandCursor
|
||||||
|
onClicked: {
|
||||||
|
if (root.eventData && root.eventData.meetingUrl)
|
||||||
|
Qt.openUrlExternally(root.eventData.meetingUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -380,6 +380,7 @@ Item {
|
|||||||
"description": e.description || "",
|
"description": e.description || "",
|
||||||
"location": e.location || "",
|
"location": e.location || "",
|
||||||
"url": e.url || "",
|
"url": e.url || "",
|
||||||
|
"meetingUrl": e.meetingUrl || "",
|
||||||
"start": allDay ? _dayBoundary(e.start) : new Date(e.start),
|
"start": allDay ? _dayBoundary(e.start) : new Date(e.start),
|
||||||
"end": allDay ? _dayBoundary(e.end) : new Date(e.end),
|
"end": allDay ? _dayBoundary(e.end) : new Date(e.end),
|
||||||
"allDay": allDay,
|
"allDay": allDay,
|
||||||
|
|||||||
@@ -700,9 +700,13 @@ Singleton {
|
|||||||
|
|
||||||
// Honor the freedesktop "suppress-sound" hint: the sender
|
// Honor the freedesktop "suppress-sound" hint: the sender
|
||||||
// plays its own audio for this notification and asks the
|
// plays its own audio for this notification and asks the
|
||||||
// server not to double up.
|
// server not to double up. "sound-name" is the opposite — an
|
||||||
const suppressSound = !!(notif.hints && notif.hints["suppress-sound"]);
|
// explicit request for audio — so it plays even when the
|
||||||
if (SettingsData.soundsEnabled && SettingsData.soundNewNotification && !suppressSound) {
|
// global new-notification sound is off.
|
||||||
|
const soundHints = notif.hints || {};
|
||||||
|
const suppressSound = !!soundHints["suppress-sound"];
|
||||||
|
const requestsSound = !!soundHints["sound-name"];
|
||||||
|
if (SettingsData.soundsEnabled && (SettingsData.soundNewNotification || requestsSound) && !suppressSound) {
|
||||||
if (policy.urgency === NotificationUrgency.Critical) {
|
if (policy.urgency === NotificationUrgency.Critical) {
|
||||||
AudioService.playCriticalNotificationSound();
|
AudioService.playCriticalNotificationSound();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user