* Fixing the Post buttons to get disabled when the limit has been exceeded

This commit is contained in:
defnax 2020-10-28 22:53:42 +01:00
parent 30956f8de5
commit 11d3583233
7 changed files with 20 additions and 11 deletions

View file

@ -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"));

View file

@ -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 );
@ -77,6 +79,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"));

View file

@ -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 {
font: bold; font: bold;
font-size: 15px; font-size: 15px;
color: white; color: white;

View file

@ -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 {
font: bold; font: bold;
font-size: 15px; font-size: 15px;
color: white; color: white;

View file

@ -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 {
font: bold; font: bold;
font-size: 15px; font-size: 15px;
color: white; color: white;

View file

@ -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)"));
} }

View file

@ -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); }