From 4bc90ea9ad9b40e35b23263e72146e833a259624 Mon Sep 17 00:00:00 2001 From: csoler Date: Tue, 11 Aug 2020 20:49:51 +0200 Subject: [PATCH] added photoview on click to compact view in boards --- .../src/gui/Posted/BoardPostDisplayWidget.cpp | 29 +++++++++++++++++++ .../src/gui/Posted/BoardPostDisplayWidget.h | 6 +++- .../src/gui/Posted/BoardPostDisplayWidget.ui | 7 ++++- retroshare-gui/src/util/ClickableLabel.cpp | 2 +- retroshare-gui/src/util/ClickableLabel.h | 7 +++-- 5 files changed, 45 insertions(+), 6 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp index 77e7305fd..7be0a157a 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.cpp @@ -25,6 +25,7 @@ #include "rshare.h" #include "BoardPostDisplayWidget.h" +#include "PhotoView.h" #include "gui/gxs/GxsIdDetails.h" #include "util/misc.h" #include "gui/common/FilesDefs.h" @@ -121,6 +122,31 @@ BoardPostDisplayWidget::~BoardPostDisplayWidget() delete(ui); } + +void BoardPostDisplayWidget::viewPicture() +{ + if(mPost.mImage.mData == NULL) + return; + + QString timestamp = misc::timeRelativeToNow(mPost.mMeta.mPublishTs); + QPixmap pixmap; + GxsIdDetails::loadPixmapFromData(mPost.mImage.mData, mPost.mImage.mSize, pixmap,GxsIdDetails::ORIGINAL); + RsGxsId authorID = mPost.mMeta.mAuthorId; + + PhotoView *PView = new PhotoView(this); + + PView->setPixmap(pixmap); + PView->setTitle(QString::fromUtf8(mPost.mMeta.mMsgName.c_str())); + PView->setName(authorID); + PView->setTime(timestamp); + PView->setGroupId(mPost.mMeta.mGroupId); + PView->setMessageId(mPost.mMeta.mMsgId); + + PView->show(); + + /* window will destroy itself! */ +} + void BoardPostDisplayWidget::toggleNotes() {} void BoardPostDisplayWidget::setup() @@ -380,6 +406,9 @@ void BoardPostDisplayWidget::setup() mInFill = false; #endif + ui->pictureLabel_compact->setUseStyleSheet(false); // If not this, causes dilation of the image. + connect(ui->pictureLabel_compact, SIGNAL(clicked()), this, SLOT(viewPicture())); + updateGeometry(); #ifdef TODO diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h index d3acbc701..434e486d1 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.h @@ -46,7 +46,11 @@ public: virtual ~BoardPostDisplayWidget(); static const char *DEFAULT_BOARD_IMAGE; -protected: + +public slots: + void viewPicture() ; + +protected slots: /* GxsGroupFeedItem */ virtual void setup(); // to be overloaded by the different views diff --git a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui index ce9cf74ae..1c7f928db 100644 --- a/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui +++ b/retroshare-gui/src/gui/Posted/BoardPostDisplayWidget.ui @@ -132,7 +132,7 @@ - + PictureLabel_compact @@ -472,6 +472,11 @@ QLabel
gui/common/StyledLabel.h
+ + ClickableLabel + QLabel +
util/ClickableLabel.h
+
diff --git a/retroshare-gui/src/util/ClickableLabel.cpp b/retroshare-gui/src/util/ClickableLabel.cpp index 7b7ccb5fb..e12e01c8d 100644 --- a/retroshare-gui/src/util/ClickableLabel.cpp +++ b/retroshare-gui/src/util/ClickableLabel.cpp @@ -32,4 +32,4 @@ ClickableLabel::~ClickableLabel() { void ClickableLabel::mousePressEvent(QMouseEvent* event) { emit clicked(); -} \ No newline at end of file +} diff --git a/retroshare-gui/src/util/ClickableLabel.h b/retroshare-gui/src/util/ClickableLabel.h index 65070fd67..bd8c68ed8 100644 --- a/retroshare-gui/src/util/ClickableLabel.h +++ b/retroshare-gui/src/util/ClickableLabel.h @@ -32,16 +32,17 @@ public: explicit ClickableLabel(QWidget* parent = Q_NULLPTR, Qt::WindowFlags f = Qt::WindowFlags()); ~ClickableLabel(); + void setUseStyleSheet(bool b){ mUseStyleSheet=b ; update();} signals: void clicked(); protected: void mousePressEvent(QMouseEvent* event); - void enterEvent(QEvent * /* ev */ ) override { setStyleSheet("QLabel { border: 2px solid #039bd5; }");} - - void leaveEvent(QEvent * /* ev */ ) override { setStyleSheet("QLabel { border: 2px solid #CCCCCC; border-radius: 3px; }");} + void enterEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #039bd5; }");} + void leaveEvent(QEvent * /* ev */ ) override { if(mUseStyleSheet) setStyleSheet("QLabel { border: 2px solid #CCCCCC; border-radius: 3px; }");} + bool mUseStyleSheet; }; #endif // CLICKABLELABEL_H