diff --git a/src/library/baseplaylistfeature.cpp b/src/library/baseplaylistfeature.cpp index b905f0285371..e48379a20e8b 100644 --- a/src/library/baseplaylistfeature.cpp +++ b/src/library/baseplaylistfeature.cpp @@ -469,23 +469,22 @@ void BasePlaylistFeature::slotExportPlaylist() { // Open a dialog to let the user choose the file location for playlist export. // The location is set to the last used directory for import/export and the file // name to the playlist name. - QString fileFilter = tr("M3U Playlist (*.m3u)"); - QString fileLocationInput = QFileDialog::getSaveFileName( - nullptr, + const QString fileLocation = checkedFilePathWithSelectedExtension( tr("Export Playlist"), - lastPlaylistDirectory.append("/").append(playlistName), + lastPlaylistDirectory.append("/").append(playlistName).append(".m3u"), tr("M3U Playlist (*.m3u);;M3U8 Playlist (*.m3u8);;" "PLS Playlist (*.pls);;Text CSV (*.csv);;Readable Text (*.txt)"), - &fileFilter); - QString fileLocation = filePathWithSelectedExtension(fileLocationInput, fileFilter); - // Exit method if user cancelled the open dialog. + tr("M3U Playlist (*.m3u)")); + // Exit method if the file name is empty because the user cancelled the save dialog. if (fileLocation.isEmpty()) { return; } - QFileInfo fileInfo(fileLocation); + // Update the import/export playlist directory + QString fileDirectory(fileLocation); + fileDirectory.truncate(fileLocation.lastIndexOf(QDir::separator())); m_pConfig->set(kConfigKeyLastImportExportPlaylistDirectory, - ConfigValue(fileInfo.dir().absolutePath())); + ConfigValue(fileDirectory)); // The user has picked a new directory via a file dialog. This means the // system sandboxer (if we are sandboxed) has granted us permission to this