Merge branch '0.5.x' into 0.6.0.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 MessagePage;
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     MessagePage *messagePage;
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 *messageAction;
81     QAction *aboutAction;
82     QAction *receiveCoinsAction;
83     QAction *optionsAction;
84     QAction *openBitcoinAction;
85     QAction *exportAction;
86     QAction *encryptWalletAction;
87     QAction *backupWalletAction;
88     QAction *changePassphraseAction;
89     QAction *aboutQtAction;
90
91     QSystemTrayIcon *trayIcon;
92     Notificator *notificator;
93     TransactionView *transactionView;
94
95     QMovie *syncIconMovie;
96
97     /** Create the main UI actions. */
98     void createActions();
99     /** Create the menu bar and submenus. */
100     void createMenuBar();
101     /** Create the toolbars */
102     void createToolBars();
103     /** Create system tray (notification) icon */
104     void createTrayIcon();
105
106 public slots:
107     /** Set number of connections shown in the UI */
108     void setNumConnections(int count);
109     /** Set number of blocks shown in the UI */
110     void setNumBlocks(int count);
111     /** Set the encryption status as shown in the UI.
112        @param[in] status            current encryption status
113        @see WalletModel::EncryptionStatus
114     */
115     void setEncryptionStatus(int status);
116     /** Set the status bar text if there are any warnings (removes sync progress bar if applicable) */
117     void refreshStatusBar();
118
119     /** Notify the user of an error in the network or transaction handling code. */
120     void error(const QString &title, const QString &message, bool modal = false);
121     /** Asks the user whether to pay the transaction fee or to cancel the transaction.
122        It is currently not possible to pass a return value to another thread through
123        BlockingQueuedConnection, so an indirected pointer is used.
124        http://bugreports.qt.nokia.com/browse/QTBUG-10440
125
126       @param[in] nFeeRequired       the required fee
127       @param[out] payFee            true to pay the fee, false to not pay the fee
128     */
129     void askFee(qint64 nFeeRequired, bool *payFee);
130     void handleURL(QString strURL);
131
132     void gotoMessagePage();
133     void gotoMessagePage(QString);
134
135 private slots:
136     /** Switch to overview (home) page */
137     void gotoOverviewPage();
138     /** Switch to history (transactions) page */
139     void gotoHistoryPage();
140     /** Switch to address book page */
141     void gotoAddressBookPage();
142     /** Switch to receive coins page */
143     void gotoReceiveCoinsPage();
144     /** Switch to send coins page */
145     void gotoSendCoinsPage();
146
147     /** Show configuration dialog */
148     void optionsClicked();
149     /** Show about dialog */
150     void aboutClicked();
151 #ifndef Q_WS_MAC
152     /** Handle tray icon clicked */
153     void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
154 #endif
155     /** Show incoming transaction notification for new transactions.
156
157         The new items are those between start and end inclusive, under the given parent item.
158     */
159     void incomingTransaction(const QModelIndex & parent, int start, int end);
160     /** Encrypt the wallet */
161     void encryptWallet(bool status);
162     /** Backup the wallet */
163     void backupWallet();
164     /** Change encrypted wallet passphrase */
165     void changePassphrase();
166     /** Ask for pass phrase to unlock wallet temporarily */
167     void unlockWallet();
168
169     /** Show window if hidden, unminimize when minimized */
170     void showNormalIfMinimized();
171 };
172
173 #endif