From daa724151bea825d0e38c08b51595c0439a00b1d Mon Sep 17 00:00:00 2001 From: defnax Date: Wed, 30 Dec 2020 01:31:27 +0100 Subject: [PATCH] Added to get view the attached Pulse images --- retroshare-gui/src/gui/Posted/PhotoView.cpp | 5 ++ retroshare-gui/src/gui/Posted/PhotoView.h | 1 + .../src/gui/TheWire/PulseMessage.cpp | 52 +++++++++++++++++++ retroshare-gui/src/gui/TheWire/PulseMessage.h | 7 +++ .../src/gui/TheWire/PulseMessage.ui | 27 ++++++++-- 5 files changed, 88 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PhotoView.cpp b/retroshare-gui/src/gui/Posted/PhotoView.cpp index 839e5f4d3..0c45914f4 100644 --- a/retroshare-gui/src/gui/Posted/PhotoView.cpp +++ b/retroshare-gui/src/gui/Posted/PhotoView.cpp @@ -101,3 +101,8 @@ void PhotoView::copyMessageLink() QMessageBox::information(NULL,tr("information"),tr("The Retrohare link was copied to your clipboard.")) ; } } + +void PhotoView::setGroupNameString(const QString& name) +{ + ui->nameLabel->setText("@" + name); +} diff --git a/retroshare-gui/src/gui/Posted/PhotoView.h b/retroshare-gui/src/gui/Posted/PhotoView.h index d44406af3..dea6528d1 100644 --- a/retroshare-gui/src/gui/Posted/PhotoView.h +++ b/retroshare-gui/src/gui/Posted/PhotoView.h @@ -48,6 +48,7 @@ public slots: void setTime(const QString& text); void setGroupId(const RsGxsGroupId &groupId); void setMessageId(const RsGxsMessageId& messageId); + void setGroupNameString(const QString& name); private slots: void copyMessageLink(); diff --git a/retroshare-gui/src/gui/TheWire/PulseMessage.cpp b/retroshare-gui/src/gui/TheWire/PulseMessage.cpp index 91af09b3a..8f4a91873 100644 --- a/retroshare-gui/src/gui/TheWire/PulseMessage.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseMessage.cpp @@ -19,6 +19,8 @@ *******************************************************************************/ #include "PulseMessage.h" +#include "gui/Posted/PhotoView.h" +#include "util/misc.h" /** Constructor */ @@ -26,6 +28,11 @@ PulseMessage::PulseMessage(QWidget *parent) :QWidget(parent) { setupUi(this); + + connect(label_image1, SIGNAL(clicked()), this, SLOT(viewPicture())); + connect(label_image2, SIGNAL(clicked()), this, SLOT(viewPicture())); + connect(label_image3, SIGNAL(clicked()), this, SLOT(viewPicture())); + connect(label_image4, SIGNAL(clicked()), this, SLOT(viewPicture())); } void PulseMessage::setup(RsWirePulseSPtr pulse) @@ -34,6 +41,8 @@ void PulseMessage::setup(RsWirePulseSPtr pulse) return; } + mPulse = pulse; + setMessage(QString::fromStdString(pulse->mPulseText)); // show indent if republish (both RESPONSE or REF) @@ -139,3 +148,46 @@ void PulseMessage::setRefImageCount(uint32_t count) } } +void PulseMessage::viewPicture() +{ + PhotoView *photoView = new PhotoView(this); + + if (!mPulse->mImage1.empty()) { + // install image. + QPixmap pixmap; + pixmap.loadFromData(mPulse->mImage1.mData, mPulse->mImage1.mSize); + photoView->setPixmap(pixmap); + } + + if (!mPulse->mImage2.empty()) { + // install image. + QPixmap pixmap; + pixmap.loadFromData(mPulse->mImage2.mData, mPulse->mImage2.mSize); + photoView->setPixmap(pixmap); + } + + if (!mPulse->mImage3.empty()) { + // install image. + QPixmap pixmap; + pixmap.loadFromData(mPulse->mImage3.mData, mPulse->mImage3.mSize); + photoView->setPixmap(pixmap); + } + + if (!mPulse->mImage4.empty()) { + // install image. + QPixmap pixmap; + pixmap.loadFromData(mPulse->mImage4.mData, mPulse->mImage4.mSize); + photoView->setPixmap(pixmap); + } + + QString timestamp = misc::timeRelativeToNow(mPulse->mRefPublishTs); + + photoView->setTitle(QString::fromStdString(mPulse->mPulseText)); + photoView->setGroupNameString(QString::fromStdString(mPulse->mRefGroupName)); + photoView->setTime(timestamp); + //photoView->setGroupId(mPulse->mRefGroupId); + + photoView->show(); + + /* window will destroy itself! */ +} diff --git a/retroshare-gui/src/gui/TheWire/PulseMessage.h b/retroshare-gui/src/gui/TheWire/PulseMessage.h index 7e94a23db..a2372ebbf 100644 --- a/retroshare-gui/src/gui/TheWire/PulseMessage.h +++ b/retroshare-gui/src/gui/TheWire/PulseMessage.h @@ -35,6 +35,13 @@ public: void setup(RsWirePulseSPtr pulse); void setMessage(QString msg); void setRefImageCount(uint32_t count); + +private slots: + void viewPicture(); + +private: + RsWirePulseSPtr mPulse; + }; #endif diff --git a/retroshare-gui/src/gui/TheWire/PulseMessage.ui b/retroshare-gui/src/gui/TheWire/PulseMessage.ui index 40e684e60..8af226cea 100644 --- a/retroshare-gui/src/gui/TheWire/PulseMessage.ui +++ b/retroshare-gui/src/gui/TheWire/PulseMessage.ui @@ -68,13 +68,16 @@ - + 128 128 + + Click to view picture + Image @@ -84,13 +87,16 @@ - + 128 128 + + Click to view picture + Image @@ -100,13 +106,16 @@ - + 128 128 + + Click to view picture + Image @@ -116,13 +125,16 @@ - + 128 128 + + Click to view picture + Image @@ -136,6 +148,13 @@ + + + ClickableLabel + QLabel +
util/ClickableLabel.h
+
+