Commit 16f85088 authored by Méven Car's avatar Méven Car

MimeUtils: fix warnings for missing mime types

Previously when opening the open dialog you'd have the warnings:
kf.kio.filewidgets.kfilefiltercombo: "" is not a valid mimeType
kf.kio.filewidgets.kfilefiltercombo: "image/x-nikon-nrw" is not a valid mimeType
kf.kio.filewidgets.kfilefiltercombo: "image/x-samsung-srw" is not a valid mimeType
kf.kio.filewidgets.kfilefiltercombo: "" is not a valid mimeType
kf.kio.filewidgets.kfilefiltercombo: "image/x-nikon-nrw" is not a valid mimeType
kf.kio.filewidgets.kfilefiltercombo: "image/x-samsung-srw" is not a valid mimeType

After this patch you have :
org.kde.kdegraphics.gwenview.lib: Unresolved mime type  "image/x-mng"
org.kde.kdegraphics.gwenview.lib: Unresolved raw mime type  "image/x-nikon-nrw"
org.kde.kdegraphics.gwenview.lib: Unresolved raw mime type  "image/x-samsung-srw"
parent 8fbf2ab1
......@@ -63,26 +63,28 @@ static void resolveAliasInList(QStringList* list)
}
}
static void addRawMimeTypes(QStringList* list)
static inline QStringList rawMimeTypes()
{
// need to invent more intelligent way to whitelist raws
*list += QStringLiteral("image/x-nikon-nef");
*list += QStringLiteral("image/x-nikon-nrw");
*list += QStringLiteral("image/x-canon-cr2");
*list += QStringLiteral("image/x-canon-crw");
*list += QStringLiteral("image/x-pentax-pef");
*list += QStringLiteral("image/x-adobe-dng");
*list += QStringLiteral("image/x-sony-arw");
*list += QStringLiteral("image/x-minolta-mrw");
*list += QStringLiteral("image/x-panasonic-raw");
*list += QStringLiteral("image/x-panasonic-raw2");
*list += QStringLiteral("image/x-panasonic-rw");
*list += QStringLiteral("image/x-panasonic-rw2");
*list += QStringLiteral("image/x-samsung-srw");
*list += QStringLiteral("image/x-olympus-orf");
*list += QStringLiteral("image/x-fuji-raf");
*list += QStringLiteral("image/x-kodak-dcr");
*list += QStringLiteral("image/x-sigma-x3f");
return {
QStringLiteral("image/x-nikon-nef"),
QStringLiteral("image/x-nikon-nrw"),
QStringLiteral("image/x-canon-cr2"),
QStringLiteral("image/x-canon-crw"),
QStringLiteral("image/x-pentax-pef"),
QStringLiteral("image/x-adobe-dng"),
QStringLiteral("image/x-sony-arw"),
QStringLiteral("image/x-minolta-mrw"),
QStringLiteral("image/x-panasonic-raw"),
QStringLiteral("image/x-panasonic-raw2"),
QStringLiteral("image/x-panasonic-rw"),
QStringLiteral("image/x-panasonic-rw2"),
QStringLiteral("image/x-samsung-srw"),
QStringLiteral("image/x-olympus-orf"),
QStringLiteral("image/x-fuji-raf"),
QStringLiteral("image/x-kodak-dcr"),
QStringLiteral("image/x-sigma-x3f")
};
}
const QStringList& rasterImageMimeTypes()
......@@ -91,14 +93,26 @@ const QStringList& rasterImageMimeTypes()
if (list.isEmpty()) {
const auto supported = QImageReader::supportedMimeTypes();
for (const auto &mime: supported) {
list << resolveAlias(QString::fromUtf8(mime));
const auto resolved = resolveAlias(QString::fromUtf8(mime));
if (resolved.isEmpty()) {
qCWarning(GWENVIEW_LIB_LOG) << "Unresolved mime type " << mime;
} else {
list << resolved;
}
}
// We don't want svg images to be considered as raster images
const QStringList svgImageMimeTypesList = svgImageMimeTypes();
for (const QString& mimeType : svgImageMimeTypesList) {
list.removeOne(mimeType);
}
addRawMimeTypes(&list);
for (const QString &rawMimetype : rawMimeTypes()) {
const auto resolved = resolveAlias(rawMimetype);
if (resolved.isEmpty()) {
qCWarning(GWENVIEW_LIB_LOG) << "Unresolved raw mime type " << rawMimetype;
} else {
list << resolved;
}
}
}
return list;
}
......
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