diff --git a/docs/TODO.md b/docs/TODO.md index 4da208f7..dc38123c 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -1,16 +1,18 @@ # TODO -- custom action - sfx selection +- custom action + +- fix spinbox buttons - combo box custom item - 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 - import/export/json edit rules? -- fix flickable popups can't be flicked by keyboard - room selector for room rules - validate json for unknown action/condition -- seen tooltips can't be shown on image hover - PCN docstrings - PCN error handling @@ -19,8 +21,6 @@ - Implement fallback QML notifications, usable if dbus isn't available - 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 - Fix right margin of own `\n` messages - warn on ambiguously activated shortcut diff --git a/mirage.pro b/mirage.pro index 2febc543..ae91489f 100644 --- a/mirage.pro +++ b/mirage.pro @@ -112,7 +112,7 @@ QMAKE_CLEAN *= packaging/flatpak/flatpak-pip.json .flatpak-builder # Generate resource file 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 += '' file_content += '' diff --git a/src/config/settings.py b/src/config/settings.py index ab5d33da..96da9cde 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -56,6 +56,14 @@ class Notifications: # keep seeing raw 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. diff --git a/src/gui/PythonBridge/EventHandlers.qml b/src/gui/PythonBridge/EventHandlers.qml index 626aafd7..a8d5aaf6 100644 --- a/src/gui/PythonBridge/EventHandlers.qml +++ b/src/gui/PythonBridge/EventHandlers.qml @@ -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 ? diff --git a/src/gui/UI.qml b/src/gui/UI.qml index 8d824214..03cc89c6 100644 --- a/src/gui/UI.qml +++ b/src/gui/UI.qml @@ -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 diff --git a/src/sounds/default.wav b/src/sounds/default.wav new file mode 100644 index 00000000..7e2abdd8 Binary files /dev/null and b/src/sounds/default.wav differ