Mercurial > minori
changeset 49:f4bea5ef5b8a
paragraph: fix size hint
only tested on Linux (KDE)
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Mon, 25 Sep 2023 11:40:14 -0400 |
parents | e613772f41d5 |
children | 10868c3fb2be |
files | src/gui/pages/statistics.cpp src/gui/widgets/text.cpp |
diffstat | 2 files changed, 9 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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);
--- 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 <QPixmap> #include <QTextBlock> #include <QVBoxLayout> +#include <QDebug> 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); }