Added 'Backup Wallet' menu option
[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     QWidget *dummyWidget;
62
63     OverviewPage *overviewPage;
64     QWidget *transactionsPage;
65     AddressBookPage *addressBookPage;
66     AddressBookPage *receiveCoinsPage;
67     SendCoinsDialog *sendCoinsPage;
68     MessagePage *messagePage;
69
70     QLabel *labelEncryptionIcon;
71     QLabel *labelConnectionsIcon;
72     QLabel *labelBlocksIcon;
73     QLabel *progressBarLabel;
74     QProgressBar *progressBar;
75
76     QMenuBar *appMenuBar;
77     QAction *overviewAction;
78     QAction *historyAction;
79     QAction *quitAction;
80     QAction *sendCoinsAction;
81     QAction *addressBookAction;
82     QAction *messageAction;
83     QAction *aboutAction;
84     QAction *receiveCoinsAction;
85     QAction *optionsAction;
86     QAction *openBitcoinAction;
87     QAction *exportAction;
88     QAction *encryptWalletAction;
89     QAction *backupWalletAction;
90     QAction *changePassphraseAction;
91     QAction *aboutQtAction;
92
93     QSystemTrayIcon *trayIcon;
94     Notificator *notificator;
95     TransactionView *transactionView;
96
97     QMovie *syncIconMovie;
98
99     /** Create the main UI actions. */
100     void createActions();
101     /** Create the menu bar and submenus. */
102     void createMenuBar();
103     /** Create the toolbars */
104     void createToolBars();
105     /** Create system tray (notification) icon */
106     void createTrayIcon();
107
108 public slots:
109     /** Set number of connections shown in the UI */
110     void setNumConnections(int count);
111     /** Set number of blocks shown in the UI */
112     void setNumBlocks(int count);
113     /** Set the encryption status as shown in the UI.
114        @param[in] status            current encryption status
115        @see WalletModel::EncryptionStatus
116     */
117     void setEncryptionStatus(int status);
118     /** Set the status bar text if there are any warnings (removes sync progress bar if applicable) */
119     void refreshStatusBar();
120
121     /** Notify the user of an error in the network or transaction handling code. */
122     void error(const QString &title, const QString &message);
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        http://bugreports.qt.nokia.com/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 handleURL(QString strURL);
133
134     void gotoMessagePage();
135     void gotoMessagePage(QString);
136
137     void showNormal();
138
139 private slots:
140     /** Switch to overview (home) page */
141     void gotoOverviewPage();
142     /** Switch to history (transactions) page */
143     void gotoHistoryPage();
144     /** Switch to address book page */
145     void gotoAddressBookPage();
146     /** Switch to receive coins page */
147     void gotoReceiveCoinsPage();
148     /** Switch to send coins page */
149     void gotoSendCoinsPage();
150
151     /** Show configuration dialog */
152     void optionsClicked();
153     /** Show about dialog */
154     void aboutClicked();
155 #ifndef Q_WS_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 pass phrase to unlock wallet temporarily */
171     void unlockWallet();
172 };
173
174 #endif