Skip to content

Commit

Permalink
use QFileDialog helper for playlist export
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Dec 14, 2021
1 parent 06eae4c commit c14ccfd
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/library/baseplaylistfeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c14ccfd

Please sign in to comment.