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