(chatWidget->getTypingNotification()->getContent(1));
QString name = f->getDisplayedName();
text->setText("" + tr("%1 is typing").arg(name) + "
");
}
void ChatForm::show(ContentLayout* contentLayout)
{
GenericChatForm::show(contentLayout);
if (callConfirm)
{
callConfirm->show();
}
}
void ChatForm::showEvent(QShowEvent* event)
{
if (callConfirm)
{
callConfirm->show();
}
GenericChatForm::showEvent(event);
}
void ChatForm::hideEvent(QHideEvent* event)
{
if (callConfirm)
{
callConfirm->hide();
}
GenericChatForm::hideEvent(event);
}
OfflineMsgEngine *ChatForm::getOfflineMsgEngine()
{
return offlineEngine;
}
void ChatForm::SendMessageStr(QString msg)
{
if (msg.isEmpty())
{
return;
}
bool isAction = msg.startsWith(ACTION_PREFIX, Qt::CaseInsensitive);
if (isAction)
{
msg.remove(0, ACTION_PREFIX.length());
}
QList splittedMsg = Core::splitMessage(msg, TOX_MAX_MESSAGE_LENGTH);
QDateTime timestamp = QDateTime::currentDateTime();
for (CString& c_msg : splittedMsg)
{
QString qt_msg = CString::toString(c_msg.data(), c_msg.size());
QString qt_msg_hist = qt_msg;
if (isAction)
{
qt_msg_hist = ACTION_PREFIX + qt_msg;
}
bool status = !Settings::getInstance().getFauxOfflineMessaging();
ChatMessage::Ptr ma = addSelfMessage(qt_msg, isAction, timestamp, false);
Core* core = Core::getInstance();
uint32_t friendId = f->getFriendId();
int rec = isAction ? core->sendAction(friendId, qt_msg)
: core->sendMessage(friendId, qt_msg);
Profile* profile = Nexus::getProfile();
if (profile->isHistoryEnabled())
{
auto* offMsgEngine = getOfflineMsgEngine();
QString selfPk = Core::getInstance()->getSelfId().publicKey;
QString pk = f->getToxId().getPublicKeyString();
QString name = Core::getInstance()->getUsername();
profile->getHistory()->addNewMessage(
pk, qt_msg_hist, selfPk, timestamp, status,
name, [offMsgEngine, rec, ma](int64_t id)
{
offMsgEngine->registerReceipt(rec, id, ma);
});
}
else
{
// TODO: Make faux-offline messaging work partially with the history disabled
ma->markAsSent(QDateTime::currentDateTime());
}
msgEdit->setLastMessage(msg); //set last message only when sending it
Widget::getInstance()->updateFriendActivity(f);
}
}
void ChatForm::retranslateUi()
{
QString volObjectName = volButton->objectName();
QString micObjectName = micButton->objectName();
loadHistoryAction->setText(tr("Load chat history..."));
copyStatusAction->setText(tr("Copy"));
updateMuteMicButton();
updateMuteVolButton();
if (netcam)
{
netcam->setShowMessages(chatWidget->isVisible());
}
}