1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

Merge pull request #4440

ezavod (1):
      fix(ui): add date message before info messages
This commit is contained in:
sudden6 2017-06-04 23:52:13 +02:00
commit 98a01dfefc
No known key found for this signature in database
GPG Key ID: 279509B499E032B9
2 changed files with 15 additions and 3 deletions

View File

@ -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);

View File

@ -101,6 +101,7 @@ protected slots:
private:
void retranslateUi();
void addSystemDateMessage();
protected:
ChatMessage::Ptr createMessage(const ToxPk& author, const QString& message,