mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Merge pull request #4620
anthony.bilinski (1): fix(chatform): Hide author on history like on new messages
This commit is contained in:
commit
c49959711e
|
@ -743,7 +743,7 @@ void ChatForm::loadHistory(const QDateTime& since, bool processUndelivered)
|
||||||
ChatMessage::MessageType type = isAction ? ChatMessage::ACTION : ChatMessage::NORMAL;
|
ChatMessage::MessageType type = isAction ? ChatMessage::ACTION : ChatMessage::NORMAL;
|
||||||
QDateTime dateTime = needSending ? QDateTime() : msgDateTime;
|
QDateTime dateTime = needSending ? QDateTime() : msgDateTime;
|
||||||
auto msg = ChatMessage::createChatMessage(authorStr, messageText, type, isSelf, dateTime);
|
auto msg = ChatMessage::createChatMessage(authorStr, messageText, type, isSelf, dateTime);
|
||||||
if (!isAction && needsToHideName(authorPk)) {
|
if (!isAction && needsToHideName(authorPk, msgDateTime)) {
|
||||||
msg->hideSender();
|
msg->hideSender();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -378,11 +378,12 @@ void GenericChatForm::onChatContextMenuRequested(QPoint pos)
|
||||||
/**
|
/**
|
||||||
* @brief Show, is it needed to hide message author name or not
|
* @brief Show, is it needed to hide message author name or not
|
||||||
* @param messageAuthor Author of the sent message
|
* @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
|
* @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;
|
return messageAuthor == previousId && messagesTimeDiff < chatWidget->repNameAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,12 +412,13 @@ ChatMessage::Ptr GenericChatForm::createMessage(const ToxPk& author, const QStri
|
||||||
previousId = ToxPk{};
|
previousId = ToxPk{};
|
||||||
} else {
|
} else {
|
||||||
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::NORMAL, isSelf);
|
msg = ChatMessage::createChatMessage(authorStr, message, ChatMessage::NORMAL, isSelf);
|
||||||
if (needsToHideName(author)) {
|
const QDateTime newMsgDateTime = QDateTime::currentDateTime();
|
||||||
|
if (needsToHideName(author, newMsgDateTime)) {
|
||||||
msg->hideSender();
|
msg->hideSender();
|
||||||
}
|
}
|
||||||
|
|
||||||
previousId = author;
|
previousId = author;
|
||||||
prevMsgDateTime = QDateTime::currentDateTime();
|
prevMsgDateTime = newMsgDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isSent) {
|
if (isSent) {
|
||||||
|
@ -459,13 +461,14 @@ void GenericChatForm::addAlertMessage(const ToxPk& author, const QString& msg, c
|
||||||
QString authorStr = resolveToxPk(author);
|
QString authorStr = resolveToxPk(author);
|
||||||
bool isSelf = author == Core::getInstance()->getSelfId().getPublicKey();
|
bool isSelf = author == Core::getInstance()->getSelfId().getPublicKey();
|
||||||
auto chatMsg = ChatMessage::createChatMessage(authorStr, msg, ChatMessage::ALERT, isSelf, dt);
|
auto chatMsg = ChatMessage::createChatMessage(authorStr, msg, ChatMessage::ALERT, isSelf, dt);
|
||||||
if (needsToHideName(author)) {
|
const QDateTime newMsgDateTime = QDateTime::currentDateTime();
|
||||||
|
if (needsToHideName(author, newMsgDateTime)) {
|
||||||
chatMsg->hideSender();
|
chatMsg->hideSender();
|
||||||
}
|
}
|
||||||
|
|
||||||
insertChatMessage(chatMsg);
|
insertChatMessage(chatMsg);
|
||||||
previousId = author;
|
previousId = author;
|
||||||
prevMsgDateTime = QDateTime::currentDateTime();
|
prevMsgDateTime = newMsgDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GenericChatForm::onEmoteButtonClicked()
|
void GenericChatForm::onEmoteButtonClicked()
|
||||||
|
|
|
@ -108,7 +108,7 @@ protected:
|
||||||
const QDateTime& datetime, bool isAction, bool isSent);
|
const QDateTime& datetime, bool isAction, bool isSent);
|
||||||
ChatMessage::Ptr createSelfMessage(const QString& message, const QDateTime& datetime,
|
ChatMessage::Ptr createSelfMessage(const QString& message, const QDateTime& datetime,
|
||||||
bool isAction, bool isSent);
|
bool isAction, bool isSent);
|
||||||
bool needsToHideName(const ToxPk& author) const;
|
bool needsToHideName(const ToxPk& messageAuthor, const QDateTime& messageTime) const;
|
||||||
void showNetcam();
|
void showNetcam();
|
||||||
void hideNetcam();
|
void hideNetcam();
|
||||||
virtual GenericNetCamView* createNetcam() = 0;
|
virtual GenericNetCamView* createNetcam() = 0;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user