Skip to content

Commit

Permalink
fix file dialog extension handler, playlist export
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Feb 20, 2025
1 parent 0041a92 commit b0952cc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/util/file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <QRegExp> // required for 'indexIn(QString &str, int pos)
#include <QRegularExpression>

#include "util/assert.h"

namespace {

const QRegularExpression kExtractExtensionRegex(R"(\(\*\.(.*)\)$)");
Expand All @@ -27,11 +29,13 @@ QString filePathWithSelectedExtension(const QString& fileLocationInput,
// Extract 'ext' from QFileDialog file filter string 'Funky type (*.ext)'
const auto extMatch = kExtractExtensionRegex.match(selectedFileFilter);
const QString ext = extMatch.captured(1);
if (ext.isNull()) {
VERIFY_OR_DEBUG_ASSERT(!ext.isNull() && !ext.isEmpty()) {
return fileLocation;
}
const QFileInfo fileName(fileLocation);
if (!ext.isEmpty() && fileName.suffix() != ext) {
if (fileName.suffix().isEmpty()) {
fileLocation.append(".").append(ext);
} else if (fileName.suffix() != ext) {
// Check if fileLocation ends with any of the available extensions
int pos = 0;
// Extract all extensions from the filter list
Expand Down

0 comments on commit b0952cc

Please sign in to comment.