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());
|
this->setSceneRect(m_theThing->boundingRect());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsScene::showGif(const QString &filepath)
|
void GraphicsScene::showAnimated(const QString &filepath)
|
||||||
{
|
{
|
||||||
this->clear();
|
this->clear();
|
||||||
QMovie * movie = new QMovie(filepath);
|
QMovie * movie = new QMovie(filepath);
|
||||||
|
@ -13,7 +13,7 @@ public:
|
|||||||
void showImage(const QPixmap &pixmap);
|
void showImage(const QPixmap &pixmap);
|
||||||
void showText(const QString &text);
|
void showText(const QString &text);
|
||||||
void showSvg(const QString &filepath);
|
void showSvg(const QString &filepath);
|
||||||
void showGif(const QString &filepath);
|
void showAnimated(const QString &filepath);
|
||||||
|
|
||||||
bool trySetTransformationMode(Qt::TransformationMode mode);
|
bool trySetTransformationMode(Qt::TransformationMode mode);
|
||||||
|
|
||||||
|
@ -39,19 +39,20 @@ void GraphicsView::showFileFromPath(const QString &filePath, bool doRequestGalle
|
|||||||
|
|
||||||
if (filePath.endsWith(".svg")) {
|
if (filePath.endsWith(".svg")) {
|
||||||
showSvg(filePath);
|
showSvg(filePath);
|
||||||
} else if (filePath.endsWith(".gif")) {
|
|
||||||
showGif(filePath);
|
|
||||||
} else {
|
} else {
|
||||||
QImageReader imageReader(filePath);
|
QImageReader imageReader(filePath);
|
||||||
imageReader.setAutoTransform(true);
|
imageReader.setAutoTransform(true);
|
||||||
imageReader.setDecideFormatFromContent(true);
|
imageReader.setDecideFormatFromContent(true);
|
||||||
|
|
||||||
// Since if the image format / plugin does not support this feature, imageFormat() will returns an invalid format.
|
// 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.
|
// 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();
|
// QImage::Format imageFormat = imageReader.imageFormat();
|
||||||
if (imageReader.format().isEmpty()) {
|
if (imageReader.format().isEmpty()) {
|
||||||
doRequestGallery = false;
|
doRequestGallery = false;
|
||||||
showText(tr("File is not a valid image"));
|
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;
|
doRequestGallery = false;
|
||||||
showText(tr("Image data is invalid or currently unsupported"));
|
showText(tr("Image data is invalid or currently unsupported"));
|
||||||
} else {
|
} else {
|
||||||
@ -98,10 +99,10 @@ void GraphicsView::showSvg(const QString &filepath)
|
|||||||
checkAndDoFitInView();
|
checkAndDoFitInView();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphicsView::showGif(const QString &filepath)
|
void GraphicsView::showAnimated(const QString &filepath)
|
||||||
{
|
{
|
||||||
resetTransform();
|
resetTransform();
|
||||||
scene()->showGif(filepath);
|
scene()->showAnimated(filepath);
|
||||||
checkAndDoFitInView();
|
checkAndDoFitInView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public:
|
|||||||
void showImage(const QImage &image);
|
void showImage(const QImage &image);
|
||||||
void showText(const QString &text);
|
void showText(const QString &text);
|
||||||
void showSvg(const QString &filepath);
|
void showSvg(const QString &filepath);
|
||||||
void showGif(const QString &filepath);
|
void showAnimated(const QString &filepath);
|
||||||
|
|
||||||
GraphicsScene * scene() const;
|
GraphicsScene * scene() const;
|
||||||
void setScene(GraphicsScene *scene);
|
void setScene(GraphicsScene *scene);
|
||||||
|
Loading…
Reference in New Issue
Block a user