okular: use KImageIO::typeForMime() to get the format for the image that is saved

much more reliable than assuming that the plugin to be used matches the
end of the mime type

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-08-08 18:01:24 +03:00
parent 233adf2643
commit 994a53cdbb

View file

@ -2505,12 +2505,14 @@ void PageView::mouseReleaseEvent( QMouseEvent * e )
else
{
KMimeType::Ptr mime = KMimeType::findByUrl( fileName );
QString type;
if ( !mime || mime == KMimeType::defaultMimeTypePtr() )
type = "PNG";
else
type = mime->name().section( '/', -1 ).toUpper();
copyPix.save( fileName, qPrintable( type ) );
QString type = QString::fromLatin1("PNG");
if ( mime && mime != KMimeType::defaultMimeTypePtr() ) {
const QString formatType = KImageIO::typeForMime(mime->name(), KImageIO::Writing);
if (!formatType.isEmpty()) {
type = formatType;
}
}
copyPix.save( fileName, type.toLatin1() );
d->messageWindow->display( i18n( "Image [%1x%2] saved to %3 file.", copyPix.width(), copyPix.height(), type ) );
}
}