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:
authorRobert Adam <dev@robert-adam.de>2022-10-14 21:03:31 +0300
committerGitHub <noreply@github.com>2022-10-14 21:03:31 +0300
commit6aeb26a795f69dd91d2856658d442dea325a9d3e (patch)
tree48700b82670ac7bf66b4e7ebf9367f5c9a36f8dc
parent78350de057a75c062e2cc314cf2df675517712e6 (diff)
parentc21c6a0dcd8e465e47ddbd9adcc033836ae4ba5e (diff)
Merge PR #5927: FIX(client, ui): remove gaps within chat
This commit removes the additional gaps within the chat. The gaps were introduced by Qt's block-padding between frames. With this commit, the block after the last chat message is set to invisible. The previous approach of a very small fontPoinzSize() within the blockCharFormat() unfortunately didn't work on Windows. This variant should work on both Windows and Linux. Fixes #5886.
-rw-r--r--src/mumble/Log.cpp34
1 files changed, 24 insertions, 10 deletions
diff --git a/src/mumble/Log.cpp b/src/mumble/Log.cpp
index 330dba748..1c0f2bcf7 100644
--- a/src/mumble/Log.cpp
+++ b/src/mumble/Log.cpp
@@ -404,6 +404,10 @@ Log::Log(QObject *p) : QObject(p) {
#endif
uiLastId = 0;
qdDate = QDate::currentDate();
+
+ // remove gap above first chat message; the gaps below
+ // each chat message are handled within `Log::log`.
+ Global::get().mw->qteLog->document()->firstBlock().setVisible(false);
}
// Display order in settingsscreen, allows to insert new events without breaking config-compatibility with older
@@ -709,14 +713,6 @@ void Log::log(MsgType mt, const QString &console, const QString &terse, bool own
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).
@@ -762,8 +758,26 @@ 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);
+ // Qt's document model for [Rich Text Documents][RT] is based on blocks and frames.
+ // You always have a root frame and at least one block per frame:
+ //
+ // [Document]
+ // +--> [Root frame]
+ // +--> [Block]
+ // +--> [Frame]
+ // +--> [Block]
+ // +--> [Frame]
+ // +--> [Block]
+ //
+ // [RT]: https://doc.qt.io/qt-5/richtext-structure.html
+ //
+ // However, the issue is that the blocks between the frames are mandatory. They lead
+ // to additional gaps, especially on Windows, where `QTextCursor::setBlockCharFormat`
+ // cannot be used to decrease the trailing block's size.
+ //
+ // Fortunately, the `tlog`/`LogTextBrowser` is a `QTextBrowser` with a `QDocument*`.
+ // This allows us to hide the last block created by `QTextCursor::insertFrame()`.
+ tlog->document()->lastBlock().setVisible(false);
if (scroll || ownMessage)
tlog->scrollLogToBottom();