LCOV - code coverage report
Current view: top level - src - qpushbuttonwithclipboard.cpp (source / functions) Coverage Total Hit
Test: .lcov.total Lines: 0.0 % 20 0
Test Date: 2026-03-23 21:55:57 Functions: 0.0 % 5 0

            Line data    Source code
       1              : // SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
       2              : // SPDX-License-Identifier: GPL-3.0-or-later
       3              : #include "qpushbuttonwithclipboard.h"
       4              : #include <QTimer>
       5              : #include <utility>
       6              : 
       7              : /**
       8              :  * @brief QPushButtonWithClipboard::QPushButtonWithClipboard
       9              :  *  basic constructor
      10              :  * @param textToCopy
      11              :  *  the text to paste into the clipboard
      12              :  * @param parent
      13              :  *  the parent window
      14              :  */
      15            0 : QPushButtonWithClipboard::QPushButtonWithClipboard(QString textToCopy,
      16            0 :                                                    QWidget *parent)
      17              :     : QPushButton(parent), textToCopy(std::move(textToCopy)),
      18            0 :       iconEdit(QIcon::fromTheme("edit-copy", QIcon(":/icons/edit-copy.svg"))),
      19            0 :       iconEditPushed(
      20            0 :           QIcon::fromTheme("document-new", QIcon(":/icons/document-new.svg"))) {
      21            0 :   setIcon(iconEdit);
      22            0 :   connect(this, &QPushButton::clicked, this,
      23            0 :           &QPushButtonWithClipboard::buttonClicked);
      24            0 : }
      25              : 
      26              : /**
      27              :  * @brief QPushButtonWithClipboard::getTextToCopy returns the text of
      28              :  * associated text field
      29              :  * @return QString textToCopy
      30              :  */
      31            0 : auto QPushButtonWithClipboard::getTextToCopy() const -> QString {
      32            0 :   return textToCopy;
      33              : }
      34              : 
      35              : /**
      36              :  * @brief QPushButtonWithClipboard::setTextToCopy sets text from associated
      37              :  * text field
      38              :  * @param value QString text to be copied
      39              :  */
      40            0 : void QPushButtonWithClipboard::setTextToCopy(const QString &value) {
      41            0 :   textToCopy = value;
      42            0 : }
      43              : 
      44              : /**
      45              :  * @brief QPushButtonWithClipboard::buttonClicked handles clicked event by
      46              :  * emitting clicked(QString) with string provided to constructor
      47              :  */
      48            0 : void QPushButtonWithClipboard::buttonClicked(bool /*unused*/) {
      49            0 :   setIcon(iconEditPushed);
      50            0 :   QTimer::singleShot(500, this, SLOT(changeIconDefault()));
      51            0 :   emit clicked(textToCopy);
      52            0 : }
      53              : 
      54              : /**
      55              :  * @brief QPushButtonWithClipboard::changeIconDefault change the icon back to
      56              :  * the default copy icon
      57              :  */
      58            0 : void QPushButtonWithClipboard::changeIconDefault() { this->setIcon(iconEdit); }
        

Generated by: LCOV version 2.4-beta