fix: should show any animated image than just gif
This commit is contained in:
parent
52a7883dbf
commit
8ae93ac4ae
@ -48,7 +48,7 @@ void GraphicsScene::showSvg(const QString &filepath)
|
||||
this->setSceneRect(m_theThing->boundingRect());
|
||||
}
|
||||
|
||||
void GraphicsScene::showGif(const QString &filepath)
|
||||
void GraphicsScene::showAnimated(const QString &filepath)
|
||||
{
|
||||
this->clear();
|
||||
QMovie * movie = new QMovie(filepath);
|
||||
|
@ -13,7 +13,7 @@ public:
|
||||
void showImage(const QPixmap &pixmap);
|
||||
void showText(const QString &text);
|
||||
void showSvg(const QString &filepath);
|
||||
void showGif(const QString &filepath);
|
||||
void showAnimated(const QString &filepath);
|
||||
|
||||
bool trySetTransformationMode(Qt::TransformationMode mode);
|
||||
|
||||
|
@ -39,19 +39,20 @@ void GraphicsView::showFileFromPath(const QString &filePath, bool doRequestGalle
|
||||
|
||||
if (filePath.endsWith(".svg")) {
|
||||
showSvg(filePath);
|
||||
} else if (filePath.endsWith(".gif")) {
|
||||
showGif(filePath);
|
||||
} else {
|
||||
QImageReader imageReader(filePath);
|
||||
imageReader.setAutoTransform(true);
|
||||
imageReader.setDecideFormatFromContent(true);
|
||||
|
||||
// Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format.
|
||||
// So we cannot use imageFormat() and check if it returns QImage::Format_Invalid to detect if we support the file.
|
||||
// QImage::Format imageFormat = imageReader.imageFormat();
|
||||
if (imageReader.format().isEmpty()) {
|
||||
doRequestGallery = false;
|
||||
showText(tr("File is not a valid image"));
|
||||
} else if (!imageReader.supportsAnimation() && !imageReader.canRead()) {
|
||||
} else if (imageReader.supportsAnimation() && imageReader.imageCount() > 1) {
|
||||
showAnimated(filePath);
|
||||
} else if (!imageReader.canRead()) {
|
||||
doRequestGallery = false;
|
||||
showText(tr("Image data is invalid or currently unsupported"));
|
||||
} else {
|
||||
@ -98,10 +99,10 @@ void GraphicsView::showSvg(const QString &filepath)
|
||||
checkAndDoFitInView();
|
||||
}
|
||||
|
||||
void GraphicsView::showGif(const QString &filepath)
|
||||
void GraphicsView::showAnimated(const QString &filepath)
|
||||
{
|
||||
resetTransform();
|
||||
scene()->showGif(filepath);
|
||||
scene()->showAnimated(filepath);
|
||||
checkAndDoFitInView();
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ public:
|
||||
void showImage(const QImage &image);
|
||||
void showText(const QString &text);
|
||||
void showSvg(const QString &filepath);
|
||||
void showGif(const QString &filepath);
|
||||
void showAnimated(const QString &filepath);
|
||||
|
||||
GraphicsScene * scene() const;
|
||||
void setScene(GraphicsScene *scene);
|
||||
|
Loading…
Reference in New Issue
Block a user