* 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,8 +56,9 @@ PostedCreatePostDialog::PostedCreatePostDialog(RsPosted *posted, const RsGxsGrou
connect(ui->submitButton, SIGNAL(clicked()), this, SLOT(createPost()));
connect(ui->buttonBox, SIGNAL(rejected()), this, SLOT(close()));
connect(ui->addPicButton, SIGNAL(clicked() ), this , SLOT(addPicture()));
ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/postedlinks.png"));
connect(ui->RichTextEditWidget, SIGNAL(textSizeOk(bool)),ui->submitButton, SLOT(setEnabled(bool)));
ui->headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/postedlinks.png"));
ui->headerFrame->setHeaderText(tr("Create a new Post"));
setAttribute ( Qt::WA_DeleteOnClose, true );

View File

@ -58,10 +58,12 @@ CreateGxsChannelMsg::CreateGxsChannelMsg(const RsGxsGroupId &cId, RsGxsMessageId
headerFrame->setHeaderImage(FilesDefs::getPixmapFromQtResourcePath(":/icons/png/channel.png"));
if(!existing_post.isNull())
if(!existing_post.isNull()){
headerFrame->setHeaderText(tr("Edit Channel Post"));
else
postButton->setText(tr("Update"));
}else{
headerFrame->setHeaderText(tr("New Channel Post"));
}
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(generateCheckBox, SIGNAL(toggled(bool)), generateSpinBox, SLOT(setEnabled(bool)));
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"));
attachmentsButton->setIcon(FilesDefs::getIconFromQtResourcePath(":/icons/png/attachements.png"));

View File

@ -187,7 +187,8 @@ ShareManager QPushButton#addButton:hover {
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-size: 15px;
color: white;

View File

@ -2109,7 +2109,8 @@ GxsCreateCommentDialog QPushButton#postButton:hover, , GxsGroupDialog QPushButto
padding: 2px;
}
CreateGxsForumMsg QPushButton#postButton:disabled {
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
CreateGxsChannelMsg QPushButton#postButton:disabled {
font: bold;
font-size: 15px;
color: white;

View File

@ -1262,7 +1262,8 @@ ShareManager QPushButton#closeButton {
padding: 2px;
}
CreateGxsForumMsg QPushButton#postButton:disabled {
CreateGxsForumMsg QPushButton#postButton:disabled, PostedCreatePostDialog QPushButton#submitButton:disabled,
CreateGxsChannelMsg QPushButton#postButton:disabled {
font: bold;
font-size: 15px;
color: white;

View File

@ -602,15 +602,15 @@ void RichTextEdit::checkLength(){
if(charRemains >= 0) {
text = tr("It remains %1 characters after HTML conversion.").arg(charRemains);
f_info->setStyleSheet("QLabel#f_info { }");
emit textSizeOk(true);
}else{
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);
}
void RichTextEdit::setPlaceHolderTextPosted() {
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(); }
void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); }
signals:
void textSizeOk(bool);
public slots:
void setText(const QString &text);
void setPlaceHolderTextPosted();
protected slots:
void setPlainText(const QString &text) { f_textedit->setPlainText(text); }
void setHtml(const QString &text) { f_textedit->setHtml(text); }