Fix PlaySound with correct QUrl

It was missing to use fromLocalFile

BUG: 452591
This commit is contained in:
Ömer Fadıl Usta 2022-04-21 13:16:40 +00:00
parent 2dc5d53ec4
commit da84914b7d

View file

@ -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);
}
}