diff --git a/libretroshare/src/retroshare/rswire.h b/libretroshare/src/retroshare/rswire.h index 233befc11..03da21116 100644 --- a/libretroshare/src/retroshare/rswire.h +++ b/libretroshare/src/retroshare/rswire.h @@ -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 diff --git a/libretroshare/src/rsitems/rswireitems.cc b/libretroshare/src/rsitems/rswireitems.cc index 65360dbf4..69774ffc5 100644 --- a/libretroshare/src/rsitems/rswireitems.cc +++ b/libretroshare/src/rsitems/rswireitems.cc @@ -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") ; diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp index fa0e7bd9a..9a493b7d0 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.cpp @@ -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 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. diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.h b/retroshare-gui/src/gui/TheWire/PulseAddDialog.h index e48ecfeea..0ab3c826a 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.h +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.h @@ -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: diff --git a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui index cdcbf632c..b87d02794 100644 --- a/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui +++ b/retroshare-gui/src/gui/TheWire/PulseAddDialog.ui @@ -13,9 +13,67 @@ - - - + + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + 100 + 16777215 + + + + + 12 + 75 + true + + + + Post From: + + + + + + + GroupLabel + + + + + + + IDLabel + + + + + + + + QFrame::StyledPanel @@ -24,50 +82,74 @@ - - - - - In Reply to: - - - - - - - - 11 - 75 - true - - - - Positive / Neutral / Negative - - - - - - - Qt::Horizontal - - - - 238 - 20 - - - - - + - + + + + + + Response Sentiment: + + + + + + + + 0 + 0 + + + + + 150 + 0 + + + + + No Sentiment + + + + + Positive + + + + + Neutral + + + + + Negative + + + + + + + + Qt::Horizontal + + + + 238 + 20 + + + + + + - + QFrame::StyledPanel @@ -79,220 +161,80 @@ - - - - - - - URL Adder - - - - - - Qt::Horizontal - - - - 331 - 24 - - - - - - - - Add to Pulse - - - - - - - Display As - - - - - - - - - - URL - - - - - - - - - - - - - Cancel - - - - - - - Qt::Horizontal - - - - 298 - 24 - - - - - - - - Post Pulse to Wire - - - - - - - Qt::Vertical - - - - - 160 - 16777215 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - 12 - 75 - true - - - - Post From: - - - - - - - GroupLabel - - - - - - - IDLabel - - - - - - - - true - - - - - 0 - 0 - 150 - 423 - - - - - - - Add to Pulse - - - - - - - filter - - - - - - - true - - - - - 0 - 0 - 130 - 341 - + + + + + + + URL - - - - - Account 1 - - - - - - - Account 2 - - - - - - - Account 3 - - - - - - - Qt::Vertical - - - - 20 - 70 - - - - - - - - - - + + + + + + + + Add to Pulse + + + + + + + Display As + + + + + + + + + + Clear Display As + + + + + + + + + + + + + Cancel + + + + + + + Qt::Horizontal + + + + 298 + 24 + + + + + + + + Post Pulse to Wire + + + + + diff --git a/retroshare-gui/src/gui/TheWire/WireDialog.cpp b/retroshare-gui/src/gui/TheWire/WireDialog.cpp index 16df723bb..35f6f20b9 100644 --- a/retroshare-gui/src/gui/TheWire/WireDialog.cpp +++ b/retroshare-gui/src/gui/TheWire/WireDialog.cpp @@ -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(); }