Fixup PulseAddDialog and underlying datatypes

Cleaned up UI, removing unnecessary sidebar.
Added cleanup of Dialog to reset properly
Disabled URL adder, until it is complete
Added ComboBox for reply sentiment
Only enable Post button when length between 1 and 999 characters
Add Icon to WireGroup (future proofing datatype)
This commit is contained in:
drbob 2020-04-11 12:55:04 +10:00
parent 9e0d56f408
commit 124781c1e0
6 changed files with 261 additions and 262 deletions

View File

@ -28,6 +28,7 @@
#include "retroshare/rstokenservice.h"
#include "retroshare/rsgxsifacehelper.h"
#include "retroshare/rsgxscommon.h"
/* The Main Interface Class - for information about your Peers */
@ -38,6 +39,7 @@ struct RsWireGroup: RsGxsGenericGroupData
{
public:
std::string mDescription;
RsGxsImage mIcon;
};
@ -93,9 +95,10 @@ class RsWirePlace
#define WIRE_PULSE_TYPE_REPLY_MSG (0x0002)
#define WIRE_PULSE_TYPE_REPLY_REFERENCE (0x0004)
#define WIRE_PULSE_TYPE_SENTIMENT_POSITIVE (0x0010)
#define WIRE_PULSE_TYPE_SENTIMENT_NEUTRAL (0x0020)
#define WIRE_PULSE_TYPE_SENTIMENT_NEGATIVE (0x0040)
#define WIRE_PULSE_SENTIMENT_NO_SENTIMENT (0x0000)
#define WIRE_PULSE_SENTIMENT_POSITIVE (0x0001)
#define WIRE_PULSE_SENTIMENT_NEUTRAL (0x0002)
#define WIRE_PULSE_SENTIMENT_NEGATIVE (0x0003)
class RsWirePulse
{
@ -107,6 +110,7 @@ class RsWirePulse
std::string mPulseText;
uint32_t mPulseType;
uint32_t mReplySentiment; // only relevant if a reply.
// These Ref to the related (parent or reply) if reply (MODE_REPLY_MSG set)
// Mode REPLY_MSG only REPLY_REFERENCE

View File

@ -44,17 +44,20 @@ RsItem *RsGxsWireSerialiser::create_item(uint16_t service,uint8_t item_subtype)
void RsGxsWireGroupItem::clear()
{
group.mDescription.clear();
group.mIcon.clear();
}
void RsGxsWireGroupItem::serial_process(RsGenericSerializer::SerializeJob j,RsGenericSerializer::SerializeContext& ctx)
{
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_DESCR,group.mDescription,"group.mDescription") ;
group.mIcon.serial_process(j, ctx);
}
void RsGxsWirePulseItem::clear()
{
pulse.mPulseText.clear();
pulse.mPulseType = 0;
pulse.mReplySentiment = 0;
pulse.mRefGroupId.clear();
pulse.mRefGroupName.clear();
pulse.mRefOrigMsgId.clear();
@ -66,6 +69,7 @@ void RsGxsWirePulseItem::serial_process(RsGenericSerializer::SerializeJob j,RsGe
{
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_MSG,pulse.mPulseText,"pulse.mPulseText") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mPulseType,"pulse.mPulseType") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_UINT32_PARAM,pulse.mReplySentiment,"pulse.mReplySentiment") ;
RsTypeSerializer::serial_process(j,ctx,pulse.mRefGroupId,"pulse.mRefGroupId") ;
RsTypeSerializer::serial_process(j,ctx,TLV_TYPE_STR_NAME,pulse.mRefGroupName,"pulse.mRefGroupName") ;
RsTypeSerializer::serial_process(j,ctx,pulse.mRefOrigMsgId,"pulse.mRefOrigMsgId") ;

View File

