Commit e5814f40 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Fix code that tries to add extension if it's missing

BUGS: 444998
parent f0b88fb7
Pipeline #101102 skipped
......@@ -871,6 +871,16 @@ void KWordQuizApp::slotFileSaveAs()
slotStatusMsg(i18nc("@info:status ready", "Ready"));
}
static QString extractSuffixFromQtPattern(const QString &qtPattern)
{
static const QRegularExpression regexp(".*\\((.*)\\)");
const QRegularExpressionMatch match = regexp.match(qtPattern);
if (!match.hasMatch()) {
qWarning() << "extractSuffixesFromQtPattern regexp match failed" << qtPattern;
return { ".report_bug_please" };
}
return match.captured(1);
}
bool KWordQuizApp::saveDocAsFileName(KEduVocDocument *document)
{
......@@ -887,15 +897,16 @@ bool KWordQuizApp::saveDocAsFileName(KEduVocDocument *document)
if (fd->exec() == QDialog::Accepted) {
QUrl url = fd->selectedUrls().at(0);
if (!url.isEmpty()) {
QString chosenFilter = fd->selectedNameFilter();
const QString chosenQtFilter = fd->selectedNameFilter();
const QString chosenFilter = extractSuffixFromQtPattern(chosenQtFilter);
if (!url.fileName().contains('.')) {
qDebug() << "Selected name filter is " << chosenFilter;
qDebug() << "Selected name filter is " << chosenQtFilter << chosenFilter;
if (chosenFilter == QLatin1String("*.csv"))
url = QUrl(url.path().append(".csv"));
url.setPath(url.path().append(".csv"));
else if (chosenFilter == QLatin1String("*.kvtml"))
url = QUrl(url.path().append(".kvtml"));
url.setPath(url.path().append(".kvtml"));
else if (chosenFilter == QLatin1String("*.html"))
url = QUrl(url.path().append(".html"));
url.setPath(url.path().append(".html"));
}
if (chosenFilter == QLatin1String("*.html")) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment