Added size limit for chat types - Public, Private, Lobby, Distant

Set the size limit for private and distant chat to unlimited.

git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@7761 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
thunder2 2014-12-16 10:39:56 +00:00
parent 93f77a0e2c
commit 55be6675af
6 changed files with 60 additions and 17 deletions

View file

@ -848,10 +848,29 @@ void ChatWidget::updateLenOfChatTextEdit()
QString text;
RsHtml::optimizeHtml(chatWidget, text);
std::wstring msg = text.toStdWString();
bool msgToLarge = (msg.length()>=size_t(rsMsgs->getMaxMessageSecuritySize()));
uint32_t maxMessageSize = 0;
switch (chatType()) {
case CHATTYPE_UNKNOWN:
break;
case CHATTYPE_PRIVATE:
maxMessageSize = rsMsgs->getMaxMessageSecuritySize(RS_CHAT_TYPE_PRIVATE);
break;
case CHATTYPE_LOBBY:
maxMessageSize = rsMsgs->getMaxMessageSecuritySize(RS_CHAT_TYPE_LOBBY);
break;
case CHATTYPE_DISTANT:
maxMessageSize = rsMsgs->getMaxMessageSecuritySize(RS_CHAT_TYPE_DISTANT);
break;
}
bool msgToLarge = false;
if (maxMessageSize > 0) {
msgToLarge = (msg.length() >= maxMessageSize);
}
ui->sendButton->setEnabled(!msgToLarge);
text = tr("%1This message counts %2 characters.").arg(msgToLarge?tr("Warning: "):"").arg(msg.length());
text = tr("%1This message counts %2 characters.").arg(msgToLarge ? tr("Warning: ") : "").arg(msg.length());
ui->sendButton->setToolTip(text);
ui->chatTextEdit->setToolTip(msgToLarge?text:"");
}