Merge pull request #2038 from drbob/TheWire-fix-Show-Follow-Buttons

[TheWire] fix Show and Follow Buttons
This commit is contained in:
drbob 2020-08-11 12:13:27 +10:00 committed by GitHub
commit fe5a0e023e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 417 additions and 30 deletions

View File

@ -302,6 +302,18 @@ void PulseAddDialog::postReplyPulse()
pPulse->mImage3 = mImage3;
pPulse->mImage4 = mImage4;
if (mReplyType & WIRE_PULSE_TYPE_REPUBLISH) {
// Copy details from parent, and override
pPulse->mSentiment = mReplyToPulse.mSentiment;
pPulse->mPulseText = mReplyToPulse.mPulseText;
// Copy images.
pPulse->mImage1 = mReplyToPulse.mImage1;
pPulse->mImage2 = mReplyToPulse.mImage2;
pPulse->mImage3 = mReplyToPulse.mImage3;
pPulse->mImage4 = mReplyToPulse.mImage4;
}
// this should be in async thread, so doesn't block UI thread.
if (!rsWire->createReplyPulse(mReplyToPulse.mMeta.mGroupId,
mReplyToPulse.mMeta.mOrigMsgId,

View File

@ -36,6 +36,10 @@ void PulseMessage::setup(RsWirePulseSPtr pulse)
setMessage(QString::fromStdString(pulse->mPulseText));
// show indent if republish (both RESPONSE or REF)
bool showIndent = (pulse->mPulseType & WIRE_PULSE_TYPE_REPUBLISH);
widget_indent->setVisible(showIndent);
// setup images.
int width = 256;
int height = 128;

View File

@ -13,11 +13,39 @@
<property name="windowTitle">
<string>Form</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0" rowspan="2">
<widget class="QWidget" name="widget_indent" native="true">
<property name="enabled">
<bool>true</bool>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="Line" name="line">
<property name="minimumSize">
<size>
<width>20</width>
<height>0</height>
</size>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="1">
<widget class="QTextBrowser" name="textBrowser"/>
</item>
<item>
<item row="1" column="1">
<widget class="QFrame" name="frame_expand">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>

View File

@ -114,10 +114,25 @@ void PulseReply::setRepliesString(QString reply)
label_replies->setText(reply);
}
void PulseReply::showResponseStats(bool enable)
void PulseReply::setPulseStatus(PulseStatus status)
{
widget_actions->setVisible(enable);
widget_follow->setVisible(!enable);
widget_actions->setVisible(status == PulseStatus::FULL);
widget_follow->setVisible(status != PulseStatus::FULL);
toolButton_follow->setEnabled(status == PulseStatus::UNSUBSCRIBED);
switch(status)
{
case PulseStatus::FULL:
break;
case PulseStatus::UNSUBSCRIBED:
break;
case PulseStatus::NO_GROUP:
label_follow_msg->setText("Group unavailable");
break;
case PulseStatus::REF_MSG:
label_follow_msg->setText("Full Pulse unavailable");
break;
}
}
void PulseReply::setReferenceString(QString ref)

View File

@ -56,7 +56,7 @@ protected:
//
virtual void setReferenceString(QString ref) override;
virtual void showResponseStats(bool enable) override;
virtual void setPulseStatus(PulseStatus status) override;
// PulseDataInterface ===========
void mousePressEvent(QMouseEvent *event);

View File

@ -154,6 +154,13 @@ border-radius: 10px}</string>
<property name="text">
<string>REPLY</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/reply.png</normaloff>:/images/reply.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
@ -198,6 +205,13 @@ border-radius: 10px}</string>
<property name="text">
<string>REPUBLISH</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/retweet.png</normaloff>:/images/retweet.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
@ -242,6 +256,13 @@ border-radius: 10px}</string>
<property name="text">
<string>LIKE</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/like.png</normaloff>:/images/like.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
@ -286,6 +307,13 @@ border-radius: 10px}</string>
<property name="text">
<string>SHOW</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/external-link.svg</normaloff>:/images/external-link.svg</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
@ -339,10 +367,23 @@ border-radius: 10px}</string>
<property name="text">
<string>FOLLOW</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/invite.png</normaloff>:/images/invite.png</iconset>
</property>
<property name="iconSize">
<size>
<width>16</width>
<height>16</height>
</size>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<widget class="QLabel" name="label_follow_msg">
<property name="text">
<string> for response statistics </string>
</property>

View File

