From e3ce8b486a0f75bc1a839ed12e112a3b5463af01 Mon Sep 17 00:00:00 2001 From: Pro Date: Tue, 12 May 2015 18:17:12 -0700 Subject: [PATCH 1/2] make /ME work --- src/widget/form/chatform.cpp | 4 ++-- src/widget/form/groupchatform.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index a37f9d7f8..3cd22aa7e 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -815,7 +815,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered) // Show each messages ToxID authorId = ToxID::fromString(it.sender); QString authorStr = authorId.isMine() ? Core::getInstance()->getUsername() : resolveToxID(authorId); - bool isAction = it.message.startsWith("/me "); + bool isAction = it.message.startsWith("/me ") || it.message.startsWith("/ME "); ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr, isAction ? it.message.right(it.message.length() - 4) : it.message, @@ -999,7 +999,7 @@ void ChatForm::SendMessageStr(QString msg) if (msg.isEmpty()) return; - bool isAction = msg.startsWith("/me "); + bool isAction = msg.startsWith("/me ") || msg.startsWith("/ME "); if (isAction) msg = msg = msg.right(msg.length() - 4); diff --git a/src/widget/form/groupchatform.cpp b/src/widget/form/groupchatform.cpp index c9cea1236..96733ec5e 100644 --- a/src/widget/form/groupchatform.cpp +++ b/src/widget/form/groupchatform.cpp @@ -101,7 +101,7 @@ void GroupChatForm::onSendTriggered() if (group->getPeersCount() != 1) { - if (msg.startsWith("/me ")) + if (msg.startsWith("/me ") || msg.startsWith("/ME ")) { msg = msg.right(msg.length() - 4); emit sendAction(group->getGroupId(), msg); @@ -113,7 +113,7 @@ void GroupChatForm::onSendTriggered() } else { - if (msg.startsWith("/me ")) + if (msg.startsWith("/me ") || msg.startsWith("/ME ")) addSelfMessage(msg.right(msg.length() - 4), true, QDateTime::currentDateTime(), true); else addSelfMessage(msg, false, QDateTime::currentDateTime(), true); From 15f0360d4efeaf41788fb85e75d84e6d2fe8cb31 Mon Sep 17 00:00:00 2001 From: Pro Date: Tue, 12 May 2015 19:18:55 -0700 Subject: [PATCH 2/2] change to Qt::CaseInseisitive --- src/widget/form/chatform.cpp | 4 ++-- src/widget/form/groupchatform.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 3cd22aa7e..e75728116 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -815,7 +815,7 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered) // Show each messages ToxID authorId = ToxID::fromString(it.sender); QString authorStr = authorId.isMine() ? Core::getInstance()->getUsername() : resolveToxID(authorId); - bool isAction = it.message.startsWith("/me ") || it.message.startsWith("/ME "); + bool isAction = it.message.startsWith("/me ", Qt::CaseInsensitive); ChatMessage::Ptr msg = ChatMessage::createChatMessage(authorStr, isAction ? it.message.right(it.message.length() - 4) : it.message, @@ -999,7 +999,7 @@ void ChatForm::SendMessageStr(QString msg) if (msg.isEmpty()) return; - bool isAction = msg.startsWith("/me ") || msg.startsWith("/ME "); + bool isAction = msg.startsWith("/me ", Qt::CaseInsensitive); if (isAction) msg = msg = msg.right(msg.length() - 4); diff --git a/src/widget/form/groupchatform.cpp b/src/widget/form/groupchatform.cpp index 96733ec5e..ab6411a00 100644 --- a/src/widget/form/groupchatform.cpp +++ b/src/widget/form/groupchatform.cpp @@ -101,7 +101,7 @@ void GroupChatForm::onSendTriggered() if (group->getPeersCount() != 1) { - if (msg.startsWith("/me ") || msg.startsWith("/ME ")) + if (msg.startsWith("/me ", Qt::CaseInsensitive)) { msg = msg.right(msg.length() - 4); emit sendAction(group->getGroupId(), msg); @@ -113,7 +113,7 @@ void GroupChatForm::onSendTriggered() } else { - if (msg.startsWith("/me ") || msg.startsWith("/ME ")) + if (msg.startsWith("/me ", Qt::CaseInsensitive)) addSelfMessage(msg.right(msg.length() - 4), true, QDateTime::currentDateTime(), true); else addSelfMessage(msg, false, QDateTime::currentDateTime(), true);