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