diff --git a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.cpp b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.cpp index d823414de..ff31b10d9 100644 --- a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.cpp +++ b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.cpp @@ -26,6 +26,8 @@ #include #include +static const uint32_t MAX_ALLOWED_GXS_MESSAGE_SIZE = 199000; + GxsCreateCommentDialog::GxsCreateCommentDialog(RsGxsCommentService *service, const RsGxsGrpMsgIdPair &parentId, const RsGxsMessageId& threadId, const RsGxsId& default_author,QWidget *parent) : QDialog(parent), ui(new Ui::GxsCreateCommentDialog), mCommentService(service), mParentId(parentId), mThreadId(threadId) @@ -33,9 +35,10 @@ GxsCreateCommentDialog::GxsCreateCommentDialog(RsGxsCommentService *service, co ui->setupUi(this); connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createComment())); connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close())); + connect(ui->commentTextEdit, SIGNAL(textChanged()), this, SLOT(checkLength())); /* fill in the available OwnIds for signing */ - ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, default_author); + ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, default_author); } void GxsCreateCommentDialog::loadComment(const QString &msgText, const QString &msgAuthor, const RsGxsId &msgAuthorId) @@ -105,3 +108,19 @@ GxsCreateCommentDialog::~GxsCreateCommentDialog() { delete ui; } + +void GxsCreateCommentDialog::checkLength(){ + QString text; + RsHtml::optimizeHtml(ui->commentTextEdit, text); + std::wstring msg = text.toStdWString(); + int charRemains = MAX_ALLOWED_GXS_MESSAGE_SIZE - msg.length(); + if(charRemains >= 0) { + text = tr("It remains %1 characters after HTML conversion.").arg(charRemains); + ui->infoLabel->setStyleSheet("QLabel#infoLabel { }"); + }else{ + text = tr("Warning: This message is too big of %1 characters after HTML conversion.").arg((0-charRemains)); + ui->infoLabel->setStyleSheet("QLabel#infoLabel {color: red; font: bold; }"); + } + ui->postButton->setEnabled(charRemains>=0); + ui->infoLabel->setText(text); +} \ No newline at end of file diff --git a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.h b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.h index ce394bf5e..1f38e2a98 100644 --- a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.h +++ b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.h @@ -43,7 +43,8 @@ public: private slots: void createComment(); - + void checkLength(); + private: Ui::GxsCreateCommentDialog *ui; RsGxsCommentService *mCommentService; diff --git a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui index 1825bcf55..46b547412 100644 --- a/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui +++ b/retroshare-gui/src/gui/gxs/GxsCreateCommentDialog.ui @@ -6,8 +6,8 @@ 0 0 - 459 - 324 + 505 + 367 @@ -32,7 +32,7 @@ - + 0 0 @@ -142,17 +142,20 @@ p, li { white-space: pre-wrap; } 6 - - - - + + + + Qt::Horizontal - - + + + 276 + 20 + - + - + @@ -162,7 +165,21 @@ p, li { white-space: pre-wrap; } - + + + + Cancel + + + + + + + TextLabel + + + + @@ -186,30 +203,26 @@ p, li { white-space: pre-wrap; } - - - - Qt::Horizontal - - - - 276 - 20 - - - - - + Post - - + + + + + 0 + 0 + + + + + - Cancel + diff --git a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss index 54c501504..50ae5b314 100644 --- a/retroshare-gui/src/gui/qss/stylesheet/Standard.qss +++ b/retroshare-gui/src/gui/qss/stylesheet/Standard.qss @@ -188,7 +188,7 @@ ShareManager QPushButton#addButton:hover { } CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled, -CreateGxsChannelMsg QPushButton#postButton:disabled { +CreateGxsChannelMsg QPushButton#postButton:disabled, GxsCreateCommentDialog QPushButton#postButton:disabled { font: bold; font-size: 15px; color: white; diff --git a/retroshare-gui/src/qss/qdarkstyle-v2.qss b/retroshare-gui/src/qss/qdarkstyle-v2.qss index 5f541b007..0040d2cb6 100644 --- a/retroshare-gui/src/qss/qdarkstyle-v2.qss +++ b/retroshare-gui/src/qss/qdarkstyle-v2.qss @@ -2110,7 +2110,7 @@ GxsCreateCommentDialog QPushButton#postButton:hover, , GxsGroupDialog QPushButto } CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled, -CreateGxsChannelMsg QPushButton#postButton:disabled { +CreateGxsChannelMsg QPushButton#postButton:disabled, GxsCreateCommentDialog QPushButton#postButton:disabled { font: bold; font-size: 15px; color: white; diff --git a/retroshare-gui/src/qss/qdarkstyle.qss b/retroshare-gui/src/qss/qdarkstyle.qss index 97c078c02..6e37f3a82 100644 --- a/retroshare-gui/src/qss/qdarkstyle.qss +++ b/retroshare-gui/src/qss/qdarkstyle.qss @@ -1263,7 +1263,7 @@ ShareManager QPushButton#closeButton { } CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled, -CreateGxsChannelMsg QPushButton#postButton:disabled { +CreateGxsChannelMsg QPushButton#postButton:disabled, GxsCreateCommentDialog QPushButton#postButton:disabled { font: bold; font-size: 15px; color: white;