@ -24,6 +24,7 @@
#include "PulseAddDialog.h"
const uint32_t PULSE_MAX_SIZE = 1000; // 1k char.
/** Constructor */
PulseAddDialog::PulseAddDialog(QWidget *parent)
@ -35,8 +36,9 @@ PulseAddDialog::PulseAddDialog(QWidget *parent)
connect(ui.pushButton_Post, SIGNAL( clicked( void ) ), this, SLOT( postPulse( void ) ) );
connect(ui.pushButton_AddURL, SIGNAL( clicked( void ) ), this, SLOT( addURL( void ) ) );
connect(ui.pushButton_AddTo, SIGNAL( clicked( void ) ), this, SLOT( addTo( void ) ) );
connect(ui.pushButton_ClearDisplayAs, SIGNAL( clicked( void ) ), this, SLOT( clearDisplayAs( void ) ) );
connect(ui.pushButton_Cancel, SIGNAL( clicked( void ) ), this, SLOT( cancelPulse( void ) ) );
connect(ui.textEdit_Pulse, SIGNAL( textChanged( void ) ), this, SLOT( pulseTextChanged( void ) ) );
}
void PulseAddDialog::setGroup(RsWireGroup &group)
@ -47,7 +49,7 @@ void PulseAddDialog::setGroup(RsWireGroup &group)
}
void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName)
void PulseAddDialog::cleanup()
{
if (mIsReply)
{
@ -75,11 +77,31 @@ void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName)
}
// then finally
delete layout;
mIsReply = false;
}
ui.frame_reply->setVisible(false);
ui.comboBox_sentiment->setCurrentIndex(0);
ui.lineEdit_URL->setText("");
ui.lineEdit_DisplayAs->setText("");
ui.textEdit_Pulse->setPlainText("");
ui.pushButton_Post->setEnabled(false);
// disable URL until functionality finished.
ui.frame_URL->setEnabled(false);
}
void PulseAddDialog::pulseTextChanged()
{
std::string pulseText = ui.textEdit_Pulse->toPlainText().toStdString();
bool enable = (pulseText.size() > 0) && (pulseText.size() < PULSE_MAX_SIZE);
ui.pushButton_Post->setEnabled(enable);
}
void PulseAddDialog::setReplyTo(RsWirePulse &pulse, std::string &groupName)
{
mIsReply = true;
mReplyToPulse = pulse;
mReplyGroupName = groupName;
ui.frame_reply->setVisible(true);
{
std::map<rstime_t, RsWirePulse *> replies;
@ -103,12 +125,10 @@ void PulseAddDialog::addURL()
return;
}
void PulseAddDialog::addTo()
void PulseAddDialog::clearDisplayAs()
{
std::cerr << "PulseAddDialog::addTo()";
std::cerr << "PulseAddDialog::clearDisplayAs()";
std::cerr << std::endl;
return;
}
@ -124,7 +144,6 @@ void PulseAddDialog::cancelPulse()
return;
}
void PulseAddDialog::postPulse()
{
std::cerr << "PulseAddDialog::postPulse()";
@ -154,6 +173,7 @@ void PulseAddDialog::postOriginalPulse()
pulse.mMeta.mOrigMsgId.clear();
pulse.mPulseType = WIRE_PULSE_TYPE_ORIGINAL_MSG;
pulse.mReplySentiment = WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// all mRefs should empty.
@ -164,6 +184,27 @@ void PulseAddDialog::postOriginalPulse()
hide();
}
uint32_t PulseAddDialog::toPulseSentiment(int index)
{
switch(index)
{
case 1:
return WIRE_PULSE_SENTIMENT_POSITIVE;
break;
case 2:
return WIRE_PULSE_SENTIMENT_NEUTRAL;
break;
case 3:
return WIRE_PULSE_SENTIMENT_NEGATIVE;
break;
case -1:
case 0:
default:
return WIRE_PULSE_SENTIMENT_NO_SENTIMENT;
break;
}
return 0;
}
void PulseAddDialog::postReplyPulse()
{
@ -179,6 +220,7 @@ void PulseAddDialog::postReplyPulse()
pulse.mMeta.mOrigMsgId.clear();
pulse.mPulseType = WIRE_PULSE_TYPE_REPLY_MSG;
pulse.mReplySentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
pulse.mPulseText = ui.textEdit_Pulse->toPlainText().toStdString();
// mRefs refer to parent post.
@ -213,6 +255,8 @@ void PulseAddDialog::postRefPulse(RsWirePulse &pulse)
refPulse.mMeta.mOrigMsgId.clear();
refPulse.mPulseType = WIRE_PULSE_TYPE_REPLY_REFERENCE;
refPulse.mReplySentiment = toPulseSentiment(ui.comboBox_sentiment->currentIndex());
// Dont put parent PulseText into refPulse - it is available on Thread Msg.
// otherwise gives impression it is correctly setup Parent / Reply...
// when in fact the parent PublishTS, and AuthorId are wrong.

View File

@ -33,15 +33,17 @@ class PulseAddDialog : public QWidget, public TokenResponse
public:
PulseAddDialog(QWidget *parent = 0);
void cleanup();
void setGroup(RsWireGroup &group);
void setReplyTo(RsWirePulse &pulse, std::string &groupName);
private slots:
void addURL();
void addTo();
void clearDisplayAs();
void postPulse();
void cancelPulse();
void clearDialog();
void pulseTextChanged();
private:
void postOriginalPulse();
@ -51,6 +53,7 @@ private:
void acknowledgeMessage(const uint32_t &token);
void loadPulseData(const uint32_t &token);
void loadRequest(const TokenQueue *queue, const TokenRequest &req);
uint32_t toPulseSentiment(int index);
protected:

View File

@ -13,9 +13,67 @@
<property name="windowTitle">
<string/>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="1" colspan="3">
<widget class="QFrame" name="frame_2">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>100</width>
<height>16777215</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Post From:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_groupName">
<property name="text">
<string>GroupLabel</string>
</property>
</widget>
</item>
<item>
<widget class="GxsIdLabel" name="label_idName">
<property name="text">
<string>IDLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QFrame" name="frame_reply">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
@ -24,50 +82,74 @@
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>In Reply to:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_5">
<property name="font">
<font>
<pointsize>11</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Positive / Neutral / Negative</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>238</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<widget class="QWidget" name="widget_replyto" native="true"/>
</item>
<item>
<widget class="QWidget" name="widget_replyto" native="true"/>
<widget class="QWidget" name="widget_sentiment" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label_4">
<property name="text">
<string>Response Sentiment: </string>
</property>
</widget>
</item>
<item>
<widget class="QComboBox" name="comboBox_sentiment">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<item>
<property name="text">
<string>No Sentiment</string>
</property>
</item>
<item>
<property name="text">
<string>Positive</string>
</property>
</item>
<item>
<property name="text">
<string>Neutral</string>
</property>
</item>
<item>
<property name="text">
<string>Negative</string>
</property>
</item>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>238</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item row="1" column="1" colspan="3">
<item>
<widget class="QFrame" name="frame_3">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
@ -79,220 +161,80 @@
<item>
<widget class="QTextEdit" name="textEdit_Pulse"/>
</item>
</layout>
</widget>
</item>
<item row="2" column="1" colspan="3">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>URL Adder</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>331</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_AddURL">
<property name="text">
<string>Add to Pulse</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>Display As</string>
</property>
</widget>
</item>
<item row="1" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit_2"/>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>URL</string>
</property>
</widget>
</item>
<item row="2" column="1" colspan="2">
<widget class="QLineEdit" name="lineEdit"/>
</item>
</layout>
</widget>
</item>
<item row="3" column="1">
<widget class="QPushButton" name="pushButton_Cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>298</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="3">
<widget class="QPushButton" name="pushButton_Post">
<property name="text">
<string>Post Pulse to Wire</string>
</property>
</widget>
</item>
<item row="0" column="0" rowspan="4">
<widget class="QSplitter" name="splitter">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<widget class="QFrame" name="frame">
<property name="maximumSize">
<size>
<width>160</width>
<height>16777215</height>
</size>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="label">
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string>Post From:</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_groupName">
<property name="text">
<string>GroupLabel</string>
</property>
</widget>
</item>
<item>
<widget class="GxsIdLabel" name="label_idName">
<property name="text">
<string>IDLabel</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QScrollArea" name="scrollArea_3">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents_3">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>150</width>
<height>423</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="pushButton_AddTo">
<property name="text">
<string>Add to Pulse</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_3">
<property name="text">
<string>filter</string>
</property>
</widget>
</item>
<item>
<widget class="QScrollArea" name="scrollArea">
<property name="widgetResizable">
<bool>true</bool>
</property>
<widget class="QWidget" name="scrollAreaWidgetContents">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>130</width>
<height>341</height>
</rect>
<item>
<widget class="QFrame" name="frame_URL">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>URL</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="checkBox_5">
<property name="text">
<string>Account 1</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_6">
<property name="text">
<string>Account 2</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkBox_7">
<property name="text">
<string>Account 3</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>70</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</widget>
</item>
</layout>
</widget>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEdit_URL"/>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButton_AddURL">
<property name="text">
<string>Add to Pulse</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Display As</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="lineEdit_DisplayAs"/>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButton_ClearDisplayAs">
<property name="text">
<string>Clear Display As</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QPushButton" name="pushButton_Cancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>298</width>
<height>24</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="pushButton_Post">
<property name="text">
<string>Post Pulse to Wire</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</widget>
<customwidgets>

View File

@ -137,6 +137,7 @@ void WireDialog::reply(RsWirePulse &pulse, std::string &groupName)
// publishing group.
RsWireGroup group = mOwnGroups[idx];
mAddDialog->cleanup();
mAddDialog->setGroup(group);
// establish replyTo.
@ -246,6 +247,7 @@ void WireDialog::createPulse()
RsWireGroup group = mOwnGroups[idx];
mAddDialog->cleanup();
mAddDialog->setGroup(group);
mAddDialog->show();
}