From 46a6bdc6e56836b916b89af8dc3cbdc63ad7173a Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 18 Nov 2017 19:48:38 +0100 Subject: [PATCH] Add Copy action for Gxs Comments. --- .../src/gui/gxs/GxsCommentDialog.ui | 10 +++++----- .../src/gui/gxs/GxsCommentTreeWidget.cpp | 19 ++++++++++++++++--- .../src/gui/gxs/GxsCommentTreeWidget.h | 3 +++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui index 8b91fc8ca..7961136c0 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsCommentDialog.ui @@ -13,7 +13,7 @@ Form - + @@ -22,7 +22,7 @@ 0 - + 9 @@ -36,7 +36,7 @@ - + @@ -80,7 +80,7 @@ - + Qt::Horizontal @@ -93,7 +93,7 @@ - + Voter ID: diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp index 1a20c13e5..23a5327ed 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.cpp @@ -21,13 +21,14 @@ * */ -#include -#include #include #include +#include #include #include +#include #include +#include #include "gui/common/RSElidedItemDelegate.h" #include "gui/gxs/GxsCommentTreeWidget.h" @@ -54,7 +55,8 @@ #define POST_COLOR_ROLE (Qt::UserRole+2) /* Images for context menu icons */ -#define IMAGE_MESSAGE ":/images/folder-draft.png" +#define IMAGE_MESSAGE ":/images/folder-draft.png" +#define IMAGE_COPY ":/images/copy.png" #define IMAGE_VOTEUP ":/images/vote_up.png" #define IMAGE_VOTEDOWN ":/images/vote_down.png" @@ -170,6 +172,7 @@ void GxsCommentTreeWidget::setCurrentCommentMsgId(QTreeWidgetItem *current, QTre if(current) { mCurrentCommentMsgId = RsGxsMessageId(current->text(PCITEM_COLUMN_MSGID).toStdString()); + mCurrentCommentText = current->text(PCITEM_COLUMN_COMMENT); } } @@ -180,6 +183,8 @@ void GxsCommentTreeWidget::customPopUpMenu(const QPoint& /*point*/) action->setDisabled(mCurrentCommentMsgId.isNull()); action = contextMnu.addAction(QIcon(IMAGE_MESSAGE), tr("Submit Comment"), this, SLOT(makeComment())); action->setDisabled(mMsgVersions.empty()); + action = contextMnu.addAction(QIcon(IMAGE_COPY), tr("Copy Comment"), this, SLOT(copyComment())); + action->setDisabled(mCurrentCommentMsgId.isNull()); contextMnu.addSeparator(); @@ -308,6 +313,14 @@ void GxsCommentTreeWidget::replyToComment() pcc.exec(); } +void GxsCommentTreeWidget::copyComment() +{ + QMimeData *mimeData = new QMimeData(); + mimeData->setHtml(""+mCurrentCommentText+""); + QClipboard *clipboard = QApplication::clipboard(); + clipboard->setMimeData(mimeData, QClipboard::Clipboard); +} + void GxsCommentTreeWidget::setup(RsTokenService *token_service, RsGxsCommentService *comment_service) { mRsTokenService = token_service; diff --git a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h index dcc2db991..e0cedc2f4 100644 --- a/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h +++ b/retroshare-gui/src/gui/gxs/GxsCommentTreeWidget.h @@ -71,6 +71,8 @@ public slots: void makeComment(); void replyToComment(); + void copyComment(); + void voteUp(); void voteDown(); @@ -89,6 +91,7 @@ protected: std::set mMsgVersions; RsGxsMessageId mLatestMsgId; RsGxsMessageId mCurrentCommentMsgId; + QString mCurrentCommentText; RsGxsId mVoterId; std::map mLoadingMap;