# HG changeset patch # User Paper # Date 1695656414 14400 # Node ID f4bea5ef5b8aab8dd615865673c7e829a7bdb85e # Parent e613772f41d53b20da728f11dc347ac0719ce9ba paragraph: fix size hint only tested on Linux (KDE) diff -r e613772f41d5 -r f4bea5ef5b8a src/gui/pages/statistics.cpp --- a/src/gui/pages/statistics.cpp Mon Sep 25 01:07:22 2023 -0400 +++ b/src/gui/pages/statistics.cpp Mon Sep 25 11:40:14 2023 -0400 @@ -18,18 +18,18 @@ setFrameShadow(QFrame::Sunken); QPalette pal = QPalette(); - pal.setColor(QPalette::Window, Qt::white); + pal.setColor(QPalette::Window, pal.color(QPalette::Base)); setPalette(pal); setAutoFillBackground(true); TextWidgets::LabelledTextParagraph* anime_list_paragraph = new TextWidgets::LabelledTextParagraph( "Anime list", - "Anime count:\nEpisode count:\nTime spent watching:\nTime to complete:\nAverage score:\nScore deviation:", "\n\n\n\n\n", + "Anime count:\nEpisode count:\nTime spent watching:\nTime to complete:\nAverage score:\nScore deviation:", "\n\n\n\n\n\n", this); anime_list_data = anime_list_paragraph->GetParagraph(); TextWidgets::LabelledTextParagraph* application_paragraph = - new TextWidgets::LabelledTextParagraph("Minori", "Uptime:\nRequests made:", "\n", this); + new TextWidgets::LabelledTextParagraph("Minori", "Uptime:\nRequests made:", "\n\n", this); application_data = application_paragraph->GetParagraph(); layout()->addWidget(anime_list_paragraph); diff -r e613772f41d5 -r f4bea5ef5b8a src/gui/widgets/text.cpp --- a/src/gui/widgets/text.cpp Mon Sep 25 01:07:22 2023 -0400 +++ b/src/gui/widgets/text.cpp Mon Sep 25 11:40:14 2023 -0400 @@ -5,6 +5,7 @@ #include #include #include +#include namespace TextWidgets { @@ -163,8 +164,11 @@ /* highly based upon... some stackoverflow answer for PyQt */ QSize Paragraph::minimumSizeHint() const { QTextDocument* doc = document(); - long h = (long)(blockBoundingGeometry(doc->findBlockByNumber(doc->blockCount() - 1)).bottom() + - (2 * doc->documentMargin())); + doc->adjustSize(); + long h = 0; + for (QTextBlock line = doc->begin(); line != doc->end(); line = line.next()) { + h += doc->documentLayout()->blockBoundingRect(line).height(); + } return QSize(QPlainTextEdit::sizeHint().width(), h); }