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

added sending actions, and tested both ways

This commit is contained in:
dubslow 2014-10-02 02:00:06 -05:00
parent 5f106ab618
commit cfa39460bf
5 changed files with 18 additions and 3 deletions

View File

@ -10,7 +10,7 @@ div.message {
} }
div.action { div.action {
color: @blue; color: #1818FF;
font: @big; font: @big;
} }

View File

@ -86,10 +86,19 @@ void ChatForm::onSendTriggered()
if (msg.isEmpty()) if (msg.isEmpty())
return; return;
QString name = Widget::getInstance()->getUsername(); QString name = Widget::getInstance()->getUsername();
msgEdit->clear(); if (msg.startsWith("/me "))
addMessage(name, msg); {
msg = msg.right(msg.length() - 4);
addMessage(name, msg, true);
emit sendAction(f->friendId, msg);
}
else
{
addMessage(name, msg, false);
emit sendMessage(f->friendId, msg); emit sendMessage(f->friendId, msg);
} }
msgEdit->clear();
}
void ChatForm::onAttachClicked() void ChatForm::onAttachClicked()
{ {

View File

@ -173,7 +173,11 @@ void GenericChatForm::addMessage(QString author, QString message, bool isAction,
bool isMe = (author == Widget::getInstance()->getUsername()); bool isMe = (author == Widget::getInstance()->getUsername());
if (isAction) if (isAction)
{
chatWidget->insertMessage(new ActionAction (getElidedName(author), message, date, isMe)); chatWidget->insertMessage(new ActionAction (getElidedName(author), message, date, isMe));
previousName = ""; // next msg has a name regardless
return;
}
else if (previousName == author) else if (previousName == author)
chatWidget->insertMessage(new MessageAction("", message, date, isMe)); chatWidget->insertMessage(new MessageAction("", message, date, isMe));
else else

View File

@ -49,6 +49,7 @@ public:
signals: signals:
void sendMessage(int, QString); void sendMessage(int, QString);
void sendAction(int, QString);
public slots: public slots:
void focusInput(); void focusInput();

View File

@ -455,6 +455,7 @@ void Widget::addFriend(int friendId, const QString &userId)
connect(newfriend->widget, SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int))); connect(newfriend->widget, SIGNAL(copyFriendIdToClipboard(int)), this, SLOT(copyFriendIdToClipboard(int)));
connect(newfriend->widget, SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newfriend->chatForm, SLOT(focusInput())); connect(newfriend->widget, SIGNAL(chatroomWidgetClicked(GenericChatroomWidget*)), newfriend->chatForm, SLOT(focusInput()));
connect(newfriend->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendMessage(int,QString))); connect(newfriend->chatForm, SIGNAL(sendMessage(int,QString)), core, SLOT(sendMessage(int,QString)));
connect(newfriend->chatForm, &GenericChatForm::sendAction, core, &Core::sendAction);
connect(newfriend->chatForm, SIGNAL(sendFile(int32_t, QString, QString, long long)), core, SLOT(sendFile(int32_t, QString, QString, long long))); connect(newfriend->chatForm, SIGNAL(sendFile(int32_t, QString, QString, long long)), core, SLOT(sendFile(int32_t, QString, QString, long long)));
connect(newfriend->chatForm, SIGNAL(answerCall(int)), core, SLOT(answerCall(int))); connect(newfriend->chatForm, SIGNAL(answerCall(int)), core, SLOT(answerCall(int)));
connect(newfriend->chatForm, SIGNAL(hangupCall(int)), core, SLOT(hangupCall(int))); connect(newfriend->chatForm, SIGNAL(hangupCall(int)), core, SLOT(hangupCall(int)));