Skip to content

Commit 13650d3

Browse files
Neoperolfurszy
authored andcommitted
button show password
1 parent 03e12d3 commit 13650d3

File tree

5 files changed

+161
-36
lines changed

5 files changed

+161
-36
lines changed

src/qt/askpassphrasedialog.cpp

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include "askpassphrasedialog.h"
88
#include "ui_askpassphrasedialog.h"
9+
#include <QGraphicsDropShadowEffect>
910

1011
#include "guiconstants.h"
1112
#include "guiutil.h"
@@ -24,6 +25,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
2425
mode(mode),
2526
model(model),
2627
context(context),
28+
btnWatch(new QCheckBox()),
29+
btnWatch2(new QCheckBox()),
2730
fCapsLock(false)
2831
{
2932
ui->setupUi(this);
@@ -65,6 +68,54 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
6568
ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE);
6669
ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE);
6770

71+
QGraphicsDropShadowEffect* shadowEffect = new QGraphicsDropShadowEffect();
72+
shadowEffect->setColor(QColor(0, 0, 0, 22));
73+
shadowEffect->setXOffset(0);
74+
shadowEffect->setYOffset(3);
75+
shadowEffect->setBlurRadius(6);
76+
77+
QGraphicsDropShadowEffect* shadowEffect2 = new QGraphicsDropShadowEffect();
78+
shadowEffect2->setColor(QColor(0, 0, 0, 22));
79+
shadowEffect2->setXOffset(0);
80+
shadowEffect2->setYOffset(3);
81+
shadowEffect2->setBlurRadius(6);
82+
83+
84+
ui->layoutEdit->setGraphicsEffect(shadowEffect);
85+
86+
ui->layoutEdit2->setGraphicsEffect(shadowEffect2);
87+
88+
// Button Watch
89+
90+
btnWatch = new QCheckBox(ui->layoutEdit);
91+
92+
btnWatch->setProperty("cssClass", "btn-watch-password");
93+
btnWatch->setChecked(false);
94+
QSize BUTTON_CONTACT_SIZE = QSize(24, 24);
95+
btnWatch->setMinimumSize(BUTTON_CONTACT_SIZE);
96+
btnWatch->setMaximumSize(BUTTON_CONTACT_SIZE);
97+
98+
btnWatch->show();
99+
btnWatch->raise();
100+
101+
int posXX = ui->layoutEdit->width() - 30;
102+
int posYY = 8;
103+
btnWatch->move(450, posYY);
104+
105+
btnWatch2 = new QCheckBox(ui->layoutEdit2);
106+
107+
btnWatch2->setProperty("cssClass", "btn-watch-password");
108+
btnWatch2->setChecked(false);
109+
110+
btnWatch2->setMinimumSize(BUTTON_CONTACT_SIZE);
111+
btnWatch2->setMaximumSize(BUTTON_CONTACT_SIZE);
112+
113+
btnWatch2->show();
114+
btnWatch2->raise();
115+
116+
btnWatch2->move(450, posYY);
117+
118+
68119
// Setup Caps Lock detection.
69120
ui->passEdit1->installEventFilter(this);
70121
ui->passEdit2->installEventFilter(this);
@@ -77,6 +128,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
77128
ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>ten or more random characters</b>, or <b>eight or more words</b>."));
78129
ui->passLabel1->hide();
79130
ui->passEdit1->hide();
131+
ui->layoutEdit->hide();
80132
setWindowTitle(tr("Encrypt wallet"));
81133
break;
82134
case Mode::UnlockAnonymize:
@@ -85,6 +137,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
85137
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
86138
ui->passLabel2->hide();
87139
ui->passEdit2->hide();
140+
ui->layoutEdit2->hide();
88141
ui->passLabel3->hide();
89142
ui->passEdit3->hide();
90143
setWindowTitle(tr("Unlock wallet"));
@@ -93,24 +146,39 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
93146
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet."));
94147
ui->passLabel2->hide();
95148
ui->passEdit2->hide();
149+
ui->layoutEdit2->hide();
96150
ui->passLabel3->hide();
97151
ui->passEdit3->hide();
98152
setWindowTitle(tr("Decrypt wallet"));
99153
break;
100154
case Mode::ChangePass: // Ask old passphrase + new passphrase x2
101155
setWindowTitle(tr("Change passphrase"));
156+
btnWatch2->hide();
102157
ui->warningLabel->setText(tr("Enter the old and new passphrase to the wallet."));
103158
break;
104159
}
105160

106161
textChanged();
162+
connect(btnWatch2, SIGNAL(clicked()), this, SLOT(onWatch2Clicked()));
163+
connect(btnWatch, SIGNAL(clicked()), this, SLOT(onWatchClicked()));
107164
connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
108165
connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
109166
connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
110167
connect(ui->pushButtonOk, SIGNAL(clicked()), this, SLOT(accept()));
111168
connect(ui->btnEsc, SIGNAL(clicked()), this, SLOT(close()));
112169
}
113170

