diff options
-rw-r--r-- | src/plugins/imageviewer/ImageViewer.mimetypes.xml | 9 | ||||
-rw-r--r-- | src/plugins/imageviewer/imageviewer.qrc | 1 | ||||
-rw-r--r-- | src/plugins/imageviewer/imageviewerfactory.cpp | 29 | ||||
-rw-r--r-- | src/plugins/imageviewer/imageviewerplugin.cpp | 3 |
4 files changed, 20 insertions, 22 deletions
diff --git a/src/plugins/imageviewer/ImageViewer.mimetypes.xml b/src/plugins/imageviewer/ImageViewer.mimetypes.xml new file mode 100644 index 0000000000..499b38acb4 --- /dev/null +++ b/src/plugins/imageviewer/ImageViewer.mimetypes.xml @@ -0,0 +1,9 @@ +<?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> diff --git a/src/plugins/imageviewer/imageviewer.qrc b/src/plugins/imageviewer/imageviewer.qrc index 94f8b07631..662722baf7 100644 --- a/src/plugins/imageviewer/imageviewer.qrc +++ b/src/plugins/imageviewer/imageviewer.qrc @@ -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> diff --git a/src/plugins/imageviewer/imageviewerfactory.cpp b/src/plugins/imageviewer/imageviewerfactory.cpp index 1746cb3ac9..06009c49b3 100644 --- a/src/plugins/imageviewer/imageviewerfactory.cpp +++ b/src/plugins/imageviewer/imageviewerfactory.cpp @@ -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() diff --git a/src/plugins/imageviewer/imageviewerplugin.cpp b/src/plugins/imageviewer/imageviewerplugin.cpp index 20a1cfcf43..dc72bd0553 100644 --- a/src/plugins/imageviewer/imageviewerplugin.cpp +++ b/src/plugins/imageviewer/imageviewerplugin.cpp @@ -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; |