mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
fixed aspect ratio
This commit is contained in:
parent
fcee6d3f63
commit
c4463ad5ba
@ -246,27 +246,25 @@ void PostedItem::fill()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap sqpixmap2 = QPixmap(":/images/thumb-default.png");
|
||||||
|
|
||||||
mInFill = true;
|
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)
|
if(mPost.mImage.mData != NULL)
|
||||||
{
|
{
|
||||||
QPixmap pixmap;
|
QPixmap pixmap;
|
||||||
pixmap.loadFromData(mPost.mImage.mData, mPost.mImage.mSize, "PNG");
|
pixmap.loadFromData(mPost.mImage.mData, mPost.mImage.mSize, "PNG");
|
||||||
// Wiping data - as its been passed to thumbnail.
|
// Wiping data - as its been passed to thumbnail.
|
||||||
|
|
||||||
QPixmap sqpixmap = pixmap.scaled(10*desired_height,1.5*desired_height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
QPixmap sqpixmap = pixmap.scaled(desired_width,desired_height, Qt::KeepAspectRatioByExpanding, Qt::SmoothTransformation);
|
||||||
ui->thumbnailLabel->setMaximumSize(sqpixmap.size());
|
|
||||||
ui->thumbnailLabel->setPixmap(sqpixmap);
|
ui->thumbnailLabel->setPixmap(sqpixmap);
|
||||||
ui->pictureLabel->setPixmap(pixmap);
|
ui->pictureLabel->setPixmap(pixmap);
|
||||||
std::cerr << "new size=" << desired_height << " " << sqpixmap.width() << " " << sqpixmap.height() << std::endl;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QPixmap sqpixmap = QPixmap(":/images/thumb-default.png").scaled(10*desired_height,1.5*desired_height, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
ui->thumbnailLabel->setFixedSize(desired_width,desired_height);
|
||||||
|
|
||||||
ui->thumbnailLabel->setMaximumSize(sqpixmap.size());
|
|
||||||
ui->thumbnailLabel->setPixmap(sqpixmap);
|
|
||||||
|
|
||||||
ui->expandButton->setDisabled(true);
|
ui->expandButton->setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,7 +187,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="thumbnailLabel">
|
<widget class="QLabel" name="thumbnailLabel">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Minimum">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
|
Loading…
Reference in New Issue
Block a user