You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kf5-knotifications/knotifications-review127830...

38 lines
1.8 KiB

diff --git a/src/notifybyaudio.cpp b/src/notifybyaudio.cpp
index 6ae63b8df8e7aa692e88b03ca7b7538c78101917..903e9969895af543c9ef56b39c88b3072c1a099b 100644
--- a/src/notifybyaudio.cpp
+++ b/src/notifybyaudio.cpp
@@ -60,16 +60,23 @@ void NotifyByAudio::notify(KNotification *notification, KNotifyConfig *config)
return;
}
- QUrl soundURL = QUrl(soundFilename); // this CTOR accepts both absolute paths (/usr/share/sounds/blabla.ogg and blabla.ogg) w/o screwing the scheme
- if (soundURL.isRelative() && !soundURL.toString().startsWith('/')) { // QUrl considers url.scheme.isEmpty() == url.isRelative()
- soundURL = QUrl::fromLocalFile(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("sounds/") + soundFilename));
-
- if (soundURL.isEmpty()) {
- qCWarning(LOG_KNOTIFICATIONS) << "Audio notification requested, but sound file from notifyrc file was not found, aborting audio notification";
-
- finish(notification);
- return;
+ QUrl soundURL;
+ const auto dataLocations = QStandardPaths::standardLocations(QStandardPaths::GenericDataLocation);
+ foreach (const QString &dataLocation, dataLocations) {
+ soundURL = QUrl::fromUserInput(soundFilename,
+ dataLocation + "/sounds",
+ QUrl::AssumeLocalFile);
+ if (soundURL.isLocalFile() && QFile::exists(soundURL.toLocalFile())) {
+ break;
+ } else if (!soundURL.isLocalFile() && soundURL.isValid()) {
+ break;
}
+ soundURL.clear();
+ }
+ if (soundURL.isEmpty()) {
+ qCWarning(LOG_KNOTIFICATIONS) << "Audio notification requested, but sound file from notifyrc file was not found, aborting audio notification";
+ finish(notification);
+ return;
}
Phonon::MediaObject *m;