Mercurial > minori
diff src/gui/widgets/text.cc @ 295:b82841e76e79
*: better support on Windows
things now look much better in dark mode
author | Paper <paper@paper.us.eu.org> |
---|---|
date | Sun, 12 May 2024 20:24:09 -0400 |
parents | 9a88e1725fd2 |
children | 6b0768158dcd |
line wrap: on
line diff
--- a/src/gui/widgets/text.cc Sun May 12 18:16:08 2024 -0400 +++ b/src/gui/widgets/text.cc Sun May 12 20:24:09 2024 -0400 @@ -62,6 +62,7 @@ text_edit.setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); text_edit.setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); text_edit.setStyleSheet("background: transparent;"); + text_edit.setFrameStyle(QFrame::NoFrame); text_edit.document()->setDocumentMargin(0); @@ -79,20 +80,15 @@ text_edit.setTextCursor(cursor); } -QSize Paragraph::minimumSizeHint() const { - return QSize(0, 0); +bool Paragraph::hasHeightForWidth() const { + return true; } -/* highly based upon... some stackoverflow answer for PyQt */ -QSize Paragraph::sizeHint() const { +int Paragraph::heightForWidth(int w) const { QTextDocument* doc = text_edit.document(); - doc->adjustSize(); + doc->setTextWidth(w); - long h = 0; - for (QTextBlock line = doc->begin(); line != doc->end(); line = line.next()) - h += doc->documentLayout()->blockBoundingRect(line).height(); - - return QSize(doc->size().width(), h); + return doc->size().toSize().height(); } QPlainTextEdit* Paragraph::GetLabel() {