Add support for notification sound effects

This commit is contained in:
miruka 2021-02-28 13:59:36 -04:00
parent 1b0bec3470
commit 99325fde86
6 changed files with 37 additions and 11 deletions

View File

@ -1,16 +1,18 @@
# TODO # TODO
- custom action
- sfx selection - sfx selection
- custom action
- fix spinbox buttons
- combo box custom item - combo box custom item
- explain pattern - explain pattern
- fix spinbox buttons - fix flickable popups can't be flicked by keyboard
- seen tooltips can't be shown on image hover
- quick settings - quick settings
- import/export/json edit rules? - import/export/json edit rules?
- fix flickable popups can't be flicked by keyboard
- room selector for room rules - room selector for room rules
- validate json for unknown action/condition - validate json for unknown action/condition
- seen tooltips can't be shown on image hover
- PCN docstrings - PCN docstrings
- PCN error handling - PCN error handling
@ -19,8 +21,6 @@
- Implement fallback QML notifications, usable if dbus isn't available - Implement fallback QML notifications, usable if dbus isn't available
- add http_proxy support - add http_proxy support
- image viewer: can't expand image in reduced window layout
- Encrypted rooms don't show invites in member list after Mirage restart
- Room display name not updated when someone removes theirs - Room display name not updated when someone removes theirs
- Fix right margin of own `<image url>\n<image url>` messages - Fix right margin of own `<image url>\n<image url>` messages
- warn on ambiguously activated shortcut - warn on ambiguously activated shortcut

View File

@ -112,7 +112,7 @@ QMAKE_CLEAN *= packaging/flatpak/flatpak-pip.json .flatpak-builder
# Generate resource file # Generate resource file
RESOURCE_FILES *= $$glob_filenames(qmldir, *.qml, *.qpl, *.js, *.py) RESOURCE_FILES *= $$glob_filenames(qmldir, *.qml, *.qpl, *.js, *.py)
RESOURCE_FILES *= $$glob_filenames( *.jpg, *.jpeg, *.png, *.svg) RESOURCE_FILES *= $$glob_filenames( *.jpg, *.jpeg, *.png, *.svg, *.wav)
file_content += '<!-- vim: set ft=xml : -->' file_content += '<!-- vim: set ft=xml : -->'
file_content += '<!DOCTYPE RCC>' file_content += '<!DOCTYPE RCC>'

View File

@ -56,6 +56,14 @@ class Notifications:
# keep seeing raw <tags> in notifications. # keep seeing raw <tags> in notifications.
use_html: bool = True 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 # 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 # a new message, which matches a notification push rule with a
# flash (lightbulb) action, is posted in a room. # flash (lightbulb) action, is posted in a room.

View File

@ -26,6 +26,11 @@ QtObject {
if (bubble) if (bubble)
py.callCoro("desktop_notify", [title, body, image]) py.callCoro("desktop_notify", [title, body, image])
if (sound) {
window.mainUI.defaultNotificationSound.seek(0)
window.mainUI.defaultNotificationSound.play()
}
if (urgencyHint) { if (urgencyHint) {
const msec = const msec =
critical ? critical ?

View File

@ -6,6 +6,7 @@ import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12 import QtQuick.Layouts 1.12
import QtQuick.Window 2.12 import QtQuick.Window 2.12
import QtGraphicalEffects 1.12 import QtGraphicalEffects 1.12
import QtMultimedia 5.12
import "." import "."
import "Base" import "Base"
import "MainPane" import "MainPane"
@ -35,6 +36,7 @@ Item {
return ids return ids
} }
readonly property alias defaultNotificationSound: defaultNotificationSound
readonly property alias debugConsole: debugConsole readonly property alias debugConsole: debugConsole
readonly property alias mainPane: mainPane readonly property alias mainPane: mainPane
readonly property alias pageLoader: pageLoader readonly property alias pageLoader: pageLoader
@ -114,16 +116,27 @@ Item {
font.pointSize: -1 font.pointSize: -1
} }
DebugConsole { Audio {
id: debugConsole id: defaultNotificationSound
target: mainUI
visible: false 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 { IdleManager {
id: idleManager id: idleManager
} }
DebugConsole {
id: debugConsole
target: mainUI
visible: false
}
LinearGradient { LinearGradient {
id: mainUIGradient id: mainUIGradient
visible: ! image.visible visible: ! image.visible

BIN
src/sounds/default.wav Normal file

Binary file not shown.