Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 524709e9 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Fix Save As feature

The filter format demanded by QFileDialog is different from KFileDialog.
Just use mime type filters instead.

Differential Revision: https://phabricator.kde.org/D8625
parent fb5b9a9a
......@@ -430,13 +430,23 @@ void KFindTreeView::copySelection()
void KFindTreeView::saveResults()
{
QString selectedFilter;
QUrl u = QFileDialog::getSaveFileUrl(this,
i18nc("@title:window", "Save Results As"),
QUrl(), QStringLiteral("*.html|%1\n*.txt|%2").arg(i18n("HTML page"), i18n("Text file")),
&selectedFilter);
QFileDialog dialog;
dialog.setAcceptMode(QFileDialog::AcceptSave);
dialog.setWindowTitle(i18nc("@title:window", "Save Results As"));
dialog.setMimeTypeFilters({
QStringLiteral("text/html"),
QStringLiteral("text/plain")
});
if (!dialog.exec()) {
return;
}
if (dialog.selectedUrls().isEmpty()) {
return;
}
const QUrl u = dialog.selectedUrls().constFirst();
if (!u.isValid() || !u.isLocalFile()) {
return;
}
......@@ -453,7 +463,7 @@ void KFindTreeView::saveResults()
stream.setCodec(QTextCodec::codecForLocale());
const QList<KFindItem> itemList = m_model->getItemList();
if (selectedFilter == QLatin1String("*.html")) {
if (dialog.selectedMimeTypeFilter() == QLatin1String("text/html")) {
stream << QString::fromLatin1("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\""
"\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\"><html xmlns=\"http://www.w3.org/1999/xhtml\">\n"
"<head>\n"
......
Markdown is supported
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