mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-07-28 00:45:34 -04:00
Merge pull request #2089 from defnax/Postbutton-fix
Fixing the Post buttons to get disabled when the limit has been exceeded
This commit is contained in:
commit
c8939bf8fb
10 changed files with 85 additions and 43 deletions
|
@ -56,6 +56,7 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou
|
||||||
connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(createPost()));
|
connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(createPost()));
|
||||||
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
|
||||||
connect(ui->addPicButton, SIGNAL(clicked() ), this , SLOT(addPicture()));
|
connect(ui->addPicButton, SIGNAL(clicked() ), this , SLOT(addPicture()));
|
||||||
|
connect(ui->RichTextEditWidget, SIGNAL(textSizeOk(bool)),ui->submitButton, SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/postedlinks.png"));
|
ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/postedlinks.png"));
|
||||||
ui->headerFrame->setHeaderText(tr("Create a new Post"));
|
ui->headerFrame->setHeaderText(tr("Create a new Post"));
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -58,10 +58,12 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
|
||||||
|
|
||||||
headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channel.png"));
|
headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channel.png"));
|
||||||
|
|
||||||
if(!existing_post.isNull())
|
if(!existing_post.isNull()){
|
||||||
headerFrame->setHeaderText(tr("Edit Channel Post"));
|
headerFrame->setHeaderText(tr("Edit Channel Post"));
|
||||||
else
|
postButton->setText(tr("Update"));
|
||||||
|
}else{
|
||||||
headerFrame->setHeaderText(tr("New Channel Post"));
|
headerFrame->setHeaderText(tr("New Channel Post"));
|
||||||
|
}
|
||||||
|
|
||||||
setAttribute ( Qt::WA_DeleteOnClose, true );
|
setAttribute ( Qt::WA_DeleteOnClose, true );
|
||||||
|
|
||||||
|
@ -79,6 +81,7 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
|
||||||
connect(stackedWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
|
connect(stackedWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
|
||||||
connect(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool)));
|
connect(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool)));
|
||||||
connect(aspectRatio_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(changeAspectRatio(int)));
|
connect(aspectRatio_CB,SIGNAL(currentIndexChanged(int)),this,SLOT(changeAspectRatio(int)));
|
||||||
|
connect(RichTextEditWidget, SIGNAL(textSizeOk(bool)),postButton, SLOT(setEnabled(bool)));
|
||||||
|
|
||||||
channelpostButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/comment.png"));
|
channelpostButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/comment.png"));
|
||||||
attachmentsButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/attachements.png"));
|
attachmentsButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/attachements.png"));
|
||||||
|
|
|
@ -187,7 +187,8 @@ ShareManager QPushButton#addButton:hover {
|
||||||
padding: 4px;
|
padding: 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#postButton:disabled {
|
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
|
||||||
|
CreateGxsChannelMsg QPushButton#postButton:disabled, GxsCreateCommentDialog QPushButton#postButton:disabled {
|
||||||
font: bold;
|
font: bold;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: white;
|
color: white;
|
||||||
|
|
|
@ -2109,7 +2109,8 @@ GxsCreateCommentDialog QPushButton#postButton:hover, , GxsGroupDialog QPushButto
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateGxsForumMsg QPushButton#postButton:disabled {
|
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
|
||||||
|
CreateGxsChannelMsg QPushButton#postButton:disabled, GxsCreateCommentDialog QPushButton#postButton:disabled {
|
||||||
font: bold;
|
font: bold;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: white;
|
color: white;
|
||||||
|
|
|
@ -1262,7 +1262,8 @@ ShareManager QPushButton#closeButton {
|
||||||
padding: 2px;
|
padding: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
CreateGxsForumMsg QPushButton#postButton:disabled {
|
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
|
||||||
|
CreateGxsChannelMsg QPushButton#postButton:disabled, GxsCreateCommentDialog QPushButton#postButton:disabled {
|
||||||
font: bold;
|
font: bold;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
color: white;
|
color: white;
|
||||||
|
|
|
@ -602,15 +602,15 @@ void RichTextEdit::checkLength(){
|
||||||
if(charRemains >= 0) {
|
if(charRemains >= 0) {
|
||||||
text = tr("It remains %1 characters after HTML conversion.").arg(charRemains);
|
text = tr("It remains %1 characters after HTML conversion.").arg(charRemains);
|
||||||
f_info->setStyleSheet("QLabel#f_info { }");
|
f_info->setStyleSheet("QLabel#f_info { }");
|
||||||
|
emit textSizeOk(true);
|
||||||
}else{
|
}else{
|
||||||
text = tr("Warning: This message is too big of %1 characters after HTML conversion.").arg((0-charRemains));
|
text = tr("Warning: This message is too big of %1 characters after HTML conversion.").arg((0-charRemains));
|
||||||
f_info->setStyleSheet("QLabel#f_info {color: red; font: bold; }");
|
f_info->setStyleSheet("QLabel#f_info {color: red; font: bold; }");
|
||||||
|
emit textSizeOk(false);
|
||||||
}
|
}
|
||||||
//buttonBox->button(QDialogButtonBox::Ok)->setEnabled(charRemains>=0);
|
|
||||||
f_info->setText(text);
|
f_info->setText(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RichTextEdit::setPlaceHolderTextPosted() {
|
void RichTextEdit::setPlaceHolderTextPosted() {
|
||||||
f_textedit->setPlaceholderText(tr("Text (optional)"));
|
f_textedit->setPlaceholderText(tr("Text (optional)"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,11 +38,13 @@ class RichTextEdit : public QWidget, protected Ui::RichTextEdit {
|
||||||
QTextCursor textCursor() const { return f_textedit->textCursor(); }
|
QTextCursor textCursor() const { return f_textedit->textCursor(); }
|
||||||
void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); }
|
void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); }
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void textSizeOk(bool);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void setText(const QString &text);
|
void setText(const QString &text);
|
||||||
void setPlaceHolderTextPosted();
|
void setPlaceHolderTextPosted();
|
||||||
|
|
||||||
|
|
||||||
protected slots:
|
protected slots:
|
||||||
void setPlainText(const QString &text) { f_textedit->setPlainText(text); }
|
void setPlainText(const QString &text) { f_textedit->setPlainText(text); }
|
||||||
void setHtml(const QString &text) { f_textedit->setHtml(text); }
|
void setHtml(const QString &text) { f_textedit->setHtml(text); }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue