mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-02-03 02:50:07 -05:00
Added check message length for Comments Composer
This commit is contained in:
parent
11d3583233
commit
20c3064e78
@ -26,6 +26,8 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
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) :
|
GxsCreateCommentDialog::GxsCreateCommentDialog(RsGxsCommentService *service, const RsGxsGrpMsgIdPair &parentId, const RsGxsMessageId& threadId, const RsGxsId& default_author,QWidget *parent) :
|
||||||
QDialog(parent),
|
QDialog(parent),
|
||||||
ui(new Ui::GxsCreateCommentDialog), mCommentService(service), mParentId(parentId), mThreadId(threadId)
|
ui(new Ui::GxsCreateCommentDialog), mCommentService(service), mParentId(parentId), mThreadId(threadId)
|
||||||
@ -33,6 +35,7 @@ GxsCreateCommentDialog::GxsCreateCommentDialog(RsGxsCommentService *service, co
|
|||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createComment()));
|
connect(ui->postButton, SIGNAL(clicked()), this, SLOT(createComment()));
|
||||||
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close()));
|
connect(ui->cancelButton, SIGNAL(clicked()), this, SLOT(close()));
|
||||||
|
connect(ui->commentTextEdit, SIGNAL(textChanged()), this, SLOT(checkLength()));
|
||||||
|
|
||||||
/* fill in the available OwnIds for signing */
|
/* fill in the available OwnIds for signing */
|
||||||
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, default_author);
|
ui->idChooser->loadIds(IDCHOOSER_ID_REQUIRED, default_author);
|
||||||
@ -105,3 +108,19 @@ GxsCreateCommentDialog::~GxsCreateCommentDialog()
|
|||||||
{
|
{
|
||||||
delete ui;
|
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);
|
||||||
|
}
|
@ -43,6 +43,7 @@ public:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void createComment();
|
void createComment();
|
||||||
|
void checkLength();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::GxsCreateCommentDialog *ui;
|
Ui::GxsCreateCommentDialog *ui;
|
||||||
|
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>459</width>
|
<width>505</width>
|
||||||
<height>324</height>
|
<height>367</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QFrame" name="frame">
|
<widget class="QFrame" name="frame">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -142,17 +142,20 @@ p, li { white-space: pre-wrap; }
|
|||||||
<property name="topMargin">
|
<property name="topMargin">
|
||||||
<number>6</number>
|
<number>6</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="5" column="0">
|
||||||
<widget class="GxsIdLabel" name="replaytolabel">
|
<spacer name="horizontalSpacer">
|
||||||
<property name="styleSheet">
|
<property name="orientation">
|
||||||
<string notr="true"/>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="sizeHint" stdset="0">
|
||||||
<string/>
|
<size>
|
||||||
|
<width>276</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="3">
|
<item row="2" column="0" colspan="3">
|
||||||
<widget class="MimeTextEdit" name="commentTextEdit">
|
<widget class="MimeTextEdit" name="commentTextEdit">
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true"/>
|
<string notr="true"/>
|
||||||
@ -162,7 +165,21 @@ p, li { white-space: pre-wrap; }
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="3">
|
<item row="5" column="2">
|
||||||
|
<widget class="QPushButton" name="cancelButton">
|
||||||
|
<property name="text">
|
||||||
|
<string>Cancel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
|
<widget class="QLabel" name="infoLabel">
|
||||||
|
<property name="text">
|
||||||
|
<string>TextLabel</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="0" colspan="3">
|
||||||
<layout class="QHBoxLayout" name="signedHLayout">
|
<layout class="QHBoxLayout" name="signedHLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="signedLabel">
|
<widget class="QLabel" name="signedLabel">
|
||||||
@ -186,30 +203,26 @@ p, li { white-space: pre-wrap; }
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0">
|
<item row="5" column="1">
|
||||||
<spacer name="horizontalSpacer">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>276</width>
|
|
||||||
<height>20</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QPushButton" name="postButton">
|
<widget class="QPushButton" name="postButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Post</string>
|
<string>Post</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="2">
|
<item row="0" column="0" colspan="3">
|
||||||
<widget class="QPushButton" name="cancelButton">
|
<widget class="GxsIdLabel" name="replaytolabel">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true"/>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Cancel</string>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
@ -188,7 +188,7 @@ ShareManager QPushButton#addButton:hover {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
|
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
|
||||||
CreateGxsChannelMsg QPushButton#postButton:disabled {
|
CreateGxsChannelMsg QPushButton#postButton:disabled, GxsCreateCommentDialog QPushButton#postButton:disabled {
|
||||||
font: bold;
|
font: bold;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: white;
|
color: white;
|
||||||
|
@ -2110,7 +2110,7 @@ GxsCreateCommentDialog QPushButton#postButton:hover, , GxsGroupDialog QPushButto
|
|||||||
}
|
}
|
||||||
|
|
||||||
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
|
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
|
||||||
CreateGxsChannelMsg QPushButton#postButton:disabled {
|
CreateGxsChannelMsg QPushButton#postButton:disabled, GxsCreateCommentDialog QPushButton#postButton:disabled {
|
||||||
font: bold;
|
font: bold;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: white;
|
color: white;
|
||||||
|
@ -1263,7 +1263,7 @@ ShareManager QPushButton#closeButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
|
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
|
||||||
CreateGxsChannelMsg QPushButton#postButton:disabled {
|
CreateGxsChannelMsg QPushButton#postButton:disabled, GxsCreateCommentDialog QPushButton#postButton:disabled {
|
||||||
font: bold;
|
font: bold;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: white;
|
color: white;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user