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 <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) :
|
||||
QDialog(parent),
|
||||
ui(new Ui::GxsCreateCommentDialog), mCommentService(service), mParentId(parentId), mThreadId(threadId)
|
||||
@ -33,6 +35,7 @@ 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);
|
||||
@ -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);
|
||||
}
|
@ -43,6 +43,7 @@ public:
|
||||
|
||||
private slots:
|
||||
void createComment();
|
||||
void checkLength();
|
||||
|
||||
private:
|
||||
Ui::GxsCreateCommentDialog *ui;
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>459</width>
|
||||
<height>324</height>
|
||||
<width>505</width>
|
||||
<height>367</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -32,7 +32,7 @@
|
||||
<item row="0" column="0">
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
@ -142,17 +142,20 @@ p, li { white-space: pre-wrap; }
|
||||
<property name="topMargin">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="GxsIdLabel" name="replaytolabel">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
<item row="5" column="0">
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>276</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="MimeTextEdit" name="commentTextEdit">
|
||||
<property name="styleSheet">
|
||||
<string notr="true"/>
|
||||
@ -162,7 +165,21 @@ p, li { white-space: pre-wrap; }
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<item>
|
||||
<widget class="QLabel" name="signedLabel">
|
||||
@ -186,30 +203,26 @@ p, li { white-space: pre-wrap; }
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<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">
|
||||
<item row="5" column="1">
|
||||
<widget class="QPushButton" name="postButton">
|
||||
<property name="text">
|
||||
<string>Post</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="2">
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<item row="0" column="0" colspan="3">
|
||||
<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">
|
||||
<string>Cancel</string>
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user