QtPass Developer documentation
QtPass test coverage
Current view: top level - src/secrettextbrowser.cpp (source / functions) Coverage Total Hit
Test: QtPass Lines: 100.0 % 5 5
Test Date: 2026-11-14 13:19:18 Functions: 100.0 % 2 2

            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 SecretTextBrowser::createMimeDataFromSelection(), copying
       6              :  * plain text only so no unmarked HTML reaches the clipboard.
       7              :  */
       8              : #include "secrettextbrowser.h"
       9              : #include "clipboardmanager.h"
      10              : #include <QTextDocumentFragment>
      11              : 
      12          236 : SecretTextBrowser::SecretTextBrowser(QWidget *parent) : QTextBrowser(parent) {}
      13              : 
      14            1 : auto SecretTextBrowser::createMimeDataFromSelection() const -> QMimeData * {
      15              :   // Plain text only: the default would also put the selection's HTML on the
      16              :   // clipboard, without the hints.
      17            1 :   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            1 :   emit const_cast<SecretTextBrowser *>(this)->copied(text);
      21            2 :   return buildClipboardMimeData(text);
      22              : }
        

Generated by: LCOV version 2.0-1