@ -45,10 +45,10 @@ PulseTopLevel::PulseTopLevel(PulseViewHolder *holder, RsWirePulseSPtr pulse)
void PulseTopLevel::setup()
{
connect(pushButton_tmpViewGroup, SIGNAL(clicked()), this, SLOT(actionViewGroup()));
connect(pushButton_tmpViewParent, SIGNAL(clicked()), this, SLOT(actionViewParent()));
// connect(toolButton_follow, SIGNAL(clicked()), this, SLOT(follow()));
connect(toolButton_viewGroup, SIGNAL(clicked()), this, SLOT(actionViewGroup()));
connect(toolButton_viewParent, SIGNAL(clicked()), this, SLOT(actionViewParent()));
connect(toolButton_follow, SIGNAL(clicked()), this, SLOT(actionFollow()));
connect(toolButton_followParent, SIGNAL(clicked()), this, SLOT(actionFollowParent()));
// connect(toolButton_rate, SIGNAL(clicked()), this, SLOT(rate()));
connect(toolButton_reply, SIGNAL(clicked()), this, SLOT(actionReply()));
@ -107,10 +107,11 @@ void PulseTopLevel::setRepliesString(QString reply)
label_replies->setText(reply);
}
void PulseTopLevel::showResponseStats(bool enable)
void PulseTopLevel::setPulseStatus(PulseStatus status)
{
widget_replies->setVisible(enable);
widget_actions->setVisible(enable);
widget_replies->setVisible(true); // this is only reachable if we have ORIG so show always.
widget_actions->setVisible(status == PulseStatus::FULL);
widget_actionsFollow->setVisible(status == PulseStatus::UNSUBSCRIBED);
}
void PulseTopLevel::setReferenceString(QString ref)
@ -122,6 +123,28 @@ void PulseTopLevel::setReferenceString(QString ref)
else
{
label_reference->setText(ref);
// set ref icon
if (mPulse->mPulseType & WIRE_PULSE_TYPE_REPUBLISH) {
label_reficon->setPixmap(QPixmap(":/images/retweet.png"));
} else {
label_reficon->setPixmap(QPixmap(":/images/reply.png"));
}
}
if (mPulse->mRefGroupPtr) {
if (mPulse->mRefGroupPtr->mMeta.mSubscribeFlags &
(GXS_SERV::GROUP_SUBSCRIBE_ADMIN |
GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)) {
toolButton_viewParent->setVisible(true);
toolButton_followParent->setVisible(false);
} else {
toolButton_viewParent->setVisible(false);
toolButton_followParent->setVisible(true);
}
} else {
toolButton_viewParent->setVisible(false);
toolButton_followParent->setVisible(false);
}
}

View File

@ -55,7 +55,7 @@ protected:
//
virtual void setReferenceString(QString ref) override;
virtual void showResponseStats(bool enable) override;
virtual void setPulseStatus(PulseStatus status) override;
// PulseDataInterface ===========
protected:

View File

@ -91,8 +91,20 @@ border-radius: 10px}</string>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>icn</string>
<string/>
</property>
<property name="pixmap">
<pixmap resource="TheWire_images.qrc">:/images/reply.png</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</item>
@ -104,10 +116,43 @@ border-radius: 10px}</string>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButton_tmpViewParent">
<widget class="QToolButton" name="toolButton_viewParent">
<property name="toolTip">
<string>open Parent Pulse</string>
</property>
<property name="text">
<string>SHOW PARENT</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/external-link.svg</normaloff>:/images/external-link.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolButton_followParent">
<property name="toolTip">
<string>follow Parent Group</string>
</property>
<property name="text">
<string>...</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/invite.png</normaloff>:/images/invite.png</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
<item>
@ -228,16 +273,29 @@ border-radius: 10px}</string>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_tmpViewGroup">
<widget class="QToolButton" name="toolButton_viewGroup">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="toolTip">
<string>open Group</string>
</property>
<property name="text">
<string>SHOW GROUP</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/external-link.svg</normaloff>:/images/external-link.svg</iconset>
</property>
<property name="iconSize">
<size>
<width>24</width>
<height>24</height>
</size>
</property>
</widget>
</item>
</layout>
@ -472,6 +530,13 @@ border-radius: 10px}</string>
<property name="text">
<string>REPLY</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/reply.png</normaloff>:/images/reply.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
@ -516,6 +581,13 @@ border-radius: 10px}</string>
<property name="text">
<string>REPUBLISH</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/retweet.png</normaloff>:/images/retweet.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
@ -560,6 +632,13 @@ border-radius: 10px}</string>
<property name="text">
<string>LIKE</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/like.png</normaloff>:/images/like.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
@ -604,6 +683,13 @@ border-radius: 10px}</string>
<property name="text">
<string>SHOW</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/external-link.svg</normaloff>:/images/external-link.svg</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
@ -624,6 +710,64 @@ border-radius: 10px}</string>
</layout>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_actionsFollow" native="true">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>40</height>
</size>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_11">
<item>
<spacer name="horizontalSpacer_20">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>298</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton_follow">
<property name="text">
<string>FOLLOW</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/invite.png</normaloff>:/images/invite.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_21">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>297</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>

