QtPass 2.0.0
Developer documentation
Loading...
Searching...
No Matches
QPushButtonWithClipboard Class Reference

QPushButton that stores a text payload and emits it when activated. More...

#include <qpushbuttonwithclipboard.h>

Inheritance diagram for QPushButtonWithClipboard:
Collaboration diagram for QPushButtonWithClipboard:

Signals

void clicked (const QString &text)
 Emitted when the button is activated with the stored text.

Public Member Functions

 QPushButtonWithClipboard (QString textToCopy="", QWidget *parent=nullptr)
 Construct a QPushButtonWithClipboard with an optional initial text.
auto getTextToCopy () const -> QString
 Return the stored text used for copying.
void setTextToCopy (const QString &value)
 Update the stored text used for copying.

Private Slots

void changeIconDefault ()
 Restores the default copy icon; fired by a single-shot timer 500 ms after a click.
void buttonClicked (bool checked)
 Connected to QPushButton::clicked(bool); shows the pushed icon, arms the revert timer and re-emits clicked with the stored text.

Private Attributes

QString textToCopy
 Text handed to receivers on click; set by the owning panel.
QIcon iconEdit
 edit-copy icon shown at rest.
QIcon iconEditPushed
 document-new icon flashed for 500 ms after a click.

Detailed Description

QPushButton that stores a text payload and emits it when activated.

The button does not touch the clipboard itself. On activation it briefly swaps to a "done" icon (reverted after 500 ms) and re-emits clicked(const QString&) with the stored text; the receiver (normally ClipboardManager via PasswordDisplayPanel) performs the copy and the autoclear bookkeeping.

Definition at line 25 of file qpushbuttonwithclipboard.h.

Constructor & Destructor Documentation

◆ QPushButtonWithClipboard()

QPushButtonWithClipboard::QPushButtonWithClipboard ( QString textToCopy = "",
QWidget * parent = nullptr )
explicit

Construct a QPushButtonWithClipboard with an optional initial text.

Parameters
textToCopyInitial text to store and emit on activation.
parentOptional parent widget.

Definition at line 12 of file qpushbuttonwithclipboard.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ buttonClicked

void QPushButtonWithClipboard::buttonClicked ( bool checked)
privateslot

Connected to QPushButton::clicked(bool); shows the pushed icon, arms the revert timer and re-emits clicked with the stored text.

Parameters
checkedUnused; the button is not checkable.

Definition at line 35 of file qpushbuttonwithclipboard.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ changeIconDefault

void QPushButtonWithClipboard::changeIconDefault ( )
privateslot

Restores the default copy icon; fired by a single-shot timer 500 ms after a click.

Definition at line 41 of file qpushbuttonwithclipboard.cpp.

Here is the caller graph for this function:

◆ clicked

void QPushButtonWithClipboard::clicked ( const QString & text)
signal

Emitted when the button is activated with the stored text.

Parameters
textThe stored text associated with this button.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTextToCopy()

auto QPushButtonWithClipboard::getTextToCopy ( ) const -> QString
nodiscard

Return the stored text used for copying.

Returns
The current stored text.

Definition at line 27 of file qpushbuttonwithclipboard.cpp.

◆ setTextToCopy()

void QPushButtonWithClipboard::setTextToCopy ( const QString & value)

Update the stored text used for copying.

Parameters
valueThe new text to store.

Definition at line 31 of file qpushbuttonwithclipboard.cpp.

Here is the caller graph for this function:

Member Data Documentation

◆ iconEdit

QIcon QPushButtonWithClipboard::iconEdit
private

edit-copy icon shown at rest.

Definition at line 72 of file qpushbuttonwithclipboard.h.

◆ iconEditPushed

QIcon QPushButtonWithClipboard::iconEditPushed
private

document-new icon flashed for 500 ms after a click.

Definition at line 74 of file qpushbuttonwithclipboard.h.

◆ textToCopy

QString QPushButtonWithClipboard::textToCopy
private

Text handed to receivers on click; set by the owning panel.

Definition at line 70 of file qpushbuttonwithclipboard.h.


The documentation for this class was generated from the following files: