Add support for notification sound effects
This commit is contained in:
@@ -56,6 +56,14 @@ class Notifications:
|
||||
# keep seeing raw <tags> in notifications.
|
||||
use_html: bool = True
|
||||
|
||||
# Default sound to play for notifications. Can be the filename
|
||||
# of a builtin sound (only "default.wav" currently exists), or the
|
||||
# absolute path to an audio file, preferably in the WAV format.
|
||||
default_sound: str = "default.wav"
|
||||
|
||||
# Volume at which the notification sound will be played, 0-100.
|
||||
volume: int = 75
|
||||
|
||||
# How long in seconds the window will flash in your dock or taskbar when
|
||||
# a new message, which matches a notification push rule with a
|
||||
# flash (lightbulb) action, is posted in a room.
|
||||
|
@@ -26,6 +26,11 @@ QtObject {
|
||||
if (bubble)
|
||||
py.callCoro("desktop_notify", [title, body, image])
|
||||
|
||||
if (sound) {
|
||||
window.mainUI.defaultNotificationSound.seek(0)
|
||||
window.mainUI.defaultNotificationSound.play()
|
||||
}
|
||||
|
||||
if (urgencyHint) {
|
||||
const msec =
|
||||
critical ?
|
||||
|
@@ -6,6 +6,7 @@ import QtQuick.Controls 2.12
|
||||
import QtQuick.Layouts 1.12
|
||||
import QtQuick.Window 2.12
|
||||
import QtGraphicalEffects 1.12
|
||||
import QtMultimedia 5.12
|
||||
import "."
|
||||
import "Base"
|
||||
import "MainPane"
|
||||
@@ -35,6 +36,7 @@ Item {
|
||||
return ids
|
||||
}
|
||||
|
||||
readonly property alias defaultNotificationSound: defaultNotificationSound
|
||||
readonly property alias debugConsole: debugConsole
|
||||
readonly property alias mainPane: mainPane
|
||||
readonly property alias pageLoader: pageLoader
|
||||
@@ -114,16 +116,27 @@ Item {
|
||||
font.pointSize: -1
|
||||
}
|
||||
|
||||
DebugConsole {
|
||||
id: debugConsole
|
||||
target: mainUI
|
||||
visible: false
|
||||
Audio {
|
||||
id: defaultNotificationSound
|
||||
|
||||
readonly property string sfx:
|
||||
window.settings.Notifications.default_sound
|
||||
|
||||
audioRole: Audio.NotificationRole
|
||||
volume: window.settings.Notifications.volume / 100
|
||||
source: sfx.trim() === "default.wav" ? "../sounds/default.wav" : sfx
|
||||
}
|
||||
|
||||
IdleManager {
|
||||
id: idleManager
|
||||
}
|
||||
|
||||
DebugConsole {
|
||||
id: debugConsole
|
||||
target: mainUI
|
||||
visible: false
|
||||
}
|
||||
|
||||
LinearGradient {
|
||||
id: mainUIGradient
|
||||
visible: ! image.visible
|
||||
|
BIN
src/sounds/default.wav
Normal file
BIN
src/sounds/default.wav
Normal file
Binary file not shown.
Reference in New Issue
Block a user