From c0cac9ec2d030a0efab579f34109f66908a9a812 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 22 Feb 2022 21:46:05 +0100 Subject: [PATCH] fixed Boards item in feeds to display a constant-aspect-ratio picture using ZoomableLabel --- libretroshare | 2 +- retroshare-gui/src/gui/Posted/PostedItem.cpp | 26 +++++++++++--------- retroshare-gui/src/gui/Posted/PostedItem.h | 10 ++++---- retroshare-gui/src/gui/Posted/PostedItem.ui | 14 ++++++++--- 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/libretroshare b/libretroshare index 87fdae942..1965f2000 160000 --- a/libretroshare +++ b/libretroshare @@ -1 +1 @@ -Subproject commit 87fdae942186ab3412ce40438e30f76670dd55d0 +Subproject commit 1965f200033cc6a5bbf46fcda21e87248b181076 diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index 90f393dab..d9242c571 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -495,7 +495,7 @@ void PostedItem::fill() ui->voteUpButton->setDisabled(true); ui->voteDownButton->setDisabled(true); - ui->thumbnailLabel->setPixmap( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png")); + ui->thumbnailLabel->setPicture( FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png")); ui->fromLabel->setId(mPost.mMeta.mAuthorId); ui->titleLabel->setText(tr( "

The author of this message (with ID %1) is banned.").arg(QString::fromStdString(mPost.mMeta.mAuthorId.toStdString()))) ; QDateTime qtime; @@ -509,8 +509,10 @@ void PostedItem::fill() QPixmap sqpixmap2 = FilesDefs::getPixmapFromQtResourcePath(":/images/thumb-default.png"); mInFill = true; - int desired_height = 1.5*(ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height()); - int desired_width = sqpixmap2.width()*desired_height/(float)sqpixmap2.height(); + int desired_height = ui->voteDownButton->height() + ui->voteUpButton->height() + ui->scoreLabel->height(); + int desired_width = 16/9.0 * desired_height; //sqpixmap2.width()*desired_height/(float)sqpixmap2.height(); + + ui->thumbnailLabel->setFixedSize(desired_width,desired_height); QDateTime qtime; qtime.setTime_t(mPost.mMeta.mPublishTs); @@ -573,17 +575,17 @@ void PostedItem::fill() 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->setPixmap(sqpixmap); +// 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); - } + 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)) { diff --git a/retroshare-gui/src/gui/Posted/PostedItem.h b/retroshare-gui/src/gui/Posted/PostedItem.h index d726cf830..a2f432dc0 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.h +++ b/retroshare-gui/src/gui/Posted/PostedItem.h @@ -112,11 +112,11 @@ protected: void setCommentsSize(int comNb) override; private slots: - void doExpand(bool open); - void toggle(); - void makeUpVote(); - void makeDownVote(); - void toggleNotes() ; + void doExpand(bool open) override; + void toggle() override; + void makeUpVote() override; + void makeDownVote() override; + void toggleNotes() override; private: /** Qt Designer generated object */ diff --git a/retroshare-gui/src/gui/Posted/PostedItem.ui b/retroshare-gui/src/gui/Posted/PostedItem.ui index 6c6b290f8..aafc8528c 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.ui +++ b/retroshare-gui/src/gui/Posted/PostedItem.ui @@ -176,6 +176,12 @@ QSizePolicy::Expanding + + + 0 + 0 + + @@ -190,7 +196,7 @@ 6 - + 0 @@ -732,15 +738,15 @@ 1 - ClickableLabel + ZoomableLabel QLabel -

util/ClickableLabel.h
+
gui/gxschannels/GxsChannelPostThumbnail.h
- +