fixed aspect ratio

This commit is contained in:
csoler 2019-03-28 22:57:56 +01:00
parent fcee6d3f63
commit c4463ad5ba
No known key found for this signature in database
GPG Key ID: 7BCA522266C0804C
2 changed files with 8 additions and 10 deletions

View File

@ -246,27 +246,25 @@ void PostedItem::fill()
return;
}
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");
mInFill = true;
int desired_height = ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height();
int desired_height = 1.5*(ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height());
int desired_width = sqpixmap2.width()*desired_height/(float)sqpixmap2.height();
if(mPost.mImage.mData != NULL)
{
QPixmap pixmap;
pixmap.loadFromData(mPost.mImage.mData, mPost.mImage.mSize, "PNG");
// Wiping data - as its been passed to thumbnail.
QPixmap sqpixmap = pixmap.scaled(10*desired_height,1.5*desired_height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui->thumbnailLabel->setMaximumSize(sqpixmap.size());
QPixmap sqpixmap = pixmap.scaled(desired_width,desired_height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
ui->thumbnailLabel->setPixmap(sqpixmap);
ui->pictureLabel->setPixmap(pixmap);
std::cerr << "new size=" << desired_height << " " << sqpixmap.width() << " " << sqpixmap.height() << std::endl;
}
else
{
QPixmap sqpixmap = QPixmap(":/images/thumb-default.png").scaled(10*desired_height,1.5*desired_height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
ui->thumbnailLabel->setMaximumSize(sqpixmap.size());
ui->thumbnailLabel->setPixmap(sqpixmap);
ui->thumbnailLabel->setFixedSize(desired_width,desired_height);
ui->expandButton->setDisabled(true);
}

View File

@ -187,7 +187,7 @@
<item>
<widget class="QLabel" name="thumbnailLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>