annotate src/gui/widgets/text.cc @ 87:4aef97f4d998

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