Line data Source code
1 : // SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2 : // SPDX-License-Identifier: GPL-3.0-or-later
3 : /**
4 : * @file
5 : * @brief Implements SecretPlainTextEdit::createMimeDataFromSelection(), the
6 : * single hook through which all copies leave the editor.
7 : */
8 : #include "secretplaintextedit.h"
9 : #include "clipboardmanager.h"
10 : #include <QTextCursor>
11 : #include <QTextDocumentFragment>
12 :
13 91 : SecretPlainTextEdit::SecretPlainTextEdit(QWidget *parent)
14 91 : : QPlainTextEdit(parent) {}
15 :
16 3 : auto SecretPlainTextEdit::createMimeDataFromSelection() const -> QMimeData * {
17 3 : const QString text = textCursor().selection().toPlainText();
18 : // copied() is a notification, not a change to this widget; the signal is
19 : // declared non-const as all signals are.
20 3 : emit const_cast<SecretPlainTextEdit *>(this)->copied(text);
21 6 : return buildClipboardMimeData(text);
22 : }
|