Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

bitcoingui.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2015 The Bitcoin Core developers
2 // Copyright (c) 2014-2019 The Dash 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 #include <qt/bitcoingui.h>
7 
8 #include <qt/bitcoinunits.h>
9 #include <qt/clientmodel.h>
10 #include <qt/guiconstants.h>
11 #include <qt/guiutil.h>
12 #include <qt/modaloverlay.h>
13 #include <qt/networkstyle.h>
14 #include <qt/notificator.h>
15 #include <qt/openuridialog.h>
16 #include <qt/optionsdialog.h>
17 #include <qt/optionsmodel.h>
18 #include <qt/rpcconsole.h>
19 #include <qt/utilitydialog.h>
20 
21 #ifdef ENABLE_WALLET
23 #include <qt/walletframe.h>
24 #include <qt/walletmodel.h>
25 #include <qt/walletview.h>
26 #endif // ENABLE_WALLET
27 
28 #ifdef Q_OS_MAC
29 #include <qt/macdockiconhandler.h>
30 #endif
31 
32 #include <chainparams.h>
33 #include <init.h>
34 #include <ui_interface.h>
35 #include <util.h>
37 #include <qt/masternodelist.h>
38 
39 #include <iostream>
40 
41 #include <QAction>
42 #include <QApplication>
43 #include <QButtonGroup>
44 #include <QDateTime>
45 #include <QDesktopWidget>
46 #include <QDragEnterEvent>
47 #include <QListWidget>
48 #include <QMenuBar>
49 #include <QMessageBox>
50 #include <QMimeData>
51 #include <QProgressDialog>
52 #include <QSettings>
53 #include <QShortcut>
54 #include <QStackedWidget>
55 #include <QStatusBar>
56 #include <QStyle>
57 #include <QTimer>
58 #include <QToolBar>
59 #include <QToolButton>
60 #include <QVBoxLayout>
61 
62 #if QT_VERSION < 0x050000
63 #include <QTextDocument>
64 #include <QUrl>
65 #else
66 #include <QUrlQuery>
67 #endif
68 
69 const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
70 #if defined(Q_OS_MAC)
71  "macosx"
72 #elif defined(Q_OS_WIN)
73  "windows"
74 #else
75  "other"
76 #endif
77  ;
78 
81 const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
82 
83 BitcoinGUI::BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent) :
84  QMainWindow(parent),
85  enableWallet(false),
86  clientModel(0),
87  walletFrame(0),
88  unitDisplayControl(0),
89  labelWalletEncryptionIcon(0),
90  labelWalletHDStatusIcon(0),
91  labelConnectionsIcon(0),
92  labelBlocksIcon(0),
93  progressBarLabel(0),
94  progressBar(0),
95  progressDialog(0),
96  appMenuBar(0),
97  overviewAction(0),
98  historyAction(0),
99  masternodeAction(0),
100  quitAction(0),
101  sendCoinsAction(0),
102  privateSendCoinsAction(0),
103  sendCoinsMenuAction(0),
104  privateSendCoinsMenuAction(0),
105  usedSendingAddressesAction(0),
106  usedReceivingAddressesAction(0),
107  signMessageAction(0),
108  verifyMessageAction(0),
109  aboutAction(0),
110  receiveCoinsAction(0),
111  receiveCoinsMenuAction(0),
112  optionsAction(0),
113  toggleHideAction(0),
114  encryptWalletAction(0),
115  backupWalletAction(0),
116  changePassphraseAction(0),
117  aboutQtAction(0),
118  openRPCConsoleAction(0),
119  openAction(0),
120  showHelpMessageAction(0),
121  showPrivateSendHelpAction(0),
122  trayIcon(0),
123  trayIconMenu(0),
124  dockIconMenu(0),
125  notificator(0),
126  rpcConsole(0),
127  helpMessageDialog(0),
128  modalOverlay(0),
129  tabGroup(0),
130  timerConnecting(0),
131  timerSpinner(0)
132 {
133  QSettings settings;
134  if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
135  // Restore failed (perhaps missing setting), center the window
136  move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
137  }
138 
139  QString windowTitle = tr(PACKAGE_NAME) + " - ";
140 #ifdef ENABLE_WALLET
142 #endif // ENABLE_WALLET
143  if(enableWallet)
144  {
145  windowTitle += tr("Wallet");
146  } else {
147  windowTitle += tr("Node");
148  }
149  QString userWindowTitle = QString::fromStdString(gArgs.GetArg("-windowtitle", ""));
150  if(!userWindowTitle.isEmpty()) windowTitle += " - " + userWindowTitle;
151  windowTitle += " " + networkStyle->getTitleAddText();
152  QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
153  setWindowIcon(networkStyle->getTrayAndWindowIcon());
154  setWindowTitle(windowTitle);
155 
156 #if defined(Q_OS_MAC) && QT_VERSION < 0x050000
157  // This property is not implemented in Qt 5. Setting it has no effect.
158  // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
159  setUnifiedTitleAndToolBarOnMac(true);
160 #endif
161 
162  rpcConsole = new RPCConsole(this);
164 #ifdef ENABLE_WALLET
165  if(enableWallet)
166  {
168  walletFrame = new WalletFrame(this);
169  } else
170 #endif // ENABLE_WALLET
171  {
172  /* When compiled without wallet or -disablewallet is provided,
173  * the central widget is the rpc console.
174  */
175  setCentralWidget(rpcConsole);
176  }
177 
178  // Accept D&D of URIs
179  setAcceptDrops(true);
180 
181  // Create actions for the toolbar, menu bar and tray/dock icon
182  // Needs walletFrame to be initialized
183  createActions();
184 
185  // Create application menu bar
186  createMenuBar();
187 
188  // Create the toolbars
189  createToolBars();
190 
191  // Create system tray icon and notification
192  createTrayIcon(networkStyle);
193 
194  // Create status bar
195  statusBar();
196 
197  // Disable size grip because it looks ugly and nobody needs it
198  statusBar()->setSizeGripEnabled(false);
199 
200  // Status bar notification icons
201  QFrame *frameBlocks = new QFrame();
202  frameBlocks->setContentsMargins(0,0,0,0);
203  frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
204  QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
205  frameBlocksLayout->setContentsMargins(3,0,3,0);
206  frameBlocksLayout->setSpacing(3);
208  labelWalletEncryptionIcon = new QLabel();
209  labelWalletHDStatusIcon = new QLabel();
211 
213  if(enableWallet)
214  {
215  frameBlocksLayout->addStretch();
216  frameBlocksLayout->addWidget(unitDisplayControl);
217  frameBlocksLayout->addStretch();
218  frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
219  frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
220  }
221  frameBlocksLayout->addStretch();
222  frameBlocksLayout->addWidget(labelConnectionsIcon);
223  frameBlocksLayout->addStretch();
224  frameBlocksLayout->addWidget(labelBlocksIcon);
225  frameBlocksLayout->addStretch();
226 
227  // Hide the spinner/synced icon by default to avoid
228  // that the spinner starts before we have any connections
229  labelBlocksIcon->hide();
230 
231  // Progress bar and label for blocks download
232  progressBarLabel = new QLabel();
233  progressBarLabel->setVisible(true);
234  progressBarLabel->setObjectName("lblStatusBarProgress");
236  progressBar->setAlignment(Qt::AlignCenter);
237  progressBar->setVisible(true);
238 
239  // Override style sheet for progress bar for styles that have a segmented progress bar,
240  // as they make the text unreadable (workaround for issue #1071)
241  // See https://qt-project.org/doc/qt-4.8/gallery.html
242  QString curStyle = QApplication::style()->metaObject()->className();
243  if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
244  {
245  progressBar->setStyleSheet("QProgressBar { background-color: #F8F8F8; 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 #00CCFF, stop: 1 #33CCFF); border-radius: 7px; margin: 0px; }");
246  }
247 
248  statusBar()->addWidget(progressBarLabel);
249  statusBar()->addWidget(progressBar);
250  statusBar()->addPermanentWidget(frameBlocks);
251 
252  // Install event filter to be able to catch status tip events (QEvent::StatusTip)
253  this->installEventFilter(this);
254 
255  // Initially wallet actions should be disabled
257 
258  // Subscribe to notifications from core
260 
261  // Jump to peers tab by clicking on connections icon
262  connect(labelConnectionsIcon, SIGNAL(clicked(QPoint)), this, SLOT(showPeers()));
263 
264  modalOverlay = new ModalOverlay(this->centralWidget());
265 #ifdef ENABLE_WALLET
266  if(enableWallet) {
267  connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay()));
268  connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
269  connect(progressBar, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
270  }
271 #endif
272 
273 #ifdef Q_OS_MAC
274  m_app_nap_inhibitor = new CAppNapInhibitor;
275 #endif
276 
277  incomingTransactionsTimer = new QTimer(this);
278  incomingTransactionsTimer->setSingleShot(true);
279  connect(incomingTransactionsTimer, SIGNAL(timeout()), SLOT(showIncomingTransactions()));
280 }
281 
283 {
284  // Unsubscribe from notifications from core
286 
287  QSettings settings;
288  settings.setValue("MainWindowGeometry", saveGeometry());
289  if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
290  trayIcon->hide();
291 #ifdef Q_OS_MAC
292  delete m_app_nap_inhibitor;
293  delete appMenuBar;
295 #endif
296 
297  delete rpcConsole;
298  delete tabGroup;
299 }
300 
302 {
303  if (labelBlocksIcon == nullptr || labelBlocksIcon->isHidden() || timerSpinner != nullptr) {
304  return;
305  }
306  auto getNextFrame = []() {
307  static std::vector<std::unique_ptr<QPixmap>> vecFrames;
308  static std::vector<std::unique_ptr<QPixmap>>::iterator itFrame;
309  while (vecFrames.size() < SPINNER_FRAMES) {
310  QString&& strFrame = QString("spinner-%1").arg(vecFrames.size(), 3, 10, QChar('0'));
312  itFrame = vecFrames.insert(vecFrames.end(), std::make_unique<QPixmap>(frame));
313  }
314  assert(vecFrames.size() == SPINNER_FRAMES);
315  if (itFrame == vecFrames.end()) {
316  itFrame = vecFrames.begin();
317  }
318  return *itFrame++->get();
319  };
320 
321  timerSpinner = new QTimer(this);
322  QObject::connect(timerSpinner, &QTimer::timeout, [=]() {
323  if (timerSpinner == nullptr) {
324  return;
325  }
326  labelBlocksIcon->setPixmap(getNextFrame());
327  });
328  timerSpinner->start(40);
329 }
330 
332 {
333  if (timerSpinner == nullptr) {
334  return;
335  }
336  timerSpinner->deleteLater();
337  timerSpinner = nullptr;
338 }
339 
341 {
342  static int nStep{-1};
343  const int nAnimationSteps = 10;
344 
345  if (timerConnecting != nullptr) {
346  return;
347  }
348 
349  timerConnecting = new QTimer(this);
350  QObject::connect(timerConnecting, &QTimer::timeout, [=]() {
351 
352  if (timerConnecting == nullptr) {
353  return;
354  }
355 
356  QString strImage;
357  GUIUtil::ThemedColor color;
358 
359  nStep = (nStep + 1) % (nAnimationSteps + 1);
360  if (nStep == 0) {
361  strImage = "connect_4";
363  } else if (nStep == nAnimationSteps / 2) {
364  strImage = "connect_1";
366  } else {
367  return;
368  }
369  labelConnectionsIcon->setPixmap(GUIUtil::getIcon(strImage, color).pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
370  });
371  timerConnecting->start(100);
372 }
373 
375 {
376  if (timerConnecting == nullptr) {
377  return;
378  }
379  timerConnecting->deleteLater();
380  timerConnecting = nullptr;
381 }
382 
384 {
385  tabGroup = new QButtonGroup(this);
386 
387  overviewAction = new QToolButton(this);
388  overviewAction->setText(tr("&Overview"));
389  overviewAction->setStatusTip(tr("Show general overview of wallet"));
390  overviewAction->setToolTip(overviewAction->statusTip());
391  overviewAction->setCheckable(true);
392  tabGroup->addButton(overviewAction);
393 
394  sendCoinsAction = new QToolButton(this);
395  sendCoinsAction->setText(tr("&Send"));
396  sendCoinsAction->setStatusTip(tr("Send coins to a Dash address"));
397  sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
398  sendCoinsAction->setCheckable(true);
399  tabGroup->addButton(sendCoinsAction);
400 
401  sendCoinsMenuAction = new QAction(sendCoinsAction->text(), this);
402  sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip());
403  sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip());
404 
405  privateSendCoinsAction = new QToolButton(this);
406  privateSendCoinsAction->setText("&PrivateSend");
407  privateSendCoinsAction->setStatusTip(tr("PrivateSend coins to a Dash address"));
408  privateSendCoinsAction->setToolTip(privateSendCoinsAction->statusTip());
409  privateSendCoinsAction->setCheckable(true);
410  tabGroup->addButton(privateSendCoinsAction);
411 
412  privateSendCoinsMenuAction = new QAction(privateSendCoinsAction->text(), this);
413  privateSendCoinsMenuAction->setStatusTip(privateSendCoinsAction->statusTip());
414  privateSendCoinsMenuAction->setToolTip(privateSendCoinsMenuAction->statusTip());
415 
416  receiveCoinsAction = new QToolButton(this);
417  receiveCoinsAction->setText(tr("&Receive"));
418  receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and dash: URIs)"));
419  receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
420  receiveCoinsAction->setCheckable(true);
421  tabGroup->addButton(receiveCoinsAction);
422 
423  receiveCoinsMenuAction = new QAction(receiveCoinsAction->text(), this);
424  receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip());
425  receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip());
426 
427  historyAction = new QToolButton(this);
428  historyAction->setText(tr("&Transactions"));
429  historyAction->setStatusTip(tr("Browse transaction history"));
430  historyAction->setToolTip(historyAction->statusTip());
431  historyAction->setCheckable(true);
432  tabGroup->addButton(historyAction);
433 
434 #ifdef ENABLE_WALLET
435  QSettings settings;
436  if (settings.value("fShowMasternodesTab").toBool()) {
437  masternodeAction = new QToolButton(this);
438  masternodeAction->setText(tr("&Masternodes"));
439  masternodeAction->setStatusTip(tr("Browse masternodes"));
440  masternodeAction->setToolTip(masternodeAction->statusTip());
441  masternodeAction->setCheckable(true);
442  tabGroup->addButton(masternodeAction);
443  connect(masternodeAction, SIGNAL(clicked()), this, SLOT(showNormalIfMinimized()));
444  connect(masternodeAction, SIGNAL(clicked()), this, SLOT(gotoMasternodePage()));
445  }
446 
447  // These showNormalIfMinimized are needed because Send Coins and Receive Coins
448  // can be triggered from the tray menu, and need to show the GUI to be useful.
449  connect(overviewAction, SIGNAL(clicked()), this, SLOT(showNormalIfMinimized()));
450  connect(overviewAction, SIGNAL(clicked()), this, SLOT(gotoOverviewPage()));
451  connect(sendCoinsAction, SIGNAL(clicked()), this, SLOT(showNormalIfMinimized()));
452  connect(sendCoinsAction, SIGNAL(clicked()), this, SLOT(gotoSendCoinsPage()));
453  connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
454  connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
455  connect(privateSendCoinsAction, SIGNAL(clicked()), this, SLOT(showNormalIfMinimized()));
456  connect(privateSendCoinsAction, SIGNAL(clicked()), this, SLOT(gotoPrivateSendCoinsPage()));
457  connect(privateSendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
458  connect(privateSendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoPrivateSendCoinsPage()));
459  connect(receiveCoinsAction, SIGNAL(clicked()), this, SLOT(showNormalIfMinimized()));
460  connect(receiveCoinsAction, SIGNAL(clicked()), this, SLOT(gotoReceiveCoinsPage()));
461  connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
462  connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
463  connect(historyAction, SIGNAL(clicked()), this, SLOT(showNormalIfMinimized()));
464  connect(historyAction, SIGNAL(clicked()), this, SLOT(gotoHistoryPage()));
465 
466  for (auto button : tabGroup->buttons()) {
468  }
470 
471  // Give the selected tab button a bolder font.
472  connect(tabGroup, SIGNAL(buttonToggled(QAbstractButton *, bool)), this, SLOT(highlightTabButton(QAbstractButton *, bool)));
473 #endif // ENABLE_WALLET
474 
475  quitAction = new QAction(tr("E&xit"), this);
476  quitAction->setStatusTip(tr("Quit application"));
477  quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
478  quitAction->setMenuRole(QAction::QuitRole);
479  aboutAction = new QAction(tr("&About %1").arg(tr(PACKAGE_NAME)), this);
480  aboutAction->setStatusTip(tr("Show information about Dash Core"));
481  aboutAction->setMenuRole(QAction::AboutRole);
482  aboutAction->setEnabled(false);
483  aboutQtAction = new QAction(tr("About &Qt"), this);
484  aboutQtAction->setStatusTip(tr("Show information about Qt"));
485  aboutQtAction->setMenuRole(QAction::AboutQtRole);
486  optionsAction = new QAction(tr("&Options..."), this);
487  optionsAction->setStatusTip(tr("Modify configuration options for %1").arg(tr(PACKAGE_NAME)));
488  optionsAction->setMenuRole(QAction::PreferencesRole);
489  optionsAction->setEnabled(false);
490  toggleHideAction = new QAction(tr("&Show / Hide"), this);
491  toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
492 
493  encryptWalletAction = new QAction(tr("&Encrypt Wallet..."), this);
494  encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
495  encryptWalletAction->setCheckable(true);
496  backupWalletAction = new QAction(tr("&Backup Wallet..."), this);
497  backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
498  changePassphraseAction = new QAction(tr("&Change Passphrase..."), this);
499  changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
500  unlockWalletAction = new QAction(tr("&Unlock Wallet..."), this);
501  unlockWalletAction->setToolTip(tr("Unlock wallet"));
502  lockWalletAction = new QAction(tr("&Lock Wallet"), this);
503  signMessageAction = new QAction(tr("Sign &message..."), this);
504  signMessageAction->setStatusTip(tr("Sign messages with your Dash addresses to prove you own them"));
505  verifyMessageAction = new QAction(tr("&Verify message..."), this);
506  verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Dash addresses"));
507 
508  openInfoAction = new QAction(tr("&Information"), this);
509  openInfoAction->setStatusTip(tr("Show diagnostic information"));
510  openRPCConsoleAction = new QAction(tr("&Debug console"), this);
511  openRPCConsoleAction->setStatusTip(tr("Open debugging console"));
512  openGraphAction = new QAction(tr("&Network Monitor"), this);
513  openGraphAction->setStatusTip(tr("Show network monitor"));
514  openPeersAction = new QAction(tr("&Peers list"), this);
515  openPeersAction->setStatusTip(tr("Show peers info"));
516  openRepairAction = new QAction(tr("Wallet &Repair"), this);
517  openRepairAction->setStatusTip(tr("Show wallet repair options"));
518  openConfEditorAction = new QAction(tr("Open Wallet &Configuration File"), this);
519  openConfEditorAction->setStatusTip(tr("Open configuration file"));
520  // override TextHeuristicRole set by default which confuses this action with application settings
521  openConfEditorAction->setMenuRole(QAction::NoRole);
522  showBackupsAction = new QAction(tr("Show Automatic &Backups"), this);
523  showBackupsAction->setStatusTip(tr("Show automatically created wallet backups"));
524  // initially disable the debug window menu items
525  openInfoAction->setEnabled(false);
526  openRPCConsoleAction->setEnabled(false);
527  openGraphAction->setEnabled(false);
528  openPeersAction->setEnabled(false);
529  openRepairAction->setEnabled(false);
530 
531  usedSendingAddressesAction = new QAction(tr("&Sending addresses..."), this);
532  usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
533  usedReceivingAddressesAction = new QAction(tr("&Receiving addresses..."), this);
534  usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
535 
536  openAction = new QAction(tr("Open &URI..."), this);
537  openAction->setStatusTip(tr("Open a dash: URI or payment request"));
538 
539  showHelpMessageAction = new QAction(tr("&Command-line options"), this);
540  showHelpMessageAction->setMenuRole(QAction::NoRole);
541  showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Dash command-line options").arg(tr(PACKAGE_NAME)));
542 
543  showPrivateSendHelpAction = new QAction(tr("&PrivateSend information"), this);
544  showPrivateSendHelpAction->setMenuRole(QAction::NoRole);
545  showPrivateSendHelpAction->setStatusTip(tr("Show the PrivateSend basic information"));
546 
547  connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
548  connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
549  connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
550  connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
551  connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
552  connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked()));
553  connect(showPrivateSendHelpAction, SIGNAL(triggered()), this, SLOT(showPrivateSendHelpClicked()));
554 
555  // Jump directly to tabs in RPC-console
556  connect(openInfoAction, SIGNAL(triggered()), this, SLOT(showInfo()));
557  connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showConsole()));
558  connect(openGraphAction, SIGNAL(triggered()), this, SLOT(showGraph()));
559  connect(openPeersAction, SIGNAL(triggered()), this, SLOT(showPeers()));
560  connect(openRepairAction, SIGNAL(triggered()), this, SLOT(showRepair()));
561 
562  // Open configs and backup folder from menu
563  connect(openConfEditorAction, SIGNAL(triggered()), this, SLOT(showConfEditor()));
564  connect(showBackupsAction, SIGNAL(triggered()), this, SLOT(showBackups()));
565 
566  // Get restart command-line parameters and handle restart
567  connect(rpcConsole, SIGNAL(handleRestart(QStringList)), this, SLOT(handleRestart(QStringList)));
568 
569  // prevents an open debug window from becoming stuck/unusable on client shutdown
570  connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
571 
572 #ifdef ENABLE_WALLET
573  if(walletFrame)
574  {
575  connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
576  connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
577  connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
578  connect(unlockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(unlockWallet()));
579  connect(lockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(lockWallet()));
580  connect(signMessageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
581  connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
582  connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
583  connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
584  connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
585  connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
586  connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
587  }
588 #endif // ENABLE_WALLET
589 
590  new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_I), this, SLOT(showInfo()));
591  new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this, SLOT(showConsole()));
592  new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_G), this, SLOT(showGraph()));
593  new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_P), this, SLOT(showPeers()));
594  new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_R), this, SLOT(showRepair()));
595 }
596 
598 {
599 #ifdef Q_OS_MAC
600  // Create a decoupled menu bar on Mac which stays even if the window is closed
601  appMenuBar = new QMenuBar();
602 #else
603  // Get the main window's menu bar on other platforms
604  appMenuBar = menuBar();
605 #endif
606 
607  // Configure the menus
608  QMenu *file = appMenuBar->addMenu(tr("&File"));
609  if(walletFrame)
610  {
611  file->addAction(openAction);
612  file->addAction(backupWalletAction);
613  file->addAction(signMessageAction);
614  file->addAction(verifyMessageAction);
615  file->addSeparator();
616  file->addAction(usedSendingAddressesAction);
617  file->addAction(usedReceivingAddressesAction);
618  file->addSeparator();
619  }
620  file->addAction(quitAction);
621 
622  QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
623  if(walletFrame)
624  {
625  settings->addAction(encryptWalletAction);
626  settings->addAction(changePassphraseAction);
627  settings->addAction(unlockWalletAction);
628  settings->addAction(lockWalletAction);
629  settings->addSeparator();
630  }
631  settings->addAction(optionsAction);
632 
633  if(walletFrame)
634  {
635  QMenu *tools = appMenuBar->addMenu(tr("&Tools"));
636  tools->addAction(openInfoAction);
637  tools->addAction(openRPCConsoleAction);
638  tools->addAction(openGraphAction);
639  tools->addAction(openPeersAction);
640  tools->addAction(openRepairAction);
641  tools->addSeparator();
642  tools->addAction(openConfEditorAction);
643  tools->addAction(showBackupsAction);
644  }
645 
646  QMenu *help = appMenuBar->addMenu(tr("&Help"));
647  help->addAction(showHelpMessageAction);
648  help->addAction(showPrivateSendHelpAction);
649  help->addSeparator();
650  help->addAction(aboutAction);
651  help->addAction(aboutQtAction);
652 }
653 
655 {
656 #ifdef ENABLE_WALLET
657  if(walletFrame)
658  {
659  QToolBar *toolbar = new QToolBar(tr("Tabs toolbar"));
660  toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
661  toolbar->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
662  toolbar->setToolButtonStyle(Qt::ToolButtonTextOnly);
663 
664  overviewAction->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
665  sendCoinsAction->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
666  privateSendCoinsAction->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
667  receiveCoinsAction->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
668  historyAction->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
669 
670  toolbar->addWidget(overviewAction);
671  toolbar->addWidget(sendCoinsAction);
672  toolbar->addWidget(privateSendCoinsAction);
673  toolbar->addWidget(receiveCoinsAction);
674  toolbar->addWidget(historyAction);
675 
676  QSettings settings;
677  if (settings.value("fShowMasternodesTab").toBool() && masternodeAction) {
678  masternodeAction->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
679  toolbar->addWidget(masternodeAction);
680  }
681  toolbar->setMovable(false); // remove unused icon in upper left corner
682  overviewAction->setChecked(true);
683 
684  QLabel *logoLabel = new QLabel();
685  logoLabel->setObjectName("lblToolbarLogo");
686  logoLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
687 
688  toolbar->addWidget(logoLabel);
689 
693  QVBoxLayout *layout = new QVBoxLayout;
694  layout->addWidget(toolbar);
695  layout->addWidget(walletFrame);
696  layout->setSpacing(0);
697  layout->setContentsMargins(QMargins());
698  QWidget *containerWidget = new QWidget();
699  containerWidget->setLayout(layout);
700  setCentralWidget(containerWidget);
701  }
702 #endif // ENABLE_WALLET
703 }
704 
706 {
707  this->clientModel = _clientModel;
708  if(_clientModel)
709  {
710  // Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
711  // while the client has not yet fully loaded
712  if (trayIcon) {
713  // do so only if trayIcon is already set
714  trayIconMenu = new QMenu(this);
715  trayIcon->setContextMenu(trayIconMenu);
717 
718 #ifndef Q_OS_MAC
719  // Show main window on tray icon click
720  // Note: ignore this on Mac - this is not the way tray should work there
721  connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
722  this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
723 #else
724  // Note: On Mac, the dock icon is also used to provide menu functionality
725  // similar to one for tray icon
727  connect(dockIconHandler, SIGNAL(dockIconClicked()), this, SLOT(macosDockIconActivated()));
728 
729  dockIconMenu = new QMenu(this);
730  dockIconMenu->setAsDockMenu();
731 
733 #endif
734  }
735 
736  // Keep up to date with client
738  setNumConnections(_clientModel->getNumConnections());
739  connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
740  connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool)));
741 
742  modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime()));
743  setNumBlocks(_clientModel->getNumBlocks(), _clientModel->getLastBlockDate(), _clientModel->getLastBlockHash(), _clientModel->getVerificationProgress(nullptr), false);
744  connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,QString,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,QString,double,bool)));
745 
746  connect(_clientModel, SIGNAL(additionalDataSyncProgressChanged(double)), this, SLOT(setAdditionalDataSyncProgress(double)));
747 
748  // Receive and report messages from client model
749  connect(_clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
750 
751  // Show progress dialog
752  connect(_clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
753 
754  rpcConsole->setClientModel(_clientModel);
755 #ifdef ENABLE_WALLET
756  if(walletFrame)
757  {
758  walletFrame->setClientModel(_clientModel);
759  }
760 #endif // ENABLE_WALLET
762 
763  OptionsModel* optionsModel = _clientModel->getOptionsModel();
764  if(optionsModel)
765  {
766  // be aware of the tray icon disable state change reported by the OptionsModel object.
767  connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool)));
768 
769  // initialize the disable state of the tray icon with the current value in the model.
770  setTrayIconVisible(optionsModel->getHideTrayIcon());
771 
772  connect(optionsModel, SIGNAL(privateSendEnabledChanged()), this, SLOT(updatePrivateSendVisibility()));
773  }
774  } else {
775  // Disable possibility to show main window via action
776  toggleHideAction->setEnabled(false);
777  if(trayIconMenu)
778  {
779  // Disable context menu on tray icon
780  trayIconMenu->clear();
781  }
782  // Propagate cleared model to child objects
783  rpcConsole->setClientModel(nullptr);
784 #ifdef ENABLE_WALLET
785  if (walletFrame)
786  {
787  walletFrame->setClientModel(nullptr);
788  }
789 #endif // ENABLE_WALLET
791 
792 #ifdef Q_OS_MAC
793  if(dockIconMenu)
794  {
795  // Disable context menu on dock icon
796  dockIconMenu->clear();
797  }
798 #endif
799  }
800 
802 }
803 
804 #ifdef ENABLE_WALLET
805 bool BitcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
806 {
807  if(!walletFrame)
808  return false;
810  return walletFrame->addWallet(name, walletModel);
811 }
812 
813 bool BitcoinGUI::setCurrentWallet(const QString& name)
814 {
815  if(!walletFrame)
816  return false;
818 }
819 
820 void BitcoinGUI::removeAllWallets()
821 {
822  if(!walletFrame)
823  return;
826 }
827 #endif // ENABLE_WALLET
828 
830 {
831  overviewAction->setEnabled(enabled);
832  sendCoinsAction->setEnabled(enabled);
833  sendCoinsMenuAction->setEnabled(enabled);
834 #ifdef ENABLE_WALLET
837 #else
838  privateSendCoinsAction->setEnabled(enabled);
839  privateSendCoinsMenuAction->setEnabled(enabled);
840 #endif // ENABLE_WALLET
841  receiveCoinsAction->setEnabled(enabled);
842  receiveCoinsMenuAction->setEnabled(enabled);
843  historyAction->setEnabled(enabled);
844  QSettings settings;
845  if (settings.value("fShowMasternodesTab").toBool() && masternodeAction) {
846  masternodeAction->setEnabled(enabled);
847  }
848  encryptWalletAction->setEnabled(enabled);
849  backupWalletAction->setEnabled(enabled);
850  changePassphraseAction->setEnabled(enabled);
851  signMessageAction->setEnabled(enabled);
852  verifyMessageAction->setEnabled(enabled);
853  usedSendingAddressesAction->setEnabled(enabled);
854  usedReceivingAddressesAction->setEnabled(enabled);
855  openAction->setEnabled(enabled);
856 }
857 
858 void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
859 {
860  trayIcon = new QSystemTrayIcon(this);
861  QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
862  trayIcon->setToolTip(toolTip);
863  trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
864  trayIcon->hide();
865  notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
866 }
867 
868 void BitcoinGUI::createIconMenu(QMenu *pmenu)
869 {
870  // Configuration of the tray icon (or dock icon) icon menu
871  pmenu->addAction(toggleHideAction);
872  pmenu->addSeparator();
873  pmenu->addAction(sendCoinsMenuAction);
874  pmenu->addAction(privateSendCoinsMenuAction);
875  pmenu->addAction(receiveCoinsMenuAction);
876  pmenu->addSeparator();
877  pmenu->addAction(signMessageAction);
878  pmenu->addAction(verifyMessageAction);
879  pmenu->addSeparator();
880  pmenu->addAction(optionsAction);
881  pmenu->addAction(openInfoAction);
882  pmenu->addAction(openRPCConsoleAction);
883  pmenu->addAction(openGraphAction);
884  pmenu->addAction(openPeersAction);
885  pmenu->addAction(openRepairAction);
886  pmenu->addSeparator();
887  pmenu->addAction(openConfEditorAction);
888  pmenu->addAction(showBackupsAction);
889 #ifndef Q_OS_MAC // This is built-in on Mac
890  pmenu->addSeparator();
891  pmenu->addAction(quitAction);
892 #endif
893 }
894 
895 #ifndef Q_OS_MAC
896 void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
897 {
898  if(reason == QSystemTrayIcon::Trigger)
899  {
900  // Click on system tray icon triggers show/hide of the main window
901  toggleHidden();
902  }
903 }
904 #else
905 void BitcoinGUI::macosDockIconActivated()
906 {
908  activateWindow();
909 }
910 #endif
911 
913 {
915  return;
916 
917  OptionsDialog dlg(this, enableWallet);
919  connect(&dlg, &OptionsDialog::appearanceChanged, [=]() {
920  updateWidth();
921  });
922  dlg.exec();
923 
925 }
926 
928 {
929  if(!clientModel)
930  return;
931 
933  dlg.exec();
934 }
935 
937 {
939 }
940 
942 {
944  showDebugWindow();
945 }
946 
948 {
950  showDebugWindow();
951 }
952 
954 {
956  showDebugWindow();
957 }
958 
960 {
962  showDebugWindow();
963 }
964 
966 {
968  showDebugWindow();
969 }
970 
972 {
974 }
975 
977 {
979 }
980 
982 {
983  helpMessageDialog->show();
984 }
985 
987 {
988  if(!clientModel)
989  return;
990 
992  dlg.exec();
993 }
994 
995 #ifdef ENABLE_WALLET
996 void BitcoinGUI::openClicked()
997 {
998  OpenURIDialog dlg(this);
999  if(dlg.exec())
1000  {
1001  Q_EMIT receivedURI(dlg.getURI());
1002  }
1003 }
1004 
1005 void BitcoinGUI::highlightTabButton(QAbstractButton *button, bool checked)
1006 {
1009 }
1010 
1011 void BitcoinGUI::gotoOverviewPage()
1012 {
1013  overviewAction->setChecked(true);
1015 }
1016 
1017 void BitcoinGUI::gotoHistoryPage()
1018 {
1019  historyAction->setChecked(true);
1021 }
1022 
1023 void BitcoinGUI::gotoMasternodePage()
1024 {
1025  QSettings settings;
1026  if (settings.value("fShowMasternodesTab").toBool() && masternodeAction) {
1027  masternodeAction->setChecked(true);
1029  }
1030 }
1031 
1032 void BitcoinGUI::gotoReceiveCoinsPage()
1033 {
1034  receiveCoinsAction->setChecked(true);
1036 }
1037 
1038 void BitcoinGUI::gotoSendCoinsPage(QString addr)
1039 {
1040  sendCoinsAction->setChecked(true);
1042 }
1043 
1044 void BitcoinGUI::gotoPrivateSendCoinsPage(QString addr)
1045 {
1046  privateSendCoinsAction->setChecked(true);
1048 }
1049 
1050 void BitcoinGUI::gotoSignMessageTab(QString addr)
1051 {
1053 }
1054 
1055 void BitcoinGUI::gotoVerifyMessageTab(QString addr)
1056 {
1058 }
1059 #endif // ENABLE_WALLET
1060 
1062 {
1063  static int nCountPrev{0};
1064  static bool fNetworkActivePrev{false};
1066  bool fNetworkActive = clientModel->getNetworkActive();
1067  QString icon;
1069  switch(count)
1070  {
1071  case 0: icon = "connect_4"; color = GUIUtil::ThemedColor::ICON_ALTERNATIVE_COLOR; break;
1072  case 1: case 2: icon = "connect_1"; break;
1073  case 3: case 4: case 5: icon = "connect_2"; break;
1074  case 6: case 7: icon = "connect_3"; break;
1075  default: icon = "connect_4"; color = GUIUtil::ThemedColor::GREEN; break;
1076  }
1077 
1078  labelBlocksIcon->setVisible(count > 0);
1080 
1081  bool fNetworkBecameActive = (!fNetworkActivePrev && fNetworkActive) || (nCountPrev == 0 && count > 0);
1082  bool fNetworkBecameInactive = (fNetworkActivePrev && !fNetworkActive) || (nCountPrev > 0 && count == 0);
1083 
1084  if (fNetworkBecameActive) {
1085  // If the sync process still signals synced after five seconds represent it in the UI.
1086  if (masternodeSync.IsSynced()) {
1087  QTimer::singleShot(5000, this, [&]() {
1090  }
1091  });
1092  }
1093  startSpinner();
1094  } else if (fNetworkBecameInactive) {
1095  labelBlocksIcon->hide();
1096  stopSpinner();
1097  }
1098 
1099  if (fNetworkBecameActive || fNetworkBecameInactive) {
1101  }
1102 
1103  nCountPrev = count;
1104  fNetworkActivePrev = fNetworkActive;
1105 
1106  if (fNetworkActive) {
1107  labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Dash network", "", count));
1108  } else {
1109  labelConnectionsIcon->setToolTip(tr("Network activity disabled"));
1110  icon = "connect_4";
1111  color = GUIUtil::ThemedColor::RED;
1112  }
1113 
1114  if (fNetworkActive && count == 0) {
1116  }
1117  if (!fNetworkActive || count > 0) {
1120  }
1121 }
1122 
1124 {
1126 }
1127 
1128 void BitcoinGUI::setNetworkActive(bool networkActive)
1129 {
1131 }
1132 
1134 {
1135  int64_t headersTipTime = clientModel->getHeaderTipTime();
1136  int headersTipHeight = clientModel->getHeaderTipHeight();
1137  int estHeadersLeft = (GetTime() - headersTipTime) / Params().GetConsensus().nPowTargetSpacing;
1138  if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
1139  progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
1140 }
1141 
1143 {
1144  if (clientModel == nullptr) {
1145  return;
1146  }
1147  // Show the progress bar label if the network is active + we are out of sync or we have no connections.
1148  bool fShowProgressBarLabel = clientModel->getNetworkActive() && (!masternodeSync.IsSynced() || clientModel->getNumConnections() == 0);
1149  // Show the progress bar only if the the network active + we are not synced + we have any connection. Unlike with the label
1150  // which gives an info text about the connecting phase there is no reason to show the progress bar if we don't have connections
1151  // since it will not get any updates in this case.
1152  bool fShowProgressBar = clientModel->getNetworkActive() && !masternodeSync.IsSynced() && clientModel->getNumConnections() > 0;
1153  progressBarLabel->setVisible(fShowProgressBarLabel);
1154  progressBar->setVisible(fShowProgressBar);
1155 }
1156 
1158 {
1159 #ifdef ENABLE_WALLET
1160  bool fEnabled = privateSendClient.fEnablePrivateSend;
1161 #else
1162  bool fEnabled = false;
1163 #endif
1164  // PrivateSend button is the third QToolButton, show/hide the underlying QAction
1165  // Hiding the QToolButton itself doesn't work.
1166  qobject_cast<QToolBar*>(centralWidget()->layout()->itemAt(0)->widget())->actions()[2]->setVisible(fEnabled);
1167  privateSendCoinsMenuAction->setVisible(fEnabled);
1168  showPrivateSendHelpAction->setVisible(fEnabled);
1170  updateWidth();
1171 }
1172 
1174 {
1175  int nWidthWidestButton{0};
1176  int nButtonsVisible{0};
1177  for (QAbstractButton* button : tabGroup->buttons()) {
1178  if (!button->isEnabled()) {
1179  continue;
1180  }
1181  QFontMetrics fm(button->font());
1182  nWidthWidestButton = std::max<int>(nWidthWidestButton, fm.width(button->text()));
1183  ++nButtonsVisible;
1184  }
1185  // Add 30 per button as padding and use minimum 980 which is the minimum required to show all tab's contents
1186  // Use nButtonsVisible + 1 <- for the dash logo
1187  int nWidth = std::max<int>(980, (nWidthWidestButton + 30) * (nButtonsVisible + 1));
1188  setMinimumWidth(nWidth);
1189  resize(nWidth, height());
1190 }
1191 
1193 {
1194 #ifdef Q_OS_MAC
1195  auto modifier = Qt::CTRL;
1196 #else
1197  auto modifier = Qt::ALT;
1198 #endif
1199  int nKey = 0;
1200  for (int i = 0; i < tabGroup->buttons().size(); ++i) {
1201  if (qobject_cast<QToolBar*>(centralWidget()->layout()->itemAt(0)->widget())->actions()[i]->isVisible()) {
1202  tabGroup->buttons()[i]->setShortcut(QKeySequence(modifier + Qt::Key_1 + nKey++));
1203  } else {
1204  tabGroup->buttons()[i]->setShortcut(QKeySequence());
1205  }
1206  }
1207 }
1208 
1209 void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, const QString& blockHash, double nVerificationProgress, bool header)
1210 {
1211 #ifdef Q_OS_MAC
1212  // Disabling macOS App Nap on initial sync, disk, reindex operations and mixing.
1213  bool disableAppNap = !masternodeSync.IsSynced();
1214 #ifdef ENABLE_WALLET
1215  disableAppNap |= privateSendClient.fPrivateSendRunning;
1216 #endif // ENABLE_WALLET
1217  if (disableAppNap) {
1218  m_app_nap_inhibitor->disableAppNap();
1219  } else {
1220  m_app_nap_inhibitor->enableAppNap();
1221  }
1222 #endif // Q_OS_MAC
1223 
1224  if (modalOverlay)
1225  {
1226  if (header)
1227  modalOverlay->setKnownBestHeight(count, blockDate);
1228  else
1229  modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
1230  }
1231  if (!clientModel)
1232  return;
1233 
1235 
1236  // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbled text)
1237  statusBar()->clearMessage();
1238 
1239  // Acquire current block source
1240  enum BlockSource blockSource = clientModel->getBlockSource();
1241  switch (blockSource) {
1242  case BLOCK_SOURCE_NETWORK:
1243  if (header) {
1245  return;
1246  }
1247  progressBarLabel->setText(tr("Synchronizing with network..."));
1249  break;
1250  case BLOCK_SOURCE_DISK:
1251  if (header) {
1252  progressBarLabel->setText(tr("Indexing blocks on disk..."));
1253  } else {
1254  progressBarLabel->setText(tr("Processing blocks on disk..."));
1255  }
1256  break;
1257  case BLOCK_SOURCE_REINDEX:
1258  progressBarLabel->setText(tr("Reindexing blocks on disk..."));
1259  break;
1260  case BLOCK_SOURCE_NONE:
1261  if (header) {
1262  return;
1263  }
1264  progressBarLabel->setText(tr("Connecting to peers..."));
1265  break;
1266  }
1267 
1268  QString tooltip;
1269 
1270  QDateTime currentDate = QDateTime::currentDateTime();
1271  qint64 secs = blockDate.secsTo(currentDate);
1272 
1273  tooltip = tr("Processed %n block(s) of transaction history.", "", count);
1274 
1275  // Set icon state: spinning if catching up, tick otherwise
1276 #ifdef ENABLE_WALLET
1277  if (walletFrame)
1278  {
1279  if(secs < 25*60) // 90*60 in bitcoin
1280  {
1281  modalOverlay->showHide(true, true);
1282  // TODO instead of hiding it forever, we should add meaningful information about MN sync to the overlay
1284  }
1285  else
1286  {
1288  }
1289  }
1290 #endif // ENABLE_WALLET
1291 
1293  {
1294  QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);
1295 
1296  progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
1297  progressBar->setMaximum(1000000000);
1298  progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
1299 
1300  tooltip = tr("Catching up...") + QString("<br>") + tooltip;
1301 
1302 #ifdef ENABLE_WALLET
1303  if(walletFrame)
1304  {
1306  }
1307 #endif // ENABLE_WALLET
1308 
1309  tooltip += QString("<br>");
1310  tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
1311  tooltip += QString("<br>");
1312  tooltip += tr("Transactions after this will not yet be visible.");
1313  } else if (fDisableGovernance) {
1315  }
1316 
1317  // Don't word-wrap this (fixed-width) tooltip
1318  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
1319 
1320  labelBlocksIcon->setToolTip(tooltip);
1321  progressBarLabel->setToolTip(tooltip);
1322  progressBar->setToolTip(tooltip);
1323 }
1324 
1326 {
1327  if(!clientModel)
1328  return;
1329 
1330  // If masternodeSync.Reset() has been called make sure status bar shows the correct information.
1331  if (nSyncProgress == -1) {
1333  if (clientModel->getNumConnections()) {
1334  labelBlocksIcon->show();
1335  startSpinner();
1336  }
1337  return;
1338  }
1339 
1340  // No additional data sync should be happening while blockchain is not synced, nothing to update
1342  return;
1343 
1344  // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
1345  statusBar()->clearMessage();
1346 
1347  QString tooltip;
1348 
1349  // Set icon state: spinning if catching up, tick otherwise
1350  QString strSyncStatus;
1351  tooltip = tr("Up to date") + QString(".<br>") + tooltip;
1352 
1353 #ifdef ENABLE_WALLET
1354  if(walletFrame)
1356 #endif // ENABLE_WALLET
1357 
1359 
1360  if(masternodeSync.IsSynced()) {
1361  stopSpinner();
1363  } else {
1364  progressBar->setFormat(tr("Synchronizing additional data: %p%"));
1365  progressBar->setMaximum(1000000000);
1366  progressBar->setValue(nSyncProgress * 1000000000.0 + 0.5);
1367  }
1368 
1369  strSyncStatus = QString(masternodeSync.GetSyncStatus().c_str());
1370  progressBarLabel->setText(strSyncStatus);
1371  tooltip = strSyncStatus + QString("<br>") + tooltip;
1372 
1373  // Don't word-wrap this (fixed-width) tooltip
1374  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
1375 
1376  labelBlocksIcon->setToolTip(tooltip);
1377  progressBarLabel->setToolTip(tooltip);
1378  progressBar->setToolTip(tooltip);
1379 }
1380 
1381 void BitcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
1382 {
1383  QString strTitle = tr("Dash Core"); // default title
1384  // Default to information icon
1385  int nMBoxIcon = QMessageBox::Information;
1386  int nNotifyIcon = Notificator::Information;
1387 
1388  QString msgType;
1389 
1390  // Prefer supplied title over style based title
1391  if (!title.isEmpty()) {
1392  msgType = title;
1393  }
1394  else {
1395  switch (style) {
1397  msgType = tr("Error");
1398  break;
1400  msgType = tr("Warning");
1401  break;
1403  msgType = tr("Information");
1404  break;
1405  default:
1406  break;
1407  }
1408  }
1409  // Append title to "Dash Core - "
1410  if (!msgType.isEmpty())
1411  strTitle += " - " + msgType;
1412 
1413  // Check for error/warning icon
1414  if (style & CClientUIInterface::ICON_ERROR) {
1415  nMBoxIcon = QMessageBox::Critical;
1416  nNotifyIcon = Notificator::Critical;
1417  }
1418  else if (style & CClientUIInterface::ICON_WARNING) {
1419  nMBoxIcon = QMessageBox::Warning;
1420  nNotifyIcon = Notificator::Warning;
1421  }
1422 
1423  // Display message
1424  if (style & CClientUIInterface::MODAL) {
1425  // Check for buttons, use OK as default, if none was supplied
1426  QMessageBox::StandardButton buttons;
1427  if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
1428  buttons = QMessageBox::Ok;
1429 
1431  QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
1432  mBox.setTextFormat(Qt::PlainText);
1433  int r = mBox.exec();
1434  if (ret != nullptr)
1435  *ret = r == QMessageBox::Ok;
1436  }
1437  else
1438  notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
1439 }
1440 
1442 {
1443  QMainWindow::changeEvent(e);
1444 #ifndef Q_OS_MAC // Ignored on Mac
1445  if(e->type() == QEvent::WindowStateChange)
1446  {
1448  {
1449  QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
1450  if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
1451  {
1452  QTimer::singleShot(0, this, SLOT(hide()));
1453  e->ignore();
1454  }
1455  else if((wsevt->oldState() & Qt::WindowMinimized) && !isMinimized())
1456  {
1457  QTimer::singleShot(0, this, SLOT(show()));
1458  e->ignore();
1459  }
1460  }
1461  }
1462 #endif
1463  if (e->type() == QEvent::StyleChange) {
1465 #ifdef ENABLE_WALLET
1466  updateWalletStatus();
1467 #endif
1468  if (masternodeSync.IsSynced()) {
1470  }
1471  }
1472 }
1473 
1474 void BitcoinGUI::closeEvent(QCloseEvent *event)
1475 {
1476 #ifndef Q_OS_MAC // Ignored on Mac
1478  {
1480  {
1481  // close rpcConsole in case it was open to make some space for the shutdown window
1482  rpcConsole->close();
1483 
1484  QApplication::quit();
1485  }
1486  else
1487  {
1488  QMainWindow::showMinimized();
1489  event->ignore();
1490  }
1491  }
1492 #else
1493  QMainWindow::closeEvent(event);
1494 #endif
1495 }
1496 
1497 void BitcoinGUI::showEvent(QShowEvent *event)
1498 {
1499  // enable the debug window when the main window shows up
1500  openInfoAction->setEnabled(true);
1501  openRPCConsoleAction->setEnabled(true);
1502  openGraphAction->setEnabled(true);
1503  openPeersAction->setEnabled(true);
1504  openRepairAction->setEnabled(true);
1505  aboutAction->setEnabled(true);
1506  optionsAction->setEnabled(true);
1507 
1508  if (!event->spontaneous()) {
1509  updateWidth();
1510  }
1511 }
1512 
1513 #ifdef ENABLE_WALLET
1514 void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label)
1515 {
1516  IncomingTransactionMessage itx = {
1517  date, unit, amount, type, address, label
1518  };
1519  incomingTransactions.emplace_back(itx);
1520 
1521  if (incomingTransactions.size() == 1) {
1522  // first TX since we last showed pending messages, let's wait 100ms and then show each individual message
1523  incomingTransactionsTimer->start(100);
1524  } else if (incomingTransactions.size() == 10) {
1525  // we seem to have received 10 TXs in 100ms and we can expect even more, so let's pause for 1 sec and
1526  // show a "Multiple TXs sent/received!" message instead of individual messages
1527  incomingTransactionsTimer->start(1000);
1528  }
1529 }
1530 void BitcoinGUI::showIncomingTransactions()
1531 {
1532  auto txs = std::move(this->incomingTransactions);
1533 
1534  if (txs.empty()) {
1535  return;
1536  }
1537 
1538  if (txs.size() >= 100) {
1539  // Show one balloon for all transactions instead of showing one for each individual one
1540  // (which would kill some systems)
1541 
1542  CAmount sentAmount = 0;
1543  CAmount receivedAmount = 0;
1544  int sentCount = 0;
1545  int receivedCount = 0;
1546  for (auto& itx : txs) {
1547  if (itx.amount < 0) {
1548  sentAmount += itx.amount;
1549  sentCount++;
1550  } else {
1551  receivedAmount += itx.amount;
1552  receivedCount++;
1553  }
1554  }
1555 
1556  QString title;
1557  if (sentCount > 0 && receivedCount > 0) {
1558  title = tr("Received and sent multiple transactions");
1559  } else if (sentCount > 0) {
1560  title = tr("Sent multiple transactions");
1561  } else if (receivedCount > 0) {
1562  title = tr("Received multiple transactions");
1563  } else {
1564  return;
1565  }
1566 
1567  // Use display unit of last entry
1568  int unit = txs.back().unit;
1569 
1570  QString msg;
1571  if (sentCount > 0) {
1572  msg += tr("Sent Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, sentAmount, true));
1573  }
1574  if (receivedCount > 0) {
1575  msg += tr("Received Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, receivedAmount, true));
1576  }
1577 
1579  } else {
1580  for (auto& itx : txs) {
1581  // On new transaction, make an info balloon
1582  QString msg = tr("Date: %1\n").arg(itx.date) +
1583  tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(itx.unit, itx.amount, true)) +
1584  tr("Type: %1\n").arg(itx.type);
1585  if (!itx.label.isEmpty())
1586  msg += tr("Label: %1\n").arg(itx.label);
1587  else if (!itx.address.isEmpty())
1588  msg += tr("Address: %1\n").arg(itx.address);
1589  message((itx.amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
1591  }
1592  }
1593 }
1594 #endif // ENABLE_WALLET
1595 
1596 void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
1597 {
1598  // Accept only URIs
1599  if(event->mimeData()->hasUrls())
1600  event->acceptProposedAction();
1601 }
1602 
1603 void BitcoinGUI::dropEvent(QDropEvent *event)
1604 {
1605  if(event->mimeData()->hasUrls())
1606  {
1607  for (const QUrl &uri : event->mimeData()->urls())
1608  {
1609  Q_EMIT receivedURI(uri.toString());
1610  }
1611  }
1612  event->acceptProposedAction();
1613 }
1614 
1615 bool BitcoinGUI::eventFilter(QObject *object, QEvent *event)
1616 {
1617  // Catch status tip events
1618  if (event->type() == QEvent::StatusTip)
1619  {
1620  // Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
1621  if (progressBarLabel->isVisible() || progressBar->isVisible())
1622  return true;
1623  }
1624  return QMainWindow::eventFilter(object, event);
1625 }
1626 
1627 #ifdef ENABLE_WALLET
1628 bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
1629 {
1630  // URI has to be valid
1631  if (walletFrame && walletFrame->handlePaymentRequest(recipient))
1632  {
1634  gotoSendCoinsPage();
1635  return true;
1636  }
1637  return false;
1638 }
1639 
1640 void BitcoinGUI::setHDStatus(int hdEnabled)
1641 {
1642  if (hdEnabled) {
1644  labelWalletHDStatusIcon->setToolTip(tr("HD key generation is <b>enabled</b>"));
1645  }
1646  labelWalletHDStatusIcon->setVisible(hdEnabled);
1647 }
1648 
1649 void BitcoinGUI::setEncryptionStatus(int status)
1650 {
1651  switch(status)
1652  {
1654  labelWalletEncryptionIcon->show();
1656  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>unencrypted</b>"));
1657  encryptWalletAction->setChecked(false);
1658  changePassphraseAction->setEnabled(false);
1659  unlockWalletAction->setVisible(false);
1660  lockWalletAction->setVisible(false);
1661  encryptWalletAction->setEnabled(true);
1662  break;
1663  case WalletModel::Unlocked:
1664  labelWalletEncryptionIcon->show();
1666  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
1667  encryptWalletAction->setChecked(true);
1668  changePassphraseAction->setEnabled(true);
1669  unlockWalletAction->setVisible(false);
1670  lockWalletAction->setVisible(true);
1671  encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
1672  break;
1674  labelWalletEncryptionIcon->show();
1676  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b> for mixing only"));
1677  encryptWalletAction->setChecked(true);
1678  changePassphraseAction->setEnabled(true);
1679  unlockWalletAction->setVisible(true);
1680  lockWalletAction->setVisible(true);
1681  encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
1682  break;
1683  case WalletModel::Locked:
1684  labelWalletEncryptionIcon->show();
1686  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
1687  encryptWalletAction->setChecked(true);
1688  changePassphraseAction->setEnabled(true);
1689  unlockWalletAction->setVisible(true);
1690  lockWalletAction->setVisible(false);
1691  encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
1692  break;
1693  }
1694 }
1695 
1696 void BitcoinGUI::updateWalletStatus()
1697 {
1698  if (!walletFrame) {
1699  return;
1700  }
1701  WalletView * const walletView = walletFrame->currentWalletView();
1702  if (!walletView) {
1703  return;
1704  }
1705  WalletModel * const walletModel = walletView->getWalletModel();
1706  setEncryptionStatus(walletModel->getEncryptionStatus());
1707  setHDStatus(walletModel->hdEnabled());
1708 }
1709 #endif // ENABLE_WALLET
1710 
1711 void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
1712 {
1713  if(!clientModel)
1714  return;
1715 
1716  if (!isHidden() && !isMinimized() && !GUIUtil::isObscured(this) && fToggleHidden) {
1717  hide();
1718  } else {
1719  GUIUtil::bringToFront(this);
1720  }
1721 }
1722 
1724 {
1725  showNormalIfMinimized(true);
1726 }
1727 
1729 {
1730  if (ShutdownRequested())
1731  {
1732  if(rpcConsole)
1733  rpcConsole->hide();
1734  qApp->quit();
1735  }
1736 }
1737 
1738 void BitcoinGUI::showProgress(const QString &title, int nProgress)
1739 {
1740  if (nProgress == 0)
1741  {
1742  progressDialog = new QProgressDialog(title, "", 0, 100, this);
1743  progressDialog->setWindowModality(Qt::ApplicationModal);
1744  progressDialog->setMinimumDuration(0);
1745  progressDialog->setCancelButton(0);
1746  progressDialog->setAutoClose(false);
1747  progressDialog->setValue(0);
1748  }
1749  else if (nProgress == 100)
1750  {
1751  if (progressDialog)
1752  {
1753  progressDialog->close();
1754  progressDialog->deleteLater();
1755  }
1756  }
1757  else if (progressDialog)
1758  progressDialog->setValue(nProgress);
1759 }
1760 
1761 void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
1762 {
1763  if (trayIcon)
1764  {
1765  trayIcon->setVisible(!fHideTrayIcon);
1766  }
1767 }
1768 
1770 {
1771  if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))
1773 }
1774 
1775 static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
1776 {
1777  bool modal = (style & CClientUIInterface::MODAL);
1778  // The SECURE flag has no effect in the Qt GUI.
1779  // bool secure = (style & CClientUIInterface::SECURE);
1780  style &= ~CClientUIInterface::SECURE;
1781  bool ret = false;
1782  // In case of modal message, use blocking connection to wait for user to click a button
1783  QMetaObject::invokeMethod(gui, "message",
1784  modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
1785  Q_ARG(QString, QString::fromStdString(caption)),
1786  Q_ARG(QString, QString::fromStdString(message)),
1787  Q_ARG(unsigned int, style),
1788  Q_ARG(bool*, &ret));
1789  return ret;
1790 }
1791 
1793 {
1794  // Connect signals to client
1795  uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
1796  uiInterface.ThreadSafeQuestion.connect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
1797 }
1798 
1800 {
1801  // Disconnect signals from client
1802  uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
1803  uiInterface.ThreadSafeQuestion.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
1804 }
1805 
1807 {
1808  if (clientModel) {
1810  }
1811 }
1812 
1814 void BitcoinGUI::handleRestart(QStringList args)
1815 {
1816  if (!ShutdownRequested())
1817  Q_EMIT requestedRestart(args);
1818 }
1819 
1821  optionsModel(0),
1822  menu(0)
1823 {
1825  setToolTip(tr("Unit to show amounts in. Click to select another unit."));
1826  QList<BitcoinUnits::Unit> units = BitcoinUnits::availableUnits();
1827  int max_width = 0;
1828  const QFontMetrics fm(GUIUtil::getFontNormal());
1829  for (const BitcoinUnits::Unit unit : units)
1830  {
1831  max_width = qMax(max_width, fm.width(BitcoinUnits::name(unit)));
1832  }
1833  setMinimumSize(max_width, 0);
1834  setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1835 }
1836 
1839 {
1840  onDisplayUnitsClicked(event->pos());
1841 }
1842 
1845 {
1846  menu = new QMenu(this);
1848  {
1849  QAction *menuAction = new QAction(QString(BitcoinUnits::name(u)), this);
1850  menuAction->setData(QVariant(u));
1851  menu->addAction(menuAction);
1852  }
1853  connect(menu,SIGNAL(triggered(QAction*)),this,SLOT(onMenuSelection(QAction*)));
1854 }
1855 
1858 {
1859  if (_optionsModel)
1860  {
1861  this->optionsModel = _optionsModel;
1862 
1863  // be aware of a display unit change reported by the OptionsModel object.
1864  connect(_optionsModel,SIGNAL(displayUnitChanged(int)),this,SLOT(updateDisplayUnit(int)));
1865 
1866  // initialize the display units label with the current value in the model.
1867  updateDisplayUnit(_optionsModel->getDisplayUnit());
1868  }
1869 }
1870 
1873 {
1874  setText(BitcoinUnits::name(newUnits));
1875 }
1876 
1879 {
1880  QPoint globalPos = mapToGlobal(point);
1881  menu->exec(globalPos);
1882 }
1883 
1886 {
1887  if (action)
1888  {
1889  optionsModel->setDisplayUnit(action->data());
1890  }
1891 }
void showConfEditor()
Open external (default) editor with dash.conf.
Definition: bitcoingui.cpp:971
void subscribeToCoreSignals()
Connect core signals to GUI client.
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
Definition: walletframe.cpp:95
bool setCurrentWallet(const QString &name)
Definition: walletframe.cpp:65
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
UnitDisplayStatusBarControl * unitDisplayControl
Definition: bitcoingui.h:91
Local Bitcoin RPC console.
Definition: rpcconsole.h:32
QMenuBar * appMenuBar
Definition: bitcoingui.h:100
static const QString DEFAULT_WALLET
Display name for default wallet name.
Definition: bitcoingui.h:54
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.
CMasternodeSync masternodeSync
Unit
Dash units.
Definition: bitcoinunits.h:58
void showPeers()
Definition: bitcoingui.cpp:959
QAction * signMessageAction
Definition: bitcoingui.h:111
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
void appearanceChanged()
bool getNetworkActive() const
Return true if network activity in core is enabled.
QAction * aboutAction
Definition: bitcoingui.h:113
void updateNetworkState()
Update UI with latest network info from model.
void updateToolBarShortcuts()
void gotoMasternodePage()
Switch to masternode page.
QLabel * labelWalletHDStatusIcon
Definition: bitcoingui.h:93
void showNormalIfMinimized(bool fToggleHidden=false)
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
void mousePressEvent(QMouseEvent *event)
So that it responds to left-button clicks.
QProgressDialog * progressDialog
Definition: bitcoingui.h:98
static bool isWalletEnabled()
void setAdditionalDataSyncProgress(double nSyncProgress)
Set additional data sync status shown in the UI.
QMenu * trayIconMenu
Definition: bitcoingui.h:136
void setFont(const std::vector< QWidget *> &vecWidgets, FontWeight weight, int nPointSize, bool fItalic)
Workaround to set correct font styles in all themes since there is a bug in macOS which leads to issu...
Definition: guiutil.cpp:1552
void showDebugWindow()
Show debug window.
Definition: bitcoingui.cpp:936
bool ShutdownRequested()
Definition: init.cpp:179
ClientModel * clientModel
Definition: bitcoingui.h:88
WalletView * currentWalletView()
void createToolBars()
Create the toolbars.
Definition: bitcoingui.cpp:654
ModalOverlay * modalOverlay
Definition: bitcoingui.h:141
QButtonGroup * tabGroup
Definition: bitcoingui.h:142
RPCConsole * rpcConsole
Definition: bitcoingui.h:139
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const std::string &message, const std::string &caption, unsigned int style)
QAction * verifyMessageAction
Definition: bitcoingui.h:112
QAction * quitAction
Definition: bitcoingui.h:104
static constexpr int HEADER_HEIGHT_DELTA_SYNC
The required delta of headers to the estimated number of available headers until we show the IBD prog...
Definition: modaloverlay.h:12
QAction * openRepairAction
Definition: bitcoingui.h:128
void dropEvent(QDropEvent *event)
QAction * openGraphAction
Definition: bitcoingui.h:126
QFont getFontNormal()
Get the default normal QFont.
Definition: guiutil.cpp:1735
QToolButton * historyAction
Definition: bitcoingui.h:102
void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress)
QToolButton * sendCoinsAction
Definition: bitcoingui.h:105
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
Definition: guiutil.cpp:606
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
Definition: bitcoingui.cpp:829
QAction * aboutQtAction
Definition: bitcoingui.h:123
QAction * openPeersAction
Definition: bitcoingui.h:127
void startConnectingAnimation()
Start the connecting animation.
Definition: bitcoingui.cpp:340
OptionsModel * getOptionsModel()
macOS-specific Dock icon handler.
QToolButton * masternodeAction
Definition: bitcoingui.h:103
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated...
Definition: ui_interface.h:60
Bitcoin GUI main class.
Definition: bitcoingui.h:49
bool isLayerVisible() const
Definition: modaloverlay.h:36
HelpMessageDialog * helpMessageDialog
Definition: bitcoingui.h:140
QLabel * progressBarLabel
Definition: bitcoingui.h:96
QSystemTrayIcon * trayIcon
Definition: bitcoingui.h:135
QAction * showHelpMessageAction
Definition: bitcoingui.h:132
bool IsBlockchainSynced()
Notify user of potential problem.
Definition: notificator.h:39
Modal overlay to display information about the chain-sync state.
Definition: modaloverlay.h:19
const QString & getTitleAddText() const
Definition: networkstyle.h:24
Signals for UI communication.
Definition: ui_interface.h:28
void removeAllWallets()
Definition: walletframe.cpp:87
QAction * backupWalletAction
Definition: bitcoingui.h:119
void setOptionsModel(OptionsModel *optionsModel)
Lets the control know about the Options Model (and its signals)
QLabel * labelConnectionsIcon
Definition: bitcoingui.h:94
void bringToFront(QWidget *w)
Definition: guiutil.cpp:634
void handleRestart(QStringList args)
Get restart command-line parameters and request restart.
EncryptionStatus getEncryptionStatus() const
int getDisplayUnit() const
Definition: optionsmodel.h:82
Force blocking, modal message box dialog (not just OS notification)
Definition: ui_interface.h:64
void showOutOfSyncWarning(bool fShow)
QToolButton * receiveCoinsAction
Definition: bitcoingui.h:114
QAction * unlockWalletAction
Definition: bitcoingui.h:121
void setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:584
void gotoHistoryPage()
Switch to history (transactions) page.
QAction * usedReceivingAddressesAction
Definition: bitcoingui.h:110
void openConfigfile()
Definition: guiutil.cpp:661
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
void setClientModel(ClientModel *clientModel)
Set the client model.
Definition: bitcoingui.cpp:705
WalletModel * getWalletModel()
Definition: walletview.h:48
void showModalOverlay()
void showInfo()
Show debug window and set focus to the appropriate tab.
Definition: bitcoingui.cpp:941
int64_t GetTime()
Return system time (or mocked time, if set)
Definition: utiltime.cpp:22
void updateFonts()
Update the font of all widgets where a custom font has been set with GUIUtil::setFont.
Definition: guiutil.cpp:1563
QTimer * timerConnecting
Timer to update the connection icon during connecting phase.
Definition: bitcoingui.h:156
false
Definition: bls_dkg.cpp:168
void gotoOverviewPage()
Switch to overview (home) page.
void startSpinner()
Start the spinner animation in the status bar if it&#39;s not running and if labelBlocksIcon is visible...
Definition: bitcoingui.cpp:301
QAction * toggleHideAction
Definition: bitcoingui.h:117
void showProgress(const QString &title, int nProgress)
Show progress dialog e.g.
static MacDockIconHandler * instance()
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void setClientModel(ClientModel *clientModel)
Definition: walletframe.cpp:36
bool isObscured(QWidget *w)
Definition: guiutil.cpp:625
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:62
OptionsModel * optionsModel
Definition: bitcoingui.h:343
double getVerificationProgress(const CBlockIndex *tip) const
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
void setKnownBestHeight(int count, const QDateTime &blockDate)
QTimer * incomingTransactionsTimer
Definition: bitcoingui.h:171
void optionsClicked()
Show configuration dialog.
Definition: bitcoingui.cpp:912
QToolButton * privateSendCoinsAction
Definition: bitcoingui.h:107
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
void stopSpinner()
Stop the spinner animation in the status bar.
Definition: bitcoingui.cpp:331
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.
bool eventFilter(QObject *object, QEvent *event)
const char * name
Definition: rest.cpp:36
QLabel * labelBlocksIcon
Definition: bitcoingui.h:95
bool addWallet(const QString &name, WalletModel *walletModel)
Definition: walletframe.cpp:41
std::string GetSyncStatus()
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:27
WalletFrame * walletFrame
Definition: bitcoingui.h:89
void updateDisplayUnit(int newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
void showConsole()
Definition: bitcoingui.cpp:947
void showRepair()
Definition: bitcoingui.cpp:965
QAction * usedSendingAddressesAction
Definition: bitcoingui.h:109
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
int64_t nPowTargetSpacing
Definition: params.h:176
QString getLastBlockHash() const
void createIconMenu(QMenu *pmenu)
Create system tray menu (or setup the dock menu)
Definition: bitcoingui.cpp:868
void setTrayIconVisible(bool)
When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly.
void toggleVisibility()
QIcon getIcon(const QString &strIcon, const ThemedColor color, const ThemedColor colorAlternative, const QString &strIconPath)
Helper to get an icon colorized with the given color (replaces black) and colorAlternative (replaces ...
Definition: guiutil.cpp:216
bool enableWallet
Definition: bitcoingui.h:77
void setModel(OptionsModel *model)
QAction * openRPCConsoleAction
Definition: bitcoingui.h:125
void gotoPrivateSendCoinsPage(QString addr="")
Switch to PrivateSend coins page.
QAction * openConfEditorAction
Definition: bitcoingui.h:129
void detectShutdown()
called by a timer to check if fRequestShutdown has been set
Cross-platform desktop notification client.
Definition: notificator.h:24
QLabel * labelWalletEncryptionIcon
Definition: bitcoingui.h:92
void showGraph()
Definition: bitcoingui.cpp:953
void requestedRestart(QStringList args)
Restart handling.
Informational message.
Definition: notificator.h:38
UniValue help(const JSONRPCRequest &jsonRequest)
Definition: server.cpp:263
void showHelpMessageClicked()
Show help message dialog.
Definition: bitcoingui.cpp:981
void dragEnterEvent(QDragEnterEvent *event)
Notificator * notificator
Definition: bitcoingui.h:138
Model for Dash network client.
Definition: clientmodel.h:42
void updateProgressBarVisibility()
An error occurred.
Definition: notificator.h:40
BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent=0)
Definition: bitcoingui.cpp:83
const QIcon & getTrayAndWindowIcon() const
Definition: networkstyle.h:23
#define MOVIES_PATH
Path to the movies ressource folder.
Definition: guiconstants.h:28
QAction * receiveCoinsMenuAction
Definition: bitcoingui.h:115
ClickableProgressBar ProgressBar
Definition: guiutil.h:430
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
static QString name(int unit)
Short name.
void showHide(bool hide=false, bool userRequested=false)
void toggleNetworkActive()
Toggle networking.
static const int STATUSBAR_ICONSIZE
Definition: guiconstants.h:16
QDateTime getLastBlockDate() const
QAction * openAction
Definition: bitcoingui.h:131
void showPrivateSendHelpClicked()
Show PrivateSend help message dialog.
Definition: bitcoingui.cpp:986
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
void hideForever()
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
Definition: bitcoingui.cpp:896
bool getMinimizeOnClose() const
Definition: optionsmodel.h:81
ArgsManager gArgs
Definition: util.cpp:108
QAction * changePassphraseAction
Definition: bitcoingui.h:120
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
void showBackups()
Show folder with wallet backups in default file browser.
Definition: bitcoingui.cpp:976
QAction * lockWalletAction
Definition: bitcoingui.h:122
void gotoReceiveCoinsPage()
Switch to receive coins page.
void closeEvent(QCloseEvent *event)
bool hdEnabled() const
CPrivateSendClientManager privateSendClient
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:25
const CChainParams & Params()
Return the currently selected parameters.
bool getMinimizeToTray() const
Definition: optionsmodel.h:80
void setNumBlocks(int count, const QDateTime &blockDate, const QString &blockHash, double nVerificationProgress, bool headers)
Set number of blocks and last block date shown in the UI.
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:100
void stopConnectingAnimation()
Stop the connecting animation.
Definition: bitcoingui.cpp:374
QAction * sendCoinsMenuAction
Definition: bitcoingui.h:106
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
Definition: util.cpp:808
void changeEvent(QEvent *e)
ThemedColor
Definition: guiutil.h:40
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
QAction * openInfoAction
Definition: bitcoingui.h:124
void showEvent(QShowEvent *event)
QAction * showBackupsAction
Definition: bitcoingui.h:130
QProgressBar * progressBar
Definition: bitcoingui.h:97
static int count
Definition: tests.c:45
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 setNumConnections(int count)
Set number of connections shown in the UI.
"Help message" dialog box
Definition: utilitydialog.h:18
void setNetworkActive(bool active)
Toggle network activity state in core.
void showBackups()
Definition: guiutil.cpp:670
Preferences dialog.
Definition: optionsdialog.h:37
QString formatNiceTimeOffset(qint64 secs)
Definition: guiutil.cpp:1898
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
void createContextMenu()
Creates context menu, its actions, and wires up all the relevant signals for mouse events...
QAction * showPrivateSendHelpAction
Definition: bitcoingui.h:133
void createActions()
Create the main UI actions.
Definition: bitcoingui.cpp:383
QAction * optionsAction
Definition: bitcoingui.h:116
CClientUIInterface uiInterface
Definition: ui_interface.cpp:8
QAction * encryptWalletAction
Definition: bitcoingui.h:118
int getNumBlocks() const
void aboutClicked()
Show about dialog.
Definition: bitcoingui.cpp:927
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:54
int getHeaderTipHeight() const
bool fDisableGovernance
Definition: util.cpp:94
void updateHeadersSyncProgressLabel()
static const std::string DEFAULT_UIPLATFORM
Definition: bitcoingui.h:55
void updateWidth()
int64_t getHeaderTipTime() const
A container for embedding all wallet-related controls into BitcoinGUI.
Definition: walletframe.h:28
QToolButton * overviewAction
Definition: bitcoingui.h:101
bool getHideTrayIcon() const
Definition: optionsmodel.h:79
void onDisplayUnitsClicked(const QPoint &point)
Shows context menu with Display Unit options by the mouse coordinates.
QAction * privateSendCoinsMenuAction
Definition: bitcoingui.h:108
void updatePrivateSendVisibility()
QTimer * timerSpinner
Timer to update the spinner animation in the status bar periodically.
Definition: bitcoingui.h:149
void createTrayIcon(const NetworkStyle *networkStyle)
Create system tray icon and notification.
Definition: bitcoingui.cpp:858
void createMenuBar()
Create the menu bar and sub-menus.
Definition: bitcoingui.cpp:597
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:70
QMenu * dockIconMenu
Definition: bitcoingui.h:137
#define SPINNER_FRAMES
Definition: guiconstants.h:42
std::list< IncomingTransactionMessage > incomingTransactions
Definition: bitcoingui.h:170
Released under the MIT license