Commit 4514dbfd authored by Alessandro Portale's avatar Alessandro Portale Committed by hjk

ImageViewer: Add up-to-date mimetypes (and add webp mimetype)

The list of mimetypes was missing new types like tga, dds and webp.
Just ask QImageReader::supportedMimeTypes() for the supported types,
which is also easier to maintain.

Task-number: QTBUG-45061
Change-Id: I80573da868088915b8d746c56374786e5e36903c
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
Reviewed-by: default avatarEike Ziller <eike.ziller@theqtcompany.com>
parent ec9f3ee7
<?xml version="1.0"?>
<mime-info xmlns='http://www.freedesktop.org/standards/shared-mime-info'>
<mime-type type="image/webp">
<comment>WebP Image file</comment>
<glob pattern="*.webp"/>
</mime-type>
</mime-info>
......@@ -8,5 +8,6 @@
<file>images/background.png</file>
<file>images/pause-small.png</file>
<file>images/play-small.png</file>
<file>ImageViewer.mimetypes.xml</file>
</qresource>
</RCC>
......@@ -47,29 +47,14 @@ ImageViewerFactory::ImageViewerFactory(QObject *parent) :
setId(Constants::IMAGEVIEWER_ID);
setDisplayName(qApp->translate("OpenWith::Editors", Constants::IMAGEVIEWER_DISPLAY_NAME));
QMap<QByteArray, const char *> possibleMimeTypes;
possibleMimeTypes.insert("bmp", "image/bmp");
possibleMimeTypes.insert("gif", "image/gif");
possibleMimeTypes.insert("ico", "image/x-icon");
possibleMimeTypes.insert("jpeg","image/jpeg");
possibleMimeTypes.insert("jpg", "image/jpeg");
possibleMimeTypes.insert("mng", "video/x-mng");
possibleMimeTypes.insert("pbm", "image/x-portable-bitmap");
possibleMimeTypes.insert("pgm", "image/x-portable-graymap");
possibleMimeTypes.insert("png", "image/png");
possibleMimeTypes.insert("ppm", "image/x-portable-pixmap");
possibleMimeTypes.insert("svg", "image/svg+xml");
possibleMimeTypes.insert("tif", "image/tiff");
possibleMimeTypes.insert("tiff","image/tiff");
possibleMimeTypes.insert("xbm", "image/xbm");
possibleMimeTypes.insert("xpm", "image/xpm");
const QList<QByteArray> supportedMimeTypes = QImageReader::supportedMimeTypes();
foreach (const QByteArray &format, supportedMimeTypes)
addMimeType(format.constData());
QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
foreach (const QByteArray &format, supportedFormats) {
const char *value = possibleMimeTypes.value(format);
if (value)
addMimeType(value);
}
#if (QT_VERSION < QT_VERSION_CHECK(5, 5, 0)) && !QT_NO_SVGRENDERER
// Workaround for https://codereview.qt-project.org/108693
addMimeType("image/svg+xml");
#endif
}
Core::IEditor *ImageViewerFactory::createEditor()
......
......@@ -38,6 +38,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/id.h>
#include <extensionsystem/pluginmanager.h>
#include <utils/mimetypes/mimedatabase.h>
namespace ImageViewer {
namespace Internal {
......@@ -49,6 +50,8 @@ bool ImageViewerPlugin::initialize(const QStringList &arguments, QString *errorM
Q_UNUSED(arguments)
Q_UNUSED(errorMessage)
Utils::MimeDatabase::addMimeTypes(QLatin1String(":/imageviewer/ImageViewer.mimetypes.xml"));
m_factory = new ImageViewerFactory(this);
addAutoReleasedObject(m_factory);
return true;
......
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