mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-05-07 00:25:16 -04:00
add changing state for Send button in chat when msg size exceeds allowed size (Patch from Phenom)
git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7438 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
24ad4b8880
commit
8667cf9f92
9 changed files with 56 additions and 3 deletions
|
@ -131,6 +131,7 @@ ChatWidget::ChatWidget(QWidget *parent) :
|
|||
connect(ui->chatTextEdit, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenu(QPoint)));
|
||||
// reset text and color after removing all characters from the QTextEdit and after calling QTextEdit::clear
|
||||
connect(ui->chatTextEdit, SIGNAL(currentCharFormatChanged(QTextCharFormat)), this, SLOT(chatCharFormatChanged()));
|
||||
connect(ui->chatTextEdit, SIGNAL(textChanged()), this, SLOT(updateLenOfChatTextEdit()));
|
||||
|
||||
ui->infoFrame->setVisible(false);
|
||||
ui->statusMessageLabel->hide();
|
||||
|
@ -837,8 +838,27 @@ void ChatWidget::updateStatusTyping()
|
|||
}
|
||||
}
|
||||
|
||||
void ChatWidget::updateLenOfChatTextEdit()
|
||||
{
|
||||
QTextEdit *chatWidget = ui->chatTextEdit;
|
||||
QString text;
|
||||
RsHtml::optimizeHtml(chatWidget, text);
|
||||
std::wstring msg = text.toStdWString();
|
||||
bool msgToLarge = (msg.length()>=size_t(rsMsgs->getMaxMessageSecuritySize()));
|
||||
|
||||
ui->sendButton->setEnabled(!msgToLarge);
|
||||
text = tr("%1This message counts %2 characters.").arg(msgToLarge?tr("Warning: "):"").arg(msg.length());
|
||||
ui->sendButton->setToolTip(text);
|
||||
ui->chatTextEdit->setToolTip(msgToLarge?text:"");
|
||||
}
|
||||
|
||||
void ChatWidget::sendChat()
|
||||
{
|
||||
if (!ui->sendButton->isEnabled()){
|
||||
//Something block sending
|
||||
return;
|
||||
}
|
||||
|
||||
QTextEdit *chatWidget = ui->chatTextEdit;
|
||||
|
||||
if (chatWidget->toPlainText().isEmpty()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue