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