annotate src/gui/widgets/text.cpp @ 46:d0adc4aedfc8

*: update... this commit: 1. consolidates dark theme stuff to dark_theme.cpp 2. creates a new widgets folder to store all of our custom widgets 3. creates the list settings page in the information dialog, although much of it is nonfunctional: it doesn't save, and the status doesn't even get filled in... we'll fix this later!
author Paper <mrpapersonic@gmail.com>
date Sat, 23 Sep 2023 01:02:15 -0400
parents
children f4bea5ef5b8a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "gui/widgets/text.h"
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
2 #include "core/session.h"
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 #include <QFrame>
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include <QLabel>
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include <QPixmap>
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
6 #include <QTextBlock>
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
7 #include <QVBoxLayout>
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
8
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 namespace TextWidgets {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
11 Header::Header(QString title, QWidget* parent) : QWidget(parent) {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
12 setLayout(new QVBoxLayout);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
13 setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
14
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
15 static_text_title = new QLabel(title, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
16 static_text_title->setTextFormat(Qt::PlainText);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17 QFont font = static_text_title->font();
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 font.setWeight(QFont::Bold);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
19 static_text_title->setFont(font);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 static_text_title->setFixedHeight(16);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 static_text_line = new QFrame(this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 static_text_line->setFrameShape(QFrame::HLine);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 static_text_line->setFrameShadow(QFrame::Sunken);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 static_text_line->setFixedHeight(2);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
26
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
27 layout()->addWidget(static_text_title);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
28 layout()->addWidget(static_text_line);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
29 layout()->setSpacing(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 layout()->setMargin(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
32
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
33 void Header::SetTitle(QString title) {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 static_text_title->setText(title);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
36
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
37 TextParagraph::TextParagraph(QString title, QString data, QWidget* parent) : QWidget(parent) {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 setLayout(new QVBoxLayout);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40 header = new Header(title, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
41
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
42 QWidget* content = new QWidget(this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
43 content->setLayout(new QHBoxLayout);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
44
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
45 paragraph = new Paragraph(data, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
46 paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
47 paragraph->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
48 paragraph->setWordWrapMode(QTextOption::NoWrap);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
49
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
50 content->layout()->addWidget(paragraph);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
51 content->layout()->setSpacing(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
52 content->layout()->setMargin(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
53 content->setContentsMargins(12, 0, 0, 0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
54
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
55 layout()->addWidget(header);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
56 layout()->addWidget(paragraph);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
57 layout()->setSpacing(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
58 layout()->setMargin(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
59 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
60
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
61 Header* TextParagraph::GetHeader() {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
62 return header;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
63 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
64
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
65 Paragraph* TextParagraph::GetParagraph() {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
66 return paragraph;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
67 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
68
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
69 LabelledTextParagraph::LabelledTextParagraph(QString title, QString label, QString data, QWidget* parent)
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
70 : QWidget(parent) {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
71 setLayout(new QVBoxLayout);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
72
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
73 header = new Header(title, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
74
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
75 // this is not accessible from the object because there's really
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
76 // no reason to make it accessible...
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
77 QWidget* content = new QWidget(this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
78 content->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
79
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
80 labels = new Paragraph(label, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
81 labels->setTextInteractionFlags(Qt::NoTextInteraction);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
82 labels->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
83 labels->setWordWrapMode(QTextOption::NoWrap);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
84 labels->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
85 labels->setFixedWidth(123);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
86
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
87 paragraph = new Paragraph(data, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
88 paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
89 paragraph->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
90 paragraph->setWordWrapMode(QTextOption::NoWrap);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
91
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
92 QHBoxLayout* content_layout = new QHBoxLayout;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
93 content_layout->addWidget(labels, 0, Qt::AlignTop);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
94 content_layout->addWidget(paragraph, 0, Qt::AlignTop);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
95 content_layout->setSpacing(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
96 content_layout->setMargin(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
97 content->setLayout(content_layout);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
98
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
99 content->setContentsMargins(12, 0, 0, 0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 layout()->addWidget(header);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
102 layout()->addWidget(content);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 layout()->setSpacing(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
104 layout()->setMargin(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107 Header* LabelledTextParagraph::GetHeader() {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 return header;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
109 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
111 Paragraph* LabelledTextParagraph::GetLabels() {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
112 return labels;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
113 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
114
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115 Paragraph* LabelledTextParagraph::GetParagraph() {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
116 return paragraph;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
117 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
118
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
119 SelectableTextParagraph::SelectableTextParagraph(QString title, QString data, QWidget* parent) : QWidget(parent) {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
120 setLayout(new QVBoxLayout);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
121
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
122 header = new Header(title, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
123
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
124 QWidget* content = new QWidget(this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
125 content->setLayout(new QHBoxLayout);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
126
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
127 paragraph = new Paragraph(data, content);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
128
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
129 content->layout()->addWidget(paragraph);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
130 content->layout()->setSpacing(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
131 content->layout()->setMargin(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132 content->setContentsMargins(12, 0, 0, 0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
134 layout()->addWidget(header);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 layout()->addWidget(content);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 layout()->setSpacing(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
137 layout()->setMargin(0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
138 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
139
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140 Header* SelectableTextParagraph::GetHeader() {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
141 return header;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
142 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
143
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
144 Paragraph* SelectableTextParagraph::GetParagraph() {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
145 return paragraph;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
146 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
147
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
148 /* inherits QPlainTextEdit and gives a much more reasonable minimum size */
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
149 Paragraph::Paragraph(QString text, QWidget* parent) : QPlainTextEdit(text, parent) {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
150 setReadOnly(true);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
151 setTextInteractionFlags(Qt::TextBrowserInteraction);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152 setFrameShape(QFrame::NoFrame);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
154 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
155
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
156 QPalette pal;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
157 pal.setColor(QPalette::Window, QColor(0, 0, 0, 0));
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
158 setPalette(pal);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
159
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
160 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
161 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
162
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 /* highly based upon... some stackoverflow answer for PyQt */
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
164 QSize Paragraph::minimumSizeHint() const {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
165 QTextDocument* doc = document();
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166 long h = (long)(blockBoundingGeometry(doc->findBlockByNumber(doc->blockCount() - 1)).bottom() +
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
167 (2 * doc->documentMargin()));
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
168 return QSize(QPlainTextEdit::sizeHint().width(), h);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
169 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
170
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
171 QSize Paragraph::sizeHint() const {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
172 return minimumSizeHint();
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
173 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
174
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
175 /* this is still actually useful, so we'll keep it */
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
176 void SetPlainTextEditData(QPlainTextEdit* text_edit, QString data) {
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
177 QTextDocument* document = new QTextDocument(text_edit);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
178 document->setDocumentLayout(new QPlainTextDocumentLayout(document));
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
179 document->setPlainText(data);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
180 text_edit->setDocument(document);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
181 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
182
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
183 } // namespace TextWidgets
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
184
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
185 #include "gui/widgets/moc_text.cpp"