annotate src/gui/widgets/text.cpp @ 77:6f7385bd334c

*: update formatted all source files, no more subclassing QThread... many other changes :)
author Paper <mrpapersonic@gmail.com>
date Fri, 06 Oct 2023 06:18:53 -0400
parents 3364fadc8a36
children
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"
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
3 #include <QDebug>
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4 #include <QFrame>
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
5 #include <QLabel>
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) {
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
12 QVBoxLayout* layout = new QVBoxLayout(this);
46
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
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 static_text_line = new QFrame(this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22 static_text_line->setFrameShape(QFrame::HLine);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
23 static_text_line->setFrameShadow(QFrame::Sunken);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 static_text_line->setFixedHeight(2);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
26 layout->addWidget(static_text_title);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
27 layout->addWidget(static_text_line);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
28 layout->setSpacing(0);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
29 layout->setContentsMargins(0, 0, 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
30 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
31
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
32 void Header::SetText(QString text) {
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
33 static_text_title->setText(text);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
34 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
35
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
36 /* inherits QPlainTextEdit and gives a much more reasonable minimum size */
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
37 Paragraph::Paragraph(QString text, QWidget* parent) : QPlainTextEdit(text, parent) {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
38 setTextInteractionFlags(Qt::TextBrowserInteraction);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
39 setFrameShape(QFrame::NoFrame);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
40 setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
41 setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
42
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
43 QPalette pal;
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
44 pal.setColor(QPalette::Window, Qt::transparent);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
45 setPalette(pal);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
46
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
47 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
48 }
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
49
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
50 void Paragraph::SetText(QString text) {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
51 QTextDocument* document = new QTextDocument(this);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
52 document->setDocumentLayout(new QPlainTextDocumentLayout(document));
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
53 document->setPlainText(text);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
54 setDocument(document);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
55 }
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
56
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
57 /* highly based upon... some stackoverflow answer for PyQt */
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
58 QSize Paragraph::minimumSizeHint() const {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
59 return QSize(0, 0);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
60 }
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
61
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
62 QSize Paragraph::sizeHint() const {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
63 QTextDocument* doc = document();
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
64 doc->adjustSize();
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
65 long h = 0;
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
66 for (QTextBlock line = doc->begin(); line != doc->end(); line = line.next()) {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
67 h += doc->documentLayout()->blockBoundingRect(line).height();
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
68 }
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
69 return QSize(doc->size().width(), h);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
70 }
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
71
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
72 /* Equivalent to Paragraph(), but is only capable of showing one line. Only
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
73 exists because sometimes with SelectableSection it will let you go
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
74 out of bounds */
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
75 Line::Line(QString text, QWidget* parent) : QLineEdit(text, parent) {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
76 setFrame(false);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
77 setReadOnly(true);
77
6f7385bd334c *: update
Paper <mrpapersonic@gmail.com>
parents: 76
diff changeset
78 setCursorPosition(0); /* displays left text first */
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
79
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
80 QPalette pal;
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
81 pal.setColor(QPalette::Window, Qt::transparent);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
82 setPalette(pal);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
83
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
84 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
85 }
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
86
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
87 Title::Title(QString title, QWidget* parent) : Line(title, parent) {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
88 QFont fnt(font());
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
89 fnt.setPixelSize(16);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
90 setFont(fnt);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
91
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
92 QPalette pal(palette());
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
93 pal.setColor(QPalette::Window, Qt::transparent);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
94 pal.setColor(QPalette::Text, QColor(0x00, 0x33, 0x99));
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
95 setPalette(pal);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
96 }
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
97
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
98 Section::Section(QString title, QString data, QWidget* parent) : QWidget(parent) {
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
99 QVBoxLayout* layout = new QVBoxLayout(this);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
100
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
101 header = new Header(title, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
102
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
103 QWidget* content = new QWidget(this);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
104 QHBoxLayout* content_layout = new QHBoxLayout(content);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
105
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
106 paragraph = new Paragraph(data, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
107 paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
108 paragraph->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
109 paragraph->setWordWrapMode(QTextOption::NoWrap);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
110
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
111 content_layout->addWidget(paragraph);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
112 content_layout->setSpacing(0);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
113 content_layout->setContentsMargins(0, 0, 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
114 content->setContentsMargins(12, 0, 0, 0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
115
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
116 layout->addWidget(header);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
117 layout->addWidget(paragraph);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
118 layout->setSpacing(0);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
119 layout->setContentsMargins(0, 0, 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
120 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
121
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
122 Header* Section::GetHeader() {
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
123 return header;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
124 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
125
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
126 Paragraph* Section::GetParagraph() {
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
127 return paragraph;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
128 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
129
76
3364fadc8a36 *: format source code
Paper <mrpapersonic@gmail.com>
parents: 75
diff changeset
130 LabelledSection::LabelledSection(QString title, QString label, QString data, QWidget* parent) : QWidget(parent) {
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
131 QVBoxLayout* layout = new QVBoxLayout(this);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
132
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
133 header = new Header(title, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
134
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
135 // this is not accessible from the object because there's really
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
136 // no reason to make it accessible...
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
137 QWidget* content = new QWidget(this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
138 content->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
139
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
140 labels = new Paragraph(label, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
141 labels->setTextInteractionFlags(Qt::NoTextInteraction);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
142 labels->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
143 labels->setWordWrapMode(QTextOption::NoWrap);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
144 labels->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
145
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
146 paragraph = new Paragraph(data, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
147 paragraph->setTextInteractionFlags(Qt::NoTextInteraction);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
148 paragraph->setAttribute(Qt::WidgetAttribute::WA_TransparentForMouseEvents);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
149 paragraph->setWordWrapMode(QTextOption::NoWrap);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
150
50
10868c3fb2be text.cpp: set paragraph width from document, labelled texts are now...
Paper <mrpapersonic@gmail.com>
parents: 49
diff changeset
151 QHBoxLayout* content_layout = new QHBoxLayout(content);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
152 content_layout->addWidget(labels, 0, Qt::AlignTop);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
153 content_layout->addWidget(paragraph, 0, Qt::AlignTop);
50
10868c3fb2be text.cpp: set paragraph width from document, labelled texts are now...
Paper <mrpapersonic@gmail.com>
parents: 49
diff changeset
154 content_layout->setSpacing(20);
62
4c6dd5999b39 *: update
Paper <mrpapersonic@gmail.com>
parents: 51
diff changeset
155 content_layout->setContentsMargins(0, 0, 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
156
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
157 content->setContentsMargins(12, 0, 0, 0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
158
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
159 layout->addWidget(header);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
160 layout->addWidget(content);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
161 layout->setSpacing(0);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
162 layout->setContentsMargins(0, 0, 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
163 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
164
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
165 Header* LabelledSection::GetHeader() {
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
166 return header;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
167 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
168
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
169 Paragraph* LabelledSection::GetLabels() {
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
170 return labels;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
171 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
172
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
173 Paragraph* LabelledSection::GetParagraph() {
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
174 return paragraph;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
175 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
176
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
177 SelectableSection::SelectableSection(QString title, QString data, QWidget* parent) : QWidget(parent) {
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
178 QVBoxLayout* layout = new QVBoxLayout(this);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
179
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
180 header = new Header(title, this);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
181
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
182 QWidget* content = new QWidget(this);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
183 QHBoxLayout* content_layout = new QHBoxLayout(content);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
184
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
185 paragraph = new Paragraph(data, content);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
186
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
187 content_layout->addWidget(paragraph);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
188 content_layout->setSpacing(0);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
189 content_layout->setContentsMargins(0, 0, 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
190 content->setContentsMargins(12, 0, 0, 0);
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
191
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
192 layout->addWidget(header);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
193 layout->addWidget(content);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
194 layout->setSpacing(0);
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
195 layout->setContentsMargins(0, 0, 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
196 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
197
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
198 Header* SelectableSection::GetHeader() {
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
199 return header;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
200 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
201
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
202 Paragraph* SelectableSection::GetParagraph() {
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
203 return paragraph;
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
204 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
205
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
206 OneLineSection::OneLineSection(QString title, QString text, QWidget* parent) : QWidget(parent) {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
207 QVBoxLayout* layout = new QVBoxLayout(this);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
208
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
209 header = new Header(title, this);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
210
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
211 QWidget* content = new QWidget(this);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
212 QHBoxLayout* content_layout = new QHBoxLayout(content);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
213
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
214 line = new Line(text, content);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
215
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
216 content_layout->addWidget(line);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
217 content_layout->setSpacing(0);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
218 content_layout->setContentsMargins(0, 0, 0, 0);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
219 content->setContentsMargins(12, 0, 0, 0);
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
220
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
221 layout->addWidget(header);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
222 layout->addWidget(content);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
223 layout->setSpacing(0);
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
224 layout->setContentsMargins(0, 0, 0, 0);
64
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
225 }
fe719c109dbc *: update
Paper <mrpapersonic@gmail.com>
parents: 63
diff changeset
226
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
227 Header* OneLineSection::GetHeader() {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
228 return header;
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
229 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
230
75
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
231 Line* OneLineSection::GetLine() {
d3e9310598b1 *: refactor some stuff
Paper <mrpapersonic@gmail.com>
parents: 74
diff changeset
232 return line;
46
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
233 }
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
234
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
235 } // namespace TextWidgets
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
236
d0adc4aedfc8 *: update...
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
237 #include "gui/widgets/moc_text.cpp"