Raven Core  3.0.0
P2P Digital Currency
ravengui.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2016 The Bitcoin Core developers
2 // Copyright (c) 2017-2019 The Raven Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef RAVEN_QT_RAVENGUI_H
7 #define RAVEN_QT_RAVENGUI_H
8 
9 #if defined(HAVE_CONFIG_H)
10 #include "config/raven-config.h"
11 #endif
12 
13 #include "amount.h"
14 
15 #include <QLabel>
16 #include <QMainWindow>
17 #include <QMap>
18 #include <QMenu>
19 #include <QPoint>
20 #include <QSystemTrayIcon>
21 
22 class ClientModel;
23 class NetworkStyle;
24 class Notificator;
25 class OptionsModel;
26 class PlatformStyle;
27 class RPCConsole;
28 class SendCoinsRecipient;
30 class WalletFrame;
31 class WalletModel;
32 class HelpMessageDialog;
33 class ModalOverlay;
34 
35 QT_BEGIN_NAMESPACE
36 class QAction;
37 class QProgressBar;
38 class QProgressDialog;
39 class QNetworkAccessManager;
40 class QNetworkRequest;
41 QT_END_NAMESPACE
42 
47 class RavenGUI : public QMainWindow
48 {
49  Q_OBJECT
50 
51 public:
52  static const QString DEFAULT_WALLET;
53  static const std::string DEFAULT_UIPLATFORM;
54 
55  explicit RavenGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent = 0);
56  ~RavenGUI();
57 
62 
63 #ifdef ENABLE_WALLET
64 
68  bool addWallet(const QString& name, WalletModel *walletModel);
69  bool setCurrentWallet(const QString& name);
70  void removeAllWallets();
71 #endif // ENABLE_WALLET
73 
74 protected:
75  void changeEvent(QEvent *e);
76  void closeEvent(QCloseEvent *event);
77  void showEvent(QShowEvent *event);
78  void dragEnterEvent(QDragEnterEvent *event);
79  void dropEvent(QDropEvent *event);
80  bool eventFilter(QObject *object, QEvent *event);
81 
82 private:
85 
90  QLabel *labelBlocksIcon;
92  QProgressBar *progressBar;
93  QProgressDialog *progressDialog;
94 
95  QMenuBar *appMenuBar;
96  QAction *overviewAction;
97  QAction *historyAction;
98  QAction *quitAction;
99  QAction *sendCoinsAction;
105  QAction *aboutAction;
108  QAction *optionsAction;
113  QAction *aboutQtAction;
116  QAction *openAction;
118 
123  QAction *messagingAction;
124  QAction *votingAction;
125  QWidget *headerWidget;
128  QTimer *pricingTimer;
129  QNetworkAccessManager* networkManager;
130  QNetworkRequest* request;
133  QSystemTrayIcon *trayIcon;
134  QMenu *trayIconMenu;
139 
143 
145 
147  void loadFonts();
149  void createActions();
151  void createMenuBar();
153  void createToolBars();
155  void createTrayIcon(const NetworkStyle *networkStyle);
157  void createTrayIconMenu();
158 
160  void setWalletActionsEnabled(bool enabled);
161 
163  void subscribeToCoreSignals();
166 
168  void updateNetworkState();
169 
171 
172 Q_SIGNALS:
174  void receivedURI(const QString &uri);
176  void requestedRestart(QStringList args);
177 
178 public Q_SLOTS:
180  void setNumConnections(int count);
182  void setNetworkActive(bool networkActive);
184  void handleRestart(QStringList args);
186  void setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool headers);
187 
195  void message(const QString &title, const QString &message, unsigned int style, bool *ret = nullptr);
196 
197  void getPriceInfo();
198 
199 #ifdef ENABLE_WALLET
200 
204  void setEncryptionStatus(int status);
205 
210  void setHDStatus(int hdEnabled);
211 
212  bool handlePaymentRequest(const SendCoinsRecipient& recipient);
213 
215  void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& assetName);
216 
218  void checkAssets();
219 #endif // ENABLE_WALLET
220 
221 private Q_SLOTS:
222 #ifdef ENABLE_WALLET
223 
224  void gotoOverviewPage();
226  void gotoHistoryPage();
228  void gotoReceiveCoinsPage();
230  void gotoSendCoinsPage(QString addr = "");
231 
233  void gotoSignMessageTab(QString addr = "");
235  void gotoVerifyMessageTab(QString addr = "");
236 
238  void openClicked();
239 
242  void gotoAssetsPage();
243  void gotoCreateAssetsPage();
244  void gotoManageAssetsPage();
247 #endif // ENABLE_WALLET
248 
249  void optionsClicked();
251  void aboutClicked();
253  void showDebugWindow();
257  void showWalletRepair();
259  void showHelpMessageClicked();
260 #ifndef Q_OS_MAC
261 
262  void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
263 #endif
264 
266  void showNormalIfMinimized(bool fToggleHidden = false);
268  void toggleHidden();
269 
271  void detectShutdown();
272 
274  void showProgress(const QString &title, int nProgress);
275 
277  void setTrayIconVisible(bool);
278 
280  void toggleNetworkActive();
281 
282  void showModalOverlay();
283 };
284 
285 class UnitDisplayStatusBarControl : public QLabel
286 {
287  Q_OBJECT
288 
289 public:
292  void setOptionsModel(OptionsModel *optionsModel);
293 
294 protected:
296  void mousePressEvent(QMouseEvent *event);
297 
298 private:
300  QMenu* menu;
301 
303  void onDisplayUnitsClicked(const QPoint& point);
305  void createContextMenu(const PlatformStyle *platformStyle);
306 
307 private Q_SLOTS:
309  void updateDisplayUnit(int newUnits);
311  void onMenuSelection(QAction* action);
312 };
313 
314 #endif // RAVEN_QT_RAVENGUI_H
void showDebugWindowActivateConsole()
Show debug window and set focus to the console.
Definition: ravengui.cpp:990
Local Raven RPC console.
Definition: rpcconsole.h:32
void changeEvent(QEvent *e)
Definition: ravengui.cpp:1290
RPCConsole * rpcConsole
Definition: ravengui.h:136
void dragEnterEvent(QDragEnterEvent *event)
Definition: ravengui.cpp:1380
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
Definition: ravengui.cpp:1564
QNetworkAccessManager * networkManager
Definition: ravengui.h:129
QMenu * trayIconMenu
Definition: ravengui.h:134
QAction * usedReceivingAddressesAction
Definition: ravengui.h:102
QAction * showHelpMessageAction
Definition: ravengui.h:117
QTimer * pricingTimer
Definition: ravengui.h:128
QAction * manageAssetAction
Definition: ravengui.h:122
void requestedRestart(QStringList args)
Restart handling.
QAction * openRPCConsoleAction
Definition: ravengui.h:114
void toggleNetworkActive()
Toggle networking.
Definition: ravengui.cpp:1571
void setClientModel(ClientModel *clientModel)
Set the client model.
Definition: ravengui.cpp:790
void setTrayIconVisible(bool)
When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly.
Definition: ravengui.cpp:1526
void showWalletRepair()
Show debug window and set focus to the wallet repair tab.
Definition: ravengui.cpp:996
WalletFrame * walletFrame
Definition: ravengui.h:84
QAction * aboutAction
Definition: ravengui.h:105
QAction * changePassphraseAction
Definition: ravengui.h:112
void showModalOverlay()
Definition: ravengui.cpp:1534
QProgressDialog * progressDialog
Definition: ravengui.h:93
void subscribeToCoreSignals()
Connect core signals to GUI client.
Definition: ravengui.cpp:1557
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
Definition: ravengui.cpp:1488
void handleRestart(QStringList args)
Get restart command-line parameters and request restart.
Definition: ravengui.cpp:1579
QLabel * labelWalletHDStatusIcon
Definition: ravengui.h:88
void message(const QString &title, const QString &message, unsigned int style, bool *ret=nullptr)
Notify the user of an event from the core network or transaction handling code.
Definition: ravengui.cpp:1231
QAction * overviewAction
Definition: ravengui.h:96
Modal overlay to display information about the chain-sync state.
Definition: modaloverlay.h:20
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
Definition: ravengui.cpp:1106
void optionsClicked()
Show configuration dialog.
Definition: ravengui.cpp:963
ModalOverlay * modalOverlay
Definition: ravengui.h:138
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
void loadFonts()
Load the custome open sans fonts into the font database.
Definition: ravengui.cpp:327
void setNumConnections(int count)
Set number of connections shown in the UI.
Definition: ravengui.cpp:1101
void detectShutdown()
called by a timer to check if fRequestShutdown has been set
Definition: ravengui.cpp:1493
void closeEvent(QCloseEvent *event)
Definition: ravengui.cpp:1309
QLabel * labelBlocksIcon
Definition: ravengui.h:90
int64_t CAmount
Amount in corbies (Can be negative)
Definition: amount.h:13
QAction * receiveCoinsAction
Definition: ravengui.h:106
QAction * createAssetAction
Definition: ravengui.h:121
void createMenuBar()
Create the menu bar and sub-menus.
Definition: ravengui.cpp:543
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
Definition: ravengui.cpp:916
void showHelpMessageClicked()
Show help message dialog.
Definition: ravengui.cpp:1002
static const QString DEFAULT_WALLET
Display name for default wallet name.
Definition: ravengui.h:52
OptionsModel * optionsModel
Definition: ravengui.h:299
Notificator * notificator
Definition: ravengui.h:135
QNetworkRequest * request
Definition: ravengui.h:130
static const std::string DEFAULT_UIPLATFORM
Definition: ravengui.h:53
QAction * quitAction
Definition: ravengui.h:98
QAction * sendCoinsAction
Definition: ravengui.h:99
int spinnerFrame
Definition: ravengui.h:142
void showProgress(const QString &title, int nProgress)
Show progress dialog e.g.
Definition: ravengui.cpp:1503
QAction * aboutQtAction
Definition: ravengui.h:113
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, bool headers)
Set number of blocks and last block date shown in the UI.
Definition: ravengui.cpp:1120
void updateHeadersSyncProgressLabel()
Definition: ravengui.cpp:1111
Cross-platform desktop notification client.
Definition: notificator.h:25
QWidget * headerWidget
Definition: ravengui.h:125
bool eventFilter(QObject *object, QEvent *event)
Definition: ravengui.cpp:1399
QAction * sendCoinsMenuAction
Definition: ravengui.h:100
UnitDisplayStatusBarControl * unitDisplayControl
Definition: ravengui.h:86
QAction * verifyMessageAction
Definition: ravengui.h:104
QAction * receiveCoinsMenuAction
Definition: ravengui.h:107
void updateNetworkState()
Update UI with latest network info from model.
Definition: ravengui.cpp:1072
QAction * encryptWalletAction
Definition: ravengui.h:110
Model for Raven network client.
Definition: clientmodel.h:39
void showEvent(QShowEvent *event)
Definition: ravengui.cpp:1332
QAction * optionsAction
Definition: ravengui.h:108
QAction * historyAction
Definition: ravengui.h:97
void createActions()
Create the main UI actions.
Definition: ravengui.cpp:342
QAction * usedSendingAddressesAction
Definition: ravengui.h:101
RavenGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent=0)
Definition: ravengui.cpp:96
QAction * transferAssetAction
RVN START.
Definition: ravengui.h:120
void showDebugWindow()
Show debug window.
Definition: ravengui.cpp:982
QLabel * progressBarLabel
Definition: ravengui.h:91
QSystemTrayIcon * trayIcon
RVN END.
Definition: ravengui.h:133
Interface from Qt to configuration data structure for Raven client.
Definition: optionsmodel.h:23
bool enableWallet
Definition: ravengui.h:72
Interface to Raven wallet from Qt view code.
Definition: walletmodel.h:165
Raven GUI main class.
Definition: ravengui.h:47
void showNormalIfMinimized(bool fToggleHidden=false)
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
Definition: ravengui.cpp:1463
void getPriceInfo()
Definition: ravengui.cpp:1660
QLabel * labelWalletEncryptionIcon
Definition: ravengui.h:87
QAction * messagingAction
Definition: ravengui.h:123
QLabel * labelCurrentMarket
Definition: ravengui.h:126
int prevBlocks
Keep track of previous number of blocks, to detect progress.
Definition: ravengui.h:141
void createToolBars()
Create the toolbars.
Definition: ravengui.cpp:589
QAction * signMessageAction
Definition: ravengui.h:103
void aboutClicked()
Show about dialog.
Definition: ravengui.cpp:973
QAction * openAction
Definition: ravengui.h:116
"Help message" dialog box
Definition: utilitydialog.h:19
QLabel * connectionsControl
Definition: ravengui.h:89
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
Definition: ravengui.cpp:877
QAction * backupWalletAction
Definition: ravengui.h:111
void createTrayIcon(const NetworkStyle *networkStyle)
Create system tray icon and notification.
Definition: ravengui.cpp:903
void dropEvent(QDropEvent *event)
Definition: ravengui.cpp:1387
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
Definition: ravengui.cpp:953
const PlatformStyle * platformStyle
Definition: ravengui.h:144
QProgressBar * progressBar
Definition: ravengui.h:92
QAction * votingAction
Definition: ravengui.h:124
HelpMessageDialog * helpMessageDialog
Definition: ravengui.h:137
QAction * toggleHideAction
Definition: ravengui.h:109
A container for embedding all wallet-related controls into RavenGUI.
Definition: walletframe.h:30
QAction * openWalletRepairAction
Definition: ravengui.h:115
QMenuBar * appMenuBar
Definition: ravengui.h:95
QLabel * labelCurrentPrice
Definition: ravengui.h:127
ClientModel * clientModel
Definition: ravengui.h:83