Mercurial > minori
comparison src/gui/ui_utils.cpp @ 15:cde8f67a7c7d
*: update, megacommit :)
| author | Paper <mrpapersonic@gmail.com> |
|---|---|
| date | Tue, 19 Sep 2023 22:36:08 -0400 |
| parents | 5c0397762b53 |
| children | 2743011a6042 |
comparison
equal
deleted
inserted
replaced
| 14:a29c9402faf0 | 15:cde8f67a7c7d |
|---|---|
| 8 #include <QLabel> | 8 #include <QLabel> |
| 9 #include <QPixmap> | 9 #include <QPixmap> |
| 10 #include <QTextBlock> | 10 #include <QTextBlock> |
| 11 #include <QVBoxLayout> | 11 #include <QVBoxLayout> |
| 12 #ifdef MACOSX | 12 #ifdef MACOSX |
| 13 #include "sys/osx/dark_theme.h" | 13 # include "sys/osx/dark_theme.h" |
| 14 #else | 14 #else |
| 15 #include "sys/win32/dark_theme.h" | 15 # include "sys/win32/dark_theme.h" |
| 16 #endif | 16 #endif |
| 17 | 17 |
| 18 namespace UiUtils { | 18 namespace UiUtils { |
| 19 | 19 |
| 20 bool IsInDarkMode() { | 20 bool IsInDarkMode() { |
| 96 | 96 |
| 97 Paragraph* TextParagraph::GetParagraph() { | 97 Paragraph* TextParagraph::GetParagraph() { |
| 98 return paragraph; | 98 return paragraph; |
| 99 } | 99 } |
| 100 | 100 |
| 101 LabelledTextParagraph::LabelledTextParagraph(QString title, QString label, QString data, QWidget* parent) | 101 LabelledTextParagraph::LabelledTextParagraph(QString title, QString label, QString data, |
| 102 : QWidget(parent) { | 102 QWidget* parent) |
| 103 : QWidget(parent) { | |
| 103 setLayout(new QVBoxLayout); | 104 setLayout(new QVBoxLayout); |
| 104 | 105 |
| 105 header = new Header(title, this); | 106 header = new Header(title, this); |
| 106 | 107 |
| 107 // this is not accessible from the object because there's really | 108 // this is not accessible from the object because there's really |
| 108 // no reason to make it accessible... | 109 // no reason to make it accessible... |
| 109 QWidget* content = new QWidget(this); | 110 QWidget* content = new QWidget(this); |
| 110 content->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); | 111 content->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); |
| 111 | 112 |
| 112 labels = new Paragraph(label, this); | 113 labels = new Paragraph(label, this); |
| 113 labels->setTextInteractionFlags(Qt::NoTextInteraction); | 114 labels->setTextInteractionFlags(Qt::NoTextInteraction); |
| 114 labels->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents); | 115 labels->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents); |
| 115 labels->setWordWrapMode(QTextOption::NoWrap); | 116 labels->setWordWrapMode(QTextOption::NoWrap); |
| 116 labels->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum); | 117 labels->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred); |
| 117 labels->setFixedWidth(123); | 118 labels->setFixedWidth(123); |
| 118 | 119 |
| 119 paragraph = new Paragraph(data, this); | 120 paragraph = new Paragraph(data, this); |
| 120 paragraph->setTextInteractionFlags(Qt::NoTextInteraction); | 121 paragraph->setTextInteractionFlags(Qt::NoTextInteraction); |
| 121 paragraph->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents); | 122 paragraph->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents); |
| 146 | 147 |
| 147 Paragraph* LabelledTextParagraph::GetParagraph() { | 148 Paragraph* LabelledTextParagraph::GetParagraph() { |
| 148 return paragraph; | 149 return paragraph; |
| 149 } | 150 } |
| 150 | 151 |
| 151 SelectableTextParagraph::SelectableTextParagraph(QString title, QString data, QWidget* parent) : QWidget(parent) { | 152 SelectableTextParagraph::SelectableTextParagraph(QString title, QString data, QWidget* parent) |
| 153 : QWidget(parent) { | |
| 152 setLayout(new QVBoxLayout); | 154 setLayout(new QVBoxLayout); |
| 153 | 155 |
| 154 header = new Header(title, this); | 156 header = new Header(title, this); |
| 155 | 157 |
| 156 QWidget* content = new QWidget(this); | 158 QWidget* content = new QWidget(this); |
| 197 | 199 |
| 198 /* highly based upon... some stackoverflow answer for PyQt */ | 200 /* highly based upon... some stackoverflow answer for PyQt */ |
| 199 QSize Paragraph::minimumSizeHint() const { | 201 QSize Paragraph::minimumSizeHint() const { |
| 200 QTextDocument* doc = document(); | 202 QTextDocument* doc = document(); |
| 201 long h = (long)(blockBoundingGeometry(doc->findBlockByNumber(doc->blockCount() - 1)).bottom() + | 203 long h = (long)(blockBoundingGeometry(doc->findBlockByNumber(doc->blockCount() - 1)).bottom() + |
| 202 (2 * doc->documentMargin())); | 204 (2 * doc->documentMargin())); |
| 203 return QSize(QPlainTextEdit::sizeHint().width(), (long)h); | 205 return QSize(QPlainTextEdit::sizeHint().width(), h); |
| 204 } | 206 } |
| 205 | 207 |
| 206 QSize Paragraph::sizeHint() const { | 208 QSize Paragraph::sizeHint() const { |
| 207 return minimumSizeHint(); | 209 return minimumSizeHint(); |
| 208 } | 210 } |
