mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-01 20:06:53 +01:00
Remove non-allowed characters in playlist filename when saving. (Fixes #5460)
This commit is contained in:
parent
f7eea6c505
commit
a034c2d4d0
@ -196,7 +196,7 @@ void PlaylistManager::ItemsLoadedForSavePlaylist(QFuture<SongList> future,
|
|||||||
parser_->Save(future.result(), filename, path_type);
|
parser_->Save(future.result(), filename, path_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlaylistManager::SaveWithUI(int id, const QString& suggested_filename) {
|
void PlaylistManager::SaveWithUI(int id, const QString& playlist_name) {
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup(Playlist::kSettingsGroup);
|
settings.beginGroup(Playlist::kSettingsGroup);
|
||||||
QString filename = settings.value("last_save_playlist").toString();
|
QString filename = settings.value("last_save_playlist").toString();
|
||||||
@ -205,10 +205,13 @@ void PlaylistManager::SaveWithUI(int id, const QString& suggested_filename) {
|
|||||||
QString filter =
|
QString filter =
|
||||||
settings.value("last_save_filter", parser()->default_filter()).toString();
|
settings.value("last_save_filter", parser()->default_filter()).toString();
|
||||||
|
|
||||||
|
QString suggested_filename = playlist_name;
|
||||||
|
suggested_filename.replace(QRegExp("\\W"), "");
|
||||||
|
|
||||||
qLog(Debug) << "Using extension:" << extension;
|
qLog(Debug) << "Using extension:" << extension;
|
||||||
|
|
||||||
// We want to use the playlist tab name as a default filename, but in the
|
// We want to use the playlist tab name (with disallowed characters removed)
|
||||||
// same directory as the last saved file.
|
// as a default filename, but in the same directory as the last saved file.
|
||||||
|
|
||||||
// Strip off filename components until we find something that's a folder
|
// Strip off filename components until we find something that's a folder
|
||||||
forever {
|
forever {
|
||||||
@ -237,11 +240,11 @@ void PlaylistManager::SaveWithUI(int id, const QString& suggested_filename) {
|
|||||||
QFileInfo info(filename);
|
QFileInfo info(filename);
|
||||||
ParserBase* parser = parser_->ParserForExtension(info.suffix());
|
ParserBase* parser = parser_->ParserForExtension(info.suffix());
|
||||||
if (!parser) {
|
if (!parser) {
|
||||||
qLog(Warning) << "Unknown file extension:" << info.suffix();
|
qLog(Warning) << "Unknown file extension:" << info.suffix();
|
||||||
filename = info.absolutePath() + "/" + info.fileName()
|
filename = info.absolutePath() + "/" + info.fileName() + "." +
|
||||||
+ "." + parser_->default_extension();
|
parser_->default_extension();
|
||||||
info.setFile(filename);
|
info.setFile(filename);
|
||||||
filter = info.suffix();
|
filter = info.suffix();
|
||||||
}
|
}
|
||||||
|
|
||||||
int p = settings.value(Playlist::kPathType, Playlist::Path_Automatic).toInt();
|
int p = settings.value(Playlist::kPathType, Playlist::Path_Automatic).toInt();
|
||||||
|
@ -184,7 +184,7 @@ class PlaylistManager : public PlaylistManagerInterface {
|
|||||||
void Load(const QString& filename);
|
void Load(const QString& filename);
|
||||||
void Save(int id, const QString& filename, Playlist::Path path_type);
|
void Save(int id, const QString& filename, Playlist::Path path_type);
|
||||||
// Display a file dialog to let user choose a file before saving the file
|
// Display a file dialog to let user choose a file before saving the file
|
||||||
void SaveWithUI(int id, const QString& suggested_filename);
|
void SaveWithUI(int id, const QString& playlist_name);
|
||||||
void Rename(int id, const QString& new_name);
|
void Rename(int id, const QString& new_name);
|
||||||
void Favorite(int id, bool favorite);
|
void Favorite(int id, bool favorite);
|
||||||
void Delete(int id);
|
void Delete(int id);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user