View File

@ -41,6 +41,8 @@ PulseViewGroup::PulseViewGroup(PulseViewHolder *holder, RsWireGroupSPtr group)
void PulseViewGroup::setup()
{
if (mGroup) {
connect(toolButton_follow, SIGNAL(clicked()), this, SLOT(actionFollow()));
label_groupName->setText("@" + QString::fromStdString(mGroup->mMeta.mGroupName));
label_authorName->setText(BoldString(QString::fromStdString(mGroup->mMeta.mAuthorId.toStdString())));
label_date->setText(DateTime::formatDateTime(mGroup->mMeta.mPublishTs));
@ -92,3 +94,15 @@ void PulseViewGroup::setup()
}
}
void PulseViewGroup::actionFollow()
{
RsGxsGroupId groupId = mGroup->mMeta.mGroupId;
std::cerr << "PulseViewGroup::actionFollow() following ";
std::cerr << groupId;
std::cerr << std::endl;
if (mHolder) {
mHolder->PVHfollow(groupId);
}
}

View File

@ -33,9 +33,13 @@ class PulseViewGroup : public PulseViewItem, private Ui::PulseViewGroup
public:
PulseViewGroup(PulseViewHolder *holder, RsWireGroupSPtr group);
private slots:
void actionFollow();
protected:
void setup();
protected:
RsWireGroupSPtr mGroup;
};

View File

@ -508,10 +508,17 @@ border-radius: 10px}</string>
</spacer>
</item>
<item>
<widget class="QToolButton" name="toolButton_like_2">
<widget class="QToolButton" name="toolButton_follow">
<property name="text">
<string>FOLLOW</string>
</property>
<property name="icon">
<iconset resource="TheWire_images.qrc">
<normaloff>:/images/invite.png</normaloff>:/images/invite.png</iconset>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>

View File

@ -183,8 +183,41 @@ void PulseDataItem::actionFollow()
std::cerr << "PulseDataItem::actionFollow()";
std::cerr << std::endl;
// TODO
RsGxsGroupId groupId;
if (mPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) {
std::cerr << "PulseDataItem::actionFollow() REF following Replier: ";
std::cerr << mPulse->mRefGroupId;
std::cerr << std::endl;
groupId = mPulse->mRefGroupId;
} else {
std::cerr << "PulseDataItem::actionFollow() RESPONSE following Group: ";
std::cerr << mPulse->mMeta.mGroupId;
std::cerr << std::endl;
groupId = mPulse->mMeta.mGroupId;
}
if (mHolder) {
mHolder->PVHfollow(groupId);
}
}
void PulseDataItem::actionFollowParent()
{
std::cerr << "PulseDataItem::actionFollowParent()";
std::cerr << std::endl;
RsGxsGroupId groupId;
if (mPulse->mPulseType & WIRE_PULSE_TYPE_REFERENCE) {
std::cerr << "PulseDataItem::actionFollowParent() REF following Group: ";
std::cerr << mPulse->mMeta.mGroupId;
std::cerr << std::endl;
groupId = mPulse->mMeta.mGroupId;
} else {
std::cerr << "PulseDataItem::actionFollowParent() RESPONSE following RefGroup: ";
std::cerr << mPulse->mRefGroupId;
std::cerr << std::endl;
groupId = mPulse->mRefGroupId;
}
if (mHolder) {
mHolder->PVHfollow(groupId);
@ -260,15 +293,28 @@ void PulseDataItem::showPulse()
setRefMessage(QString::fromStdString(mPulse->mRefPulseText), mPulse->mRefImageCount);
setDate(mPulse->mRefPublishTs);
// References (unknown for a REFERENCE)
// show FOLLOW button instead.
showResponseStats(false);
// Workout Pulse status for Stats/Follow/Msgs.
// Its a REF so cannot be FULL.
PulseStatus status = PulseStatus::REF_MSG;
if (mPulse->mRefGroupPtr) {
// bitwise comparisons.
if (mPulse->mRefGroupPtr->mMeta.mSubscribeFlags &
(GXS_SERV::GROUP_SUBSCRIBE_ADMIN |
GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)) {
status = PulseStatus::REF_MSG;
} else {
status = PulseStatus::UNSUBSCRIBED;
}
} else {
status = PulseStatus::NO_GROUP;
}
setPulseStatus(status);
//
if (mPulse->mGroupPtr) {
setReference(mPulse->mPulseType & WIRE_PULSE_RESPONSE_MASK, mPulse->mMeta.mGroupId, mPulse->mGroupPtr->mMeta.mGroupName);
} else {
setReference(mPulse->mPulseType & WIRE_PULSE_RESPONSE_MASK, mPulse->mMeta.mGroupId, "REF GROUP MISSING");
setReference(mPulse->mPulseType & WIRE_PULSE_RESPONSE_MASK, mPulse->mMeta.mGroupId, "UNKNOWN");
}
}
@ -310,8 +356,19 @@ void PulseDataItem::showPulse()
setMessage(mPulse);
setDate(mPulse->mMeta.mPublishTs);
// References
showResponseStats(true);
// Possible to have ORIG and be UNSUBSCRIBED.
PulseStatus status = PulseStatus::FULL;
if (mPulse->mGroupPtr) {
// bitwise comparisons.
if (mPulse->mGroupPtr->mMeta.mSubscribeFlags &
(GXS_SERV::GROUP_SUBSCRIBE_ADMIN |
GXS_SERV::GROUP_SUBSCRIBE_SUBSCRIBED)) {
status = PulseStatus::FULL;
} else {
status = PulseStatus::UNSUBSCRIBED;
}
}
setPulseStatus(status);
setLikes(mPulse->mLikes.size());
setReplies(mPulse->mReplies.size());
setRepublishes(mPulse->mRepublishes.size());
@ -322,6 +379,7 @@ void PulseDataItem::showPulse()
}
else
{
// NO Parent, so only 0 is important.
setReference(0, mPulse->mRefGroupId, mPulse->mRefGroupName);
}
}

