mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
[ChatView] Fix extra blank line at beginning (#6613)
This commit is contained in:
parent
189f3a7bbc
commit
5c3c3bfdba
1 changed files with 15 additions and 7 deletions
|
|
@ -89,9 +89,9 @@ void ChatView::refreshBlockColors()
|
|||
QTextBlockFormat fmt = block.blockFormat();
|
||||
|
||||
if (even)
|
||||
fmt.setBackground(palette().window());
|
||||
else
|
||||
fmt.setBackground(palette().base());
|
||||
else
|
||||
fmt.setBackground(palette().window());
|
||||
|
||||
fmt.setForeground(palette().text());
|
||||
|
||||
|
|
@ -113,20 +113,28 @@ QTextCursor ChatView::prepareBlock(bool same)
|
|||
{
|
||||
lastSender.clear();
|
||||
|
||||
QTextCursor cursor(document());
|
||||
QTextDocument *doc = document();
|
||||
QTextCursor cursor(doc);
|
||||
|
||||
cursor.movePosition(QTextCursor::End);
|
||||
if (same) {
|
||||
cursor.insertHtml("<br>");
|
||||
} else {
|
||||
QTextBlockFormat blockFormat;
|
||||
if ((evenNumber = !evenNumber))
|
||||
blockFormat.setBackground(palette().window());
|
||||
else
|
||||
if (evenNumber)
|
||||
blockFormat.setBackground(palette().base());
|
||||
else
|
||||
blockFormat.setBackground(palette().window());
|
||||
|
||||
evenNumber = !evenNumber;
|
||||
|
||||
blockFormat.setForeground(palette().text());
|
||||
blockFormat.setBottomMargin(4);
|
||||
cursor.insertBlock(blockFormat);
|
||||
|
||||
// Empty QTextDocuments still have 1 block. Just write to that block instead of inserting a new one
|
||||
if (!doc->isEmpty()) {
|
||||
cursor.insertBlock(blockFormat);
|
||||
}
|
||||
}
|
||||
|
||||
return cursor;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue