15 #include <QMessageBox>
16 #include <QPushButton>
41 ui->
warningLabel->setText(tr(
"Enter the new passphrase to the wallet.<br/>Please use a passphrase of <b>10 or more random characters</b>, or <b>eight or more words</b>."));
42 setWindowTitle(tr(
"Encrypt wallet"));
45 ui->
warningLabel->setText(tr(
"This operation needs your wallet passphrase to unlock the wallet."));
50 setWindowTitle(tr(
"Unlock wallet"));
53 ui->
warningLabel->setText(tr(
"This operation needs your wallet passphrase to decrypt the wallet."));
58 setWindowTitle(tr(
"Decrypt wallet"));
61 setWindowTitle(tr(
"Change passphrase"));
62 ui->
warningLabel->setText(tr(
"Enter the old and new passphrase to the wallet."));
91 oldpass.reserve(MAX_PASSPHRASE_SIZE);
92 newpass1.reserve(MAX_PASSPHRASE_SIZE);
93 newpass2.reserve(MAX_PASSPHRASE_SIZE);
96 oldpass.assign(
ui->
passEdit1->text().toStdString().c_str());
97 newpass1.assign(
ui->
passEdit2->text().toStdString().c_str());
98 newpass2.assign(
ui->
passEdit3->text().toStdString().c_str());
103 if(newpass1.empty() || newpass2.empty())
108 QMessageBox::StandardButton retval = QMessageBox::question(
this, tr(
"Confirm wallet encryption"),
109 tr(
"Warning: If you encrypt your wallet and lose your passphrase, you will <b>LOSE ALL OF YOUR ANONCOINS</b>!") +
"<br><br>" + tr(
"Are you sure you wish to encrypt your wallet?"),
110 QMessageBox::Yes|QMessageBox::Cancel,
111 QMessageBox::Cancel);
112 if(retval == QMessageBox::Yes)
114 if(newpass1 == newpass2)
118 QMessageBox::warning(
this, tr(
"Wallet encrypted"),
120 tr(
"Anoncoin will close now to finish the encryption process. "
121 "Remember that encrypting your wallet cannot fully protect "
122 "your anoncoins from being stolen by malware infecting your computer.") +
124 tr(
"IMPORTANT: Any previous backups you have made of your wallet file "
125 "should be replaced with the newly generated, encrypted wallet file. "
126 "For security reasons, previous backups of the unencrypted wallet file "
127 "will become useless as soon as you start using the new, encrypted wallet.") +
129 QApplication::quit();
133 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
134 tr(
"Wallet encryption failed due to an internal error. Your wallet was not encrypted."));
140 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
141 tr(
"The supplied passphrases do not match."));
152 QMessageBox::critical(
this, tr(
"Wallet unlock failed"),
153 tr(
"The passphrase entered for the wallet decryption was incorrect."));
163 QMessageBox::critical(
this, tr(
"Wallet decryption failed"),
164 tr(
"The passphrase entered for the wallet decryption was incorrect."));
172 if(newpass1 == newpass2)
176 QMessageBox::information(
this, tr(
"Wallet encrypted"),
177 tr(
"Wallet passphrase was successfully changed."));
182 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
183 tr(
"The passphrase entered for the wallet decryption was incorrect."));
188 QMessageBox::critical(
this, tr(
"Wallet encryption failed"),
189 tr(
"The supplied passphrases do not match."));
198 bool acceptable =
false;
212 ui->
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(acceptable);
218 if (event->type() == QEvent::KeyPress) {
219 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
220 if (ke->key() == Qt::Key_CapsLock) {
224 ui->
capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
229 return QWidget::event(event);
240 if (event->type() == QEvent::KeyPress) {
241 QKeyEvent *ke =
static_cast<QKeyEvent *
>(
event);
242 QString str = ke->text();
243 if (str.length() != 0) {
244 const QChar *psz = str.unicode();
245 bool fShift = (ke->modifiers() & Qt::ShiftModifier) != 0;
246 if ((fShift && *psz >=
'a' && *psz <=
'z') || (!fShift && *psz >=
'A' && *psz <=
'Z')) {
248 ui->
capsLabel->setText(tr(
"Warning: The Caps Lock key is on!"));
249 }
else if (psz->isLetter()) {
255 return QDialog::eventFilter(
object, event);
void setupUi(QDialog *AskPassphraseDialog)
bool event(QEvent *event)
Ask passphrase twice and encrypt.
Ask passphrase and unlock.
Ui::AskPassphraseDialog * ui
bool changePassphrase(const SecureString &oldPass, const SecureString &newPass)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
QDialogButtonBox * buttonBox
AskPassphraseDialog(Mode mode, QWidget *parent)
bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString())
Interface to Anoncoin wallet from Qt view code.
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)