Fixed to display Avatars and nickname on news feeds Messages Item for Distant Messages.

Added for Invite Message RS_MSG_USER_REQUEST flag & auto send invites to outbox.
Optimized Messages Item for Invite Messages, display a Send Invite Button, to send back own rs cert link via Distant Message.
This commit is contained in:
defnax 2017-01-29 19:01:38 +01:00
parent 7327f1a98b
commit 7861b092c3
9 changed files with 307 additions and 53 deletions

View File

@ -230,6 +230,8 @@ IdDialog::IdDialog(QWidget *parent) :
ui->mainSplitter->setStretchFactor(0, 0);
ui->mainSplitter->setStretchFactor(1, 1);
ui->inviteFrame->hide();
/*remove
QList<int> sizes;
sizes << width() << 500; // Qt calculates the right sizes
@ -2458,28 +2460,13 @@ void IdDialog::sendInvite()
{
return;
}
/* create a message */
MessageComposer *composer = MessageComposer::newMsg();
composer->setTitleText(tr("You have a friend invite"));
RsGxsId id(ui->lineEdit_KeyId->text().toStdString());
RsPeerId ownId = rsPeers->getOwnId();
RetroShareLink link;
link.createCertificate(ownId);
std::string keyId = item->text(RSID_COL_KEYID).toStdString();
QString sMsgText = inviteMessage();
sMsgText += "<br><br>";
sMsgText += tr("Respond now:") + "<br>";
sMsgText += link.toHtml() + "<br>";
sMsgText += "<br>";
sMsgText += tr("Thanks, <br>") + QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str());
composer->setMsgText(sMsgText);
composer->addRecipient(MessageComposer::TO, RsGxsId(keyId));
composer->show();
MessageComposer::sendInvite(id);
ui->inviteFrame->show();
ui->inviteButton->setEnabled(false);
}
void IdDialog::negativePerson()
@ -2557,3 +2544,7 @@ QList<QTreeWidgetItem *> selected_items = ui->idTreeWidget->selectedItems();
requestIdList();
}
void IdDialog::on_closeInfoFrameButton_clicked()
{
ui->inviteFrame->setVisible(false);
}

View File

@ -93,7 +93,7 @@ private slots:
void editIdentity();
void chatIdentity();
void sendMsg();
void on_closeInfoFrameButton_clicked();
void updateSelection();

View File

