mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
parent
89198f5e2d
commit
28979f5771
|
@ -743,7 +743,7 @@ void ChatForm::loadHistory(const QDateTime& since, bool processUndelivered)
|
|||
ChatMessage::MessageType type = isAction ? ChatMessage::ACTION : ChatMessage::NORMAL;
|
||||
QDateTime dateTime = needSending ? QDateTime() : msgDateTime;
|
||||
auto msg = ChatMessage::createChatMessage(authorStr, messageText, type, isSelf, dateTime);
|
||||
if (!isAction && needsToHideName(authorPk)) {
|
||||
if (!isAction && needsToHideName(authorPk, msgDateTime)) {
|
||||
msg->hideSender();
|
||||
}
|
||||
|
||||
|
|
|
@ -378,11 +378,12 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos)
|
|||
/**
|
||||
* @brief Show, is it needed to hide message author name or not
|
||||
* @param messageAuthor Author of the sent message
|
||||
* @oaran messageTime DateTime of the sent message
|
||||
* @return True if it's needed to hide name, false otherwise
|
||||
*/
|
||||
bool GenericChatForm::needsToHideName(const ToxPk& messageAuthor) const
|
||||
bool GenericChatForm::needsToHideName(const ToxPk& messageAuthor, const QDateTime& messageTime) const
|
||||
{
|
||||
qint64 messagesTimeDiff = prevMsgDateTime.secsTo(QDateTime::currentDateTime());
|
||||
qint64 messagesTimeDiff = prevMsgDateTime.secsTo(messageTime);
|
||||
return messageAuthor == previousId && messagesTimeDiff < chatWidget->repNameAfter;
|
||||
}
|
||||
|
||||
|
@ -411,12 +412,13 @@ ChatMessage::Ptr GenericChatForm::createMessage(const ToxPk& author, const QStri
|
|||
previousId = ToxPk{};
|
||||
} else {
|
||||
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::NORMAL, isSelf);
|
||||
if (needsToHideName(author)) {
|
||||
const QDateTime newMsgDateTime = QDateTime::currentDateTime();
|
||||
if (needsToHideName(author, newMsgDateTime)) {
|
||||
msg->hideSender();
|
||||
}
|
||||
|
||||
previousId = author;
|
||||
prevMsgDateTime = QDateTime::currentDateTime();
|
||||
prevMsgDateTime = newMsgDateTime;
|
||||
}
|
||||
|
||||
if (isSent) {
|
||||
|
@ -459,13 +461,14 @@ void GenericChatForm::addAlertMessage(const ToxPk& author, const QString& msg, c
|
|||
QString authorStr = resolveToxPk(author);
|
||||
bool isSelf = author == Core::getInstance()->getSelfId().getPublicKey();
|
||||
auto chatMsg = ChatMessage::createChatMessage(authorStr, msg, ChatMessage::ALERT, isSelf, dt);
|
||||
if (needsToHideName(author)) {
|
||||
const QDateTime newMsgDateTime = QDateTime::currentDateTime();
|
||||
if (needsToHideName(author, newMsgDateTime)) {
|
||||
chatMsg->hideSender();
|
||||
}
|
||||
|
||||
insertChatMessage(chatMsg);
|
||||
previousId = author;
|
||||
prevMsgDateTime = QDateTime::currentDateTime();
|
||||
prevMsgDateTime = newMsgDateTime;
|
||||
}
|
||||
|
||||
void GenericChatForm::onEmoteButtonClicked()
|
||||
|
|
|
@ -108,7 +108,7 @@ protected:
|
|||
const QDateTime& datetime, bool isAction, bool isSent);
|
||||
ChatMessage::Ptr createSelfMessage(const QString& message, const QDateTime& datetime,
|
||||
bool isAction, bool isSent);
|
||||
bool needsToHideName(const ToxPk& author) const;
|
||||
bool needsToHideName(const ToxPk& messageAuthor, const QDateTime& messageTime) const;
|
||||
void showNetcam();
|
||||
void hideNetcam();
|
||||
virtual GenericNetCamView* createNetcam() = 0;
|
||||
|
|
Loading…
Reference in New Issue
Block a user