5 #if defined(HAVE_CONFIG_H) 20 #include <QMessageBox> 21 #include <QPushButton> 54 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>."));
57 setWindowTitle(tr(
"Encrypt wallet"));
63 ui->
warningLabel->setText(tr(
"This operation needs your wallet passphrase to unlock the wallet."));
68 setWindowTitle(tr(
"Unlock wallet"));
71 ui->
warningLabel->setText(tr(
"This operation needs your wallet passphrase to decrypt the wallet."));
76 setWindowTitle(tr(
"Decrypt wallet"));
79 setWindowTitle(tr(
"Change passphrase"));
80 ui->
warningLabel->setText(tr(
"Enter the old passphrase and new passphrase to the wallet."));
105 oldpass.reserve(MAX_PASSPHRASE_SIZE);
106 newpass1.reserve(MAX_PASSPHRASE_SIZE);
107 newpass2.reserve(MAX_PASSPHRASE_SIZE);
110 oldpass.assign(
ui->
passEdit1->text().toStdString().c_str());
111 newpass1.assign(
ui->
passEdit2->text().toStdString().c_str());
112 newpass2.assign(
ui->
passEdit3->text().toStdString().c_str());
119 if(newpass1.empty() || newpass2.empty())
124 QMessageBox::StandardButton retval = QMessageBox::question(
this, tr(
"Confirm wallet encryption"),
125 tr(
"Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR FABCOINS</b>!") +
"<br><br>" + tr(
"Are you sure you wish to encrypt your wallet?"),
126 QMessageBox::Yes|QMessageBox::Cancel,
127 QMessageBox::Cancel);
128 if(retval == QMessageBox::Yes)
130 if(newpass1 == newpass2)
134 QMessageBox::warning(
this, tr(
"Wallet encrypted"),
136 tr(
"%1 will close now to finish the encryption process. " 137 "Remember that encrypting your wallet cannot fully protect " 138 "your fabcoins from being stolen by malware infecting your computer.").arg(tr(
PACKAGE_NAME)) +
140 tr(
"IMPORTANT: Any previous backups you have made of your wallet file " 141 "should be replaced with the newly generated, encrypted wallet file. " 142 "For security reasons, previous backups of the unencrypted wallet file " 143 "will become useless as soon as you start using the new, encrypted wallet.") +
145 QApplication::quit();
149 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
150 tr(
"Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
156 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
157 tr(
"The supplied passphrases do not match."));
169 QMessageBox::critical(
this, tr(
"Wallet unlock failed"),
170 tr(
"The passphrase entered for the wallet decryption was incorrect."));
181 QMessageBox::critical(
this, tr(
"Wallet decryption failed"),
182 tr(
"The passphrase entered for the wallet decryption was incorrect."));
190 if(newpass1 == newpass2)
194 QMessageBox::information(
this, tr(
"Wallet encrypted"),
195 tr(
"Wallet passphrase was successfully changed."));
200 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
201 tr(
"The passphrase entered for the wallet decryption was incorrect."));
206 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
207 tr(
"The supplied passphrases do not match."));
216 bool acceptable =
false;
231 ui->
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
237 if (event->type() == QEvent::KeyPress) {
238 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
239 if (ke->key() == Qt::Key_CapsLock) {
243 ui->
capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
248 return QWidget::event(event);
259 if (event->type() == QEvent::KeyPress) {
260 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
261 QString str = ke->text();
262 if (str.length() != 0) {
263 const QChar *psz = str.unicode();
264 bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
265 if ((fShift && *psz >=
'a' && *psz <=
'z') || (!fShift && *psz >=
'A' && *psz <=
'Z')) {
267 ui->
capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
268 }
else if (psz->isLetter()) {
274 return QDialog::eventFilter(
object, event);
277 static void SecureClearQLineEdit(QLineEdit* edit)
280 edit->setText(QString(
" ").repeated(edit->text().size()));
Ask passphrase and unlock staking only.
void setupUi(QDialog *AskPassphraseDialog)
#define SetObjectStyleSheet(object, name)
bool event(QEvent *event)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Ask passphrase twice and encrypt.
QCheckBox * stakingCheckBox
Ask passphrase and unlock.
Ui::AskPassphraseDialog * ui
void secureClearPassFields()
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
QDialogButtonBox * buttonBox
AskPassphraseDialog(Mode mode, QWidget *parent)
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
Interface to Fabcoin wallet from Qt view code.
bool fWalletUnlockStakingOnly
Multifunctional dialog to ask for passphrases.
bool setWalletEncrypted(bool encrypted, const SecureString &passphrase)
Ask passphrase and decrypt wallet.
bool eventFilter(QObject *object, QEvent *event)
Ask old passphrase + new passphrase twice.
void setModel(WalletModel *model)