Skip to content

Commit

Permalink
fix(MessageLogger): use append instead of insertHtml
Browse files Browse the repository at this point in the history
In the old version, if you click in the messageLogger, the place of the "cursor" will change, and new logs will be inserted after the "cursor".
  • Loading branch information
ouuan committed Dec 16, 2019
1 parent f0c91a1 commit 39fb83a
Showing 1 changed file with 3 additions and 12 deletions.
15 changes: 3 additions & 12 deletions src/MessageLogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ void MessageLogger::info(std::string head, std::string body) {
ans += "[";
ans += body;
ans += "]";
if (box->toPlainText().isEmpty())
box->insertHtml(QString::fromStdString(ans));
else
box->insertHtml("<br>" + QString::fromStdString(ans));
box->append(QString::fromStdString(ans));
}

void MessageLogger::warn(std::string head, std::string body, bool multiline) {
Expand All @@ -60,10 +57,7 @@ void MessageLogger::warn(std::string head, std::string body, bool multiline) {
ans += body;
ans += "]</font>";

if (box->toPlainText().isEmpty())
box->insertHtml(QString::fromStdString(ans));
else
box->insertHtml("<br>" + QString::fromStdString(ans));
box->append(QString::fromStdString(ans));
}
void MessageLogger::error(std::string head, std::string body, bool multiline) {
std::string ans = "<b>[";
Expand All @@ -81,10 +75,7 @@ void MessageLogger::error(std::string head, std::string body, bool multiline) {
ans += body;
ans += "]</font>";

if (box->toPlainText().isEmpty())
box->insertHtml(QString::fromStdString(ans));
else
box->insertHtml("<br>" + QString::fromStdString(ans));
box->append(QString::fromStdString(ans));
}
void MessageLogger::clear() {
box->clear();
Expand Down

0 comments on commit 39fb83a

Please sign in to comment.