Example documented class
[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     OverviewPage *overviewPage;
61     QWidget *transactionsPage;
62     AddressBookPage *addressBookPage;
63     AddressBookPage *receiveCoinsPage;
64     SendCoinsDialog *sendCoinsPage;
65
66     QLabel *labelEncryptionIcon;
67     QLabel *labelConnectionsIcon;
68     QLabel *labelBlocksIcon;
69     QLabel *progressBarLabel;
70     QProgressBar *progressBar;
71
72     QMenuBar *appMenuBar;
73     QAction *overviewAction;
74     QAction *historyAction;
75     QAction *quitAction;
76     QAction *sendCoinsAction;
77     QAction *addressBookAction;
78     QAction *aboutAction;
79     QAction *receiveCoinsAction;
80     QAction *optionsAction;
81     QAction *openBitcoinAction;
82     QAction *exportAction;
83     QAction *encryptWalletAction;
84     QAction *changePassphraseAction;
85
86     QSystemTrayIcon *trayIcon;
87     Notificator *notificator;
88     TransactionView *transactionView;
89
90     QMovie *syncIconMovie;
91
92     /** Create the main UI actions. */
93     void createActions();
94     /** Create the menu bar and submenus. */
95     void createMenuBar();
96     /** Create the toolbars */
97     void createToolBars();
98     /** Create system tray (notification) icon */
99     void createTrayIcon();
100
101 public slots:
102     /** Set number of connections shown in the UI */
103     void setNumConnections(int count);
104     /** Set number of blocks shown in the UI */
105     void setNumBlocks(int count);
106     /** Set the encryption status as shown in the UI.
107        @param[in] status            current encryption status
108        @see WalletModel::EncryptionStatus
109     */
110     void setEncryptionStatus(int status);
111
112     /** Notify the user of an error in the network or transaction handling code. */
113     void error(const QString &title, const QString &message);
114     /** Asks the user whether to pay the transaction fee or to cancel the transaction.
115        It is currently not possible to pass a return value to another thread through
116        BlockingQueuedConnection, so an indirected pointer is used.
117        http://bugreports.qt.nokia.com/browse/QTBUG-10440
118
119       @param[in] nFeeRequired       the required fee
120       @param[out] payFee            true to pay the fee, false to not pay the fee
121     */
122     void askFee(qint64 nFeeRequired, bool *payFee);
123
124 private slots:
125     /** Switch to overview (home) page */
126     void gotoOverviewPage();
127     /** Switch to history (transactions) page */
128     void gotoHistoryPage();
129     /** Switch to address book page */
130     void gotoAddressBookPage();
131     /** Switch to receive coins page */
132     void gotoReceiveCoinsPage();
133     /** Switch to send coins page */
134     void gotoSendCoinsPage();
135
136     /** Show configuration dialog */
137     void optionsClicked();
138     /** Show about dialog */
139     void aboutClicked();
140 #ifndef Q_WS_MAC
141     /** Handle tray icon clicked */
142     void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
143 #endif
144     /** Show incoming transaction notification for new transactions.
145
146         The new items are those between start and end inclusive, under the given parent item.
147     */
148     void incomingTransaction(const QModelIndex & parent, int start, int end);
149     /** Encrypt the wallet */
150     void encryptWallet(bool status);
151     /** Change encrypted wallet passphrase */
152     void changePassphrase();
153     /** Ask for pass phrase to unlock wallet temporarily */
154     void unlockWallet();
155 };
156
157 #endif