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

            Line data    Source code
       1              : // SPDX-FileCopyrightText: 2018 Anne Jan Brouwer
       2              : // SPDX-License-Identifier: GPL-3.0-or-later
       3              : /**
       4              :  * @file
       5              :  * @brief Implements QPushButtonAsQRCode: icon setup and the click re-emit.
       6              :  */
       7              : #include "qpushbuttonasqrcode.h"
       8              : #include <QTimer>
       9              : #include <utility>
      10              : 
      11           18 : QPushButtonAsQRCode::QPushButtonAsQRCode(QString textToCopy, QWidget *parent)
      12              :     : QPushButton(parent), textToCopy(std::move(textToCopy)),
      13           36 :       iconEdit(QIcon::fromTheme("qrcode", QIcon(":/icons/qrcode.svg"))) {
      14           18 :   setIcon(iconEdit);
      15              :   // Icon-only: give screen readers and hovering users a name.
      16           36 :   setToolTip(tr("Show as QR code"));
      17           18 :   setAccessibleName(tr("Show as QR code"));
      18           18 :   setForegroundRole(QPalette::ButtonText);
      19           18 :   connect(this, &QPushButton::clicked, this,
      20           18 :           &QPushButtonAsQRCode::buttonClicked);
      21           18 : }
      22              : 
      23            5 : auto QPushButtonAsQRCode::getTextToCopy() const -> QString {
      24            5 :   return textToCopy;
      25              : }
      26              : 
      27            4 : void QPushButtonAsQRCode::setTextToCopy(const QString &value) {
      28            4 :   textToCopy = value;
      29            4 : }
      30              : 
      31            3 : void QPushButtonAsQRCode::buttonClicked(bool /*unused*/) {
      32            3 :   emit clicked(textToCopy);
      33            3 : }
        

Generated by: LCOV version 2.0-1