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