Raven Core  3.0.0
P2P Digital Currency
ravengui.cpp
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 #if defined(HAVE_CONFIG_H)
7 #include "config/raven-config.h"
8 #endif
9 
10 #include "ravengui.h"
11 
12 #include "ravenunits.h"
13 #include "clientmodel.h"
14 #include "guiconstants.h"
15 #include "guiutil.h"
16 #include "modaloverlay.h"
17 #include "networkstyle.h"
18 #include "notificator.h"
19 #include "openuridialog.h"
20 #include "optionsdialog.h"
21 #include "optionsmodel.h"
22 #include "platformstyle.h"
23 #include "rpcconsole.h"
24 #include "utilitydialog.h"
25 
26 #ifdef ENABLE_WALLET
27 #include "walletframe.h"
28 #include "walletmodel.h"
29 #endif // ENABLE_WALLET
30 
31 #ifdef Q_OS_MAC
32 #include "macdockiconhandler.h"
33 #endif
34 
35 #include "chainparams.h"
36 #include "init.h"
37 #include "ui_interface.h"
38 #include "util.h"
39 #include "core_io.h"
40 #include "darkstyle.h"
41 
42 #include <iostream>
43 
44 #include <QDebug>
45 #include <QtNetwork/QNetworkAccessManager>
46 #include <QtNetwork/QNetworkReply>
47 #include <QGraphicsDropShadowEffect>
48 #include <QToolButton>
49 #include <QPushButton>
50 #include <QPainter>
51 #include <QWidgetAction>
52 #include <QAction>
53 #include <QApplication>
54 #include <QDateTime>
55 #include <QDesktopWidget>
56 #include <QDragEnterEvent>
57 #include <QListWidget>
58 #include <QMenuBar>
59 #include <QMessageBox>
60 #include <QMimeData>
61 #include <QProgressDialog>
62 #include <QSettings>
63 #include <QShortcut>
64 #include <QStackedWidget>
65 #include <QStatusBar>
66 #include <QStyle>
67 #include <QTimer>
68 #include <QToolBar>
69 #include <QVBoxLayout>
70 
71 #if QT_VERSION < 0x050000
72 #include <QTextDocument>
73 #include <QUrl>
74 #else
75 #include <QUrlQuery>
76 #include <validation.h>
77 #include <tinyformat.h>
78 #include <QFontDatabase>
79 
80 #endif
81 
82 const std::string RavenGUI::DEFAULT_UIPLATFORM =
83 #if defined(Q_OS_MAC)
84  "macosx"
85 #elif defined(Q_OS_WIN)
86  "windows"
87 #else
88  "other"
89 #endif
90  ;
91 
94 const QString RavenGUI::DEFAULT_WALLET = "~Default";
95 
96 RavenGUI::RavenGUI(const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
97  QMainWindow(parent),
98  enableWallet(false),
99  clientModel(0),
100  walletFrame(0),
101  unitDisplayControl(0),
102  labelWalletEncryptionIcon(0),
103  labelWalletHDStatusIcon(0),
104  connectionsControl(0),
105  labelBlocksIcon(0),
106  progressBarLabel(0),
107  progressBar(0),
108  progressDialog(0),
109  appMenuBar(0),
110  overviewAction(0),
111  historyAction(0),
112  quitAction(0),
113  sendCoinsAction(0),
114  sendCoinsMenuAction(0),
115  usedSendingAddressesAction(0),
116  usedReceivingAddressesAction(0),
117  signMessageAction(0),
118  verifyMessageAction(0),
119  aboutAction(0),
120  receiveCoinsAction(0),
121  receiveCoinsMenuAction(0),
122  optionsAction(0),
123  toggleHideAction(0),
124  encryptWalletAction(0),
125  backupWalletAction(0),
126  changePassphraseAction(0),
127  aboutQtAction(0),
128  openRPCConsoleAction(0),
129  openWalletRepairAction(0),
130  openAction(0),
131  showHelpMessageAction(0),
132  transferAssetAction(0),
133  createAssetAction(0),
134  manageAssetAction(0),
135  messagingAction(0),
136  votingAction(0),
137  headerWidget(0),
138  labelCurrentMarket(0),
139  labelCurrentPrice(0),
140  pricingTimer(0),
141  networkManager(0),
142  request(0),
143  trayIcon(0),
144  trayIconMenu(0),
145  notificator(0),
146  rpcConsole(0),
147  helpMessageDialog(0),
148  modalOverlay(0),
149  prevBlocks(0),
150  spinnerFrame(0),
151  platformStyle(_platformStyle)
152 
153 {
154  QSettings settings;
155  if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
156  // Restore failed (perhaps missing setting), center the window
157  move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
158  }
159 
160  QString windowTitle = tr(PACKAGE_NAME) + " - ";
161 #ifdef ENABLE_WALLET
163 #endif // ENABLE_WALLET
164  if(enableWallet)
165  {
166  windowTitle += tr("Wallet");
167  } else {
168  windowTitle += tr("Node");
169  }
170  windowTitle += " " + networkStyle->getTitleAddText();
171 #ifndef Q_OS_MAC
172  QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
173  setWindowIcon(networkStyle->getTrayAndWindowIcon());
174 #else
175  MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
176 #endif
177  setWindowTitle(windowTitle);
178 
179 #if defined(Q_OS_MAC) && QT_VERSION < 0x050000
180  // This property is not implemented in Qt 5. Setting it has no effect.
181  // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
182  setUnifiedTitleAndToolBarOnMac(true);
183 #endif
184 
185  rpcConsole = new RPCConsole(_platformStyle, 0);
186  helpMessageDialog = new HelpMessageDialog(this, false);
187 #ifdef ENABLE_WALLET
188  if(enableWallet)
189  {
191  walletFrame = new WalletFrame(_platformStyle, this);
192  setCentralWidget(walletFrame);
193  } else
194 #endif // ENABLE_WALLET
195  {
196  /* When compiled without wallet or -disablewallet is provided,
197  * the central widget is the rpc console.
198  */
199  setCentralWidget(rpcConsole);
200  }
201 
203  labelCurrentMarket = new QLabel();
204  labelCurrentPrice = new QLabel();
205  headerWidget = new QWidget();
206  pricingTimer = new QTimer();
207  networkManager = new QNetworkAccessManager();
208  request = new QNetworkRequest();
211  // Accept D&D of URIs
212  setAcceptDrops(true);
213 
214  loadFonts();
215 
216 #if !defined(Q_OS_MAC)
217  this->setFont(QFont("Open Sans"));
218 #endif
219 
220  // Create actions for the toolbar, menu bar and tray/dock icon
221  // Needs walletFrame to be initialized
222  createActions();
223 
224  // Create application menu bar
225  createMenuBar();
226 
227  // Create the toolbars
228  createToolBars();
229 
230  // Create system tray icon and notification
231  createTrayIcon(networkStyle);
232 
233  // Create status bar
234  statusBar();
235 
236  // Disable size grip because it looks ugly and nobody needs it
237  statusBar()->setSizeGripEnabled(false);
238 
239  // Status bar notification icons
240  QFrame *frameBlocks = new QFrame();
241  frameBlocks->setContentsMargins(0,0,0,0);
242  frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
243  QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
244  frameBlocksLayout->setContentsMargins(3,0,3,0);
245  frameBlocksLayout->setSpacing(3);
247  labelWalletEncryptionIcon = new QLabel();
248  labelWalletHDStatusIcon = new QLabel();
251  if(enableWallet)
252  {
253  frameBlocksLayout->addStretch();
254  frameBlocksLayout->addWidget(unitDisplayControl);
255  frameBlocksLayout->addStretch();
256  frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
257  frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
258  }
259  frameBlocksLayout->addStretch();
260  frameBlocksLayout->addWidget(connectionsControl);
261  frameBlocksLayout->addStretch();
262  frameBlocksLayout->addWidget(labelBlocksIcon);
263  frameBlocksLayout->addStretch();
264 
265  // Progress bar and label for blocks download
266  progressBarLabel = new QLabel();
267  progressBarLabel->setVisible(false);
268  progressBarLabel->setStyleSheet(QString(".QLabel { color : %1; }").arg(platformStyle->TextColor().name()));
270  progressBar->setAlignment(Qt::AlignCenter);
271  progressBar->setVisible(false);
272 
273  // Override style sheet for progress bar for styles that have a segmented progress bar,
274  // as they make the text unreadable (workaround for issue #1071)
275  // See https://qt-project.org/doc/qt-4.8/gallery.html
276  QString curStyle = QApplication::style()->metaObject()->className();
277  if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
278  {
279  progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
280  }
281 
282  statusBar()->addWidget(progressBarLabel);
283  statusBar()->addWidget(progressBar);
284  statusBar()->addPermanentWidget(frameBlocks);
285 
286  if(darkModeEnabled)
287  statusBar()->setStyleSheet(QString(".QStatusBar{background-color: %1; border-top: 1px solid %2;}").arg(platformStyle->TopWidgetBackGroundColor().name(), platformStyle->TextColor().name()));
288 
289  // Install event filter to be able to catch status tip events (QEvent::StatusTip)
290  this->installEventFilter(this);
291 
292  // Initially wallet actions should be disabled
294 
295  // Subscribe to notifications from core
297 
298  connect(connectionsControl, SIGNAL(clicked(QPoint)), this, SLOT(toggleNetworkActive()));
299 
300  modalOverlay = new ModalOverlay(this->centralWidget());
301 #ifdef ENABLE_WALLET
302  if(enableWallet) {
303  connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay()));
304  connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
305  connect(progressBar, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
306  }
307 #endif
308 }
309 
311 {
312  // Unsubscribe from notifications from core
314 
315  QSettings settings;
316  settings.setValue("MainWindowGeometry", saveGeometry());
317  if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
318  trayIcon->hide();
319 #ifdef Q_OS_MAC
320  delete appMenuBar;
322 #endif
323 
324  delete rpcConsole;
325 }
326 
328 {
329  QFontDatabase::addApplicationFont(":/fonts/opensans-bold");
330  QFontDatabase::addApplicationFont(":/fonts/opensans-bolditalic");
331  QFontDatabase::addApplicationFont(":/fonts/opensans-extrabold");
332  QFontDatabase::addApplicationFont(":/fonts/opensans-extrabolditalic");
333  QFontDatabase::addApplicationFont(":/fonts/opensans-italic");
334  QFontDatabase::addApplicationFont(":/fonts/opensans-light");
335  QFontDatabase::addApplicationFont(":/fonts/opensans-lightitalic");
336  QFontDatabase::addApplicationFont(":/fonts/opensans-regular");
337  QFontDatabase::addApplicationFont(":/fonts/opensans-semibold");
338  QFontDatabase::addApplicationFont(":/fonts/opensans-semibolditalic");
339 }
340 
341 
343 {
344  QFont font = QFont();
345  font.setPixelSize(22);
346  font.setLetterSpacing(QFont::SpacingType::AbsoluteSpacing, -0.43);
347 #if !defined(Q_OS_MAC)
348  font.setFamily("Open Sans");
349 #endif
350  font.setWeight(QFont::Weight::ExtraLight);
351 
352  QActionGroup *tabGroup = new QActionGroup(this);
353 
354  overviewAction = new QAction(platformStyle->SingleColorIconOnOff(":/icons/overview_selected", ":/icons/overview"), tr("&Overview"), this);
355  overviewAction->setStatusTip(tr("Show general overview of wallet"));
356  overviewAction->setToolTip(overviewAction->statusTip());
357  overviewAction->setCheckable(true);
358  overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
359  overviewAction->setFont(font);
360  tabGroup->addAction(overviewAction);
361 
362  sendCoinsAction = new QAction(platformStyle->SingleColorIconOnOff(":/icons/send_selected", ":/icons/send"), tr("&Send"), this);
363  sendCoinsAction->setStatusTip(tr("Send coins to a Raven address"));
364  sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
365  sendCoinsAction->setCheckable(true);
366  sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
367  sendCoinsAction->setFont(font);
368  tabGroup->addAction(sendCoinsAction);
369 
370  sendCoinsMenuAction = new QAction(platformStyle->TextColorIcon(":/icons/send"), sendCoinsAction->text(), this);
371  sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip());
372  sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip());
373 
374  receiveCoinsAction = new QAction(platformStyle->SingleColorIconOnOff(":/icons/receiving_addresses_selected", ":/icons/receiving_addresses"), tr("&Receive"), this);
375  receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and raven: URIs)"));
376  receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
377  receiveCoinsAction->setCheckable(true);
378  receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
379  receiveCoinsAction->setFont(font);
380  tabGroup->addAction(receiveCoinsAction);
381 
382  receiveCoinsMenuAction = new QAction(platformStyle->TextColorIcon(":/icons/receiving_addresses"), receiveCoinsAction->text(), this);
383  receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip());
384  receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip());
385 
386  historyAction = new QAction(platformStyle->SingleColorIconOnOff(":/icons/history_selected", ":/icons/history"), tr("&Transactions"), this);
387  historyAction->setStatusTip(tr("Browse transaction history"));
388  historyAction->setToolTip(historyAction->statusTip());
389  historyAction->setCheckable(true);
390  historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
391  historyAction->setFont(font);
392  tabGroup->addAction(historyAction);
393 
395  transferAssetAction = new QAction(platformStyle->SingleColorIconOnOff(":/icons/asset_transfer_selected", ":/icons/asset_transfer"), tr("&Transfer Assets"), this);
396  transferAssetAction->setStatusTip(tr("Transfer assets to RVN addresses"));
397  transferAssetAction->setToolTip(transferAssetAction->statusTip());
398  transferAssetAction->setCheckable(true);
399  transferAssetAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
400  transferAssetAction->setFont(font);
401  tabGroup->addAction(transferAssetAction);
402 
403  createAssetAction = new QAction(platformStyle->SingleColorIconOnOff(":/icons/asset_create_selected", ":/icons/asset_create"), tr("&Create Assets"), this);
404  createAssetAction->setStatusTip(tr("Create new main/sub/unique assets"));
405  createAssetAction->setToolTip(createAssetAction->statusTip());
406  createAssetAction->setCheckable(true);
407  createAssetAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
408  createAssetAction->setFont(font);
409  tabGroup->addAction(createAssetAction);
410 
411  manageAssetAction = new QAction(platformStyle->SingleColorIconOnOff(":/icons/asset_manage_selected", ":/icons/asset_manage"), tr("&Manage Assets"), this);
412  manageAssetAction->setStatusTip(tr("Manage assets you are the administrator of"));
413  manageAssetAction->setToolTip(manageAssetAction->statusTip());
414  manageAssetAction->setCheckable(true);
415  manageAssetAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_7));
416  manageAssetAction->setFont(font);
417  tabGroup->addAction(manageAssetAction);
418 
419  messagingAction = new QAction(platformStyle->SingleColorIcon(":/icons/editcopy"), tr("&Messaging"), this);
420  messagingAction->setStatusTip(tr("Coming Soon"));
421  messagingAction->setToolTip(messagingAction->statusTip());
422  messagingAction->setCheckable(true);
423  messagingAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_8));
424  messagingAction->setFont(font);
425  tabGroup->addAction(messagingAction);
426 
427  votingAction = new QAction(platformStyle->SingleColorIcon(":/icons/edit"), tr("&Voting"), this);
428  votingAction->setStatusTip(tr("Coming Soon"));
429  votingAction->setToolTip(votingAction->statusTip());
430  votingAction->setCheckable(true);
431  votingAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_9));
432  votingAction->setFont(font);
433  tabGroup->addAction(votingAction);
434 
437 #ifdef ENABLE_WALLET
438  // These showNormalIfMinimized are needed because Send Coins and Receive Coins
439  // can be triggered from the tray menu, and need to show the GUI to be useful.
440  connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
441  connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
442  connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
443  connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
444  connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
445  connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
446  connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
447  connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
448  connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
449  connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
450  connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
451  connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
452  connect(transferAssetAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
453  connect(transferAssetAction, SIGNAL(triggered()), this, SLOT(gotoAssetsPage()));
454  connect(createAssetAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
455  connect(createAssetAction, SIGNAL(triggered()), this, SLOT(gotoCreateAssetsPage()));
456  connect(manageAssetAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
457  connect(manageAssetAction, SIGNAL(triggered()), this, SLOT(gotoManageAssetsPage()));
458  // TODO add messaging actions to go to messaging page when clicked
459  // TODO add voting actions to go to voting page when clicked
460 #endif // ENABLE_WALLET
461 
462  quitAction = new QAction(platformStyle->TextColorIcon(":/icons/quit"), tr("E&xit"), this);
463  quitAction->setStatusTip(tr("Quit application"));
464  quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
465  quitAction->setMenuRole(QAction::QuitRole);
466  aboutAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), tr("&About %1").arg(tr(PACKAGE_NAME)), this);
467  aboutAction->setStatusTip(tr("Show information about %1").arg(tr(PACKAGE_NAME)));
468  aboutAction->setMenuRole(QAction::AboutRole);
469  aboutAction->setEnabled(false);
470  aboutQtAction = new QAction(platformStyle->TextColorIcon(":/icons/about_qt"), tr("About &Qt"), this);
471  aboutQtAction->setStatusTip(tr("Show information about Qt"));
472  aboutQtAction->setMenuRole(QAction::AboutQtRole);
473  optionsAction = new QAction(platformStyle->TextColorIcon(":/icons/options"), tr("&Options..."), this);
474  optionsAction->setStatusTip(tr("Modify configuration options for %1").arg(tr(PACKAGE_NAME)));
475  optionsAction->setMenuRole(QAction::PreferencesRole);
476  optionsAction->setEnabled(false);
477  toggleHideAction = new QAction(platformStyle->TextColorIcon(":/icons/about"), tr("&Show / Hide"), this);
478  toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
479 
480  encryptWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
481  encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
482  encryptWalletAction->setCheckable(true);
483  backupWalletAction = new QAction(platformStyle->TextColorIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
484  backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
485  changePassphraseAction = new QAction(platformStyle->TextColorIcon(":/icons/key"), tr("&Change Passphrase..."), this);
486  changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
487  signMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/edit"), tr("Sign &message..."), this);
488  signMessageAction->setStatusTip(tr("Sign messages with your Raven addresses to prove you own them"));
489  verifyMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/verify"), tr("&Verify message..."), this);
490  verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Raven addresses"));
491 
492  openRPCConsoleAction = new QAction(platformStyle->TextColorIcon(":/icons/debugwindow"), tr("&Debug Window"), this);
493  openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
494  // initially disable the debug window menu item
495  openRPCConsoleAction->setEnabled(false);
496 
497  openWalletRepairAction = new QAction(platformStyle->TextColorIcon(":/icons/debugwindow"), tr("&Wallet Repair"), this);
498  openWalletRepairAction->setStatusTip(tr("Open wallet repair options"));
499 
500  usedSendingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
501  usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
502  usedReceivingAddressesAction = new QAction(platformStyle->TextColorIcon(":/icons/address-book"), tr("&Receiving addresses..."), this);
503  usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
504 
505  openAction = new QAction(platformStyle->TextColorIcon(":/icons/open"), tr("Open &URI..."), this);
506  openAction->setStatusTip(tr("Open a raven: URI or payment request"));
507 
508  showHelpMessageAction = new QAction(platformStyle->TextColorIcon(":/icons/info"), tr("&Command-line options"), this);
509  showHelpMessageAction->setMenuRole(QAction::NoRole);
510  showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Raven command-line options").arg(tr(PACKAGE_NAME)));
511 
512  connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
513  connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
514  connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
515  connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
516  connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
517  connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked()));
518  connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showDebugWindow()));
519  connect(openWalletRepairAction, SIGNAL(triggered()), this, SLOT(showWalletRepair()));
520  // Get restart command-line parameters and handle restart
521  connect(rpcConsole, SIGNAL(handleRestart(QStringList)), this, SLOT(handleRestart(QStringList)));
522  // prevents an open debug window from becoming stuck/unusable on client shutdown
523  connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
524 
525 #ifdef ENABLE_WALLET
526  if(walletFrame)
527  {
528  connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
529  connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
530  connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
531  connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
532  connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
533  connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
534  connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
535  connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
536  }
537 #endif // ENABLE_WALLET
538 
539  new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this, SLOT(showDebugWindowActivateConsole()));
540  new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D), this, SLOT(showDebugWindow()));
541 }
542 
544 {
545 #ifdef Q_OS_MAC
546  // Create a decoupled menu bar on Mac which stays even if the window is closed
547  appMenuBar = new QMenuBar();
548 #else
549  // Get the main window's menu bar on other platforms
550  appMenuBar = menuBar();
551 #endif
552 
553  // Configure the menus
554  QMenu *file = appMenuBar->addMenu(tr("&File"));
555  if(walletFrame)
556  {
557  file->addAction(openAction);
558  file->addAction(signMessageAction);
559  file->addAction(verifyMessageAction);
560  file->addSeparator();
561  file->addAction(usedSendingAddressesAction);
562  file->addAction(usedReceivingAddressesAction);
563  file->addSeparator();
564  }
565  file->addAction(quitAction);
566 
567  QMenu *settings = appMenuBar->addMenu(tr("&Wallet"));
568  if(walletFrame)
569  {
570  settings->addAction(encryptWalletAction);
571  settings->addAction(backupWalletAction);
572  settings->addAction(changePassphraseAction);
573  settings->addSeparator();
574  }
575  settings->addAction(optionsAction);
576 
577  QMenu *help = appMenuBar->addMenu(tr("&Help"));
578  if(walletFrame)
579  {
580  help->addAction(openRPCConsoleAction);
581  help->addAction(openWalletRepairAction);
582  }
583  help->addAction(showHelpMessageAction);
584  help->addSeparator();
585  help->addAction(aboutAction);
586  help->addAction(aboutQtAction);
587 }
588 
590 {
591  if(walletFrame)
592  {
594  // Create the orange background and the vertical tool bar
595  QWidget* toolbarWidget = new QWidget();
596 
597  QString widgetStyleSheet = ".QWidget {background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 %1, stop: 1 %2);}";
598 
599  toolbarWidget->setStyleSheet(widgetStyleSheet.arg(platformStyle->LightBlueColor().name(), platformStyle->DarkBlueColor().name()));
600 
601  QLabel* label = new QLabel();
602  label->setPixmap(QPixmap::fromImage(QImage(":/icons/ravencointext")));
603  label->setContentsMargins(0,0,0,50);
604  label->setStyleSheet(".QLabel{background-color: transparent;}");
607  QToolBar *toolbar = new QToolBar();
608  toolbar->setStyle(style());
609  toolbar->setMinimumWidth(label->width());
610  toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
611  toolbar->setMovable(false);
612  toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
613  toolbar->addAction(overviewAction);
614  toolbar->addAction(sendCoinsAction);
615  toolbar->addAction(receiveCoinsAction);
616  toolbar->addAction(historyAction);
617  toolbar->addAction(createAssetAction);
618  toolbar->addAction(transferAssetAction);
619  toolbar->addAction(manageAssetAction);
620 // toolbar->addAction(messagingAction);
621 // toolbar->addAction(votingAction);
622 
623  QString openSansFontString = "font: normal 22pt \"Open Sans\";";
624  QString normalString = "font: normal 22pt \"Arial\";";
625  QString stringToUse = "";
626 
627 #if !defined(Q_OS_MAC)
628  stringToUse = openSansFontString;
629 #else
630  stringToUse = normalString;
631 #endif
632 
634  QString tbStyleSheet = ".QToolBar {background-color : transparent; border-color: transparent; } "
635  ".QToolButton {background-color: transparent; border-color: transparent; width: 249px; color: %1; border: none;} "
636  ".QToolButton:checked {background: none; background-color: none; selection-background-color: none; color: %2; border: none; font: %4} "
637  ".QToolButton:hover {background: none; background-color: none; border: none; color: %3;} "
638  ".QToolButton:disabled {color: gray;}";
639 
640  toolbar->setStyleSheet(tbStyleSheet.arg(platformStyle->ToolBarNotSelectedTextColor().name(),
642  platformStyle->DarkOrangeColor().name(), stringToUse));
643 
644  toolbar->setOrientation(Qt::Vertical);
645  toolbar->setIconSize(QSize(40, 40));
646 
647  QLayout* lay = toolbar->layout();
648  for(int i = 0; i < lay->count(); ++i)
649  lay->itemAt(i)->setAlignment(Qt::AlignLeft);
650 
651  overviewAction->setChecked(true);
652 
653  QVBoxLayout* ravenLabelLayout = new QVBoxLayout(toolbarWidget);
654  ravenLabelLayout->addWidget(label);
655  ravenLabelLayout->addWidget(toolbar);
656  ravenLabelLayout->setDirection(QBoxLayout::TopToBottom);
657  ravenLabelLayout->addStretch(1);
658 
659  QString mainWalletWidgetStyle = QString(".QWidget{background-color: %1}").arg(platformStyle->MainBackGroundColor().name());
660  QWidget* mainWalletWidget = new QWidget();
661  mainWalletWidget->setStyleSheet(mainWalletWidgetStyle);
662 
664 #if !defined(Q_OS_MAC)
665  QGraphicsDropShadowEffect *walletFrameShadow = new QGraphicsDropShadowEffect;
666  walletFrameShadow->setBlurRadius(50);
667  walletFrameShadow->setColor(COLOR_WALLETFRAME_SHADOW);
668  walletFrameShadow->setXOffset(-8.0);
669  walletFrameShadow->setYOffset(0);
670  mainWalletWidget->setGraphicsEffect(walletFrameShadow);
671 #endif
672 
673  QString widgetBackgroundSytleSheet = QString(".QWidget{background-color: %1}").arg(platformStyle->TopWidgetBackGroundColor().name());
674 
675  // Set the headers widget options
676  headerWidget->setContentsMargins(0,0,0,50);
677  headerWidget->setStyleSheet(widgetBackgroundSytleSheet);
678  headerWidget->setGraphicsEffect(GUIUtil::getShadowEffect());
679  headerWidget->setFixedHeight(75);
680 
681  QFont currentMarketFont;
682  currentMarketFont.setFamily("Open Sans");
683  currentMarketFont.setWeight(QFont::Weight::Normal);
684  currentMarketFont.setLetterSpacing(QFont::SpacingType::AbsoluteSpacing, -0.6);
685  currentMarketFont.setPixelSize(18);
686 
687  // Set the pricing information
688  QHBoxLayout* priceLayout = new QHBoxLayout(headerWidget);
689  priceLayout->setContentsMargins(QMargins());
690  priceLayout->setDirection(QBoxLayout::LeftToRight);
691  priceLayout->setAlignment(Qt::AlignVCenter);
692  labelCurrentMarket->setContentsMargins(50,0,0,0);
693  labelCurrentMarket->setFixedHeight(75);
694  labelCurrentMarket->setAlignment(Qt::AlignVCenter);
695  labelCurrentMarket->setStyleSheet(STRING_LABEL_COLOR);
696  labelCurrentMarket->setFont(currentMarketFont);
697  labelCurrentMarket->setText(tr("Ravencoin Market Price"));
698 
699  QString currentPriceStyleSheet = ".QLabel{color: %1;}";
700  labelCurrentPrice->setContentsMargins(25,0,0,0);
701  labelCurrentPrice->setFixedHeight(75);
702  labelCurrentPrice->setAlignment(Qt::AlignVCenter);
703  labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name()));
704  labelCurrentPrice->setFont(currentMarketFont);
705 
706  QLabel* labelBtcRvn = new QLabel();
707  labelBtcRvn->setText("BTC / RVN");
708  labelBtcRvn->setContentsMargins(15,0,0,0);
709  labelBtcRvn->setFixedHeight(75);
710  labelBtcRvn->setAlignment(Qt::AlignVCenter);
711  labelBtcRvn->setStyleSheet(STRING_LABEL_COLOR);
712  labelBtcRvn->setFont(currentMarketFont);
713 
714  priceLayout->setGeometry(headerWidget->rect());
715  priceLayout->addWidget(labelCurrentMarket, 0, Qt::AlignVCenter | Qt::AlignLeft);
716  priceLayout->addWidget(labelCurrentPrice, 0, Qt::AlignVCenter | Qt::AlignLeft);
717  priceLayout->addWidget(labelBtcRvn, 0 , Qt::AlignVCenter | Qt::AlignLeft);
718  priceLayout->addStretch();
719 
720  // Create the layout for widget to the right of the tool bar
721  QVBoxLayout* mainFrameLayout = new QVBoxLayout(mainWalletWidget);
722  mainFrameLayout->addWidget(headerWidget);
723  mainFrameLayout->addWidget(walletFrame);
724  mainFrameLayout->setDirection(QBoxLayout::TopToBottom);
725  mainFrameLayout->setContentsMargins(QMargins());
726 
727  QVBoxLayout* layout = new QVBoxLayout();
728  layout->addWidget(toolbarWidget);
729  layout->addWidget(mainWalletWidget);
730  layout->setSpacing(0);
731  layout->setContentsMargins(QMargins());
732  layout->setDirection(QBoxLayout::LeftToRight);
733  QWidget* containerWidget = new QWidget();
734  containerWidget->setLayout(layout);
735  setCentralWidget(containerWidget);
736 
737  // Network request code for the header widget
738  QObject::connect(networkManager, &QNetworkAccessManager::finished,
739  this, [=](QNetworkReply *reply) {
740  if (reply->error()) {
741  labelCurrentPrice->setText("");
742  qDebug() << reply->errorString();
743  return;
744  }
745  // Get the data from the network request
746  QString answer = reply->readAll();
747 
748  // Create regex expression to find the value with 8 decimals
749  QRegExp rx("\\d*.\\d\\d\\d\\d\\d\\d\\d\\d");
750  rx.indexIn(answer);
751 
752  // List the found values
753  QStringList list = rx.capturedTexts();
754 
755  QString currentPriceStyleSheet = ".QLabel{color: %1;}";
756  // Evaluate the current and next numbers and assign a color (green for positive, red for negative)
757  bool ok;
758  if (!list.isEmpty()) {
759  double next = list.first().toDouble(&ok);
760  if (!ok) {
761  labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name()));
762  labelCurrentPrice->setText("");
763  } else {
764  double current = labelCurrentPrice->text().toDouble(&ok);
765  if (!ok) {
766  current = 0.00000000;
767  } else {
768  if (next < current)
769  labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("red"));
770  else if (next > current)
771  labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg("green"));
772  else
773  labelCurrentPrice->setStyleSheet(currentPriceStyleSheet.arg(COLOR_LABELS.name()));
774  }
775  labelCurrentPrice->setText(QString("%1").arg(QString().setNum(next, 'f', 8)));
776  labelCurrentPrice->setToolTip(tr("Brought to you by binance.com"));
777  }
778  }
779  }
780  );
781 
782  // Create the timer
783  connect(pricingTimer, SIGNAL(timeout()), this, SLOT(getPriceInfo()));
784  pricingTimer->start(10000);
785  getPriceInfo();
787  }
788 }
789 
791 {
792  this->clientModel = _clientModel;
793  if(_clientModel)
794  {
795  // Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
796  // while the client has not yet fully loaded
798 
799  // Keep up to date with client
801  connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
802  connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool)));
803 
804  modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime()));
805  setNumBlocks(_clientModel->getNumBlocks(), _clientModel->getLastBlockDate(), _clientModel->getVerificationProgress(nullptr), false);
806  connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool)));
807 
808  // Receive and report messages from client model
809  connect(_clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
810 
811  // Show progress dialog
812  connect(_clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
813 
814  rpcConsole->setClientModel(_clientModel);
815 #ifdef ENABLE_WALLET
816  if(walletFrame)
817  {
818  walletFrame->setClientModel(_clientModel);
819  }
820 #endif // ENABLE_WALLET
822 
823  OptionsModel* optionsModel = _clientModel->getOptionsModel();
824  if(optionsModel)
825  {
826  // be aware of the tray icon disable state change reported by the OptionsModel object.
827  connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool)));
828 
829  // initialize the disable state of the tray icon with the current value in the model.
830  setTrayIconVisible(optionsModel->getHideTrayIcon());
831  }
832  } else {
833  // Disable possibility to show main window via action
834  toggleHideAction->setEnabled(false);
835  if(trayIconMenu)
836  {
837  // Disable context menu on tray icon
838  trayIconMenu->clear();
839  }
840  // Propagate cleared model to child objects
841  rpcConsole->setClientModel(nullptr);
842 #ifdef ENABLE_WALLET
843  if (walletFrame)
844  {
845  walletFrame->setClientModel(nullptr);
846  }
847 #endif // ENABLE_WALLET
849  }
850 }
851 
852 #ifdef ENABLE_WALLET
853 bool RavenGUI::addWallet(const QString& name, WalletModel *walletModel)
854 {
855  if(!walletFrame)
856  return false;
858  return walletFrame->addWallet(name, walletModel);
859 }
860 
861 bool RavenGUI::setCurrentWallet(const QString& name)
862 {
863  if(!walletFrame)
864  return false;
865  return walletFrame->setCurrentWallet(name);
866 }
867 
868 void RavenGUI::removeAllWallets()
869 {
870  if(!walletFrame)
871  return;
874 }
875 #endif // ENABLE_WALLET
876 
878 {
879  overviewAction->setEnabled(enabled);
880  sendCoinsAction->setEnabled(enabled);
881  sendCoinsMenuAction->setEnabled(enabled);
882  receiveCoinsAction->setEnabled(enabled);
883  receiveCoinsMenuAction->setEnabled(enabled);
884  historyAction->setEnabled(enabled);
885  encryptWalletAction->setEnabled(enabled);
886  backupWalletAction->setEnabled(enabled);
887  changePassphraseAction->setEnabled(enabled);
888  signMessageAction->setEnabled(enabled);
889  verifyMessageAction->setEnabled(enabled);
890  usedSendingAddressesAction->setEnabled(enabled);
891  usedReceivingAddressesAction->setEnabled(enabled);
892  openAction->setEnabled(enabled);
893 
895  transferAssetAction->setEnabled(false);
896  createAssetAction->setEnabled(false);
897  manageAssetAction->setEnabled(false);
898  messagingAction->setEnabled(false);
899  votingAction->setEnabled(false);
901 }
902 
903 void RavenGUI::createTrayIcon(const NetworkStyle *networkStyle)
904 {
905 #ifndef Q_OS_MAC
906  trayIcon = new QSystemTrayIcon(this);
907  QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
908  trayIcon->setToolTip(toolTip);
909  trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
910  trayIcon->hide();
911 #endif
912 
913  notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
914 }
915 
917 {
918 #ifndef Q_OS_MAC
919  // return if trayIcon is unset (only on non-Mac OSes)
920  if (!trayIcon)
921  return;
922 
923  trayIconMenu = new QMenu(this);
924  trayIcon->setContextMenu(trayIconMenu);
925 
926  connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
927  this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
928 #else
929  // Note: On Mac, the dock icon is used to provide the tray's functionality.
931  dockIconHandler->setMainWindow((QMainWindow *)this);
932  trayIconMenu = dockIconHandler->dockMenu();
933 #endif
934 
935  // Configuration of the tray icon (or dock icon) icon menu
936  trayIconMenu->addAction(toggleHideAction);
937  trayIconMenu->addSeparator();
938  trayIconMenu->addAction(sendCoinsMenuAction);
940  trayIconMenu->addSeparator();
941  trayIconMenu->addAction(signMessageAction);
942  trayIconMenu->addAction(verifyMessageAction);
943  trayIconMenu->addSeparator();
944  trayIconMenu->addAction(optionsAction);
946 #ifndef Q_OS_MAC // This is built-in on Mac
947  trayIconMenu->addSeparator();
948  trayIconMenu->addAction(quitAction);
949 #endif
950 }
951 
952 #ifndef Q_OS_MAC
953 void RavenGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
954 {
955  if(reason == QSystemTrayIcon::Trigger)
956  {
957  // Click on system tray icon triggers show/hide of the main window
958  toggleHidden();
959  }
960 }
961 #endif
962 
964 {
966  return;
967 
968  OptionsDialog dlg(this, enableWallet);
970  dlg.exec();
971 }
972 
974 {
975  if(!clientModel)
976  return;
977 
978  HelpMessageDialog dlg(this, true);
979  dlg.exec();
980 }
981 
983 {
984  rpcConsole->showNormal();
985  rpcConsole->show();
986  rpcConsole->raise();
987  rpcConsole->activateWindow();
988 }
989 
991 {
993  showDebugWindow();
994 }
995 
997 {
999  showDebugWindow();
1000 }
1001 
1003 {
1004  helpMessageDialog->show();
1005 }
1006 
1007 #ifdef ENABLE_WALLET
1008 void RavenGUI::openClicked()
1009 {
1010  OpenURIDialog dlg(this);
1011  if(dlg.exec())
1012  {
1013  Q_EMIT receivedURI(dlg.getURI());
1014  }
1015 }
1016 
1017 void RavenGUI::gotoOverviewPage()
1018 {
1019  overviewAction->setChecked(true);
1021 }
1022 
1023 void RavenGUI::gotoHistoryPage()
1024 {
1025  historyAction->setChecked(true);
1027 }
1028 
1029 void RavenGUI::gotoReceiveCoinsPage()
1030 {
1031  receiveCoinsAction->setChecked(true);
1033 }
1034 
1035 void RavenGUI::gotoSendCoinsPage(QString addr)
1036 {
1037  sendCoinsAction->setChecked(true);
1039 }
1040 
1041 void RavenGUI::gotoSignMessageTab(QString addr)
1042 {
1044 }
1045 
1046 void RavenGUI::gotoVerifyMessageTab(QString addr)
1047 {
1049 }
1050 
1052 void RavenGUI::gotoAssetsPage()
1053 {
1054  transferAssetAction->setChecked(true);
1056 };
1057 
1058 void RavenGUI::gotoCreateAssetsPage()
1059 {
1060  createAssetAction->setChecked(true);
1062 };
1063 
1064 void RavenGUI::gotoManageAssetsPage()
1065 {
1066  manageAssetAction->setChecked(true);
1068 };
1070 #endif // ENABLE_WALLET
1071 
1073 {
1074  int count = clientModel->getNumConnections();
1075  QString icon;
1076  switch(count)
1077  {
1078  case 0: icon = ":/icons/connect_0"; break;
1079  case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
1080  case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
1081  case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
1082  default: icon = ":/icons/connect_4"; break;
1083  }
1084 
1085  QString tooltip;
1086 
1087  if (clientModel->getNetworkActive()) {
1088  tooltip = tr("%n active connection(s) to Raven network", "", count) + QString(".<br>") + tr("Click to disable network activity.");
1089  } else {
1090  tooltip = tr("Network activity disabled.") + QString("<br>") + tr("Click to enable network activity again.");
1091  icon = ":/icons/network_disabled";
1092  }
1093 
1094  // Don't word-wrap this (fixed-width) tooltip
1095  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
1096  connectionsControl->setToolTip(tooltip);
1097 
1098  connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1099 }
1100 
1102 {
1104 }
1105 
1106 void RavenGUI::setNetworkActive(bool networkActive)
1107 {
1109 }
1110 
1112 {
1113  int64_t headersTipTime = clientModel->getHeaderTipTime();
1114  int headersTipHeight = clientModel->getHeaderTipHeight();
1115  int estHeadersLeft = (GetTime() - headersTipTime) / Params().GetConsensus().nPowTargetSpacing;
1116  if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
1117  progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
1118 }
1119 
1120 void RavenGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
1121 {
1122  if (modalOverlay)
1123  {
1124  if (header)
1125  modalOverlay->setKnownBestHeight(count, blockDate);
1126  else
1127  modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
1128  }
1129 
1130  if (!clientModel)
1131  return;
1132 
1133  // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbled text)
1134  statusBar()->clearMessage();
1135 
1136  // Acquire current block source
1137  enum BlockSource blockSource = clientModel->getBlockSource();
1138  switch (blockSource) {
1139  case BLOCK_SOURCE_NETWORK:
1140  if (header) {
1142  return;
1143  }
1144  progressBarLabel->setText(tr("Synchronizing with network..."));
1146  break;
1147  case BLOCK_SOURCE_DISK:
1148  if (header) {
1149  progressBarLabel->setText(tr("Indexing blocks on disk..."));
1150  } else {
1151  progressBarLabel->setText(tr("Processing blocks on disk..."));
1152  }
1153  break;
1154  case BLOCK_SOURCE_REINDEX:
1155  progressBarLabel->setText(tr("Reindexing blocks on disk..."));
1156  break;
1157  case BLOCK_SOURCE_NONE:
1158  if (header) {
1159  return;
1160  }
1161  progressBarLabel->setText(tr("Connecting to peers..."));
1162  break;
1163  }
1164 
1165  QString tooltip;
1166 
1167  QDateTime currentDate = QDateTime::currentDateTime();
1168  qint64 secs = blockDate.secsTo(currentDate);
1169 
1170  tooltip = tr("Processed %n block(s) of transaction history.", "", count);
1171 
1172  // Set icon state: spinning if catching up, tick otherwise
1173  if(secs < 90*60)
1174  {
1175  tooltip = tr("Up to date") + QString(".<br>") + tooltip;
1176  labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1177 
1178 #ifdef ENABLE_WALLET
1179  if(walletFrame)
1180  {
1182  modalOverlay->showHide(true, true);
1183  }
1184 #endif // ENABLE_WALLET
1185 
1186  progressBarLabel->setVisible(false);
1187  progressBar->setVisible(false);
1188  }
1189  else
1190  {
1191  QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);
1192 
1193  progressBarLabel->setVisible(true);
1194  progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
1195  progressBar->setMaximum(1000000000);
1196  progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
1197  progressBar->setVisible(true);
1198 
1199  tooltip = tr("Catching up...") + QString("<br>") + tooltip;
1200  if(count != prevBlocks)
1201  {
1202  labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
1203  ":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
1204  .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1206  }
1207  prevBlocks = count;
1208 
1209 #ifdef ENABLE_WALLET
1210  if(walletFrame)
1211  {
1214  }
1215 #endif // ENABLE_WALLET
1216 
1217  tooltip += QString("<br>");
1218  tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
1219  tooltip += QString("<br>");
1220  tooltip += tr("Transactions after this will not yet be visible.");
1221  }
1222 
1223  // Don't word-wrap this (fixed-width) tooltip
1224  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
1225 
1226  labelBlocksIcon->setToolTip(tooltip);
1227  progressBarLabel->setToolTip(tooltip);
1228  progressBar->setToolTip(tooltip);
1229 }
1230 
1231 void RavenGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
1232 {
1233  QString strTitle = tr("Raven"); // default title
1234  // Default to information icon
1235  int nMBoxIcon = QMessageBox::Information;
1236  int nNotifyIcon = Notificator::Information;
1237 
1238  QString msgType;
1239 
1240  // Prefer supplied title over style based title
1241  if (!title.isEmpty()) {
1242  msgType = title;
1243  }
1244  else {
1245  switch (style) {
1247  msgType = tr("Error");
1248  break;
1250  msgType = tr("Warning");
1251  break;
1253  msgType = tr("Information");
1254  break;
1255  default:
1256  break;
1257  }
1258  }
1259  // Append title to "Raven - "
1260  if (!msgType.isEmpty())
1261  strTitle += " - " + msgType;
1262 
1263  // Check for error/warning icon
1264  if (style & CClientUIInterface::ICON_ERROR) {
1265  nMBoxIcon = QMessageBox::Critical;
1266  nNotifyIcon = Notificator::Critical;
1267  }
1268  else if (style & CClientUIInterface::ICON_WARNING) {
1269  nMBoxIcon = QMessageBox::Warning;
1270  nNotifyIcon = Notificator::Warning;
1271  }
1272 
1273  // Display message
1274  if (style & CClientUIInterface::MODAL) {
1275  // Check for buttons, use OK as default, if none was supplied
1276  QMessageBox::StandardButton buttons;
1277  if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
1278  buttons = QMessageBox::Ok;
1279 
1281  QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
1282  int r = mBox.exec();
1283  if (ret != nullptr)
1284  *ret = r == QMessageBox::Ok;
1285  }
1286  else
1287  notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
1288 }
1289 
1290 void RavenGUI::changeEvent(QEvent *e)
1291 {
1292  QMainWindow::changeEvent(e);
1293 #ifndef Q_OS_MAC // Ignored on Mac
1294  if(e->type() == QEvent::WindowStateChange)
1295  {
1297  {
1298  QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
1299  if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
1300  {
1301  QTimer::singleShot(0, this, SLOT(hide()));
1302  e->ignore();
1303  }
1304  }
1305  }
1306 #endif
1307 }
1308 
1309 void RavenGUI::closeEvent(QCloseEvent *event)
1310 {
1311 #ifndef Q_OS_MAC // Ignored on Mac
1313  {
1315  {
1316  // close rpcConsole in case it was open to make some space for the shutdown window
1317  rpcConsole->close();
1318 
1319  QApplication::quit();
1320  }
1321  else
1322  {
1323  QMainWindow::showMinimized();
1324  event->ignore();
1325  }
1326  }
1327 #else
1328  QMainWindow::closeEvent(event);
1329 #endif
1330 }
1331 
1332 void RavenGUI::showEvent(QShowEvent *event)
1333 {
1334  // enable the debug window when the main window shows up
1335  openRPCConsoleAction->setEnabled(true);
1336  aboutAction->setEnabled(true);
1337  optionsAction->setEnabled(true);
1338 }
1339 
1340 #ifdef ENABLE_WALLET
1341 void RavenGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& assetName)
1342 {
1343  // On new transaction, make an info balloon
1344  QString msg = tr("Date: %1\n").arg(date);
1345  if (assetName == "RVN")
1346  msg += tr("Amount: %1\n").arg(RavenUnits::formatWithUnit(unit, amount, true));
1347  else
1348  msg += tr("Amount: %1\n").arg(RavenUnits::formatWithCustomName(assetName, amount, MAX_ASSET_UNITS, true));
1349 
1350  msg += tr("Type: %1\n").arg(type);
1351 
1352  if (!label.isEmpty())
1353  msg += tr("Label: %1\n").arg(label);
1354  else if (!address.isEmpty())
1355  msg += tr("Address: %1\n").arg(address);
1356  message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
1358 }
1359 
1360 void RavenGUI::checkAssets()
1361 {
1362  // Check that status of RIP2 and activate the assets icon if it is active
1363  if(AreAssetsDeployed()) {
1364  transferAssetAction->setDisabled(false);
1365  transferAssetAction->setToolTip(tr("Transfer assets to RVN addresses"));
1366  createAssetAction->setDisabled(false);
1367  createAssetAction->setToolTip(tr("Create new main/sub/unique assets"));
1368  manageAssetAction->setDisabled(false);
1369  }
1370  else {
1371  transferAssetAction->setDisabled(true);
1372  transferAssetAction->setToolTip(tr("Assets not yet active"));
1373  createAssetAction->setDisabled(true);
1374  createAssetAction->setToolTip(tr("Assets not yet active"));
1375  manageAssetAction->setDisabled(true);
1376  }
1377 }
1378 #endif // ENABLE_WALLET
1379 
1380 void RavenGUI::dragEnterEvent(QDragEnterEvent *event)
1381 {
1382  // Accept only URIs
1383  if(event->mimeData()->hasUrls())
1384  event->acceptProposedAction();
1385 }
1386 
1387 void RavenGUI::dropEvent(QDropEvent *event)
1388 {
1389  if(event->mimeData()->hasUrls())
1390  {
1391  for (const QUrl &uri : event->mimeData()->urls())
1392  {
1393  Q_EMIT receivedURI(uri.toString());
1394  }
1395  }
1396  event->acceptProposedAction();
1397 }
1398 
1399 bool RavenGUI::eventFilter(QObject *object, QEvent *event)
1400 {
1401  // Catch status tip events
1402  if (event->type() == QEvent::StatusTip)
1403  {
1404  // Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
1405  if (progressBarLabel->isVisible() || progressBar->isVisible())
1406  return true;
1407  }
1408  return QMainWindow::eventFilter(object, event);
1409 }
1410 
1411 #ifdef ENABLE_WALLET
1412 bool RavenGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
1413 {
1414  // URI has to be valid
1415  if (walletFrame && walletFrame->handlePaymentRequest(recipient))
1416  {
1418  gotoSendCoinsPage();
1419  return true;
1420  }
1421  return false;
1422 }
1423 
1424 void RavenGUI::setHDStatus(int hdEnabled)
1425 {
1426  labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1427  labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
1428 
1429  // eventually disable the QLabel to set its opacity to 50%
1430  labelWalletHDStatusIcon->setEnabled(hdEnabled);
1431 }
1432 
1433 void RavenGUI::setEncryptionStatus(int status)
1434 {
1435  switch(status)
1436  {
1438  labelWalletEncryptionIcon->hide();
1439  encryptWalletAction->setChecked(false);
1440  changePassphraseAction->setEnabled(false);
1441  encryptWalletAction->setEnabled(true);
1442  break;
1443  case WalletModel::Unlocked:
1444  labelWalletEncryptionIcon->show();
1445  labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1446  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
1447  encryptWalletAction->setChecked(true);
1448  changePassphraseAction->setEnabled(true);
1449  encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
1450  break;
1451  case WalletModel::Locked:
1452  labelWalletEncryptionIcon->show();
1453  labelWalletEncryptionIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1454  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
1455  encryptWalletAction->setChecked(true);
1456  changePassphraseAction->setEnabled(true);
1457  encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
1458  break;
1459  }
1460 }
1461 #endif // ENABLE_WALLET
1462 
1463 void RavenGUI::showNormalIfMinimized(bool fToggleHidden)
1464 {
1465  if(!clientModel)
1466  return;
1467 
1468  // activateWindow() (sometimes) helps with keyboard focus on Windows
1469  if (isHidden())
1470  {
1471  show();
1472  activateWindow();
1473  }
1474  else if (isMinimized())
1475  {
1476  showNormal();
1477  activateWindow();
1478  }
1479  else if (GUIUtil::isObscured(this))
1480  {
1481  raise();
1482  activateWindow();
1483  }
1484  else if(fToggleHidden)
1485  hide();
1486 }
1487 
1489 {
1490  showNormalIfMinimized(true);
1491 }
1492 
1494 {
1495  if (ShutdownRequested())
1496  {
1497  if(rpcConsole)
1498  rpcConsole->hide();
1499  qApp->quit();
1500  }
1501 }
1502 
1503 void RavenGUI::showProgress(const QString &title, int nProgress)
1504 {
1505  if (nProgress == 0)
1506  {
1507  progressDialog = new QProgressDialog(title, "", 0, 100);
1508  progressDialog->setWindowModality(Qt::ApplicationModal);
1509  progressDialog->setMinimumDuration(0);
1510  progressDialog->setCancelButton(0);
1511  progressDialog->setAutoClose(false);
1512  progressDialog->setValue(0);
1513  }
1514  else if (nProgress == 100)
1515  {
1516  if (progressDialog)
1517  {
1518  progressDialog->close();
1519  progressDialog->deleteLater();
1520  }
1521  }
1522  else if (progressDialog)
1523  progressDialog->setValue(nProgress);
1524 }
1525 
1526 void RavenGUI::setTrayIconVisible(bool fHideTrayIcon)
1527 {
1528  if (trayIcon)
1529  {
1530  trayIcon->setVisible(!fHideTrayIcon);
1531  }
1532 }
1533 
1535 {
1536  if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))
1538 }
1539 
1540 static bool ThreadSafeMessageBox(RavenGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
1541 {
1542  bool modal = (style & CClientUIInterface::MODAL);
1543  // The SECURE flag has no effect in the Qt GUI.
1544  // bool secure = (style & CClientUIInterface::SECURE);
1545  style &= ~CClientUIInterface::SECURE;
1546  bool ret = false;
1547  // In case of modal message, use blocking connection to wait for user to click a button
1548  QMetaObject::invokeMethod(gui, "message",
1549  modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
1550  Q_ARG(QString, QString::fromStdString(caption)),
1551  Q_ARG(QString, QString::fromStdString(message)),
1552  Q_ARG(unsigned int, style),
1553  Q_ARG(bool*, &ret));
1554  return ret;
1555 }
1556 
1558 {
1559  // Connect signals to client
1560  uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
1561  uiInterface.ThreadSafeQuestion.connect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
1562 }
1563 
1565 {
1566  // Disconnect signals from client
1567  uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
1568  uiInterface.ThreadSafeQuestion.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
1569 }
1570 
1572 {
1573  if (clientModel) {
1575  }
1576 }
1577 
1579 void RavenGUI::handleRestart(QStringList args)
1580 {
1581  if (!ShutdownRequested())
1582  Q_EMIT requestedRestart(args);
1583 }
1584 
1586  optionsModel(0),
1587  menu(0)
1588 {
1589  createContextMenu(platformStyle);
1590  setToolTip(tr("Unit to show amounts in. Click to select another unit."));
1591  QList<RavenUnits::Unit> units = RavenUnits::availableUnits();
1592  int max_width = 0;
1593  const QFontMetrics fm(font());
1594  for (const RavenUnits::Unit unit : units)
1595  {
1596  max_width = qMax(max_width, fm.width(RavenUnits::name(unit)));
1597  }
1598  setMinimumSize(max_width, 0);
1599  setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1600  setStyleSheet(QString("QLabel { color : %1; }").arg(platformStyle->DarkOrangeColor().name()));
1601 }
1602 
1605 {
1606  onDisplayUnitsClicked(event->pos());
1607 }
1608 
1611 {
1612  menu = new QMenu(this);
1614  {
1615  QAction *menuAction = new QAction(QString(RavenUnits::name(u)), this);
1616  menuAction->setData(QVariant(u));
1617  menu->addAction(menuAction);
1618  }
1619  menu->setStyleSheet(QString("QMenu::item{ color: %1; } QMenu::item:selected{ color: %2;}").arg(platformStyle->DarkOrangeColor().name(), platformStyle->TextColor().name()));
1620  connect(menu,SIGNAL(triggered(QAction*)),this,SLOT(onMenuSelection(QAction*)));
1621 }
1622 
1625 {
1626  if (_optionsModel)
1627  {
1628  this->optionsModel = _optionsModel;
1629 
1630  // be aware of a display unit change reported by the OptionsModel object.
1631  connect(_optionsModel,SIGNAL(displayUnitChanged(int)),this,SLOT(updateDisplayUnit(int)));
1632 
1633  // initialize the display units label with the current value in the model.
1634  updateDisplayUnit(_optionsModel->getDisplayUnit());
1635  }
1636 }
1637 
1640 {
1641  setText(RavenUnits::name(newUnits));
1642 }
1643 
1646 {
1647  QPoint globalPos = mapToGlobal(point);
1648  menu->exec(globalPos);
1649 }
1650 
1653 {
1654  if (action)
1655  {
1656  optionsModel->setDisplayUnit(action->data());
1657  }
1658 }
1659 
1661 {
1662  request->setUrl(QUrl("https://api.binance.com/api/v1/ticker/price?symbol=RVNBTC"));
1663  networkManager->get(*request);
1664 }
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
Definition: walletframe.cpp:97
bool setCurrentWallet(const QString &name)
Definition: walletframe.cpp:67
void showDebugWindowActivateConsole()
Show debug window and set focus to the console.
Definition: ravengui.cpp:990
QColor DarkOrangeColor() const
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
bool getNetworkActive() const
Return true if network activity in core is enabled.
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
void mousePressEvent(QMouseEvent *event)
So that it responds to left-button clicks.
Definition: ravengui.cpp:1604
UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
Definition: ravengui.cpp:1585
QTimer * pricingTimer
Definition: ravengui.h:128
static bool isWalletEnabled()
QGraphicsDropShadowEffect * getShadowEffect()
Definition: guiutil.cpp:146
QAction * manageAssetAction
Definition: ravengui.h:122
void requestedRestart(QStringList args)
Restart handling.
#define COLOR_WALLETFRAME_SHADOW
Definition: guiconstants.h:41
QAction * openRPCConsoleAction
Definition: ravengui.h:114
bool ShutdownRequested()
Definition: init.cpp:136
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
#define COLOR_LABELS
Definition: guiconstants.h:44
void showWalletRepair()
Show debug window and set focus to the wallet repair tab.
Definition: ravengui.cpp:996
WalletFrame * walletFrame
Definition: ravengui.h:84
void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress)
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
Definition: guiutil.cpp:460
QAction * aboutAction
Definition: ravengui.h:105
QAction * changePassphraseAction
Definition: ravengui.h:112
const QIcon & getAppIcon() const
Definition: networkstyle.h:21
void showModalOverlay()
Definition: ravengui.cpp:1534
QProgressDialog * progressDialog
Definition: ravengui.h:93
void subscribeToCoreSignals()
Connect core signals to GUI client.
Definition: ravengui.cpp:1557
OptionsModel * getOptionsModel()
QColor TopWidgetBackGroundColor() const
QIcon SingleColorIcon(const QString &filename) const
Colorize an icon (given filename) with the icon color.
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
Macintosh-specific dock icon handler.
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated...
Definition: ui_interface.h:60
QIcon SingleColorIconOnOff(const QString &filenameOn, const QString &filenameOff) const
Set icon with two states on and off.
bool isLayerVisible() const
Definition: modaloverlay.h:36
#define PACKAGE_NAME
Definition: raven-config.h:350
QLabel * labelWalletHDStatusIcon
Definition: ravengui.h:88
Notify user of potential problem.
Definition: notificator.h:40
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
const QString & getTitleAddText() const
Definition: networkstyle.h:24
Signals for UI communication.
Definition: ui_interface.h:28
void removeAllWallets()
Definition: walletframe.cpp:89
void setOptionsModel(OptionsModel *optionsModel)
Lets the control know about the Options Model (and its signals)
Definition: ravengui.cpp:1624
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
Definition: ravengui.cpp:1106
int getDisplayUnit() const
Definition: optionsmodel.h:68
Force blocking, modal message box dialog (not just OS notification)
Definition: ui_interface.h:64
void showOutOfSyncWarning(bool fShow)
void optionsClicked()
Show configuration dialog.
Definition: ravengui.cpp:963
ModalOverlay * modalOverlay
Definition: ravengui.h:138
QIcon TextColorIcon(const QString &filename) const
Colorize an icon (given filename) with the text color.
void setIcon(const QIcon &icon)
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 setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:547
void closeEvent(QCloseEvent *event)
Definition: ravengui.cpp:1309
QColor DarkBlueColor() const
QLabel * labelBlocksIcon
Definition: ravengui.h:90
void gotoHistoryPage()
Switch to history (transactions) page.
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
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
Definition: ravenunits.cpp:146
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 gotoCreateAssetsPage()
QColor MainBackGroundColor() const
void gotoOverviewPage()
Switch to overview (home) page.
bool darkModeEnabled
void showHelpMessageClicked()
Show help message dialog.
Definition: ravengui.cpp:1002
static MacDockIconHandler * instance()
static const QString DEFAULT_WALLET
Display name for default wallet name.
Definition: ravengui.h:52
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void setClientModel(ClientModel *clientModel)
Definition: walletframe.cpp:38
void setMainWindow(QMainWindow *window)
bool isObscured(QWidget *w)
Definition: guiutil.cpp:479
bool AreAssetsDeployed()
RVN START.
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:57
OptionsModel * optionsModel
Definition: ravengui.h:299
Notificator * notificator
Definition: ravengui.h:135
double getVerificationProgress(const CBlockIndex *tip) const
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
QNetworkRequest * request
Definition: ravengui.h:130
void setKnownBestHeight(int count, const QDateTime &blockDate)
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
static const std::string DEFAULT_UIPLATFORM
Definition: ravengui.h:53
#define STRING_LABEL_COLOR
Definition: guiconstants.h:90
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.
QAction * quitAction
Definition: ravengui.h:98
bool addWallet(const QString &name, WalletModel *walletModel)
Definition: walletframe.cpp:43
boost::signals2::signal< bool(const std::string &message, const std::string &noninteractive_message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeQuestion
If possible, ask the user a question.
Definition: ui_interface.h:79
BlockSource
Definition: clientmodel.h:24
void updateDisplayUnit(int newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
Definition: ravengui.cpp:1639
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
int64_t nPowTargetSpacing
Definition: params.h:71
QAction * sendCoinsAction
Definition: ravengui.h:99
void toggleVisibility()
void setModel(OptionsModel *model)
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
Informational message.
Definition: notificator.h:39
UnitDisplayStatusBarControl * unitDisplayControl
Definition: ravengui.h:86
QAction * verifyMessageAction
Definition: ravengui.h:104
UniValue help(const JSONRPCRequest &jsonRequest)
Definition: server.cpp:216
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
An error occurred.
Definition: notificator.h:41
const QIcon & getTrayAndWindowIcon() const
Definition: networkstyle.h:23
ClickableProgressBar ProgressBar
Definition: guiutil.h:258
QAction * optionsAction
Definition: ravengui.h:108
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
void showHide(bool hide=false, bool userRequested=false)
QAction * historyAction
Definition: ravengui.h:97
QColor ToolBarNotSelectedTextColor() const
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
QDateTime getLastBlockDate() const
void createContextMenu(const PlatformStyle *platformStyle)
Creates context menu, its actions, and wires up all the relevant signals for mouse events...
Definition: ravengui.cpp:1610
QAction * transferAssetAction
RVN START.
Definition: ravengui.h:120
void showDebugWindow()
Show debug window.
Definition: ravengui.cpp:982
bool getMinimizeOnClose() const
Definition: optionsmodel.h:67
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
QLabel * progressBarLabel
Definition: ravengui.h:91
void gotoReceiveCoinsPage()
Switch to receive coins page.
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
const CChainParams & Params()
Return the currently selected parameters.
bool getMinimizeToTray() const
Definition: optionsmodel.h:66
Interface to Raven wallet from Qt view code.
Definition: walletmodel.h:165
Raven GUI main class.
Definition: ravengui.h:47
QString getURI()
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
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
Definition: ravenunits.cpp:18
void aboutClicked()
Show about dialog.
Definition: ravengui.cpp:973
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
Definition: ui_interface.h:76
void gotoManageAssetsPage()
QColor TextColor() const
QAction * openAction
Definition: ravengui.h:116
static QString name(int unit)
Short name.
Definition: ravenunits.cpp:40
"Help message" dialog box
Definition: utilitydialog.h:19
Unit
Raven units.
Definition: ravenunits.h:63
QLabel * connectionsControl
Definition: ravengui.h:89
void setNetworkActive(bool active)
Toggle network activity state in core.
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
Definition: ravengui.cpp:877
Preferences dialog.
Definition: optionsdialog.h:36
QString formatNiceTimeOffset(qint64 secs)
Definition: guiutil.cpp:1029
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
Definition: utiltime.cpp:20
CClientUIInterface uiInterface
Definition: ui_interface.cpp:9
int getNumBlocks() const
Definition: clientmodel.cpp:73
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:61
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
static QString formatWithCustomName(QString customName, const CAmount &amount, int unit=MAX_ASSET_UNITS, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with custom name)
Definition: ravenunits.cpp:151
int getHeaderTipHeight() const
Definition: clientmodel.cpp:79
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
void gotoAssetsPage()
RVN START.
int64_t getHeaderTipTime() const
Definition: clientmodel.cpp:93
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
QColor LightBlueColor() const
bool getHideTrayIcon() const
Definition: optionsmodel.h:65
QAction * openWalletRepairAction
Definition: ravengui.h:115
void onDisplayUnitsClicked(const QPoint &point)
Shows context menu with Display Unit options by the mouse coordinates.
Definition: ravengui.cpp:1645
QColor ToolBarSelectedTextColor() const
#define MAX_ASSET_UNITS
Definition: ravenunits.h:15
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
Definition: ravengui.cpp:1652
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:70
#define SPINNER_FRAMES
Definition: guiconstants.h:111
QMenuBar * appMenuBar
Definition: ravengui.h:95
QLabel * labelCurrentPrice
Definition: ravengui.h:127
ClientModel * clientModel
Definition: ravengui.h:83