From da84914b7d5c39af23c3e54ff7745ce6e8c55fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=96mer=20Fad=C4=B1l=20Usta?= Date: Thu, 21 Apr 2022 13:16:40 +0000 Subject: [PATCH] Fix PlaySound with correct QUrl It was missing to use fromLocalFile BUG: 452591 --- .../findthisdevice/findthisdevice_config.cpp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/plugins/findthisdevice/findthisdevice_config.cpp b/plugins/findthisdevice/findthisdevice_config.cpp index d9a77a6b9..6971f7e07 100644 --- a/plugins/findthisdevice/findthisdevice_config.cpp +++ b/plugins/findthisdevice/findthisdevice_config.cpp @@ -74,16 +74,18 @@ void FindThisDeviceConfig::save() void FindThisDeviceConfig::playSound() { - const QString soundFile = m_ui->soundFileRequester->text(); - - QUrl soundURL = QUrl(soundFile); - QMediaPlayer* player = new QMediaPlayer; - player->setAudioRole(QAudio::Role(QAudio::NotificationRole)); - player->setMedia(soundURL); - player->setVolume(100); - player->play(); - connect(player, &QMediaPlayer::stateChanged, player, &QObject::deleteLater); + const QUrl soundURL = m_ui->soundFileRequester->url(); + if (soundURL.isEmpty()) { + qCWarning(KDECONNECT_PLUGIN_FINDTHISDEVICE) << "Not playing sound, no valid ring tone specified."; + } else { + QMediaPlayer* player = new QMediaPlayer; + player->setAudioRole(QAudio::Role(QAudio::NotificationRole)); + player->setMedia(soundURL); + player->setVolume(100); + player->play(); + connect(player, &QMediaPlayer::stateChanged, player, &QObject::deleteLater); + } }