MCPcopy Create free account
hub / github.com/KDE/labplot / NoteView

Method NoteView

src/frontend/note/NoteView.cpp:18–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16#include <QTextEdit>
17
18NoteView::NoteView(Note* note)
19 : m_note(note)
20 , m_textEdit(new QTextEdit(this)) {
21 auto* layout = new QHBoxLayout(this);
22 layout->setContentsMargins(0, 0, 0, 0);
23
24 QPalette palette = m_textEdit->palette();
25 palette.setColor(QPalette::Base, m_note->backgroundColor());
26 palette.setColor(QPalette::Text, m_note->textColor());
27
28 m_textEdit->setPalette(palette);
29 m_textEdit->setFont(m_note->textFont());
30 m_textEdit->setText(m_note->text());
31
32 layout->addWidget(m_textEdit);
33
34 connect(m_note, &Note::textChanged, this, &NoteView::noteTextChanged);
35 connect(m_note, &Note::backgroundColorChanged, this, &NoteView::noteBackgroundColorChanged);
36 connect(m_note, &Note::textColorChanged, this, &NoteView::noteTextColorChanged);
37 connect(m_note, &Note::textFontChanged, this, &NoteView::noteTextFontChanged);
38
39 // don't put every single character change onto the undo stack, delay it similarly how it's done in TimedLineEdit
40 connect(m_textEdit, &QTextEdit::textChanged, [&]() {
41 if (m_textChangedTimerId != -1)
42 killTimer(m_textChangedTimerId);
43 m_textChangedTimerId = startTimer(1000);
44 });
45}
46
47void NoteView::print(QPrinter* printer) const {
48 m_textEdit->print(printer);

Callers

nothing calls this directly

Calls 5

backgroundColorMethod · 0.80
setColorMethod · 0.45
setFontMethod · 0.45
setTextMethod · 0.45
textMethod · 0.45

Tested by

no test coverage detected