QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
secrettextbrowser.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Anne Jan Brouwer
2// SPDX-License-Identifier: GPL-3.0-or-later
8#include "secrettextbrowser.h"
9#include "clipboardmanager.h"
10#include <QTextDocumentFragment>
11
12SecretTextBrowser::SecretTextBrowser(QWidget *parent) : QTextBrowser(parent) {}
13
15 // Plain text only: the default would also put the selection's HTML on the
16 // clipboard, without the hints.
17 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 emit const_cast<SecretTextBrowser *>(this)->copied(text);
21 return buildClipboardMimeData(text);
22}
SecretTextBrowser(QWidget *parent=nullptr)
Constructs the browser.
auto createMimeDataFromSelection() const -> QMimeData *override
The selection as secret-marked plain text.
void copied(const QString &text)
Selected text was copied out of the browser.
auto buildClipboardMimeData(const QString &text) -> QMimeData *
Build clipboard MIME data with platform-specific security hints.
ClipboardManager, which puts secrets on the clipboard and removes them again, and the MIME data that ...
QTextBrowser for showing decrypted entry text that marks everything copied out of it as a secret.