multisig dialog
[novacoin.git] / src / qt / bitcoingui.h
1 #ifndef BITCOINGUI_H
2 #define BITCOINGUI_H
3
4 #include <QMainWindow>
5 #include <QSystemTrayIcon>
6
7 class TransactionTableModel;
8 class ClientModel;
9 class WalletModel;
10 class TransactionView;
11 class MintingView;
12 class OverviewPage;
13 class AddressBookPage;
14 class SendCoinsDialog;
15 class SignVerifyMessageDialog;
16 class MultisigDialog;
17 class Notificator;
18 class RPCConsole;
19
20 QT_BEGIN_NAMESPACE
21 class QLabel;
22 class QLineEdit;
23 class QTableView;
24 class QAbstractItemModel;
25 class QModelIndex;
26 class QProgressBar;
27 class QStackedWidget;
28 class QUrl;
29 QT_END_NAMESPACE
30
31 /**
32   Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and
33   wallet models to give the user an up-to-date view of the current core state.
34 */
35 class BitcoinGUI : public QMainWindow
36 {
37     Q_OBJECT
38 public:
39     explicit BitcoinGUI(QWidget *parent = 0);
40     ~BitcoinGUI();
41
42     /** Set the client model.
43         The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.
44     */
45     void setClientModel(ClientModel *clientModel);
46     /** Set the wallet model.
47         The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
48         functionality.
49     */
50     void setWalletModel(WalletModel *walletModel);
51
52 protected:
53     void changeEvent(QEvent *e);
54     void closeEvent(QCloseEvent *event);
55     void dragEnterEvent(QDragEnterEvent *event);
56     void dropEvent(QDropEvent *event);
57
58 private:
59     ClientModel *clientModel;
60     WalletModel *walletModel;
61
62     QStackedWidget *centralWidget;
63
64     OverviewPage *overviewPage;
65     QWidget *transactionsPage;
66     QWidget *mintingPage;
67     AddressBookPage *addressBookPage;
68     AddressBookPage *receiveCoinsPage;
69     SendCoinsDialog *sendCoinsPage;
70     SignVerifyMessageDialog *signVerifyMessageDialog;
71     MultisigDialog *multisigPage;
72
73     QLabel *labelEncryptionIcon;
74     QLabel *labelConnectionsIcon;
75     QLabel *labelBlocksIcon;
76     QLabel *labelMiningIcon;
77     QLabel *progressBarLabel;
78     QProgressBar *progressBar;
79
80     QMenuBar *appMenuBar;
81     QAction *overviewAction;
82     QAction *historyAction;
83     QAction *mintingAction;
84     QAction *quitAction;
85     QAction *sendCoinsAction;
86     QAction *addressBookAction;
87     QAction *signMessageAction;
88     QAction *verifyMessageAction;
89     QAction *multisigAction;
90     QAction *aboutAction;
91     QAction *receiveCoinsAction;
92     QAction *optionsAction;
93     QAction *toggleHideAction;
94     QAction *exportAction;
95     QAction *encryptWalletAction;
96     QAction *lockWalletAction;
97     QAction *unlockWalletAction;
98     QAction *unlockWalletMiningAction;
99     QAction *backupWalletAction;
100     QAction *dumpWalletAction;
101     QAction *importWalletAction;
102     QAction *changePassphraseAction;
103     QAction *aboutQtAction;
104     QAction *openRPCConsoleAction;
105
106     QSystemTrayIcon *trayIcon;
107     Notificator *notificator;
108     TransactionView *transactionView;
109     MintingView *mintingView;
110     RPCConsole *rpcConsole;
111
112     QMovie *syncIconMovie;
113
114     /** Create the main UI actions. */
115     void createActions();
116     /** Create the menu bar and sub-menus. */
117     void createMenuBar();
118     /** Create the toolbars */
119     void createToolBars();
120     /** Create system tray (notification) icon */
121     void createTrayIcon();
122
123 public slots:
124     /** Set number of connections shown in the UI */
125     void setNumConnections(int count);
126     /** Set number of blocks shown in the UI */
127     void setNumBlocks(int count, int nTotalBlocks);
128     /** Set stake miner status in the UI */
129     void updateMining();
130     /** Set the encryption status as shown in the UI.
131        @param[in] status            current encryption status
132        @see WalletModel::EncryptionStatus
133     */
134     void setEncryptionStatus(int status);
135
136     /** Notify the user of an error in the network or transaction handling code. */
137     void error(const QString &title, const QString &message, bool modal);
138     void message(const QString &title, const QString &message, unsigned int style, const QString &detail=QString());
139
140     /** Asks the user whether to pay the transaction fee or to cancel the transaction.
141        It is currently not possible to pass a return value to another thread through
142        BlockingQueuedConnection, so an indirected pointer is used.
143        https://bugreports.qt-project.org/browse/QTBUG-10440
144
145       @param[in] nFeeRequired       the required fee
146       @param[out] payFee            true to pay the fee, false to not pay the fee
147     */
148     void askFee(qint64 nFeeRequired, bool *payFee);
149     void handleURI(QString strURI);
150
151     void gotoMultisigPage();
152
153 private slots:
154     /** Switch to overview (home) page */
155     void gotoOverviewPage();
156     /** Switch to history (transactions) page */
157     void gotoHistoryPage();
158     /** Switch to minting page */
159     void gotoMintingPage();
160     /** Switch to address book page */
161     void gotoAddressBookPage();
162     /** Switch to receive coins page */
163     void gotoReceiveCoinsPage();
164     /** Switch to send coins page */
165     void gotoSendCoinsPage();
166
167     /** Show Sign/Verify Message dialog and switch to sign message tab */
168     void gotoSignMessageTab(QString addr = "");
169     /** Show Sign/Verify Message dialog and switch to verify message tab */
170     void gotoVerifyMessageTab(QString addr = "");
171
172     /** Show configuration dialog */
173     void optionsClicked();
174     /** Show about dialog */
175     void aboutClicked();
176 #ifndef Q_OS_MAC
177     /** Handle tray icon clicked */
178     void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
179 #endif
180     /** Show incoming transaction notification for new transactions.
181
182         The new items are those between start and end inclusive, under the given parent item.
183     */
184     void incomingTransaction(const QModelIndex & parent, int start, int end);
185     /** Encrypt the wallet */
186     void encryptWallet(bool status);
187     /** Backup the wallet */
188     void backupWallet();
189     /** Change encrypted wallet passphrase */
190
191     void dumpWallet();
192     void importWallet();
193
194     void changePassphrase();
195     /** Ask for passphrase to unlock wallet temporarily */
196     void lockWallet();
197     void unlockWallet();
198     void unlockWalletMining(bool status);
199
200     /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */
201     void showNormalIfMinimized(bool fToggleHidden = false);
202     /** simply calls showNormalIfMinimized(true) for use in SLOT() macro */
203     void toggleHidden();
204 };
205
206 #endif