Fix status bar not displaying Alerts.
[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     /** Set the status bar text if there are any warnings (removes sync progress bar if applicable) */
112     void refreshStatusBar();
113
114     /** Notify the user of an error in the network or transaction handling code. */
115     void error(const QString &title, const QString &message);
116     /** Asks the user whether to pay the transaction fee or to cancel the transaction.
117        It is currently not possible to pass a return value to another thread through
118        BlockingQueuedConnection, so an indirected pointer is used.
119        http://bugreports.qt.nokia.com/browse/QTBUG-10440
120
121       @param[in] nFeeRequired       the required fee
122       @param[out] payFee            true to pay the fee, false to not pay the fee
123     */
124     void askFee(qint64 nFeeRequired, bool *payFee);
125
126 private slots:
127     /** Switch to overview (home) page */
128     void gotoOverviewPage();
129     /** Switch to history (transactions) page */
130     void gotoHistoryPage();
131     /** Switch to address book page */
132     void gotoAddressBookPage();
133     /** Switch to receive coins page */
134     void gotoReceiveCoinsPage();
135     /** Switch to send coins page */
136     void gotoSendCoinsPage();
137
138     /** Show configuration dialog */
139     void optionsClicked();
140     /** Show about dialog */
141     void aboutClicked();
142 #ifndef Q_WS_MAC
143     /** Handle tray icon clicked */
144     void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
145 #endif
146     /** Show incoming transaction notification for new transactions.
147
148         The new items are those between start and end inclusive, under the given parent item.
149     */
150     void incomingTransaction(const QModelIndex & parent, int start, int end);
151     /** Encrypt the wallet */
152     void encryptWallet(bool status);
153     /** Change encrypted wallet passphrase */
154     void changePassphrase();
155     /** Ask for pass phrase to unlock wallet temporarily */
156     void unlockWallet();
157 };
158
159 #endif