forked from dashpay/dash
/
askpassphrasedialog.h
83 lines (69 loc) · 2.59 KB
/
askpassphrasedialog.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2011-2013 The Bitcoin developers
// Copyright (c) 2017-2018 The PIVX developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_QT_ASKPASSPHRASEDIALOG_H
#define BITCOIN_QT_ASKPASSPHRASEDIALOG_H
#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.
*/
class AskPassphraseDialog : public QDialog, public Runnable
{
Q_OBJECT
public:
enum class Mode {
Encrypt, /**< Ask passphrase twice and encrypt */
UnlockAnonymize, /**< Ask passphrase and unlock only for anonymization */
Unlock, /**< Ask passphrase and unlock */
ChangePass, /**< Ask old passphrase + new passphrase twice */
Decrypt /**< Ask passphrase and decrypt wallet */
};
// Context from where / for what the passphrase dialog was called to set the status of the checkbox
// Partly redundant to Mode above, but offers more flexibility for future enhancements
enum class Context {
Unlock_Menu, /** Unlock wallet from menu */
Unlock_Full, /** Wallet needs to be fully unlocked */
Encrypt, /** Encrypt unencrypted wallet */
ToggleLock, /** Toggle wallet lock state */
ChangePass, /** Change passphrase */
Send_PIV, /** Send PIV */
Send_zPIV, /** Send zPIV */
Mint_zPIV, /** Mint zPIV */
BIP_38, /** BIP38 menu */
Multi_Sig, /** Multi-Signature dialog */
Sign_Message, /** Sign/verify message dialog */
UI_Vote, /** Governance Tab UI Voting */
};
explicit AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel* model, Context context);
~AskPassphraseDialog();
void accept() override;
private:
Ui::AskPassphraseDialog* ui;
Mode mode;
WalletModel* model;
Context context;
bool fCapsLock;
SecureString newpassCache = "";
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:
bool event(QEvent* event) override ;
bool eventFilter(QObject* object, QEvent* event) override;
};
#endif // BITCOIN_QT_ASKPASSPHRASEDIALOG_H