PIVX Core  5.6.99
P2P Digital Currency
askpassphrasedialog.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2013 The Bitcoin developers
2 // Copyright (c) 2017-2021 The PIVX Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef PIVX_QT_ASKPASSPHRASEDIALOG_H
7 #define PIVX_QT_ASKPASSPHRASEDIALOG_H
8 
9 #include "prunnable.h"
11 #include <QCheckBox>
12 #include <QDialog>
13 
14 class WalletModel;
15 class PIVXGUI;
16 
17 namespace Ui
18 {
20 class QCheckBox;
21 }
22 
25 class AskPassphraseDialog : public QDialog, public Runnable
26 {
27  Q_OBJECT
28 
29 public:
30  enum class Mode {
31  Encrypt,
33  Unlock,
34  ChangePass,
35  Decrypt
36  };
37 
38  // Context from where / for what the passphrase dialog was called to set the status of the checkbox
39  // Partly redundant to Mode above, but offers more flexibility for future enhancements
40  enum class Context {
41  Unlock_Menu,
42  Unlock_Full,
43  Encrypt,
44  ToggleLock,
45  ChangePass,
46  Send_PIV,
47  BIP_38,
48  Multi_Sig,
49  Sign_Message,
50  UI_Vote,
51  };
52 
53  explicit AskPassphraseDialog(Mode mode, QWidget* parent, WalletModel* model, Context context);
55 
56  void showEvent(QShowEvent *event) override;
57  void accept() override;
58 
59 private:
60  Ui::AskPassphraseDialog* ui;
64  bool fCapsLock;
66 
67  void updateWarningsLabel();
68  void run(int type) override;
69  void onError(QString error, int type) override;
70  QCheckBox *btnWatch;
71 
72  void initWatch(QWidget *parent);
73 
74 private Q_SLOTS:
75  void onWatchClicked();
76  void textChanged();
77  void warningMessage();
78  void errorEncryptingWallet();
79  bool openStandardDialog(QString title = "", QString body = "", QString okBtn = "OK", QString cancelBtn = "");
80 
81 protected:
82  bool event(QEvent* event) override ;
83  bool eventFilter(QObject* object, QEvent* event) override;
84 };
85 
86 #endif // PIVX_QT_ASKPASSPHRASEDIALOG_H
Multifunctional dialog to ask for passphrases.
bool openStandardDialog(QString title="", QString body="", QString okBtn="OK", QString cancelBtn="")
bool eventFilter(QObject *object, QEvent *event) override
@ UI_Vote
Sign/verify message dialog.
@ Send_PIV
Change passphrase.
@ ChangePass
Toggle wallet lock state.
@ Encrypt
Wallet needs to be fully unlocked.
@ Sign_Message
Multi-Signature dialog.
@ Unlock_Full
Unlock wallet from menu
@ ToggleLock
Encrypt unencrypted wallet.
void onError(QString error, int type) override
bool event(QEvent *event) override
void run(int type) override
void initWatch(QWidget *parent)
@ ChangePass
Ask old passphrase + new passphrase twice.
@ Encrypt
Ask passphrase twice and encrypt.
@ UnlockAnonymize
Ask passphrase and unlock only for anonymization.
@ Decrypt
Ask passphrase and decrypt wallet.
@ Unlock
Ask passphrase and unlock.
AskPassphraseDialog(Mode mode, QWidget *parent, WalletModel *model, Context context)
Ui::AskPassphraseDialog * ui
void showEvent(QShowEvent *event) override
PIVX GUI main class.
Definition: pivxgui.h:46
Interface to PIVX wallet from Qt view code.
Definition: walletmodel.h:109
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Definition: secure.h:61
bool error(const char *fmt, const Args &... args)
Definition: system.h:77