Add support for opening bitcoin: URIs directly.
[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     QAction *aboutQtAction;
86
87     QSystemTrayIcon *trayIcon;
88     Notificator *notificator;
89     TransactionView *transactionView;
90
91     QMovie *syncIconMovie;
92
93     /** Create the main UI actions. */
94     void createActions();
95     /** Create the menu bar and submenus. */
96     void createMenuBar();
97     /** Create the toolbars */
98     void createToolBars();
99     /** Create system tray (notification) icon */
100     void createTrayIcon();
101
102 public slots:
103     /** Set number of connections shown in the UI */
104     void setNumConnections(int count);
105     /** Set number of blocks shown in the UI */
106     void setNumBlocks(int count);
107     /** Set the encryption status as shown in the UI.
108        @param[in] status            current encryption status
109        @see WalletModel::EncryptionStatus
110     */
111     void setEncryptionStatus(int status);
112     /** Set the status bar text if there are any warnings (removes sync progress bar if applicable) */
113     void refreshStatusBar();
114
115     /** Notify the user of an error in the network or transaction handling code. */
116     void error(const QString &title, const QString &message);
117     /** Asks the user whether to pay the transaction fee or to cancel the transaction.
118        It is currently not possible to pass a return value to another thread through
119        BlockingQueuedConnection, so an indirected pointer is used.
120        http://bugreports.qt.nokia.com/browse/QTBUG-10440
121
122       @param[in] nFeeRequired       the required fee
123       @param[out] payFee            true to pay the fee, false to not pay the fee
124     */
125     void askFee(qint64 nFeeRequired, bool *payFee);
126     void handleURL(QString strURL);
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