]> Git Repo - VerusCoin.git/blob - src/qt/bitcoingui.h
Merge pull request #2855 from Diapolo/guard_CreatePidFile
[VerusCoin.git] / src / qt / bitcoingui.h
1 #ifndef BITCOINGUI_H
2 #define BITCOINGUI_H
3
4 #include <QMainWindow>
5 #include <QSystemTrayIcon>
6 #include <QMap>
7
8 class TransactionTableModel;
9 class WalletFrame;
10 class WalletView;
11 class ClientModel;
12 class WalletModel;
13 class WalletStack;
14 class TransactionView;
15 class OverviewPage;
16 class AddressBookPage;
17 class SendCoinsDialog;
18 class SignVerifyMessageDialog;
19 class Notificator;
20 class RPCConsole;
21
22 class CWallet;
23
24 QT_BEGIN_NAMESPACE
25 class QLabel;
26 class QModelIndex;
27 class QProgressBar;
28 class QStackedWidget;
29 class QUrl;
30 class QListWidget;
31 class QPushButton;
32 class QAction;
33 QT_END_NAMESPACE
34
35 /**
36   Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and
37   wallet models to give the user an up-to-date view of the current core state.
38 */
39 class BitcoinGUI : public QMainWindow
40 {
41     Q_OBJECT
42
43 public:
44     static const QString DEFAULT_WALLET;
45
46     explicit BitcoinGUI(bool fIsTestnet = false, QWidget *parent = 0);
47     ~BitcoinGUI();
48
49     /** Set the client model.
50         The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.
51     */
52     void setClientModel(ClientModel *clientModel);
53     /** Set the wallet model.
54         The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
55         functionality.
56     */
57
58     bool addWallet(const QString& name, WalletModel *walletModel);
59     bool setCurrentWallet(const QString& name);
60
61     void removeAllWallets();
62
63     /** Used by WalletView to allow access to needed QActions */
64     // Todo: Use Qt signals for these
65     QAction * getOverviewAction() { return overviewAction; }
66     QAction * getHistoryAction() { return historyAction; }
67     QAction * getAddressBookAction() { return addressBookAction; }
68     QAction * getReceiveCoinsAction() { return receiveCoinsAction; }
69     QAction * getSendCoinsAction() { return sendCoinsAction; }
70
71 protected:
72     void changeEvent(QEvent *e);
73     void closeEvent(QCloseEvent *event);
74     void dragEnterEvent(QDragEnterEvent *event);
75     void dropEvent(QDropEvent *event);
76     bool eventFilter(QObject *object, QEvent *event);
77
78 private:
79     ClientModel *clientModel;
80     WalletFrame *walletFrame;
81
82     QLabel *labelEncryptionIcon;
83     QLabel *labelConnectionsIcon;
84     QLabel *labelBlocksIcon;
85     QLabel *progressBarLabel;
86     QProgressBar *progressBar;
87
88     QMenuBar *appMenuBar;
89     QAction *overviewAction;
90     QAction *historyAction;
91     QAction *quitAction;
92     QAction *sendCoinsAction;
93     QAction *addressBookAction;
94     QAction *signMessageAction;
95     QAction *verifyMessageAction;
96     QAction *aboutAction;
97     QAction *receiveCoinsAction;
98     QAction *optionsAction;
99     QAction *toggleHideAction;
100     QAction *encryptWalletAction;
101     QAction *backupWalletAction;
102     QAction *changePassphraseAction;
103     QAction *aboutQtAction;
104     QAction *openRPCConsoleAction;
105
106     QSystemTrayIcon *trayIcon;
107     Notificator *notificator;
108     TransactionView *transactionView;
109     RPCConsole *rpcConsole;
110
111     QMovie *syncIconMovie;
112     /** Keep track of previous number of blocks, to detect progress */
113     int prevBlocks;
114
115     /** Create the main UI actions. */
116     void createActions(bool fIsTestnet);
117     /** Create the menu bar and sub-menus. */
118     void createMenuBar();
119     /** Create the toolbars */
120     void createToolBars();
121     /** Create system tray icon and notification */
122     void createTrayIcon(bool fIsTestnet);
123     /** Create system tray menu (or setup the dock menu) */
124     void createTrayIconMenu();
125
126 public slots:
127     /** Set number of connections shown in the UI */
128     void setNumConnections(int count);
129     /** Set number of blocks shown in the UI */
130     void setNumBlocks(int count, int nTotalBlocks);
131     /** Set the encryption status as shown in the UI.
132        @param[in] status            current encryption status
133        @see WalletModel::EncryptionStatus
134     */
135     void setEncryptionStatus(int status);
136
137     /** Notify the user of an event from the core network or transaction handling code.
138        @param[in] title     the message box / notification title
139        @param[in] message   the displayed text
140        @param[in] style     modality and style definitions (icon and used buttons - buttons only for message boxes)
141                             @see CClientUIInterface::MessageBoxFlags
142        @param[in] ret       pointer to a bool that will be modified to whether Ok was clicked (modal only)
143     */
144     void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL);
145     /** Asks the user whether to pay the transaction fee or to cancel the transaction.
146        It is currently not possible to pass a return value to another thread through
147        BlockingQueuedConnection, so an indirected pointer is used.
148        https://bugreports.qt-project.org/browse/QTBUG-10440
149
150       @param[in] nFeeRequired       the required fee
151       @param[out] payFee            true to pay the fee, false to not pay the fee
152     */
153     void askFee(qint64 nFeeRequired, bool *payFee);
154     void handleURI(QString strURI);
155
156     /** Show incoming transaction notification for new transactions. */
157     void incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address);
158
159 private slots:
160     /** Switch to overview (home) page */
161     void gotoOverviewPage();
162     /** Switch to history (transactions) page */
163     void gotoHistoryPage();
164     /** Switch to address book page */
165     void gotoAddressBookPage();
166     /** Switch to receive coins page */
167     void gotoReceiveCoinsPage();
168     /** Switch to send coins page */
169     void gotoSendCoinsPage(QString addr = "");
170
171     /** Show Sign/Verify Message dialog and switch to sign message tab */
172     void gotoSignMessageTab(QString addr = "");
173     /** Show Sign/Verify Message dialog and switch to verify message tab */
174     void gotoVerifyMessageTab(QString addr = "");
175
176     /** Show configuration dialog */
177     void optionsClicked();
178     /** Show about dialog */
179     void aboutClicked();
180 #ifndef Q_OS_MAC
181     /** Handle tray icon clicked */
182     void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
183 #endif
184
185     /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */
186     void showNormalIfMinimized(bool fToggleHidden = false);
187     /** Simply calls showNormalIfMinimized(true) for use in SLOT() macro */
188     void toggleHidden();
189
190     /** called by a timer to check if fRequestShutdown has been set **/
191     void detectShutdown();
192 };
193
194 #endif // BITCOINGUI_H
This page took 0.034317 seconds and 4 git commands to generate.