Skip to content

Commit

Permalink
button show password
Browse files Browse the repository at this point in the history
  • Loading branch information
Neoperol authored and furszy committed Aug 28, 2019
1 parent 03e12d3 commit 13650d3
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 36 deletions.
68 changes: 68 additions & 0 deletions src/qt/askpassphrasedialog.cpp
Expand Up @@ -6,6 +6,7 @@

#include "askpassphrasedialog.h"
#include "ui_askpassphrasedialog.h"
#include <QGraphicsDropShadowEffect>

#include "guiconstants.h"
#include "guiutil.h"
Expand All @@ -24,6 +25,8 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
mode(mode),
model(model),
context(context),
btnWatch(new QCheckBox()),
btnWatch2(new QCheckBox()),
fCapsLock(false)
{
ui->setupUi(this);
Expand Down Expand Up @@ -65,6 +68,54 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
ui->passEdit2->setMaxLength(MAX_PASSPHRASE_SIZE);
ui->passEdit3->setMaxLength(MAX_PASSPHRASE_SIZE);

QGraphicsDropShadowEffect* shadowEffect = new QGraphicsDropShadowEffect();
shadowEffect->setColor(QColor(0, 0, 0, 22));
shadowEffect->setXOffset(0);
shadowEffect->setYOffset(3);
shadowEffect->setBlurRadius(6);

QGraphicsDropShadowEffect* shadowEffect2 = new QGraphicsDropShadowEffect();
shadowEffect2->setColor(QColor(0, 0, 0, 22));
shadowEffect2->setXOffset(0);
shadowEffect2->setYOffset(3);
shadowEffect2->setBlurRadius(6);


ui->layoutEdit->setGraphicsEffect(shadowEffect);

ui->layoutEdit2->setGraphicsEffect(shadowEffect2);

// Button Watch

btnWatch = new QCheckBox(ui->layoutEdit);

btnWatch->setProperty("cssClass", "btn-watch-password");
btnWatch->setChecked(false);
QSize BUTTON_CONTACT_SIZE = QSize(24, 24);
btnWatch->setMinimumSize(BUTTON_CONTACT_SIZE);
btnWatch->setMaximumSize(BUTTON_CONTACT_SIZE);

btnWatch->show();
btnWatch->raise();

int posXX = ui->layoutEdit->width() - 30;
int posYY = 8;
btnWatch->move(450, posYY);

btnWatch2 = new QCheckBox(ui->layoutEdit2);

btnWatch2->setProperty("cssClass", "btn-watch-password");
btnWatch2->setChecked(false);

btnWatch2->setMinimumSize(BUTTON_CONTACT_SIZE);
btnWatch2->setMaximumSize(BUTTON_CONTACT_SIZE);

btnWatch2->show();
btnWatch2->raise();

btnWatch2->move(450, posYY);


// Setup Caps Lock detection.
ui->passEdit1->installEventFilter(this);
ui->passEdit2->installEventFilter(this);
Expand All @@ -77,6 +128,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
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>."));
ui->passLabel1->hide();
ui->passEdit1->hide();
ui->layoutEdit->hide();
setWindowTitle(tr("Encrypt wallet"));
break;
case Mode::UnlockAnonymize:
Expand All @@ -85,6 +137,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->layoutEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Unlock wallet"));
Expand All @@ -93,24 +146,39 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel
ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet."));
ui->passLabel2->hide();
ui->passEdit2->hide();
ui->layoutEdit2->hide();
ui->passLabel3->hide();
ui->passEdit3->hide();
setWindowTitle(tr("Decrypt wallet"));
break;
case Mode::ChangePass: // Ask old passphrase + new passphrase x2
setWindowTitle(tr("Change passphrase"));
btnWatch2->hide();
ui->warningLabel->setText(tr("Enter the old and new passphrase to the wallet."));
break;
}

textChanged();
connect(btnWatch2, SIGNAL(clicked()), this, SLOT(onWatch2Clicked()));
connect(btnWatch, SIGNAL(clicked()), this, SLOT(onWatchClicked()));
connect(ui->passEdit1, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit2, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->passEdit3, SIGNAL(textChanged(QString)), this, SLOT(textChanged()));
connect(ui->pushButtonOk, SIGNAL(clicked()), this, SLOT(accept()));
connect(ui->btnEsc, SIGNAL(clicked()), this, SLOT(close()));
}

void AskPassphraseDialog::onWatchClicked(){
ui->passEdit3->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
ui->passEdit2->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
ui->passEdit1->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
}

void AskPassphraseDialog::onWatch2Clicked(){
ui->passEdit3->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
ui->passEdit2->setEchoMode(btnWatch->checkState() == Qt::Checked ? QLineEdit::Normal : QLineEdit::Password );
}

AskPassphraseDialog::~AskPassphraseDialog()
{
// Attempt to overwrite text so that they do not linger around in memory
Expand Down
6 changes: 6 additions & 0 deletions src/qt/askpassphrasedialog.h
Expand Up @@ -9,13 +9,15 @@
#include <QDialog>
#include "qt/pivx/prunnable.h"
#include "allocators.h"
#include <QCheckBox>

class WalletModel;
class PIVXGUI;

namespace Ui
{
class AskPassphraseDialog;
class QCheckBox;
}

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

void run(int type) override;
void onError(int type, QString error) override;
QCheckBox *btnWatch;
QCheckBox *btnWatch2;

private slots:
void onWatchClicked();
void onWatch2Clicked();
void textChanged();

protected:
Expand Down
118 changes: 83 additions & 35 deletions src/qt/forms/askpassphrasedialog.ui
Expand Up @@ -22,6 +22,12 @@
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>550</width>
<height>16777215</height>
</size>
</property>
<property name="windowTitle">
<string>Passphrase Dialog</string>
</property>
Expand Down Expand Up @@ -141,22 +147,43 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="passEdit1">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<widget class="QWidget" name="layoutEdit" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="passEdit1">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
Expand All @@ -176,25 +203,46 @@
</widget>
</item>
<item>
<widget class="QLineEdit" name="passEdit2">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
<widget class="QWidget" name="layoutEdit2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="spacing">
<number>0</number>
</property>
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLineEdit" name="passEdit2">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
Expand Down
3 changes: 3 additions & 0 deletions src/qt/pivx/res/css/style_dark.css
Expand Up @@ -2805,6 +2805,9 @@ HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
background-color:transparent;
}

*[cssClass="container-loading"]{
background-color:#4D000000;
}

*[cssClass="text-loading"]{
color:#ffffff;
Expand Down
2 changes: 1 addition & 1 deletion src/qt/pivx/res/css/style_light.css
Expand Up @@ -2773,7 +2773,7 @@ HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
*/

*[cssClass="container-loading"]{
background-color:transparent;
background-color:#4D000000;
}

*[cssClass="text-loading"]{
Expand Down

0 comments on commit 13650d3

Please sign in to comment.