@ -20,7 +20,16 @@
<string/>
</property>
<layout class="QGridLayout" name="IdDialogGLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
@ -38,7 +47,16 @@
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="titleBarFrameHLayout">
<property name="margin">
<property name="leftMargin">
<number>2</number>
</property>
<property name="topMargin">
<number>2</number>
</property>
<property name="rightMargin">
<number>2</number>
</property>
<property name="bottomMargin">
<number>2</number>
</property>
<item>
@ -129,7 +147,16 @@
<enum>QFrame::Sunken</enum>
</property>
<layout class="QHBoxLayout" name="toolBarFrameHLayout">
<property name="margin">
<property name="leftMargin">
<number>1</number>
</property>
<property name="topMargin">
<number>1</number>
</property>
<property name="rightMargin">
<number>1</number>
</property>
<property name="bottomMargin">
<number>1</number>
</property>
<item>
@ -222,7 +249,7 @@
<string>Votes</string>
</property>
<property name="textAlignment">
<set>AlignLeft|AlignVCenter</set>
<set>AlignLeading|AlignVCenter</set>
</property>
<property name="icon">
<iconset resource="../icons.qrc">
@ -299,14 +326,14 @@
<string>Identity info</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QLabel" name="label_Nickname">
<property name="text">
<string>Identity name :</string>
</property>
</widget>
</item>
<item row="0" column="1">
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_Nickname">
<property name="enabled">
<bool>true</bool>
@ -316,7 +343,7 @@
</property>
</widget>
</item>
<item row="0" column="2" rowspan="11">
<item row="1" column="2" rowspan="11">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="avatarLabel">
@ -459,14 +486,14 @@
</item>
</layout>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_KeyId">
<property name="text">
<string>Identity ID :</string>
</property>
</widget>
</item>
<item row="1" column="1">
<item row="2" column="1">
<widget class="QLineEdit" name="lineEdit_KeyId">
<property name="enabled">
<bool>true</bool>
@ -476,24 +503,24 @@
</property>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_Type">
<property name="text">
<string>Type:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="3" column="1">
<widget class="QLineEdit" name="lineEdit_Type"/>
</item>
<item row="3" column="0">
<item row="4" column="0">
<widget class="QLabel" name="label_GpgId">
<property name="text">
<string>Owner node ID :</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QLineEdit" name="lineEdit_GpgId">
<property name="enabled">
<bool>true</bool>
@ -503,14 +530,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_GpgName">
<property name="text">
<string>Owner node name :</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QLineEdit" name="lineEdit_GpgName">
<property name="enabled">
<bool>true</bool>
@ -520,31 +547,31 @@
</property>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_LastUsed">
<property name="text">
<string>Last used:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QLineEdit" name="lineEdit_LastUsed"/>
</item>
<item row="6" column="0" colspan="2">
<item row="7" column="0" colspan="2">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Your opinion:</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QComboBox" name="ownOpinion_CB">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
@ -600,28 +627,28 @@ p, li { white-space: pre-wrap; }
</item>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="banoption_label">
<property name="text">
<string>Ban-option:</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QCheckBox" name="autoBanIdentities_CB">
<property name="text">
<string>Auto-Ban all identities signed by the same node</string>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="neighborNodesOpinion_LB">
<property name="text">
<string>Friend votes:</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QLineEdit" name="neighborNodesOpinion_TF">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Average opinion of neighbor nodes about this identity. Negative is bad,&lt;/p&gt;&lt;p&gt;positive is good. Zero is neutral.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -631,7 +658,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QLabel" name="overallOpinion_LB">
<property name="font">
<font>
@ -644,7 +671,7 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QLineEdit" name="overallOpinion_TF">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Overall reputation score, accounting for yours and your friends'.&lt;/p&gt;&lt;p&gt;Negative is bad, positive is good. Zero is neutral. If the score is too low,&lt;/p&gt;&lt;p&gt;the identity is flagged as bad, and will be filtered out in forums, chat lobbies,&lt;/p&gt;&lt;p&gt;channels, etc.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
@ -654,6 +681,157 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item row="12" column="1" colspan="2">
<widget class="QFrame" name="inviteFrame">
<property name="palette">
<palette>
<active>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>178</blue>
</color>
</brush>
</colorrole>
</active>
<inactive>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>178</blue>
</color>
</brush>
</colorrole>
</inactive>
<disabled>
<colorrole role="Base">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>178</blue>
</color>
</brush>
</colorrole>
<colorrole role="Window">
<brush brushstyle="SolidPattern">
<color alpha="255">
<red>255</red>
<green>255</green>
<blue>178</blue>
</color>
</brush>
</colorrole>
</disabled>
</palette>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<layout class="QHBoxLayout" name="distantFrameHLayout">
<property name="leftMargin">
<number>6</number>
</property>
<property name="topMargin">
<number>6</number>
</property>
<property name="rightMargin">
<number>6</number>
</property>
<property name="bottomMargin">
<number>6</number>
</property>
<item>
<widget class="QLabel" name="infoPixmap">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap resource="../images.qrc">:/images/info16.png</pixmap>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="infoLabel">
<property name="text">
<string notr="true">Invite messages stay into your Outbox until an acknowledgement of receipt has been received.</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="closeInfoFrameButton">
<property name="maximumSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="toolTip">
<string>Close</string>
</property>
<property name="styleSheet">
<string notr="true">QToolButton
{
border-image: url(:/images/closenormal.png)
}
QToolButton:hover
{
border-image: url(:/images/closehover.png)
}
QToolButton:pressed {
border-image: url(:/images/closepressed.png)
}</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -62,6 +62,8 @@ MsgItem::MsgItem(FeedHolder *parent, uint32_t feedId, const std::string &msgId,
connect( playButton, SIGNAL( clicked( void ) ), this, SLOT( playMedia ( void ) ) );
connect( deleteButton, SIGNAL( clicked( void ) ), this, SLOT( deleteMsg ( void ) ) );
connect( replyButton, SIGNAL( clicked( void ) ), this, SLOT( replyMsg ( void ) ) );
connect( sendinviteButton, SIGNAL( clicked( void ) ), this, SLOT( sendInvite ( void ) ) );
expandFrame->hide();
@ -87,7 +89,7 @@ void MsgItem::updateItemStatic()
/* get peer Id */
if (mi.msgflags & RS_MSG_SIGNED)
if (mi.msgflags & RS_MSG_DISTANT)
avatar->setGxsId(mi.rsgxsid_srcId) ;
else
avatar->setId(ChatId(mi.rspeerid_srcId)) ;
@ -99,7 +101,7 @@ void MsgItem::updateItemStatic()
srcName = "RetroShare";
else
{
if(mi.msgflags & RS_MSG_SIGNED)
if(mi.msgflags & RS_MSG_DISTANT)
{
RsIdentityDetails details ;
rsIdentity->getIdDetails(mi.rsgxsid_srcId, details) ;
@ -110,11 +112,19 @@ void MsgItem::updateItemStatic()
srcName = QString::fromUtf8(rsPeers->getPeerName(mi.rspeerid_srcId).c_str());
}
timestampLabel->setText(DateTime::formatLongDateTime(mi.ts));
if (!mIsHome)
{
title = tr("Message From") + ": ";
if (mi.msgflags & RS_MSG_USER_REQUEST)
{
title = QString::fromUtf8(mi.title.c_str()) + " " + tr("from") + " " + srcName;
subjectLabel->hide();
}
else
{
title = tr("Message From") + ": " + srcName;
sendinviteButton->hide();
}
}
else
{
@ -141,11 +151,11 @@ void MsgItem::updateItemStatic()
break;
}
}
title += srcName;
titleLabel->setText(title);
subjectLabel->setText(QString::fromUtf8(mi.title.c_str()));
mMsg = QString::fromUtf8(mi.msg.c_str());
timestampLabel->setText(DateTime::formatLongDateTime(mi.ts));
if (wasExpanded() || expandFrame->isVisible()) {
fillExpandFrame();
@ -344,3 +354,18 @@ void MsgItem::checkMessageReadStatus()
removeItem();
}
void MsgItem::sendInvite()
{
MessageInfo mi;
if (!rsMail)
return;
if (!rsMail->getMessage(mMsgId, mi))
return;
MessageComposer::sendInvite(mi.rsgxsid_srcId);
}

View File

@ -56,6 +56,7 @@ private slots:
void playMedia();
void deleteMsg();
void replyMsg();
void sendInvite();
void checkMessageReadStatus();
void updateItem();

View File

@ -146,6 +146,7 @@
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<italic>true</italic>
<bold>true</bold>
@ -165,7 +166,7 @@
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeType">
<enum>QSizePolicy::Preferred</enum>
<enum>QSizePolicy::Expanding</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@ -206,6 +207,13 @@
</item>
<item row="2" column="1" colspan="3">
<layout class="QHBoxLayout" name="buttonHLayout">
<item>
<widget class="QPushButton" name="sendinviteButton">
<property name="text">
<string>Send Invite</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="replyButton">
<property name="focusPolicy">
@ -225,7 +233,7 @@
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
<property name="autoRaise">
<bool>true</bool>
<bool>false</bool>
</property>
</widget>
</item>

View File

@ -2758,3 +2758,44 @@ void MessageComposer::on_closeInfoFrameButton_clicked()
{
ui.distantFrame->setVisible(false);
}
QString MessageComposer::inviteMessage()
{
return tr("Hi,<br>I want to be friends with you on RetroShare.<br>");
}
void MessageComposer::sendInvite(const RsGxsId &to, const QString &msg, bool autoSend)
{
/* create a message */
MessageComposer *composer = MessageComposer::newMsg();
composer->setTitleText(tr("You have a friend invite"));
composer->msgFlags |= RS_MSG_USER_REQUEST;
RsPeerId ownId = rsPeers->getOwnId();
RetroShareLink link;
link.createCertificate(ownId);
QString sMsgText = inviteMessage();
sMsgText += "<br><br>";
sMsgText += tr("Respond now:") + "<br>";
sMsgText += link.toHtml() + "<br>";
sMsgText += "<br>";
sMsgText += tr("Thanks, <br>") + QString::fromUtf8(rsPeers->getGPGName(rsPeers->getGPGOwnId()).c_str());
composer->setMsgText(sMsgText);
composer->addRecipient(MessageComposer::TO, RsGxsId(to));
if (autoSend) {
if (composer->sendMessage_internal(false)) {
composer->close();
return;
}
}
//composer->show();
/* window will destroy itself! */
}

View File

@ -64,6 +64,7 @@ public:
static QString recommendMessage();
static void recommendFriend(const std::set <RsPeerId> &sslIds, const RsPeerId &to = RsPeerId(), const QString &msg = "", bool autoSend = false);
static void sendConnectAttemptMsg(const RsPgpId &gpgId, const RsPeerId &sslId, const QString &sslName);
static void sendInvite(const RsGxsId &to = RsGxsId(), const QString &msg = "", bool autoSend = true);
#ifdef UNUSED_CODE
static void sendChannelPublishKey(RsGxsChannelGroup &group);
static void sendForumPublishKey(RsGxsForumGroup &group);
@ -165,6 +166,8 @@ private slots:
void on_closeInfoFrameButton_clicked();
static QString inviteMessage();
private:
static QString buildReplyHeader(const MessageInfo &msgInfo);

View File

@ -623,6 +623,13 @@ IdDialog QLabel#avlabel {
border-radius: 10px;
}
IdDialog QFrame#inviteFrame {
border: 1px solid #DCDC41;
border-radius: 6px;
background: #FFFFD7;
background-color: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #FFFFD7, stop:1 #FFFFB2);
}
GxsChannelPostsWidget QFrame#infoFrame
{
border: 1px solid #DCDC41;