View File

@ -50,6 +50,13 @@ class PulseDataInterface
public:
virtual ~PulseDataInterface() {}
enum class PulseStatus {
FULL, // have Msg + Group: Show Stats
UNSUBSCRIBED, // Ref + unsubscribed to Group: Show Follow
NO_GROUP, // Ref Msg, unknown group: Show Missing Group.
REF_MSG // Subscribed, only Ref Msg: Show Missing Msg.
};
protected:
// Group
virtual void setHeadshot(const QPixmap &pixmap) = 0;
@ -68,7 +75,7 @@ protected:
//
virtual void setReferenceString(QString ref) = 0;
virtual void showResponseStats(bool enable) = 0;
virtual void setPulseStatus(PulseStatus status) = 0;
};
@ -105,6 +112,7 @@ private slots:
void actionViewPulse();
void actionFollow();
void actionFollowParent();
void actionRate();
// Action interfaces --------------------------

View File

@ -4,5 +4,8 @@
<file>images/like.png</file>
<file>images/reply.png</file>
<file>images/retweet.png</file>
<file>images/link.svg</file>
<file>images/external-link.svg</file>
<file>images/invite.png</file>
</qresource>
</RCC>

View File

@ -578,8 +578,12 @@ void WireDialog::PVHfollow(const RsGxsGroupId &groupId)
{
std::cerr << "WireDialog::PVHfollow(";
std::cerr << groupId.toStdString();
std::cerr << ") TODO";
std::cerr << ")";
std::cerr << std::endl;
uint32_t token;
rsWire->subscribeToGroup(token, groupId, true);
mWireQueue->queueRequest(token, TOKENREQ_GROUPINFO, RS_TOKREQ_ANSTYPE_ACK, WIRE_TOKEN_TYPE_SUBSCRIBE_CHANGE);
}
void WireDialog::PVHrate(const RsGxsId &authorId)
@ -815,6 +819,26 @@ void WireDialog::postPulseFocus(RsWirePulseSPtr pPulse)
addTwitterView(new PulseReplySeperator());
}
// Add big separator, and republishes.
if (pPulse->mReplies.size() > 0 && pPulse->mRepublishes.size() > 0)
{
addTwitterView(new PulseReplySeperator());
addTwitterView(new PulseReplySeperator());
}
for(it = pPulse->mRepublishes.begin(); it != pPulse->mRepublishes.end(); it++)
{
RsWirePulseSPtr repub = *it;
PulseReply *firstRepub = new PulseReply(this, repub);
firstRepub->showReplyLine(false);
addTwitterView(firstRepub);
addTwitterView(new PulseReplySeperator());
}
}
void WireDialog::requestGroupFocus(const RsGxsGroupId groupId)

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#3070FF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-external-link"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"></path><polyline points="15 3 21 3 21 9"></polyline><line x1="10" y1="14" x2="21" y2="3"></line></svg>

After

Width:  |  Height:  |  Size: 383 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" viewBox="0 0 24 24" fill="none" stroke="#3070FF" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-link"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>

After

Width:  |  Height:  |  Size: 366 B