QtPass  1.2.0-pre
Multi-platform GUI for pass, the standard unix password manager.
qpushbuttonwithclipboard.cpp
Go to the documentation of this file.
2 #include <QTimer>
3 
13  QWidget *parent)
14  : QPushButton(parent), textToCopy(textToCopy),
15  iconEdit(QIcon::fromTheme("edit-copy", QIcon(":/icons/edit-copy.svg"))),
16  iconEditPushed(
17  QIcon::fromTheme("document-new", QIcon(":/icons/document-new.svg"))) {
18  setIcon(iconEdit);
19  connect(this, SIGNAL(clicked(bool)), this, SLOT(buttonClicked(bool)));
20 }
21 
27 QString QPushButtonWithClipboard::getTextToCopy() const { return textToCopy; }
28 
34 void QPushButtonWithClipboard::setTextToCopy(const QString &value) {
35  textToCopy = value;
36 }
37 
42 void QPushButtonWithClipboard::buttonClicked(bool) {
43  setIcon(iconEditPushed);
44  QTimer::singleShot(500, this, SLOT(changeIconDefault()));
45  emit clicked(textToCopy);
46 }
47 
52 void QPushButtonWithClipboard::changeIconDefault() { this->setIcon(iconEdit); }
QPushButtonWithClipboard(const QString &textToCopy="", QWidget *parent=0)
QPushButtonWithClipboard::QPushButtonWithClipboard basic constructor.
QString getTextToCopy() const
QPushButtonWithClipboard::getTextToCopy returns the text of associated text field.
void setTextToCopy(const QString &value)
QPushButtonWithClipboard::setTextToCopy sets text from associated text field.