always display picture in compact view, possibly replacing missing picture by placeholder

This commit is contained in:
csoler 2020-10-03 17:56:24 +02:00
parent 780ffe3504
commit 5e3dab62fd

View File

@ -353,28 +353,26 @@ void BoardPostDisplayWidget_compact::setup()
} }
else else
{ {
if(mPost.mImage.mData != NULL) if(mPost.mImage.mData != NULL)
{ {
QPixmap pixmap; QPixmap pixmap;
GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL);
// Wiping data - as its been passed to thumbnail. // Wiping data - as its been passed to thumbnail.
#ifdef DEBUG_BOARDPOSTDISPLAYWIDGET #ifdef DEBUG_BOARDPOSTDISPLAYWIDGET
std::cerr << "Got pixmap of size " << pixmap.width() << " x " << pixmap.height() << std::endl; std::cerr << "Got pixmap of size " << pixmap.width() << " x " << pixmap.height() << std::endl;
std::cerr << "Saving to pix.png" << std::endl; std::cerr << "Saving to pix.png" << std::endl;
pixmap.save("pix.png","PNG"); pixmap.save("pix.png","PNG");
#endif #endif
int desired_height = QFontMetricsF(font()).height() * 5; int desired_height = QFontMetricsF(font()).height() * 5;
ui->pictureLabel->setFixedSize(16/9.0*desired_height,desired_height); ui->pictureLabel->setFixedSize(16/9.0*desired_height,desired_height);
ui->pictureLabel->setPicture(pixmap); ui->pictureLabel->setPicture(pixmap);
}
else if (mPost.mImage.mData == NULL)
ui->pictureLabel->hide();
else
ui->pictureLabel->show();
} }
else
ui->pictureLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png") );
}
ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS)); ui->notes->setText(RsHtml().formatText(NULL, QString::fromUtf8(mPost.mNotes.c_str()), RSHTML_FORMATTEXT_EMBED_SMILEYS | RSHTML_FORMATTEXT_EMBED_LINKS));
@ -487,11 +485,11 @@ void BoardPostDisplayWidget_card::setup()
}else{ }else{
ui->pictureLabel->setPixmap(pixmap); ui->pictureLabel->setPixmap(pixmap);
} }
ui->pictureLabel->show();
} }
else if (mPost.mImage.mData == NULL)
pictureLabel()->hide();
else else
pictureLabel()->show(); ui->pictureLabel->hide();
QTextDocument doc; QTextDocument doc;
doc.setHtml(notes()->text()); doc.setHtml(notes()->text());