diff options
author | Robert Adam <dev@robert-adam.de> | 2022-08-27 15:29:28 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-27 15:29:28 +0300 |
commit | 6067c4a56e2a09631e8084d7353cd85245084006 (patch) | |
tree | 349a1f3377e559166fa93c0662592bf9f35f181e /src/mumble | |
parent | 8288c7c0b892053db178fde2ef9c8e6d0b1a18a5 (diff) | |
parent | ece450aa3d8363a9b0728e23204c6b97e727ff62 (diff) |
Merge PR #5820: FIX(client, ui): resolve log text scaling issues
Fixed chat log scaling issue introduced by PR #5619
The bug fixed by that commit is still fixed after this PR, but the
regression introduced has been resolved.
Fixes #5818
Diffstat (limited to 'src/mumble')
-rw-r--r-- | src/mumble/Log.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp index 29dc8b040..161d0492a 100644 --- a/src/mumble/Log.cpp +++ b/src/mumble/Log.cpp @@ -679,7 +679,9 @@ QString Log::validHtml(const QString &html, QTextCursor *tc) { } if (tc) { - tc->insertHtml(qtd.toHtml()); + QTextCursor tcNew(&qtd); + tcNew.movePosition(QTextCursor::End, QTextCursor::KeepAnchor); + tc->insertFragment(tcNew.selection()); return QString(); } else { return qtd.toHtml(); @@ -705,17 +707,29 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own if ((flags & Settings::LogConsole)) { QTextCursor tc = Global::get().mw->qteLog->textCursor(); + tc.movePosition(QTextCursor::End); + + // A newline is inserted after each frame, but this spaces out the + // log entries too much, so the font size is set to near-zero in order + // to reduce the space between log entries. This font size is set only + // for the blank lines between entries, not for entries themselves. + QTextCharFormat cf = tc.blockCharFormat(); + cf.setFontPointSize(0.01); + tc.setBlockCharFormat(cf); + // We copy the value from the settings in order to make sure that // we use the same margin everywhere while in this method (even if // the setting might change in that time). const int msgMargin = Global::get().s.iChatMessageMargins; + QTextFrameFormat qttf; + qttf.setTopMargin(0); + qttf.setBottomMargin(msgMargin); + LogTextBrowser *tlog = Global::get().mw->qteLog; const int oldscrollvalue = tlog->getLogScroll(); const bool scroll = (oldscrollvalue == tlog->getLogScrollMaximum()); - tc.movePosition(QTextCursor::End); - if (qdDate != dt.date()) { qdDate = dt.date(); tc.insertBlock(); @@ -728,13 +742,6 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own QString fixedNLPlain = plain.replace(QLatin1String("\r\n"), QLatin1String("\n")).replace(QLatin1String("\r"), QLatin1String("\n")); - QTextFrameFormat qttf; - // `insertFrame` causes a blank line to precede the inserted frame. - // This is remedied by setting a negative top margin of equal height. - static int lineSpacing = QFontMetrics(tc.currentFrame()->format().toCharFormat().font()).lineSpacing(); - qttf.setTopMargin(-lineSpacing); - qttf.setBottomMargin(msgMargin); - if (fixedNLPlain.contains(QRegExp(QLatin1String("\\n[ \\t]*$")))) { // If the message ends with one or more blank lines (or lines only containing whitespace) // paint a border around the message to make clear that it contains invisible parts. @@ -755,6 +762,9 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own tc.movePosition(QTextCursor::End); Global::get().mw->qteLog->setTextCursor(tc); + // Shrink trailing blank line after the most recent log entry. + tc.setBlockCharFormat(cf); + if (scroll || ownMessage) tlog->scrollLogToBottom(); else |