From c1efdac7f6a4fbbdae8e06fbfca174f7a30c149a Mon Sep 17 00:00:00 2001 From: defnax Date: Tue, 14 Jan 2020 23:22:01 +0100 Subject: [PATCH] get the share button usable for copy the rs link --- retroshare-gui/src/gui/Posted/PhotoView.cpp | 27 ++++++++++++++++++-- retroshare-gui/src/gui/Posted/PhotoView.h | 7 +++-- retroshare-gui/src/gui/Posted/PhotoView.ui | 16 ++++++++++++ retroshare-gui/src/gui/Posted/PostedItem.cpp | 2 ++ 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/retroshare-gui/src/gui/Posted/PhotoView.cpp b/retroshare-gui/src/gui/Posted/PhotoView.cpp index 06a83f827..16b74c793 100644 --- a/retroshare-gui/src/gui/Posted/PhotoView.cpp +++ b/retroshare-gui/src/gui/Posted/PhotoView.cpp @@ -25,7 +25,10 @@ #include #include "gui/gxs/GxsIdDetails.h" +#include "gui/RetroShareLink.h" + #include +#include /** Constructor */ PhotoView::PhotoView(QWidget *parent) @@ -36,8 +39,8 @@ PhotoView::PhotoView(QWidget *parent) ui->setupUi(this); setAttribute(Qt::WA_DeleteOnClose, true); - - ui->shareButton->hide(); + + connect(ui->shareButton, SIGNAL(clicked()), this, SLOT(copyMessageLink())); } /** Destructor */ @@ -78,3 +81,23 @@ void PhotoView::setTime(const QString& text) ui->timeLabel->setText(text); } +void PhotoView::setGroupId(const RsGxsGroupId &groupId) +{ + mGroupId = groupId; +} + +void PhotoView::setMessageId(const RsGxsMessageId& messageId) +{ + mMessageId = messageId ; +} + +void PhotoView::copyMessageLink() +{ + RetroShareLink link = RetroShareLink::createGxsMessageLink(RetroShareLink::TYPE_POSTED, mGroupId, mMessageId, ui->titleLabel->text()); + + if (link.valid()) { + QList urls; + urls.push_back(link); + RSLinkClipboard::copyLinks(urls); + } +} diff --git a/retroshare-gui/src/gui/Posted/PhotoView.h b/retroshare-gui/src/gui/Posted/PhotoView.h index 9de96b620..d44406af3 100644 --- a/retroshare-gui/src/gui/Posted/PhotoView.h +++ b/retroshare-gui/src/gui/Posted/PhotoView.h @@ -46,12 +46,15 @@ public slots: void setTitle (const QString &text); void setName(const RsGxsId& authorID); void setTime(const QString& text); + void setGroupId(const RsGxsGroupId &groupId); + void setMessageId(const RsGxsMessageId& messageId); private slots: - + void copyMessageLink(); private: - + RsGxsMessageId mMessageId; + RsGxsGroupId mGroupId; /** Qt Designer generated object */ Ui::PhotoView *ui; diff --git a/retroshare-gui/src/gui/Posted/PhotoView.ui b/retroshare-gui/src/gui/Posted/PhotoView.ui index 9d159500a..9c540bc28 100644 --- a/retroshare-gui/src/gui/Posted/PhotoView.ui +++ b/retroshare-gui/src/gui/Posted/PhotoView.ui @@ -145,6 +145,19 @@ + + + + + MS Sans Serif + 9 + + + + ago + + + @@ -160,6 +173,9 @@ + + Copy RetroShare link + Share diff --git a/retroshare-gui/src/gui/Posted/PostedItem.cpp b/retroshare-gui/src/gui/Posted/PostedItem.cpp index b165f2f00..dacf83a53 100644 --- a/retroshare-gui/src/gui/Posted/PostedItem.cpp +++ b/retroshare-gui/src/gui/Posted/PostedItem.cpp @@ -605,6 +605,8 @@ void PostedItem::viewPicture() PView->setTitle(messageName()); PView->setName(authorID); PView->setTime(timestamp); + PView->setGroupId(groupId()); + PView->setMessageId(mMessageId); PView->show();