1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fixes action bugs

1) action received gets modified on restart
2) sender's name is written twice if action is sent using offline messaging
3) /me is written when action is sent in groupchat having one peer
4) /me is not saved in last message variable in friendd chat
This commit is contained in:
kushagra 2015-03-29 20:06:43 +05:30 committed by tux3
parent 2d29c3d9f4
commit b4f72b620d
4 changed files with 36 additions and 33 deletions

View File

@ -67,7 +67,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
// Note: Eliding cannot be enabled for RichText items. (QTBUG-17207) // Note: Eliding cannot be enabled for RichText items. (QTBUG-17207)
msg->addColumn(new Text(senderText, isMe ? Style::getFont(Style::BigBold) : Style::getFont(Style::Big), true, sender, type == ACTION ? actionColor : Qt::black), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); msg->addColumn(new Text(senderText, isMe ? Style::getFont(Style::BigBold) : Style::getFont(Style::Big), true, sender, type == ACTION ? actionColor : Qt::black), ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
msg->addColumn(new Text(text, Style::getFont(Style::Big), false, type == ACTION ? QString("*%1 %2*").arg(sender, rawMessage) : rawMessage), ColumnFormat(1.0, ColumnFormat::VariableSize)); msg->addColumn(new Text(text, Style::getFont(Style::Big), false, type == (ACTION && isMe) ? QString("%1 %2").arg(sender, rawMessage) : rawMessage), ColumnFormat(1.0, ColumnFormat::VariableSize));
msg->addColumn(new Spinner(":/ui/chatArea/spinner.svg", QSize(16, 16), 360.0/1.6), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right)); msg->addColumn(new Spinner(":/ui/chatArea/spinner.svg", QSize(16, 16), 360.0/1.6), ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
if(!date.isNull()) if(!date.isNull())

View File

@ -116,6 +116,8 @@ void ChatForm::onSendTriggered()
if (msg.isEmpty()) if (msg.isEmpty())
return; return;
msgEdit->setLastMessage(msg); //set last message only when sending it
bool isAction = msg.startsWith("/me "); bool isAction = msg.startsWith("/me ");
if (isAction) if (isAction)
msg = msg = msg.right(msg.length() - 4); msg = msg = msg.right(msg.length() - 4);
@ -123,8 +125,6 @@ void ChatForm::onSendTriggered()
QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH); QList<CString> splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
QDateTime timestamp = QDateTime::currentDateTime(); QDateTime timestamp = QDateTime::currentDateTime();
msgEdit->setLastMessage(msg); //set last message only when sending it
bool status = !Settings::getInstance().getFauxOfflineMessaging(); bool status = !Settings::getInstance().getFauxOfflineMessaging();
for (CString& c_msg : splittedMsg) for (CString& c_msg : splittedMsg)

View File

@ -116,7 +116,10 @@ void GroupChatForm::onSendTriggered()
} }
else else
{ {
addSelfMessage(msg, msg.startsWith("/me "), QDateTime::currentDateTime(), true); if (msg.startsWith("/me "))
addSelfMessage(msg.right(msg.length() - 4), true, QDateTime::currentDateTime(), true);
else
addSelfMessage(msg, false, QDateTime::currentDateTime(), true);
} }
} }

View File

@ -737,7 +737,7 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool
QDateTime timestamp = QDateTime::currentDateTime(); QDateTime timestamp = QDateTime::currentDateTime();
f->getChatForm()->addMessage(f->getToxID(), message, isAction, timestamp, true); f->getChatForm()->addMessage(f->getToxID(), message, isAction, timestamp, true);
HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, isAction ? "/me " + message : message, HistoryKeeper::getInstance()->addChatEntry(f->getToxID().publicKey, isAction ? "/me " + f->getDisplayedName() + " " + message : message,
f->getToxID().publicKey, timestamp, true); f->getToxID().publicKey, timestamp, true);
f->setEventFlag(f->getFriendWidget() != activeChatroomWidget); f->setEventFlag(f->getFriendWidget() != activeChatroomWidget);