171+
void AskPassphraseDialog::onWatchClicked(){
172+
ui->passEdit3->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
173+
ui->passEdit2->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
174+
ui->passEdit1->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
175+
}
176+
177+
void AskPassphraseDialog::onWatch2Clicked(){
178+
ui->passEdit3->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
179+
ui->passEdit2->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
180+
}
181+
114182
AskPassphraseDialog::~AskPassphraseDialog()
115183
{
116184
// Attempt to overwrite text so that they do not linger around in memory

src/qt/askpassphrasedialog.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,15 @@
99
#include <QDialog>
1010
#include "qt/pivx/prunnable.h"
1111
#include "allocators.h"
12+
#include <QCheckBox>
1213

1314
class WalletModel;
1415
class PIVXGUI;
1516

1617
namespace Ui
1718
{
1819
class AskPassphraseDialog;
20+
class QCheckBox;
1921
}
2022

2123
/** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase.
@@ -65,8 +67,12 @@ class AskPassphraseDialog : public QDialog, public Runnable
6567

6668
void run(int type) override;
6769
void onError(int type, QString error) override;
70+
QCheckBox *btnWatch;
71+
QCheckBox *btnWatch2;
6872

6973
private slots:
74+
void onWatchClicked();
75+
void onWatch2Clicked();
7076
void textChanged();
7177

7278
protected:

src/qt/forms/askpassphrasedialog.ui

Lines changed: 83 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
<height>0</height>
2323
</size>
2424
</property>
25+
<property name="maximumSize">
26+
<size>
27+
<width>550</width>
28+
<height>16777215</height>
29+
</size>
30+
</property>
2531
<property name="windowTitle">
2632
<string>Passphrase Dialog</string>
2733
</property>
@@ -141,22 +147,43 @@
141147
</widget>
142148
</item>
143149
<item>
144-
<widget class="QLineEdit" name="passEdit1">
145-
<property name="minimumSize">
146-
<size>
147-
<width>0</width>
148-
<height>50</height>
149-
</size>
150-
</property>
151-
<property name="maximumSize">
152-
<size>
153-
<width>16777215</width>
154-
<height>50</height>
155-
</size>
156-
</property>
157-
<property name="echoMode">
158-
<enum>QLineEdit::Password</enum>
159-
</property>
150+
<widget class="QWidget" name="layoutEdit" native="true">
151+
<layout class="QHBoxLayout" name="horizontalLayout">
152+
<property name="spacing">
153+
<number>0</number>
154+
</property>
155+
<property name="leftMargin">
156+
<number>0</number>
157+
</property>
158+
<property name="topMargin">
159+
<number>0</number>
160+
</property>
161+
<property name="rightMargin">
162+
<number>0</number>
163+
</property>
164+
<property name="bottomMargin">
165+
<number>0</number>
166+
</property>
167+
<item>
168+
<widget class="QLineEdit" name="passEdit1">
169+
<property name="minimumSize">
170+
<size>
171+
<width>0</width>
172+
<height>50</height>
173+
</size>
174+
</property>
175+
<property name="maximumSize">
176+
<size>
177+
<width>16777215</width>
178+
<height>50</height>
179+
</size>
180+
</property>
181+
<property name="echoMode">
182+
<enum>QLineEdit::Password</enum>
183+
</property>
184+
</widget>
185+
</item>
186+
</layout>
160187
</widget>
161188
</item>
162189
</layout>
@@ -176,25 +203,46 @@
176203
</widget>
177204
</item>
178205
<item>
179-
<widget class="QLineEdit" name="passEdit2">
180-
<property name="minimumSize">
181-
<size>
182-
<width>0</width>
183-
<height>50</height>
184-
</size>
185-
</property>
186-
<property name="maximumSize">
187-
<size>
188-
<width>16777215</width>
189-
<height>50</height>
190-
</size>
191-
</property>
192-
<property name="echoMode">
193-
<enum>QLineEdit::Password</enum>
194-
</property>
195-
<property name="alignment">
196-
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
197-
</property>
206+
<widget class="QWidget" name="layoutEdit2" native="true">
207+
<layout class="QHBoxLayout" name="horizontalLayout_2">
208+
<property name="spacing">
209+
<number>0</number>
210+
</property>
211+
<property name="leftMargin">
212+
<number>0</number>
213+
</property>
214+
<property name="topMargin">
215+
<number>0</number>
216+
</property>
217+
<property name="rightMargin">
218+
<number>0</number>
219+
</property>
220+
<property name="bottomMargin">
221+
<number>0</number>
222+
</property>
223+
<item>
224+
<widget class="QLineEdit" name="passEdit2">
225+
<property name="minimumSize">
226+
<size>
227+
<width>0</width>
228+
<height>50</height>
229+
</size>
230+
</property>
231+
<property name="maximumSize">
232+
<size>
233+
<width>16777215</width>
234+
<height>50</height>
235+
</size>
236+
</property>
237+
<property name="echoMode">
238+
<enum>QLineEdit::Password</enum>
239+
</property>
240+
<property name="alignment">
241+
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
242+
</property>
243+
</widget>
244+
</item>
245+
</layout>
198246
</widget>
199247
</item>
200248
</layout>

src/qt/pivx/res/css/style_dark.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2805,6 +2805,9 @@ HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
28052805
background-color:transparent;
28062806
}
28072807

2808+
*[cssClass="container-loading"]{
2809+
background-color:#4D000000;
2810+
}
28082811

28092812
*[cssClass="text-loading"]{
28102813
color:#ffffff;

src/qt/pivx/res/css/style_light.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2773,7 +2773,7 @@ HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
27732773
*/
27742774

27752775
*[cssClass="container-loading"]{
2776-
background-color:transparent;
2776+
background-color:#4D000000;
27772777
}
27782778

27792779
*[cssClass="text-loading"]{

0 commit comments

Comments
 (0)