mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-14 05:07:10 +02:00
Add support for sound-file notification hint on Linux
This commit is contained in:
parent
2b94cffe7e
commit
46cf7db242
1 changed files with 21 additions and 14 deletions
|
@ -192,7 +192,7 @@ private:
|
|||
const not_null<Manager*> _manager;
|
||||
NotificationId _id;
|
||||
|
||||
//Media::Audio::LocalDiskCache _sounds;
|
||||
Media::Audio::LocalDiskCache _sounds;
|
||||
|
||||
Gio::Application _application;
|
||||
Gio::Notification _notification;
|
||||
|
@ -222,7 +222,7 @@ NotificationData::NotificationData(
|
|||
NotificationId id)
|
||||
: _manager(manager)
|
||||
, _id(id)
|
||||
//, _sounds(cWorkingDir() + u"tdata/audio_cache"_q)
|
||||
, _sounds(cWorkingDir() + u"tdata/audio_cache"_q)
|
||||
, _application(UseGNotification()
|
||||
? Gio::Application::get_default()
|
||||
: nullptr)
|
||||
|
@ -236,8 +236,7 @@ NotificationData::NotificationData(
|
|||
bool NotificationData::init(const Info &info) {
|
||||
const auto &title = info.title;
|
||||
const auto &subtitle = info.subtitle;
|
||||
//const auto sound = info.sound ? info.sound() : Media::Audio::LocalSound();
|
||||
//const auto path = sound ? _sounds.path(sound) : QString();
|
||||
|
||||
if (_application) {
|
||||
_notification = Gio::Notification::new_(
|
||||
subtitle.isEmpty()
|
||||
|
@ -365,18 +364,23 @@ bool NotificationData::init(const Info &info) {
|
|||
_hints.insert_value("action-icons", GLib::Variant::new_boolean(true));
|
||||
}
|
||||
|
||||
// suppress system sound if telegram sound activated,
|
||||
// otherwise use system sound
|
||||
if (HasCapability("sound")) {
|
||||
if (Core::App().settings().soundNotify()) {
|
||||
const auto sound = info.sound
|
||||
? info.sound()
|
||||
: Media::Audio::LocalSound();
|
||||
|
||||
const auto path = sound
|
||||
? _sounds.path(sound).toStdString()
|
||||
: std::string();
|
||||
|
||||
if (!path.empty()) {
|
||||
_hints.insert_value(
|
||||
"sound-file",
|
||||
GLib::Variant::new_string(path));
|
||||
} else {
|
||||
_hints.insert_value(
|
||||
"suppress-sound",
|
||||
GLib::Variant::new_boolean(true));
|
||||
} else {
|
||||
// sound name according to http://0pointer.de/public/sound-naming-spec.html
|
||||
_hints.insert_value(
|
||||
"sound-name",
|
||||
GLib::Variant::new_string("message-new-instant"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -624,8 +628,9 @@ bool ByDefault() {
|
|||
"actions",
|
||||
// To have quick reply
|
||||
"inline-reply",
|
||||
}, HasCapability) && ranges::any_of(std::array{
|
||||
// To not to play sound with Don't Disturb activated
|
||||
// (no, using sound capability is not a way)
|
||||
"sound",
|
||||
"inhibitions",
|
||||
}, HasCapability);
|
||||
}
|
||||
|
@ -963,7 +968,9 @@ bool Manager::doSkipToast() const {
|
|||
}
|
||||
|
||||
void Manager::doMaybePlaySound(Fn<void()> playSound) {
|
||||
_private->invokeIfNotInhibited(std::move(playSound));
|
||||
if (UseGNotification() || !HasCapability("sound")) {
|
||||
_private->invokeIfNotInhibited(std::move(playSound));
|
||||
}
|
||||
}
|
||||
|
||||
void Manager::doMaybeFlashBounce(Fn<void()> flashBounce) {
|
||||
|
|
Loading…
Add table
Reference in a new issue