annotate src/gui/widgets/text.cc @ 217:47ddd6b638e3

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