mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
fix(ui): add date message before info messages
Fixes #4388. Separated date message in its own function. Also added date message before info messages like it is already done with normal chat messages.
This commit is contained in:
parent
331a8f1006
commit
ed45359863
|
@ -402,9 +402,7 @@ ChatMessage::Ptr GenericChatForm::createMessage(const ToxPk& author, const QStri
|
|||
bool isSelf = author == core->getSelfId().getPublicKey();
|
||||
QString authorStr = isSelf ? core->getUsername() : resolveToxPk(author);
|
||||
if (getLatestDate() != QDate::currentDate()) {
|
||||
const Settings& s = Settings::getInstance();
|
||||
QString dateText = QDate::currentDate().toString(s.getDateFormat());
|
||||
addSystemInfoMessage(dateText, ChatMessage::INFO, QDateTime());
|
||||
addSystemDateMessage();
|
||||
}
|
||||
|
||||
ChatMessage::Ptr msg;
|
||||
|
@ -553,10 +551,23 @@ void GenericChatForm::onChatMessageFontChanged(const QFont& font)
|
|||
void GenericChatForm::addSystemInfoMessage(const QString& message, ChatMessage::SystemMessageType type,
|
||||
const QDateTime& datetime)
|
||||
{
|
||||
if (getLatestDate() != QDate::currentDate()) {
|
||||
addSystemDateMessage();
|
||||
}
|
||||
|
||||
previousId = ToxPk();
|
||||
insertChatMessage(ChatMessage::createChatInfoMessage(message, type, datetime));
|
||||
}
|
||||
|
||||
void GenericChatForm::addSystemDateMessage()
|
||||
{
|
||||
const Settings& s = Settings::getInstance();
|
||||
QString dateText = QDate::currentDate().toString(s.getDateFormat());
|
||||
|
||||
previousId = ToxPk();
|
||||
insertChatMessage(ChatMessage::createChatInfoMessage(dateText, ChatMessage::INFO, QDateTime()));
|
||||
}
|
||||
|
||||
void GenericChatForm::clearChatArea()
|
||||
{
|
||||
clearChatArea(true);
|
||||
|
|
|
@ -101,6 +101,7 @@ protected slots:
|
|||
|
||||
private:
|
||||
void retranslateUi();
|
||||
void addSystemDateMessage();
|
||||
|
||||
protected:
|
||||
ChatMessage::Ptr createMessage(const ToxPk& author, const QString& message,
|
||||
|
|
Loading…
Reference in New Issue
Block a user