Allow getting name or path for sound.

This commit is contained in:
John Preston 2025-01-23 12:13:01 +04:00
parent 2e74ad6fbe
commit 2b94cffe7e
3 changed files with 8 additions and 2 deletions

View file

@ -333,7 +333,7 @@ LocalDiskCache::LocalDiskCache(const QString &folder)
QDir().mkpath(_base);
}
QString LocalDiskCache::path(const LocalSound &sound) {
QString LocalDiskCache::name(const LocalSound &sound) {
if (!sound) {
return {};
}
@ -357,4 +357,9 @@ QString LocalDiskCache::path(const LocalSound &sound) {
return result;
}
QString LocalDiskCache::path(const LocalSound &sound) {
const auto part = name(sound);
return part.isEmpty() ? QString() : _base + part + u".wav"_q;
}
} // namespace Media::Audio

View file

@ -34,6 +34,7 @@ class LocalDiskCache final {
public:
explicit LocalDiskCache(const QString &folder);
[[nodiscard]] QString name(const LocalSound &sound);
[[nodiscard]] QString path(const LocalSound &sound);
private:

View file

@ -338,7 +338,7 @@ void Manager::Private::showNotification(
const auto sound = info.sound ? info.sound() : Media::Audio::LocalSound();
if (sound) {
[notification setSoundName:Q2NSString(_sounds.path(sound))];
[notification setSoundName:Q2NSString(_sounds.name(sound))];
} else {
[notification setSoundName:nil];
}