Line data Source code
1 : // SPDX-FileCopyrightText: 2016 Anne Jan Brouwer
2 : // SPDX-License-Identifier: GPL-3.0-or-later
3 : #include "qpushbuttonshowpassword.h"
4 : #include <QTimer>
5 :
6 : /**
7 : * @brief QPushButtonAsQRCode::QPushButtonAsQRCode
8 : * basic constructor
9 : * @param textToCopy
10 : * the text to display as qrcode
11 : * @param parent
12 : * the parent window
13 : */
14 0 : QPushButtonShowPassword::QPushButtonShowPassword(QLineEdit *line,
15 0 : QWidget *parent)
16 : : QPushButton(parent),
17 0 : iconEdit(QIcon::fromTheme("show", QIcon(":/icons/view.svg"))),
18 0 : iconEditPushed(QIcon::fromTheme("hide-new", QIcon(":/icons/hide.svg"))) {
19 0 : setIcon(iconEdit);
20 0 : connect(this, &QPushButton::clicked, this,
21 0 : &QPushButtonShowPassword::buttonClicked);
22 0 : this->line = line;
23 0 : }
24 :
25 : /**
26 : * @brief QPushButtonAsQRCode::buttonClicked handles clicked event by
27 : * emitting clicked(QString) with string provided to constructor
28 : */
29 0 : void QPushButtonShowPassword::buttonClicked(bool /*unused*/) {
30 0 : if (this->line->echoMode() == QLineEdit::Password) {
31 0 : this->line->setEchoMode(QLineEdit::Normal);
32 0 : setIcon(iconEditPushed);
33 : } else {
34 0 : this->line->setEchoMode(QLineEdit::Password);
35 0 : setIcon(iconEdit);
36 : }
37 0 : }
|