mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 09:04:53 -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();
|
QTextBlockFormat fmt = block.blockFormat();
|
||||||
|
|
||||||
if (even)
|
if (even)
|
||||||
fmt.setBackground(palette().window());
|
|
||||||
else
|
|
||||||
fmt.setBackground(palette().base());
|
fmt.setBackground(palette().base());
|
||||||
|
else
|
||||||
|
fmt.setBackground(palette().window());
|
||||||
|
|
||||||
fmt.setForeground(palette().text());
|
fmt.setForeground(palette().text());
|
||||||
|
|
||||||
|
|
@ -113,20 +113,28 @@ QTextCursor ChatView::prepareBlock(bool same)
|
||||||
{
|
{
|
||||||
lastSender.clear();
|
lastSender.clear();
|
||||||
|
|
||||||
QTextCursor cursor(document());
|
QTextDocument *doc = document();
|
||||||
|
QTextCursor cursor(doc);
|
||||||
|
|
||||||
cursor.movePosition(QTextCursor::End);
|
cursor.movePosition(QTextCursor::End);
|
||||||
if (same) {
|
if (same) {
|
||||||
cursor.insertHtml("<br>");
|
cursor.insertHtml("<br>");
|
||||||
} else {
|
} else {
|
||||||
QTextBlockFormat blockFormat;
|
QTextBlockFormat blockFormat;
|
||||||
if ((evenNumber = !evenNumber))
|
if (evenNumber)
|
||||||
blockFormat.setBackground(palette().window());
|
|
||||||
else
|
|
||||||
blockFormat.setBackground(palette().base());
|
blockFormat.setBackground(palette().base());
|
||||||
|
else
|
||||||
|
blockFormat.setBackground(palette().window());
|
||||||
|
|
||||||
|
evenNumber = !evenNumber;
|
||||||
|
|
||||||
blockFormat.setForeground(palette().text());
|
blockFormat.setForeground(palette().text());
|
||||||
blockFormat.setBottomMargin(4);
|
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;
|
return cursor;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue