1
0
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:
ezavod 2017-06-03 14:33:46 +02:00
parent 331a8f1006
commit ed45359863
No known key found for this signature in database
GPG Key ID: 5DFDD9A0D8E5A9B6
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(); bool isSelf = author == core->getSelfId().getPublicKey();
QString authorStr = isSelf ? core->getUsername() : resolveToxPk(author); QString authorStr = isSelf ? core->getUsername() : resolveToxPk(author);
if (getLatestDate() != QDate::currentDate()) { if (getLatestDate() != QDate::currentDate()) {
const Settings& s = Settings::getInstance(); addSystemDateMessage();
QString dateText = QDate::currentDate().toString(s.getDateFormat());
addSystemInfoMessage(dateText, ChatMessage::INFO, QDateTime());
} }
ChatMessage::Ptr msg; ChatMessage::Ptr msg;
@ -553,10 +551,23 @@ void GenericChatForm::onChatMessageFontChanged(const QFont& font)
void GenericChatForm::addSystemInfoMessage(const QString& message, ChatMessage::SystemMessageType type, void GenericChatForm::addSystemInfoMessage(const QString& message, ChatMessage::SystemMessageType type,
const QDateTime& datetime) const QDateTime& datetime)
{ {
if (getLatestDate() != QDate::currentDate()) {
addSystemDateMessage();
}
previousId = ToxPk(); previousId = ToxPk();
insertChatMessage(ChatMessage::createChatInfoMessage(message, type, datetime)); 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() void GenericChatForm::clearChatArea()
{ {
clearChatArea(true); clearChatArea(true);

View File

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