Browse Source

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
pull/1535/head
kushagra 10 years ago committed by tux3
parent
commit
b4f72b620d
  1. 2
      src/chatlog/chatmessage.cpp
  2. 4
      src/widget/form/chatform.cpp
  3. 5
      src/widget/form/groupchatform.cpp
  4. 2
      src/widget/widget.cpp

2
src/chatlog/chatmessage.cpp

@ -67,7 +67,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt @@ -67,7 +67,7 @@ ChatMessage::Ptr ChatMessage::createChatMessage(const QString &sender, const QSt
// 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(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));
if(!date.isNull())

4
src/widget/form/chatform.cpp

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

5
src/widget/form/groupchatform.cpp

@ -116,7 +116,10 @@ void GroupChatForm::onSendTriggered() @@ -116,7 +116,10 @@ void GroupChatForm::onSendTriggered()
}
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);
}
}

2
src/widget/widget.cpp

@ -737,7 +737,7 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool @@ -737,7 +737,7 @@ void Widget::onFriendMessageReceived(int friendId, const QString& message, bool
QDateTime timestamp = QDateTime::currentDateTime();
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->setEventFlag(f->getFriendWidget() != activeChatroomWidget);

Loading…
Cancel
Save