Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix: correct format log files
Browse files Browse the repository at this point in the history
 - correct format of "save chat log"
 - add date like in chat
 - correct type dialog for export dialog
  • Loading branch information
PKEv authored and anthonybilinski committed Jul 23, 2018
1 parent ba983ae commit ee0d4bb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/chatlog/chatmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ ChatMessage::Ptr ChatMessage::createChatInfoMessage(const QString& rawMessage,

msg->addColumn(new Image(QSize(18, 18), img),
ColumnFormat(NAME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
msg->addColumn(new Text("<b>" + text + "</b>", baseFont, false, ""),
msg->addColumn(new Text("<b>" + text + "</b>", baseFont, false, text),
ColumnFormat(1.0, ColumnFormat::VariableSize, ColumnFormat::Left));
msg->addColumn(new Timestamp(date, Settings::getInstance().getTimestampFormat(), baseFont),
ColumnFormat(TIME_COL_WIDTH, ColumnFormat::FixedSize, ColumnFormat::Right));
Expand Down
5 changes: 3 additions & 2 deletions src/widget/form/chatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1087,11 +1087,12 @@ void ChatForm::onExportChat()

QString buffer;
for (const auto& it : msgs) {
QString timestamp = it.timestamp.toString();
QString timestamp = it.timestamp.time().toString("hh:mm:ss");
QString datestamp = it.timestamp.date().toString("yyyy-MM-dd");
ToxPk authorPk(ToxId(it.sender).getPublicKey());
QString author = getMsgAuthorDispName(authorPk, it.dispName);

QString line = QString("%1\t%2\t%3\n").arg(timestamp, author, it.message);
QString line = QString("%1\t%2\t%3\t%4\n").arg(datestamp, timestamp, author, it.message);
buffer = buffer % line;
}
file.write(buffer.toUtf8());
Expand Down
11 changes: 5 additions & 6 deletions src/widget/form/genericchatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,17 +494,16 @@ void GenericChatForm::onSaveLogClicked()
for (ChatLine::Ptr l : lines) {
Timestamp* rightCol = qobject_cast<Timestamp*>(l->getContent(2));

if (!rightCol)
break;

ChatLineContent* middleCol = l->getContent(1);
ChatLineContent* leftCol = l->getContent(0);

QString timestamp = rightCol->getTime().isNull() ? tr("Not sent") : rightCol->getText();
QString nick = leftCol->getText();
QString nick = leftCol->getText().isNull() ? tr("[System message]") : leftCol->getText();

QString msg = middleCol->getText();

plainText += QString("[%2] %1\n%3\n\n").arg(nick, timestamp, msg);
QString timestamp = (rightCol == nullptr) ? tr("Not sent") : rightCol->getText();

plainText += QString("%1\t%3\t%2\n").arg(nick, timestamp, msg);
}

file.write(plainText.toUtf8());
Expand Down

0 comments on commit ee0d4bb

Please sign in to comment.