Skip to content

Commit

Permalink
Allow getting name or path for sound.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Jan 23, 2025
1 parent 2e74ad6 commit 2b94cff
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion Telegram/SourceFiles/media/audio/media_audio_local_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
}
Expand All @@ -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
1 change: 1 addition & 0 deletions Telegram/SourceFiles/media/audio/media_audio_local_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ void 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];
}
Expand Down

0 comments on commit 2b94cff

Please sign in to comment.