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