mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-10-01 02:35:48 -04:00
Merge remote-tracking branch 'remotes/origin/pr/2' into feature/New-Posted-Card-View
This commit is contained in:
commit
68e6ad4880
@ -51,12 +51,17 @@ PhotoView::~PhotoView()
|
||||
|
||||
void PhotoView::setPixmap(const QPixmap& pixmap)
|
||||
{
|
||||
QPixmap sqpixmap;
|
||||
if(pixmap.width() > 800 ){
|
||||
QPixmap sqpixmap = pixmap.scaled(640,480, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
if(pixmap.width() > 800 || pixmap.height() > 700)
|
||||
ui->photoLabel->setPixmap(sqpixmap);
|
||||
else
|
||||
}else if (pixmap.height() > 600){
|
||||
QPixmap sqpixmap = pixmap.scaled(480,640, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
ui->photoLabel->setPixmap(sqpixmap);
|
||||
}
|
||||
else{
|
||||
ui->photoLabel->setPixmap(pixmap);
|
||||
}
|
||||
}
|
||||
|
||||
void PhotoView::setTitle(const QString& text)
|
||||
@ -102,5 +107,6 @@ void PhotoView::copyMessageLink()
|
||||
QList<RetroShareLink> urls;
|
||||
urls.push_back(link);
|
||||
RSLinkClipboard::copyLinks(urls);
|
||||
QMessageBox::information(NULL,tr("information"),tr("The Retrohare link was copied to your clipboard.")) ;
|
||||
}
|
||||
}
|
||||
|
@ -308,15 +308,13 @@ void PostedCardView::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);
|
||||
|
||||
QPixmap squaledpixmap = pixmap.scaled(640,480, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
if(pixmap.width() > 800)
|
||||
ui->pictureLabel->setPixmap(squaledpixmap);
|
||||
else
|
||||
QPixmap scaledpixmap;
|
||||
if(pixmap.width() > 800){
|
||||
QPixmap scaledpixmap = pixmap.scaledToWidth(800, Qt::SmoothTransformation);
|
||||
ui->pictureLabel->setPixmap(scaledpixmap);
|
||||
}else{
|
||||
ui->pictureLabel->setPixmap(pixmap);
|
||||
|
||||
}
|
||||
}
|
||||
else if (mPost.mImage.mData == NULL)
|
||||
{
|
||||
|
@ -321,13 +321,13 @@ void PostedItem::fill()
|
||||
ui->thumbnailLabel->setPixmap(sqpixmap);
|
||||
ui->thumbnailLabel->setToolTip(tr("Click to view Picture"));
|
||||
|
||||
QPixmap squaledpixmap = pixmap.scaled(640,480, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
|
||||
if(pixmap.width() > 800)
|
||||
ui->pictureLabel->setPixmap(squaledpixmap);
|
||||
else
|
||||
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))
|
||||
{
|
||||
|
@ -470,6 +470,7 @@ HEADERS += rshare.h \
|
||||
util/RsFile.h \
|
||||
util/qtthreadsutils.h \
|
||||
util/ClickableLabel.h \
|
||||
util/AspectRatioPixmapLabel.h \
|
||||
gui/profile/ProfileWidget.h \
|
||||
gui/profile/ProfileManager.h \
|
||||
gui/profile/StatusMessage.h \
|
||||
@ -830,6 +831,7 @@ SOURCES += main.cpp \
|
||||
util/RsFile.cpp \
|
||||
util/RichTextEdit.cpp \
|
||||
util/ClickableLabel.cpp \
|
||||
util/AspectRatioPixmapLabel.cpp \
|
||||
gui/profile/ProfileWidget.cpp \
|
||||
gui/profile/StatusMessage.cpp \
|
||||
gui/profile/ProfileManager.cpp \
|
||||
|
56
retroshare-gui/src/util/AspectRatioPixmapLabel.cpp
Normal file
56
retroshare-gui/src/util/AspectRatioPixmapLabel.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
/*******************************************************************************
|
||||
* retroshare-gui/src/util/AspectRatioPixmapLabel.cpp *
|
||||
* *
|
||||
* Copyright (C) 2019 Retroshare Team <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#include "AspectRatioPixmapLabel.h"
|
||||
|
||||
AspectRatioPixmapLabel::AspectRatioPixmapLabel(QWidget *parent) :
|
||||
QLabel(parent)
|
||||
{
|
||||
this->setMinimumSize(1,1);
|
||||
setScaledContents(false);
|
||||
}
|
||||
|
||||
void AspectRatioPixmapLabel::setPixmap ( const QPixmap & p)
|
||||
{
|
||||
pix = p;
|
||||
QLabel::setPixmap(scaledPixmap());
|
||||
}
|
||||
|
||||
int AspectRatioPixmapLabel::heightForWidth( int width ) const
|
||||
{
|
||||
return pix.isNull() ? this->height() : ((qreal)pix.height()*width)/pix.width();
|
||||
}
|
||||
|
||||
QSize AspectRatioPixmapLabel::sizeHint() const
|
||||
{
|
||||
int w = this->width();
|
||||
return QSize( w, heightForWidth(w) );
|
||||
}
|
||||
|
||||
QPixmap AspectRatioPixmapLabel::scaledPixmap() const
|
||||
{
|
||||
return pix.scaled(this->size(), Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||
}
|
||||
|
||||
void AspectRatioPixmapLabel::resizeEvent(QResizeEvent * e)
|
||||
{
|
||||
if(!pix.isNull())
|
||||
QLabel::setPixmap(scaledPixmap());
|
||||
}
|
43
retroshare-gui/src/util/AspectRatioPixmapLabel.h
Normal file
43
retroshare-gui/src/util/AspectRatioPixmapLabel.h
Normal file
@ -0,0 +1,43 @@
|
||||
/*******************************************************************************
|
||||
* retroshare-gui/src/util/AspectRatioPixmapLabel.h *
|
||||
* *
|
||||
* Copyright (C) 2019 Retroshare Team <retroshare.project@gmail.com> *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU Affero General Public License as *
|
||||
* published by the Free Software Foundation, either version 3 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU Affero General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Affero General Public License *
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
*******************************************************************************/
|
||||
|
||||
#ifndef ASPECTRATIOPIXMAPLABEL_H
|
||||
#define ASPECTRATIOPIXMAPLABEL_H
|
||||
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QResizeEvent>
|
||||
|
||||
class AspectRatioPixmapLabel : public QLabel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AspectRatioPixmapLabel(QWidget *parent = 0);
|
||||
virtual int heightForWidth( int width ) const;
|
||||
virtual QSize sizeHint() const;
|
||||
QPixmap scaledPixmap() const;
|
||||
public slots:
|
||||
void setPixmap ( const QPixmap & );
|
||||
void resizeEvent(QResizeEvent *);
|
||||
private:
|
||||
QPixmap pix;
|
||||
};
|
||||
|
||||
#endif // ASPECTRATIOPIXMAPLABEL_H
|
Loading…
Reference in New Issue
Block a user