TheWire fix Show and Follow Buttons

* Add Icons to Buttons
 * Wire up Follow Buttons (add in a couple of places too)
 * Show / Hide buttons depending on Following status
 * Handle cases where Msgs / Groups unavailable
This commit is contained in:
drbob 2020-08-07 23:54:14 +10:00
parent 9a90ef694e
commit ca2da39167
16 changed files with 276 additions and 26 deletions

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,9 @@ 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_rate, SIGNAL(clicked()), this, SLOT(rate()));
connect(toolButton_reply, SIGNAL(clicked()), this, SLOT(actionReply()));
@ -107,10 +106,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)
@ -123,6 +123,12 @@ void PulseTopLevel::setReferenceString(QString ref)
{
label_reference->setText(ref);
}
if (mPulse->mRefGroupPtr) {
toolButton_viewParent->setVisible(true);
} else {
toolButton_viewParent->setVisible(false);
}
}
void PulseTopLevel::mousePressEvent(QMouseEvent *event)

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

@ -104,10 +104,23 @@ 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>
@ -228,16 +241,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 +498,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 +549,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 +600,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 +651,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 +678,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,18 @@ 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);
@ -260,15 +270,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 +333,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 +356,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;
};

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)

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