restore PostedItem class

This commit is contained in:
defnax 2026-01-15 17:41:10 +01:00
parent 2a4ac83406
commit 82b62742ae

View File

@ -22,11 +22,9 @@
#include <QMenu>
#include <QStyle>
#include <QTextDocument>
#include <QMovie>
#include "rshare.h"
#include "PostedItem.h"
#include "BoardPostImageHelper.h"
#include "gui/feeds/FeedHolder.h"
#include "gui/RetroShareLink.h"
#include "gui/gxs/GxsIdDetails.h"
@ -572,45 +570,21 @@ void PostedItem::fill()
if(mPost.mImage.mData != NULL)
{
QString format;
if (BoardPostImageHelper::isAnimatedImage(mPost.mImage.mData, mPost.mImage.mSize, &format))
{
// Animated GIF/WEBP - use QMovie
QMovie* movie = BoardPostImageHelper::createMovieFromData(mPost.mImage.mData, mPost.mImage.mSize);
if (movie)
{
movie->setParent(ui->pictureLabel); // Ensure cleanup
ui->pictureLabel->setMovie(movie);
movie->start();
// Loop animation when finished
connect(movie, &QMovie::finished, movie, &QMovie::start);
// Use first frame for thumbnail (ensure it's loaded first)
movie->jumpToFrame(0);
QPixmap firstFrame = movie->currentPixmap();
if (!firstFrame.isNull())
ui->thumbnailLabel->setPicture(firstFrame);
}
}
else
{
// Static image - use QPixmap
QPixmap pixmap;
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
ui->pictureLabel->setPicture(pixmap);
// Set thumbnail
ui->thumbnailLabel->setPicture(pixmap);
// Scale for pictureLabel if needed
if(pixmap.width() > 800){
QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation);
ui->pictureLabel->setPixmap(scaledpixmap);
}else
ui->pictureLabel->setPixmap(pixmap);
}
QPixmap pixmap;
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
// Wiping data - as its been passed to thumbnail.
// QPixmap sqpixmap = pixmap.scaled(desired_width,desired_height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
ui->thumbnailLabel->setPicture(pixmap);
ui->thumbnailLabel->setToolTip(tr("Click to view Picture"));
ui->thumbnailLabel->setEnableZoom(false);
QPixmap scaledpixmap;
if(pixmap.width() > 800){
QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation);
ui->pictureLabel->setPixmap(scaledpixmap);
}else
ui->pictureLabel->setPixmap(pixmap);
}
else if (urlOkay && (mPost.mImage.mData == NULL))
{