Use QFileInfo::completeBaseName() instead of QFileInfo::baseName()

Fixes #550
This commit is contained in:
Jonas Kvinge 2020-09-29 17:30:21 +02:00
parent 5877aa822c
commit e22d463d11
4 changed files with 6 additions and 6 deletions

View File

@ -87,7 +87,7 @@ QStringList MoodbarLoader::MoodFilenames(const QString& song_filename) {
const QFileInfo file_info(song_filename);
const QString dir_path(file_info.dir().path());
const QString mood_filename = file_info.baseName() + ".mood";
const QString mood_filename = file_info.completeBaseName() + ".mood";
return QStringList() << dir_path + "/." + mood_filename << dir_path + "/" + mood_filename;

View File

@ -193,14 +193,14 @@ void PlaylistManager::Load(const QString &filename) {
QFileInfo info(filename);
int id = playlist_backend_->CreatePlaylist(info.baseName(), QString());
int id = playlist_backend_->CreatePlaylist(info.completeBaseName(), QString());
if (id == -1) {
emit Error(tr("Couldn't create playlist"));
return;
}
Playlist *playlist = AddPlaylist(id, info.baseName(), QString(), QString(), false);
Playlist *playlist = AddPlaylist(id, info.completeBaseName(), QString(), QString(), false);
QList<QUrl> urls;
playlist->InsertUrls(urls << QUrl::fromLocalFile(filename));

View File

@ -292,7 +292,7 @@ QString Transcoder::GetFile(const QString &input, const TranscoderPreset &preset
if (!fileinfo_output.isFile() || fileinfo_output.filePath().isEmpty() || fileinfo_output.path().isEmpty() || fileinfo_output.fileName().isEmpty() || fileinfo_output.suffix().isEmpty()) {
QFileInfo fileinfo_input(input);
QString filename = fileinfo_input.baseName() + "." + preset.extension_;
QString filename = fileinfo_input.completeBaseName() + "." + preset.extension_;
fileinfo_output.setFile(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/transcoder/" + filename);
QDir dir;
dir.mkdir(QStandardPaths::writableLocation(QStandardPaths::CacheLocation) + "/transcoder");
@ -301,7 +301,7 @@ QString Transcoder::GetFile(const QString &input, const TranscoderPreset &preset
// Never overwrite existing files
if (fileinfo_output.exists()) {
QString path = fileinfo_output.path();
QString filename = fileinfo_output.baseName();
QString filename = fileinfo_output.completeBaseName();
QString suffix = fileinfo_output.suffix();
for (int i = 0;; ++i) {
QString new_filename = QString("%1/%2-%3.%4").arg(path).arg(filename).arg(i).arg(suffix);

View File

@ -105,7 +105,7 @@ MimeData *FileViewList::MimeDataFromSelection() const {
mimedata->name_for_new_playlist_ = QDir(info.filePath()).dirName();
}
else {
mimedata->name_for_new_playlist_ = info.baseName();
mimedata->name_for_new_playlist_ = info.completeBaseName();
}
}
else {