Add Copy action for Gxs Comments.

This commit is contained in:
Phenom 2017-11-18 19:48:38 +01:00
parent ba7cf4995b
commit 46a6bdc6e5
3 changed files with 24 additions and 8 deletions

View File

@ -13,7 +13,7 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<layout class="QVBoxLayout" name="GxsCommentDialogVLayout">
<item>
<widget class="QFrame" name="postFrame">
<property name="sizePolicy">
@ -22,7 +22,7 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<layout class="QVBoxLayout" name="postFrameVLayout">
<property name="leftMargin">
<number>9</number>
</property>
@ -36,7 +36,7 @@
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="toolBarHLayout">
<item>
<widget class="QPushButton" name="hotSortButton">
<property name="text">
@ -80,7 +80,7 @@
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<spacer name="toolBarHSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
@ -93,7 +93,7 @@
</spacer>
</item>
<item>
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="idLabel">
<property name="text">
<string>Voter ID:</string>
</property>

View File

@ -21,13 +21,14 @@
*
*/
#include <QMimeData>
#include <QTextDocument>
#include <QAbstractTextDocumentLayout>
#include <QApplication>
#include <QClipboard>
#include <QDateTime>
#include <QMenu>
#include <QMimeData>
#include <QPainter>
#include <QTextDocument>
#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("<html>"+mCurrentCommentText+"</html>");
QClipboard *clipboard = QApplication::clipboard();
clipboard->setMimeData(mimeData, QClipboard::Clipboard);
}
void GxsCommentTreeWidget::setup(RsTokenService *token_service, RsGxsCommentService *comment_service)
{
mRsTokenService = token_service;

View File

@ -71,6 +71,8 @@ public slots:
void makeComment();
void replyToComment();
void copyComment();
void voteUp();
void voteDown();
@ -89,6 +91,7 @@ protected:
std::set<RsGxsMessageId> mMsgVersions;
RsGxsMessageId mLatestMsgId;
RsGxsMessageId mCurrentCommentMsgId;
QString mCurrentCommentText;
RsGxsId mVoterId;
std::map<RsGxsMessageId, QTreeWidgetItem *> mLoadingMap;