Commit b5ec972b authored by Ralf Habacker's avatar Ralf Habacker

Cleanup of mime type detection when exporting bitmaps.

The usage of KDE4's KFileDialog::currentMimeFilter() is broken,
because it returns a list of the currently selected file type.
In the opposite the code expects a single mime type of the selected file.

BUG:316095
FIXED-IN:4.11.3
parent bcb2e07e
......@@ -91,18 +91,15 @@ void UMLFileDialog::setMimeFilter(const QStringList &types, const QString &defau
m_dialog->setFilter(filters.join(QLatin1String("\n")));
}
/**
* @brief return the mime type of the selected file
* @return mime type string
*/
QString UMLFileDialog::currentMimeFilter()
{
QString currentFilter = m_dialog->currentFilter();
#ifdef Q_OS_WIN
// using native KFileDialog returns empty filter, so we need a workaround
if (currentFilter.isEmpty()) {
KUrl url = m_dialog->selectedUrl();
QFileInfo fi(url.toLocalFile());
return UMLViewImageExporterModel::imageTypeToMimeType(fi.suffix());
}
#endif
return UMLViewImageExporterModel::imageTypeToMimeType(currentFilter.remove("*."));
KUrl url = m_dialog->selectedUrl();
QFileInfo fi(url.toLocalFile());
return UMLViewImageExporterModel::imageTypeToMimeType(fi.suffix());
}
#include "umlfiledialog.moc"
......@@ -142,14 +142,6 @@ bool UMLViewImageExporter::getParametersFromUser()
m_imageMimeType = dialog->currentMimeFilter();
UMLApp::app()->setImageMimeType(m_imageMimeType);
m_imageURL = dialog->selectedUrl();
// check if the extension is the extension of the mime type
QFileInfo info(m_imageURL.fileName());
QString ext = info.suffix();
QString extDef = UMLViewImageExporterModel::mimeTypeToImageType(m_imageMimeType);
if (ext != extDef) {
m_imageURL.setFileName(m_imageURL.fileName() + '.' + extDef);
}
}
delete dialog;
return success;
......
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