Use standard C99 (and Qt) types for 64-bit integers
[novacoin.git] / src / qt / bitcoingui.h
1 #ifndef BITCOINGUI_H
2 #define BITCOINGUI_H
3
4 #include <QtGlobal>
5 #include <QMainWindow>
6 #include <QSystemTrayIcon>
7
8 class TransactionTableModel;
9 class ClientModel;
10 class WalletModel;
11 class TransactionView;
12 class OverviewPage;
13 class AddressBookPage;
14 class SendCoinsDialog;
15 class Notificator;
16
17 QT_BEGIN_NAMESPACE
18 class QLabel;
19 class QLineEdit;
20 class QTableView;
21 class QAbstractItemModel;
22 class QModelIndex;
23 class QProgressBar;
24 class QStackedWidget;
25 class QUrl;
26 QT_END_NAMESPACE
27
28 /**
29   Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and
30   wallet models to give the user an up-to-date view of the current core state.
31 */
32 class BitcoinGUI : public QMainWindow
33 {
34     Q_OBJECT
35 public:
36     explicit BitcoinGUI(QWidget *parent = 0);
37     ~BitcoinGUI();
38
39     /** Set the client model.
40         The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.
41     */
42     void setClientModel(ClientModel *clientModel);
43     /** Set the wallet model.
44         The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
45         functionality.
46     */
47     void setWalletModel(WalletModel *walletModel);
48     
49 protected:
50     void changeEvent(QEvent *e);
51     void closeEvent(QCloseEvent *event);
52     void dragEnterEvent(QDragEnterEvent *event);
53     void dropEvent(QDropEvent *event);
54
55 private:
56     ClientModel *clientModel;
57     WalletModel *walletModel;
58
59     QStackedWidget *centralWidget;
60
61     OverviewPage *overviewPage;
62     QWidget *transactionsPage;
63     AddressBookPage *addressBookPage;
64     AddressBookPage *receiveCoinsPage;
65     SendCoinsDialog *sendCoinsPage;
66
67     QLabel *labelEncryptionIcon;
68     QLabel *labelConnectionsIcon;
69     QLabel *labelBlocksIcon;
70     QLabel *progressBarLabel;
71     QProgressBar *progressBar;
72
73     QMenuBar *appMenuBar;
74     QAction *overviewAction;
75     QAction *historyAction;
76     QAction *quitAction;
77     QAction *sendCoinsAction;
78     QAction *addressBookAction;
79     QAction *aboutAction;
80     QAction *receiveCoinsAction;
81     QAction *optionsAction;
82     QAction *openBitcoinAction;
83     QAction *exportAction;
84     QAction *encryptWalletAction;
85     QAction *changePassphraseAction;
86     QAction *aboutQtAction;
87
88     QSystemTrayIcon *trayIcon;
89     Notificator *notificator;
90     TransactionView *transactionView;
91
92     QMovie *syncIconMovie;
93
94     /** Create the main UI actions. */
95     void createActions();
96     /** Create the menu bar and submenus. */
97     void createMenuBar();
98     /** Create the toolbars */
99     void createToolBars();
100     /** Create system tray (notification) icon */
101     void createTrayIcon();
102
103 public slots:
104     /** Set number of connections shown in the UI */
105     void setNumConnections(int count);
106     /** Set number of blocks shown in the UI */
107     void setNumBlocks(int count);
108     /** Set the encryption status as shown in the UI.
109        @param[in] status            current encryption status
110        @see WalletModel::EncryptionStatus
111     */
112     void setEncryptionStatus(int status);
113     /** Set the status bar text if there are any warnings (removes sync progress bar if applicable) */
114     void refreshStatusBar();
115
116     /** Notify the user of an error in the network or transaction handling code. */
117     void error(const QString &title, const QString &message);
118     /** Asks the user whether to pay the transaction fee or to cancel the transaction.
119        It is currently not possible to pass a return value to another thread through
120        BlockingQueuedConnection, so an indirected pointer is used.
121        http://bugreports.qt.nokia.com/browse/QTBUG-10440
122
123       @param[in] nFeeRequired       the required fee
124       @param[out] payFee            true to pay the fee, false to not pay the fee
125     */
126     void askFee(qint64 nFeeRequired, bool *payFee);
127
128 private slots:
129     /** Switch to overview (home) page */
130     void gotoOverviewPage();
131     /** Switch to history (transactions) page */
132     void gotoHistoryPage();
133     /** Switch to address book page */
134     void gotoAddressBookPage();
135     /** Switch to receive coins page */
136     void gotoReceiveCoinsPage();
137     /** Switch to send coins page */
138     void gotoSendCoinsPage();
139
140     /** Show configuration dialog */
141     void optionsClicked();
142     /** Show about dialog */
143     void aboutClicked();
144 #ifndef Q_WS_MAC
145     /** Handle tray icon clicked */
146     void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
147 #endif
148     /** Show incoming transaction notification for new transactions.
149
150         The new items are those between start and end inclusive, under the given parent item.
151     */
152     void incomingTransaction(const QModelIndex & parent, int start, int end);
153     /** Encrypt the wallet */
154     void encryptWallet(bool status);
155     /** Change encrypted wallet passphrase */
156     void changePassphrase();
157     /** Ask for pass phrase to unlock wallet temporarily */
158     void unlockWallet();
159 };
160
161 #endif