Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDexter Gaon-Shatford <dexter@gaonshatford.ca>2022-08-22 07:55:26 +0300
committerDexter Gaon-Shatford <dexter@gaonshatford.ca>2022-08-25 18:22:51 +0300
commitece450aa3d8363a9b0728e23204c6b97e727ff62 (patch)
treef18091c20458ce72d113822b338ccf03d92b627f /src/mumble
parent227d7fcee38d7bfdeac2aa9621f5b525ccdf3836 (diff)
FIX(client, ui): resolve log text scaling issues
Fixed chat log scaling issue introduced by PR #5619 (my fault, whoops) 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.cpp30
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