From 13650d33f0499cf54e8a5840a983b33a44054da9 Mon Sep 17 00:00:00 2001 From: Gregory Solarte Date: Tue, 7 May 2019 14:44:16 -0300 Subject: [PATCH] button show password --- src/qt/askpassphrasedialog.cpp | 68 ++++++++++++++++ src/qt/askpassphrasedialog.h | 6 ++ src/qt/forms/askpassphrasedialog.ui | 118 +++++++++++++++++++--------- src/qt/pivx/res/css/style_dark.css | 3 + src/qt/pivx/res/css/style_light.css | 2 +- 5 files changed, 161 insertions(+), 36 deletions(-) diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index 426f20e58825e..9cd626d8faa3b 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -6,6 +6,7 @@ #include "askpassphrasedialog.h" #include "ui_askpassphrasedialog.h" +#include #include "guiconstants.h" #include "guiutil.h" @@ -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); @@ -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); @@ -77,6 +128,7 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.
Please use a passphrase of ten or more random characters, or eight or more words.")); ui->passLabel1->hide(); ui->passEdit1->hide(); + ui->layoutEdit->hide(); setWindowTitle(tr("Encrypt wallet")); break; case Mode::UnlockAnonymize: @@ -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")); @@ -93,17 +146,21 @@ 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())); @@ -111,6 +168,17 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel 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 diff --git a/src/qt/askpassphrasedialog.h b/src/qt/askpassphrasedialog.h index 40487234c001c..3e4dfee8625d0 100644 --- a/src/qt/askpassphrasedialog.h +++ b/src/qt/askpassphrasedialog.h @@ -9,6 +9,7 @@ #include #include "qt/pivx/prunnable.h" #include "allocators.h" +#include class WalletModel; class PIVXGUI; @@ -16,6 +17,7 @@ class PIVXGUI; namespace Ui { class AskPassphraseDialog; +class QCheckBox; } /** Multifunctional dialog to ask for passphrases. Used for encryption, unlocking, and changing the passphrase. @@ -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: diff --git a/src/qt/forms/askpassphrasedialog.ui b/src/qt/forms/askpassphrasedialog.ui index 01e2cf349111d..252d15d30eb02 100644 --- a/src/qt/forms/askpassphrasedialog.ui +++ b/src/qt/forms/askpassphrasedialog.ui @@ -22,6 +22,12 @@ 0 + + + 550 + 16777215 + + Passphrase Dialog @@ -141,22 +147,43 @@ - - - - 0 - 50 - - - - - 16777215 - 50 - - - - QLineEdit::Password - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 50 + + + + + 16777215 + 50 + + + + QLineEdit::Password + + + + @@ -176,25 +203,46 @@ - - - - 0 - 50 - - - - - 16777215 - 50 - - - - QLineEdit::Password - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 50 + + + + + 16777215 + 50 + + + + QLineEdit::Password + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + diff --git a/src/qt/pivx/res/css/style_dark.css b/src/qt/pivx/res/css/style_dark.css index 83071a646f325..bc6d7ff55f876 100644 --- a/src/qt/pivx/res/css/style_dark.css +++ b/src/qt/pivx/res/css/style_dark.css @@ -2805,6 +2805,9 @@ HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH background-color:transparent; } +*[cssClass="container-loading"]{ + background-color:#4D000000; +} *[cssClass="text-loading"]{ color:#ffffff; diff --git a/src/qt/pivx/res/css/style_light.css b/src/qt/pivx/res/css/style_light.css index 4c41ec2f185b0..e6afaa8497488 100644 --- a/src/qt/pivx/res/css/style_light.css +++ b/src/qt/pivx/res/css/style_light.css @@ -2773,7 +2773,7 @@ HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH */ *[cssClass="container-loading"]{ - background-color:transparent; + background-color:#4D000000; } *[cssClass="text-loading"]{