Qt::SubWindow is needed to make QSizeGrip work
| 192 | |
| 193 | // Qt::SubWindow is needed to make QSizeGrip work |
| 194 | AnnotWindow::AnnotWindow(QWidget *parent, QRect initialViewportBounds, Okular::Annotation *annot, Okular::Document *document, int page) |
| 195 | : QFrame(parent, Qt::SubWindow) |
| 196 | , m_viewportBounds(initialViewportBounds) |
| 197 | , m_annot(annot) |
| 198 | , m_document(document) |
| 199 | , m_page(page) |
| 200 | { |
| 201 | setAutoFillBackground(true); |
| 202 | setFrameStyle(Panel | Raised); |
| 203 | setAttribute(Qt::WA_DeleteOnClose); |
| 204 | setObjectName(QStringLiteral("AnnotWindow")); |
| 205 | |
| 206 | const bool canEditAnnotation = m_document->canModifyPageAnnotation(annot); |
| 207 | |
| 208 | textEdit = new KTextEdit(this); |
| 209 | textEdit->setAcceptRichText(false); |
| 210 | textEdit->setPlainText(m_annot->contents()); |
| 211 | textEdit->installEventFilter(this); |
| 212 | textEdit->setUndoRedoEnabled(false); |
| 213 | |
| 214 | m_prevCursorPos = textEdit->textCursor().position(); |
| 215 | m_prevAnchorPos = textEdit->textCursor().anchor(); |
| 216 | |
| 217 | connect(textEdit, &KTextEdit::textChanged, this, &AnnotWindow::slotsaveWindowText); |
| 218 | connect(textEdit, &KTextEdit::cursorPositionChanged, this, &AnnotWindow::slotsaveWindowText); |
| 219 | connect(textEdit, &KTextEdit::aboutToShowContextMenu, this, &AnnotWindow::slotUpdateUndoAndRedoInContextMenu); |
| 220 | connect(m_document, &Okular::Document::annotationContentsChangedByUndoRedo, this, &AnnotWindow::slotHandleContentsChangedByUndoRedo); |
| 221 | |
| 222 | if (!canEditAnnotation) { |
| 223 | textEdit->setReadOnly(true); |
| 224 | } |
| 225 | |
| 226 | QVBoxLayout *mainlay = new QVBoxLayout(this); |
| 227 | mainlay->setContentsMargins(2, 2, 2, 2); |
| 228 | mainlay->setSpacing(0); |
| 229 | m_title = new MovableTitle(this); |
| 230 | mainlay->addWidget(m_title); |
| 231 | mainlay->addWidget(textEdit); |
| 232 | QHBoxLayout *lowerlay = new QHBoxLayout(); |
| 233 | mainlay->addLayout(lowerlay); |
| 234 | lowerlay->addItem(new QSpacerItem(5, 5, QSizePolicy::Expanding, QSizePolicy::Fixed)); |
| 235 | QSizeGrip *sb = new QSizeGrip(this); |
| 236 | lowerlay->addWidget(sb); |
| 237 | |
| 238 | m_latexRenderer = new GuiUtils::LatexRenderer(); |
| 239 | // The Q_EMIT below is not wrong even if emitting signals from the constructor it's usually wrong |
| 240 | // in this case the signal it's connected to inside MovableTitle constructor a few lines above |
| 241 | Q_EMIT containsLatex(GuiUtils::LatexRenderer::mightContainLatex(m_annot->contents())); // clazy:exclude=incorrect-emit |
| 242 | |
| 243 | m_title->setTitle(m_annot->window().summary()); |
| 244 | m_title->connectOptionButton(this, SLOT(slotOptionBtn())); |
| 245 | |
| 246 | const auto initialPosition = qApp->isRightToLeft() // |
| 247 | ? initialViewportBounds.topRight() + QPoint(-defaultSize.width() - defaultPosition.x(), defaultPosition.y()) |
| 248 | : initialViewportBounds.topLeft() + defaultPosition; |
| 249 | setGeometry(QRect(initialPosition, defaultSize)); |
| 250 | |
| 251 | reloadInfo(); |
nothing calls this directly
no test coverage detected