Bitcoin ABC  0.22.12
P2P Digital Currency
bitcoingui.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <qt/bitcoingui.h>
6 
7 #include <chain.h>
8 #include <chainparams.h>
9 #include <config.h>
10 #include <interfaces/handler.h>
11 #include <interfaces/node.h>
12 #include <node/ui_interface.h>
13 #include <qt/bitcoinunits.h>
14 #include <qt/clientmodel.h>
15 #include <qt/createwalletdialog.h>
16 #include <qt/guiconstants.h>
17 #include <qt/guiutil.h>
18 #ifdef Q_OS_MAC
19 #include <qt/macdockiconhandler.h>
20 #endif
21 #include <qt/modaloverlay.h>
22 #include <qt/networkstyle.h>
23 #include <qt/notificator.h>
24 #include <qt/openuridialog.h>
25 #include <qt/optionsmodel.h>
26 #include <qt/platformstyle.h>
27 #include <qt/rpcconsole.h>
28 #include <qt/utilitydialog.h>
29 #ifdef ENABLE_WALLET
30 #include <qt/walletcontroller.h>
31 #include <qt/walletframe.h>
32 #include <qt/walletmodel.h>
33 #include <qt/walletview.h>
34 #endif // ENABLE_WALLET
35 #include <util/system.h>
36 #include <util/translation.h>
37 #include <validation.h>
38 
39 #include <memory>
40 
41 #include <QAction>
42 #include <QApplication>
43 #include <QComboBox>
44 #include <QDateTime>
45 #include <QDragEnterEvent>
46 #include <QListWidget>
47 #include <QMenu>
48 #include <QMenuBar>
49 #include <QMessageBox>
50 #include <QMimeData>
51 #include <QProgressDialog>
52 #include <QScreen>
53 #include <QSettings>
54 #include <QShortcut>
55 #include <QStackedWidget>
56 #include <QStatusBar>
57 #include <QStyle>
58 #include <QSystemTrayIcon>
59 #include <QTimer>
60 #include <QToolBar>
61 #include <QUrlQuery>
62 #include <QVBoxLayout>
63 #include <QWindow>
64 
65 const std::string BitcoinGUI::DEFAULT_UIPLATFORM =
66 #if defined(Q_OS_MAC)
67  "macosx"
68 #elif defined(Q_OS_WIN)
69  "windows"
70 #else
71  "other"
72 #endif
73  ;
74 
76  const PlatformStyle *_platformStyle,
77  const NetworkStyle *networkStyle, QWidget *parent)
78  : QMainWindow(parent), m_node(node), trayIconMenu{new QMenu()},
79  config(configIn), platformStyle(_platformStyle),
80  m_network_style(networkStyle) {
81  QSettings settings;
82  if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
83  // Restore failed (perhaps missing setting), center the window
84  move(QGuiApplication::primaryScreen()->availableGeometry().center() -
85  frameGeometry().center());
86  }
87 
88 #ifdef ENABLE_WALLET
90 #endif // ENABLE_WALLET
91  QApplication::setWindowIcon(m_network_style->getTrayAndWindowIcon());
92  setWindowIcon(m_network_style->getTrayAndWindowIcon());
94 
95  rpcConsole = new RPCConsole(node, _platformStyle, nullptr);
96  helpMessageDialog = new HelpMessageDialog(this, false);
97 #ifdef ENABLE_WALLET
98  if (enableWallet) {
100  walletFrame = new WalletFrame(_platformStyle, this);
101  setCentralWidget(walletFrame);
102  } else
103 #endif // ENABLE_WALLET
104  {
109  setCentralWidget(rpcConsole);
110  Q_EMIT consoleShown(rpcConsole);
111  }
112 
113  // Accept D&D of URIs
114  setAcceptDrops(true);
115 
116  // Create actions for the toolbar, menu bar and tray/dock icon
117  // Needs walletFrame to be initialized
118  createActions();
119 
120  // Create application menu bar
121  createMenuBar();
122 
123  // Create the toolbars
124  createToolBars();
125 
126  // Create system tray icon and notification
127  if (QSystemTrayIcon::isSystemTrayAvailable()) {
128  createTrayIcon();
129  }
130  notificator =
131  new Notificator(QApplication::applicationName(), trayIcon, this);
132 
133  // Create status bar
134  statusBar();
135 
136  // Disable size grip because it looks ugly and nobody needs it
137  statusBar()->setSizeGripEnabled(false);
138 
139  // Status bar notification icons
140  QFrame *frameBlocks = new QFrame();
141  frameBlocks->setContentsMargins(0, 0, 0, 0);
142  frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
143  QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
144  frameBlocksLayout->setContentsMargins(3, 0, 3, 0);
145  frameBlocksLayout->setSpacing(3);
147  labelWalletEncryptionIcon = new QLabel();
148  labelWalletHDStatusIcon = new QLabel();
152  if (enableWallet) {
153  frameBlocksLayout->addStretch();
154  frameBlocksLayout->addWidget(unitDisplayControl);
155  frameBlocksLayout->addStretch();
156  frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
157  frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
158  }
159  frameBlocksLayout->addWidget(labelProxyIcon);
160  frameBlocksLayout->addStretch();
161  frameBlocksLayout->addWidget(connectionsControl);
162  frameBlocksLayout->addStretch();
163  frameBlocksLayout->addWidget(labelBlocksIcon);
164  frameBlocksLayout->addStretch();
165 
166  // Progress bar and label for blocks download
167  progressBarLabel = new QLabel();
168  progressBarLabel->setVisible(false);
170  progressBar->setAlignment(Qt::AlignCenter);
171  progressBar->setVisible(false);
172 
173  // Override style sheet for progress bar for styles that have a segmented
174  // progress bar, as they make the text unreadable (workaround for issue
175  // #1071)
176  // See https://doc.qt.io/qt-5/gallery.html
177  QString curStyle = QApplication::style()->metaObject()->className();
178  if (curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle") {
179  progressBar->setStyleSheet(
180  "QProgressBar { background-color: #e8e8e8; border: 1px solid grey; "
181  "border-radius: 7px; padding: 1px; text-align: center; } "
182  "QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, "
183  "x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: "
184  "7px; margin: 0px; }");
185  }
186 
187  statusBar()->addWidget(progressBarLabel);
188  statusBar()->addWidget(progressBar);
189  statusBar()->addPermanentWidget(frameBlocks);
190 
191  // Install event filter to be able to catch status tip events
192  // (QEvent::StatusTip)
193  this->installEventFilter(this);
194 
195  // Initially wallet actions should be disabled
197 
198  // Subscribe to notifications from core
200 
205 
206  modalOverlay = new ModalOverlay(enableWallet, this->centralWidget());
211 #ifdef ENABLE_WALLET
212  if (enableWallet) {
215  }
216 #endif
217 
218 #ifdef Q_OS_MAC
219  m_app_nap_inhibitor = new CAppNapInhibitor;
220 #endif
221 }
222 
224  // Unsubscribe from notifications from core
226 
227  QSettings settings;
228  settings.setValue("MainWindowGeometry", saveGeometry());
229  // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
230  if (trayIcon) {
231  trayIcon->hide();
232  }
233 #ifdef Q_OS_MAC
234  delete m_app_nap_inhibitor;
235  delete appMenuBar;
237 #endif
238 
239  delete rpcConsole;
240 }
241 
243  QActionGroup *tabGroup = new QActionGroup(this);
244 
246  new QAction(platformStyle->SingleColorIcon(":/icons/overview"),
247  tr("&Overview"), this);
248  overviewAction->setStatusTip(tr("Show general overview of wallet"));
249  overviewAction->setToolTip(overviewAction->statusTip());
250  overviewAction->setCheckable(true);
251  overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
252  tabGroup->addAction(overviewAction);
253 
254  sendCoinsAction = new QAction(
255  platformStyle->SingleColorIcon(":/icons/send"), tr("&Send"), this);
256  sendCoinsAction->setStatusTip(tr("Send coins to a Bitcoin address"));
257  sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
258  sendCoinsAction->setCheckable(true);
259  sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
260  tabGroup->addAction(sendCoinsAction);
261 
262  sendCoinsMenuAction = new QAction(sendCoinsAction->text(), this);
263  sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip());
264  sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip());
265 
266  receiveCoinsAction = new QAction(
267  platformStyle->SingleColorIcon(":/icons/receiving_addresses"),
268  tr("&Receive"), this);
269  receiveCoinsAction->setStatusTip(
270  tr("Request payments (generates QR codes and %1: URIs)")
271  .arg(QString::fromStdString(
273  receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
274  receiveCoinsAction->setCheckable(true);
275  receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
276  tabGroup->addAction(receiveCoinsAction);
277 
278  receiveCoinsMenuAction = new QAction(receiveCoinsAction->text(), this);
279  receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip());
280  receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip());
281 
282  historyAction =
283  new QAction(platformStyle->SingleColorIcon(":/icons/history"),
284  tr("&Transactions"), this);
285  historyAction->setStatusTip(tr("Browse transaction history"));
286  historyAction->setToolTip(historyAction->statusTip());
287  historyAction->setCheckable(true);
288  historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
289  tabGroup->addAction(historyAction);
290 
291 #ifdef ENABLE_WALLET
292  // These showNormalIfMinimized are needed because Send Coins and Receive
293  // Coins can be triggered from the tray menu, and need to show the GUI to be
294  // useful.
295  connect(overviewAction, &QAction::triggered,
296  [this] { showNormalIfMinimized(); });
297  connect(overviewAction, &QAction::triggered, this,
298  &BitcoinGUI::gotoOverviewPage);
299  connect(sendCoinsAction, &QAction::triggered,
300  [this] { showNormalIfMinimized(); });
301  connect(sendCoinsAction, &QAction::triggered,
302  [this] { gotoSendCoinsPage(); });
303  connect(sendCoinsMenuAction, &QAction::triggered,
304  [this] { showNormalIfMinimized(); });
305  connect(sendCoinsMenuAction, &QAction::triggered,
306  [this] { gotoSendCoinsPage(); });
307  connect(receiveCoinsAction, &QAction::triggered,
308  [this] { showNormalIfMinimized(); });
309  connect(receiveCoinsAction, &QAction::triggered, this,
310  &BitcoinGUI::gotoReceiveCoinsPage);
311  connect(receiveCoinsMenuAction, &QAction::triggered,
312  [this] { showNormalIfMinimized(); });
313  connect(receiveCoinsMenuAction, &QAction::triggered, this,
314  &BitcoinGUI::gotoReceiveCoinsPage);
315  connect(historyAction, &QAction::triggered,
316  [this] { showNormalIfMinimized(); });
317  connect(historyAction, &QAction::triggered, this,
318  &BitcoinGUI::gotoHistoryPage);
319 #endif // ENABLE_WALLET
320 
321  quitAction = new QAction(tr("E&xit"), this);
322  quitAction->setStatusTip(tr("Quit application"));
323  quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
324  quitAction->setMenuRole(QAction::QuitRole);
325  aboutAction = new QAction(tr("&About %1").arg(PACKAGE_NAME), this);
326  aboutAction->setStatusTip(
327  tr("Show information about %1").arg(PACKAGE_NAME));
328  aboutAction->setMenuRole(QAction::AboutRole);
329  aboutAction->setEnabled(false);
330  aboutQtAction = new QAction(tr("About &Qt"), this);
331  aboutQtAction->setStatusTip(tr("Show information about Qt"));
332  aboutQtAction->setMenuRole(QAction::AboutQtRole);
333  optionsAction = new QAction(tr("&Options..."), this);
334  optionsAction->setStatusTip(
335  tr("Modify configuration options for %1").arg(PACKAGE_NAME));
336  optionsAction->setMenuRole(QAction::PreferencesRole);
337  optionsAction->setEnabled(false);
338  toggleHideAction = new QAction(tr("&Show / Hide"), this);
339  toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
340 
341  encryptWalletAction = new QAction(tr("&Encrypt Wallet..."), this);
342  encryptWalletAction->setStatusTip(
343  tr("Encrypt the private keys that belong to your wallet"));
344  encryptWalletAction->setCheckable(true);
345  backupWalletAction = new QAction(tr("&Backup Wallet..."), this);
346  backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
347  changePassphraseAction = new QAction(tr("&Change Passphrase..."), this);
348  changePassphraseAction->setStatusTip(
349  tr("Change the passphrase used for wallet encryption"));
350  signMessageAction = new QAction(tr("Sign &message..."), this);
351  signMessageAction->setStatusTip(
352  tr("Sign messages with your Bitcoin addresses to prove you own them"));
353  verifyMessageAction = new QAction(tr("&Verify message..."), this);
354  verifyMessageAction->setStatusTip(
355  tr("Verify messages to ensure they were signed with specified Bitcoin "
356  "addresses"));
357  m_load_psbt_action = new QAction(tr("Load PSBT..."), this);
358  m_load_psbt_action->setStatusTip(
359  tr("Load Partially Signed Bitcoin Transaction"));
360 
361  openRPCConsoleAction = new QAction(tr("&Debug window"), this);
362  openRPCConsoleAction->setStatusTip(
363  tr("Open node debugging and diagnostic console"));
364  // initially disable the debug window menu item
365  openRPCConsoleAction->setEnabled(false);
366  openRPCConsoleAction->setObjectName("openRPCConsoleAction");
367 
368  usedSendingAddressesAction = new QAction(tr("&Sending addresses"), this);
369  usedSendingAddressesAction->setStatusTip(
370  tr("Show the list of used sending addresses and labels"));
372  new QAction(tr("&Receiving addresses"), this);
373  usedReceivingAddressesAction->setStatusTip(
374  tr("Show the list of used receiving addresses and labels"));
375 
376  openAction = new QAction(tr("Open &URI..."), this);
377  openAction->setStatusTip(
378  tr("Open a %1: URI or payment request")
379  .arg(QString::fromStdString(
381 
382  m_open_wallet_action = new QAction(tr("Open Wallet"), this);
383  m_open_wallet_action->setEnabled(false);
384  m_open_wallet_action->setStatusTip(tr("Open a wallet"));
385  m_open_wallet_menu = new QMenu(this);
386 
387  m_close_wallet_action = new QAction(tr("Close Wallet..."), this);
388  m_close_wallet_action->setStatusTip(tr("Close wallet"));
389 
390  m_create_wallet_action = new QAction(tr("Create Wallet..."), this);
391  m_create_wallet_action->setEnabled(false);
392  m_create_wallet_action->setStatusTip(tr("Create a new wallet"));
393 
394  showHelpMessageAction = new QAction(tr("&Command-line options"), this);
395  showHelpMessageAction->setMenuRole(QAction::NoRole);
396  showHelpMessageAction->setStatusTip(
397  tr("Show the %1 help message to get a list with possible Bitcoin "
398  "command-line options")
399  .arg(PACKAGE_NAME));
400 
401  connect(quitAction, &QAction::triggered, qApp, QApplication::quit);
402  connect(aboutAction, &QAction::triggered, this, &BitcoinGUI::aboutClicked);
403  connect(aboutQtAction, &QAction::triggered, qApp, QApplication::aboutQt);
404  connect(optionsAction, &QAction::triggered, this,
406  connect(toggleHideAction, &QAction::triggered, this,
408  connect(showHelpMessageAction, &QAction::triggered, this,
410  connect(openRPCConsoleAction, &QAction::triggered, this,
412  // prevents an open debug window from becoming stuck/unusable on client
413  // shutdown
414  connect(quitAction, &QAction::triggered, rpcConsole, &QWidget::hide);
415 
416 #ifdef ENABLE_WALLET
417  if (walletFrame) {
418  connect(encryptWalletAction, &QAction::triggered, walletFrame,
420  connect(backupWalletAction, &QAction::triggered, walletFrame,
422  connect(changePassphraseAction, &QAction::triggered, walletFrame,
424  connect(signMessageAction, &QAction::triggered,
425  [this] { showNormalIfMinimized(); });
426  connect(signMessageAction, &QAction::triggered,
427  [this] { gotoSignMessageTab(); });
428  connect(verifyMessageAction, &QAction::triggered,
429  [this] { showNormalIfMinimized(); });
430  connect(verifyMessageAction, &QAction::triggered,
431  [this] { gotoVerifyMessageTab(); });
432  connect(m_load_psbt_action, &QAction::triggered,
433  [this] { gotoLoadPSBT(); });
434  connect(usedSendingAddressesAction, &QAction::triggered, walletFrame,
436  connect(usedReceivingAddressesAction, &QAction::triggered, walletFrame,
438  connect(openAction, &QAction::triggered, this,
439  &BitcoinGUI::openClicked);
440  connect(m_open_wallet_menu, &QMenu::aboutToShow, [this] {
441  m_open_wallet_menu->clear();
442  for (const std::pair<const std::string, bool> &i :
444  const std::string &path = i.first;
445  QString name = path.empty()
446  ? QString("[" + tr("default wallet") + "]")
447  : QString::fromStdString(path);
448  // Menu items remove single &. Single & are shown when && is in
449  // the string, but only the first occurrence. So replace only
450  // the first & with &&
451  name.replace(name.indexOf(QChar('&')), 1, QString("&&"));
452  QAction *action = m_open_wallet_menu->addAction(name);
453 
454  if (i.second) {
455  // This wallet is already loaded
456  action->setEnabled(false);
457  continue;
458  }
459 
460  connect(action, &QAction::triggered, [this, path] {
461  auto activity =
463  this->config->GetChainParams());
464  connect(activity, &OpenWalletActivity::opened, this,
465  &BitcoinGUI::setCurrentWallet);
466  connect(activity, &OpenWalletActivity::finished, activity,
467  &QObject::deleteLater);
468  activity->open(path);
469  });
470  }
471  if (m_open_wallet_menu->isEmpty()) {
472  QAction *action =
473  m_open_wallet_menu->addAction(tr("No wallets available"));
474  action->setEnabled(false);
475  }
476  });
477  connect(m_close_wallet_action, &QAction::triggered, [this] {
479  this);
480  });
481  connect(m_create_wallet_action, &QAction::triggered, [this] {
482  auto activity = new CreateWalletActivity(
483  m_wallet_controller, this, this->config->GetChainParams());
484  connect(activity, &CreateWalletActivity::created, this,
485  &BitcoinGUI::setCurrentWallet);
486  connect(activity, &CreateWalletActivity::finished, activity,
487  &QObject::deleteLater);
488  activity->create();
489  });
490  }
491 #endif // ENABLE_WALLET
492 
493  connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this),
494  &QShortcut::activated, this,
496  connect(new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D), this),
497  &QShortcut::activated, this, &BitcoinGUI::showDebugWindow);
498 }
499 
501 #ifdef Q_OS_MAC
502  // Create a decoupled menu bar on Mac which stays even if the window is
503  // closed
504  appMenuBar = new QMenuBar();
505 #else
506  // Get the main window's menu bar on other platforms
507  appMenuBar = menuBar();
508 #endif
509 
510  // Configure the menus
511  QMenu *file = appMenuBar->addMenu(tr("&File"));
512  if (walletFrame) {
513  file->addAction(m_create_wallet_action);
514  file->addAction(m_open_wallet_action);
515  file->addAction(m_close_wallet_action);
516  file->addSeparator();
517  file->addAction(openAction);
518  file->addAction(backupWalletAction);
519  file->addAction(signMessageAction);
520  file->addAction(verifyMessageAction);
521  file->addAction(m_load_psbt_action);
522  file->addSeparator();
523  }
524  file->addAction(quitAction);
525 
526  QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
527  if (walletFrame) {
528  settings->addAction(encryptWalletAction);
529  settings->addAction(changePassphraseAction);
530  settings->addSeparator();
531  }
532  settings->addAction(optionsAction);
533 
534  QMenu *window_menu = appMenuBar->addMenu(tr("&Window"));
535 
536  QAction *minimize_action = window_menu->addAction(tr("Minimize"));
537  minimize_action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M));
538  connect(minimize_action, &QAction::triggered,
539  [] { QApplication::activeWindow()->showMinimized(); });
540  connect(qApp, &QApplication::focusWindowChanged,
541  [minimize_action](QWindow *window) {
542  minimize_action->setEnabled(
543  window != nullptr &&
544  (window->flags() & Qt::Dialog) != Qt::Dialog &&
545  window->windowState() != Qt::WindowMinimized);
546  });
547 
548 #ifdef Q_OS_MAC
549  QAction *zoom_action = window_menu->addAction(tr("Zoom"));
550  connect(zoom_action, &QAction::triggered, [] {
551  QWindow *window = qApp->focusWindow();
552  if (window->windowState() != Qt::WindowMaximized) {
553  window->showMaximized();
554  } else {
555  window->showNormal();
556  }
557  });
558 
559  connect(qApp, &QApplication::focusWindowChanged,
560  [zoom_action](QWindow *window) {
561  zoom_action->setEnabled(window != nullptr);
562  });
563 #endif
564 
565  if (walletFrame) {
566 #ifdef Q_OS_MAC
567  window_menu->addSeparator();
568  QAction *main_window_action = window_menu->addAction(tr("Main Window"));
569  connect(main_window_action, &QAction::triggered,
570  [this] { GUIUtil::bringToFront(this); });
571 #endif
572  window_menu->addSeparator();
573  window_menu->addAction(usedSendingAddressesAction);
574  window_menu->addAction(usedReceivingAddressesAction);
575  }
576 
577  window_menu->addSeparator();
578  for (RPCConsole::TabTypes tab_type : rpcConsole->tabs()) {
579  QAction *tab_action =
580  window_menu->addAction(rpcConsole->tabTitle(tab_type));
581  tab_action->setShortcut(rpcConsole->tabShortcut(tab_type));
582  connect(tab_action, &QAction::triggered, [this, tab_type] {
583  rpcConsole->setTabFocus(tab_type);
584  showDebugWindow();
585  });
586  }
587 
588  QMenu *help = appMenuBar->addMenu(tr("&Help"));
589  help->addAction(showHelpMessageAction);
590  help->addSeparator();
591  help->addAction(aboutAction);
592  help->addAction(aboutQtAction);
593 }
594 
596  if (walletFrame) {
597  QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
598  appToolBar = toolbar;
599  toolbar->setContextMenuPolicy(Qt::PreventContextMenu);
600  toolbar->setMovable(false);
601  toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
602  toolbar->addAction(overviewAction);
603  toolbar->addAction(sendCoinsAction);
604  toolbar->addAction(receiveCoinsAction);
605  toolbar->addAction(historyAction);
606  overviewAction->setChecked(true);
607 
608 #ifdef ENABLE_WALLET
609  QWidget *spacer = new QWidget();
610  spacer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
611  toolbar->addWidget(spacer);
612 
613  m_wallet_selector = new QComboBox();
614  m_wallet_selector->setSizeAdjustPolicy(QComboBox::AdjustToContents);
615  connect(m_wallet_selector,
616  static_cast<void (QComboBox::*)(int)>(
617  &QComboBox::currentIndexChanged),
618  this, &BitcoinGUI::setCurrentWalletBySelectorIndex);
619 
620  m_wallet_selector_label = new QLabel();
621  m_wallet_selector_label->setText(tr("Wallet:") + " ");
623 
627 
628  m_wallet_selector_label_action->setVisible(false);
629  m_wallet_selector_action->setVisible(false);
630 #endif
631  }
632 }
633 
635  this->clientModel = _clientModel;
636  if (_clientModel) {
637  // Create system tray menu (or setup the dock menu) that late to prevent
638  // users from calling actions, while the client has not yet fully loaded
640 
641  // Keep up to date with client
643  connect(_clientModel, &ClientModel::numConnectionsChanged, this,
645  connect(_clientModel, &ClientModel::networkActiveChanged, this,
647 
649  _clientModel->getHeaderTipHeight(),
650  QDateTime::fromTime_t(_clientModel->getHeaderTipTime()));
652  QDateTime::fromTime_t(m_node.getLastBlockTime()),
655  connect(_clientModel, &ClientModel::numBlocksChanged, this,
657 
658  // Receive and report messages from client model
659  connect(_clientModel, &ClientModel::message,
660  [this](const QString &title, const QString &message,
661  unsigned int style) {
662  this->message(title, message, style);
663  });
664 
665  // Show progress dialog
666  connect(_clientModel, &ClientModel::showProgress, this,
668 
669  rpcConsole->setClientModel(_clientModel);
670 
671  updateProxyIcon();
672 
673 #ifdef ENABLE_WALLET
674  if (walletFrame) {
675  walletFrame->setClientModel(_clientModel);
676  }
677 #endif // ENABLE_WALLET
679 
680  OptionsModel *optionsModel = _clientModel->getOptionsModel();
681  if (optionsModel && trayIcon) {
682  // be aware of the tray icon disable state change reported by the
683  // OptionsModel object.
684  connect(optionsModel, &OptionsModel::hideTrayIconChanged, this,
686 
687  // initialize the disable state of the tray icon with the current
688  // value in the model.
689  setTrayIconVisible(optionsModel->getHideTrayIcon());
690  }
691  } else {
692  // Disable possibility to show main window via action
693  toggleHideAction->setEnabled(false);
694  if (trayIconMenu) {
695  // Disable context menu on tray icon
696  trayIconMenu->clear();
697  }
698  // Propagate cleared model to child objects
699  rpcConsole->setClientModel(nullptr);
700 #ifdef ENABLE_WALLET
701  if (walletFrame) {
702  walletFrame->setClientModel(nullptr);
703  }
704 #endif // ENABLE_WALLET
706  }
707 }
708 
709 #ifdef ENABLE_WALLET
710 void BitcoinGUI::setWalletController(WalletController *wallet_controller) {
711  assert(!m_wallet_controller);
712  assert(wallet_controller);
713 
714  m_wallet_controller = wallet_controller;
715 
716  m_create_wallet_action->setEnabled(true);
717  m_open_wallet_action->setEnabled(true);
719 
720  connect(wallet_controller, &WalletController::walletAdded, this,
721  &BitcoinGUI::addWallet);
722  connect(wallet_controller, &WalletController::walletRemoved, this,
723  &BitcoinGUI::removeWallet);
724 
725  for (WalletModel *wallet_model : m_wallet_controller->getOpenWallets()) {
726  addWallet(wallet_model);
727  }
728 }
729 
730 void BitcoinGUI::addWallet(WalletModel *walletModel) {
731  if (!walletFrame) {
732  return;
733  }
734  if (!walletFrame->addWallet(walletModel)) {
735  return;
736  }
737  const QString display_name = walletModel->getDisplayName();
739  rpcConsole->addWallet(walletModel);
740  m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
741  if (m_wallet_selector->count() == 2) {
742  m_wallet_selector_label_action->setVisible(true);
743  m_wallet_selector_action->setVisible(true);
744  }
745 }
746 
747 void BitcoinGUI::removeWallet(WalletModel *walletModel) {
748  if (!walletFrame) {
749  return;
750  }
751 
752  labelWalletHDStatusIcon->hide();
754 
755  int index = m_wallet_selector->findData(QVariant::fromValue(walletModel));
756  m_wallet_selector->removeItem(index);
757  if (m_wallet_selector->count() == 0) {
759  } else if (m_wallet_selector->count() == 1) {
760  m_wallet_selector_label_action->setVisible(false);
761  m_wallet_selector_action->setVisible(false);
762  }
763  rpcConsole->removeWallet(walletModel);
764  walletFrame->removeWallet(walletModel);
766 }
767 
768 void BitcoinGUI::setCurrentWallet(WalletModel *wallet_model) {
769  if (!walletFrame) {
770  return;
771  }
772  walletFrame->setCurrentWallet(wallet_model);
773  for (int index = 0; index < m_wallet_selector->count(); ++index) {
774  if (m_wallet_selector->itemData(index).value<WalletModel *>() ==
775  wallet_model) {
776  m_wallet_selector->setCurrentIndex(index);
777  break;
778  }
779  }
781 }
782 
783 void BitcoinGUI::setCurrentWalletBySelectorIndex(int index) {
784  WalletModel *wallet_model =
785  m_wallet_selector->itemData(index).value<WalletModel *>();
786  if (wallet_model) {
787  setCurrentWallet(wallet_model);
788  }
789 }
790 
791 void BitcoinGUI::removeAllWallets() {
792  if (!walletFrame) {
793  return;
794  }
797 }
798 #endif // ENABLE_WALLET
799 
801  overviewAction->setEnabled(enabled);
802  sendCoinsAction->setEnabled(enabled);
803  sendCoinsMenuAction->setEnabled(enabled);
804  receiveCoinsAction->setEnabled(enabled);
805  receiveCoinsMenuAction->setEnabled(enabled);
806  historyAction->setEnabled(enabled);
807  encryptWalletAction->setEnabled(enabled);
808  backupWalletAction->setEnabled(enabled);
809  changePassphraseAction->setEnabled(enabled);
810  signMessageAction->setEnabled(enabled);
811  verifyMessageAction->setEnabled(enabled);
812  usedSendingAddressesAction->setEnabled(enabled);
813  usedReceivingAddressesAction->setEnabled(enabled);
814  openAction->setEnabled(enabled);
815  m_close_wallet_action->setEnabled(enabled);
816 }
817 
819  assert(QSystemTrayIcon::isSystemTrayAvailable());
820 
821 #ifndef Q_OS_MAC
822  if (QSystemTrayIcon::isSystemTrayAvailable()) {
823  trayIcon =
824  new QSystemTrayIcon(m_network_style->getTrayAndWindowIcon(), this);
825  QString toolTip = tr("%1 client").arg(PACKAGE_NAME) + " " +
827  trayIcon->setToolTip(toolTip);
828  }
829 #endif
830 }
831 
833 #ifndef Q_OS_MAC
834  // Return if trayIcon is unset (only on non-macOSes)
835  if (!trayIcon) {
836  return;
837  }
838 
839  trayIcon->setContextMenu(trayIconMenu.get());
840  connect(trayIcon, &QSystemTrayIcon::activated, this,
842 #else
843  // Note: On macOS, the Dock icon is used to provide the tray's
844  // functionality.
846  connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, this,
847  &BitcoinGUI::macosDockIconActivated);
848  trayIconMenu->setAsDockMenu();
849 #endif
850 
851  // Configuration of the tray icon (or Dock icon) menu
852 #ifndef Q_OS_MAC
853  // Note: On macOS, the Dock icon's menu already has Show / Hide action.
854  trayIconMenu->addAction(toggleHideAction);
855  trayIconMenu->addSeparator();
856 #endif
857  if (enableWallet) {
858  trayIconMenu->addAction(sendCoinsMenuAction);
860  trayIconMenu->addSeparator();
861  trayIconMenu->addAction(signMessageAction);
862  trayIconMenu->addAction(verifyMessageAction);
863  trayIconMenu->addSeparator();
864  }
865  trayIconMenu->addAction(optionsAction);
867 #ifndef Q_OS_MAC
868  // This is built-in on macOS
869  trayIconMenu->addSeparator();
870  trayIconMenu->addAction(quitAction);
871 #endif
872 }
873 
874 #ifndef Q_OS_MAC
875 void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) {
876  if (reason == QSystemTrayIcon::Trigger) {
877  // Click on system tray icon triggers show/hide of the main window
878  toggleHidden();
879  }
880 }
881 #else
882 void BitcoinGUI::macosDockIconActivated() {
883  show();
884  activateWindow();
885 }
886 #endif
887 
890 }
891 
893  if (!clientModel) {
894  return;
895  }
896 
897  HelpMessageDialog dlg(this, true);
898  dlg.exec();
899 }
900 
903  Q_EMIT consoleShown(rpcConsole);
904 }
905 
908  showDebugWindow();
909 }
910 
912  helpMessageDialog->show();
913 }
914 
915 #ifdef ENABLE_WALLET
916 void BitcoinGUI::openClicked() {
917  OpenURIDialog dlg(config->GetChainParams(), this);
918  if (dlg.exec()) {
919  Q_EMIT receivedURI(dlg.getURI());
920  }
921 }
922 
923 void BitcoinGUI::gotoOverviewPage() {
924  overviewAction->setChecked(true);
925  if (walletFrame) {
927  }
928 }
929 
930 void BitcoinGUI::gotoHistoryPage() {
931  historyAction->setChecked(true);
932  if (walletFrame) {
934  }
935 }
936 
937 void BitcoinGUI::gotoReceiveCoinsPage() {
938  receiveCoinsAction->setChecked(true);
939  if (walletFrame) {
941  }
942 }
943 
944 void BitcoinGUI::gotoSendCoinsPage(QString addr) {
945  sendCoinsAction->setChecked(true);
946  if (walletFrame) {
948  }
949 }
950 
951 void BitcoinGUI::gotoSignMessageTab(QString addr) {
952  if (walletFrame) {
954  }
955 }
956 
957 void BitcoinGUI::gotoVerifyMessageTab(QString addr) {
958  if (walletFrame) {
960  }
961 }
962 void BitcoinGUI::gotoLoadPSBT() {
963  if (walletFrame) {
965  }
966 }
967 #endif // ENABLE_WALLET
968 
971  QString icon;
972  switch (count) {
973  case 0:
974  icon = ":/icons/connect_0";
975  break;
976  case 1:
977  case 2:
978  case 3:
979  icon = ":/icons/connect_1";
980  break;
981  case 4:
982  case 5:
983  case 6:
984  icon = ":/icons/connect_2";
985  break;
986  case 7:
987  case 8:
988  case 9:
989  icon = ":/icons/connect_3";
990  break;
991  default:
992  icon = ":/icons/connect_4";
993  break;
994  }
995 
996  QString tooltip;
997 
998  if (m_node.getNetworkActive()) {
999  tooltip = tr("%n active connection(s) to Bitcoin network", "", count) +
1000  QString(".<br>") + tr("Click to disable network activity.");
1001  } else {
1002  tooltip = tr("Network activity disabled.") + QString("<br>") +
1003  tr("Click to enable network activity again.");
1004  icon = ":/icons/network_disabled";
1005  }
1006 
1007  // Don't word-wrap this (fixed-width) tooltip
1008  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
1009  connectionsControl->setToolTip(tooltip);
1010 
1011  connectionsControl->setPixmap(platformStyle->SingleColorIcon(icon).pixmap(
1013 }
1014 
1017 }
1018 
1019 void BitcoinGUI::setNetworkActive(bool networkActive) {
1021 }
1022 
1024  int64_t headersTipTime = clientModel->getHeaderTipTime();
1025  int headersTipHeight = clientModel->getHeaderTipHeight();
1026  int estHeadersLeft =
1027  (GetTime() - headersTipTime) /
1029  if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC) {
1030  progressBarLabel->setText(
1031  tr("Syncing Headers (%1%)...")
1032  .arg(QString::number(100.0 /
1033  (headersTipHeight + estHeadersLeft) *
1034  headersTipHeight,
1035  'f', 1)));
1036  }
1037 }
1038 
1040  if (!clientModel || !clientModel->getOptionsModel()) {
1041  return;
1042  }
1043 
1044  OptionsDialog dlg(this, enableWallet);
1045  dlg.setCurrentTab(tab);
1047  dlg.exec();
1048 }
1049 
1050 void BitcoinGUI::setNumBlocks(int count, const QDateTime &blockDate,
1051  double nVerificationProgress, bool header,
1052  SynchronizationState sync_state) {
1053 // Disabling macOS App Nap on initial sync, disk and reindex operations.
1054 #ifdef Q_OS_MAC
1055  if (sync_state == SynchronizationState::POST_INIT) {
1056  m_app_nap_inhibitor->enableAppNap();
1057  } else {
1058  m_app_nap_inhibitor->disableAppNap();
1059  }
1060 #endif
1061 
1062  if (modalOverlay) {
1063  if (header) {
1064  modalOverlay->setKnownBestHeight(count, blockDate);
1065  } else {
1066  modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
1067  }
1068  }
1069  if (!clientModel) {
1070  return;
1071  }
1072 
1073  // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait
1074  // until chain-sync starts -> garbled text)
1075  statusBar()->clearMessage();
1076 
1077  // Acquire current block source
1078  enum BlockSource blockSource = clientModel->getBlockSource();
1079  switch (blockSource) {
1080  case BlockSource::NETWORK:
1081  if (header) {
1083  return;
1084  }
1085  progressBarLabel->setText(tr("Synchronizing with network..."));
1087  break;
1088  case BlockSource::DISK:
1089  if (header) {
1090  progressBarLabel->setText(tr("Indexing blocks on disk..."));
1091  } else {
1092  progressBarLabel->setText(tr("Processing blocks on disk..."));
1093  }
1094  break;
1095  case BlockSource::REINDEX:
1096  progressBarLabel->setText(tr("Reindexing blocks on disk..."));
1097  break;
1098  case BlockSource::NONE:
1099  if (header) {
1100  return;
1101  }
1102  progressBarLabel->setText(tr("Connecting to peers..."));
1103  break;
1104  }
1105 
1106  QString tooltip;
1107 
1108  QDateTime currentDate = QDateTime::currentDateTime();
1109  qint64 secs = blockDate.secsTo(currentDate);
1110 
1111  tooltip = tr("Processed %n block(s) of transaction history.", "", count);
1112 
1113  // Set icon state: spinning if catching up, tick otherwise
1114  if (secs < MAX_BLOCK_TIME_GAP) {
1115  tooltip = tr("Up to date") + QString(".<br>") + tooltip;
1116  labelBlocksIcon->setPixmap(
1117  platformStyle->SingleColorIcon(":/icons/synced")
1119 
1120 #ifdef ENABLE_WALLET
1121  if (walletFrame) {
1123  modalOverlay->showHide(true, true);
1124  }
1125 #endif // ENABLE_WALLET
1126 
1127  progressBarLabel->setVisible(false);
1128  progressBar->setVisible(false);
1129  } else {
1130  QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);
1131 
1132  progressBarLabel->setVisible(true);
1133  progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
1134  progressBar->setMaximum(1000000000);
1135  progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
1136  progressBar->setVisible(true);
1137 
1138  tooltip = tr("Catching up...") + QString("<br>") + tooltip;
1139  if (count != prevBlocks) {
1140  labelBlocksIcon->setPixmap(
1142  ->SingleColorIcon(QString(":/movies/spinner-%1")
1143  .arg(spinnerFrame, 3, 10, QChar('0')))
1146  }
1147  prevBlocks = count;
1148 
1149 #ifdef ENABLE_WALLET
1150  if (walletFrame) {
1153  }
1154 #endif // ENABLE_WALLET
1155 
1156  tooltip += QString("<br>");
1157  tooltip +=
1158  tr("Last received block was generated %1 ago.").arg(timeBehindText);
1159  tooltip += QString("<br>");
1160  tooltip += tr("Transactions after this will not yet be visible.");
1161  }
1162 
1163  // Don't word-wrap this (fixed-width) tooltip
1164  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
1165 
1166  labelBlocksIcon->setToolTip(tooltip);
1167  progressBarLabel->setToolTip(tooltip);
1168  progressBar->setToolTip(tooltip);
1169 }
1170 
1171 void BitcoinGUI::message(const QString &title, QString message,
1172  unsigned int style, bool *ret,
1173  const QString &detailed_message) {
1174  // Default title. On macOS, the window title is ignored (as required by the
1175  // macOS Guidelines).
1176  QString strTitle{PACKAGE_NAME};
1177  // Default to information icon
1178  int nMBoxIcon = QMessageBox::Information;
1179  int nNotifyIcon = Notificator::Information;
1180 
1181  QString msgType;
1182  if (!title.isEmpty()) {
1183  msgType = title;
1184  } else {
1185  switch (style) {
1187  msgType = tr("Error");
1188  message = tr("Error: %1").arg(message);
1189  break;
1191  msgType = tr("Warning");
1192  message = tr("Warning: %1").arg(message);
1193  break;
1195  msgType = tr("Information");
1196  // No need to prepend the prefix here.
1197  break;
1198  default:
1199  break;
1200  }
1201  }
1202 
1203  if (!msgType.isEmpty()) {
1204  strTitle += " - " + msgType;
1205  }
1206 
1207  if (style & CClientUIInterface::ICON_ERROR) {
1208  nMBoxIcon = QMessageBox::Critical;
1209  nNotifyIcon = Notificator::Critical;
1210  } else if (style & CClientUIInterface::ICON_WARNING) {
1211  nMBoxIcon = QMessageBox::Warning;
1212  nNotifyIcon = Notificator::Warning;
1213  }
1214 
1215  if (style & CClientUIInterface::MODAL) {
1216  // Check for buttons, use OK as default, if none was supplied
1217  QMessageBox::StandardButton buttons;
1218  if (!(buttons = (QMessageBox::StandardButton)(
1219  style & CClientUIInterface::BTN_MASK))) {
1220  buttons = QMessageBox::Ok;
1221  }
1222 
1224  QMessageBox mBox(static_cast<QMessageBox::Icon>(nMBoxIcon), strTitle,
1225  message, buttons, this);
1226  mBox.setTextFormat(Qt::PlainText);
1227  mBox.setDetailedText(detailed_message);
1228  int r = mBox.exec();
1229  if (ret != nullptr) {
1230  *ret = r == QMessageBox::Ok;
1231  }
1232  } else {
1233  notificator->notify(static_cast<Notificator::Class>(nNotifyIcon),
1234  strTitle, message);
1235  }
1236 }
1237 
1238 void BitcoinGUI::changeEvent(QEvent *e) {
1239  QMainWindow::changeEvent(e);
1240 #ifndef Q_OS_MAC // Ignored on Mac
1241  if (e->type() == QEvent::WindowStateChange) {
1244  QWindowStateChangeEvent *wsevt =
1245  static_cast<QWindowStateChangeEvent *>(e);
1246  if (!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized()) {
1247  QTimer::singleShot(0, this, &BitcoinGUI::hide);
1248  e->ignore();
1249  } else if ((wsevt->oldState() & Qt::WindowMinimized) &&
1250  !isMinimized()) {
1251  QTimer::singleShot(0, this, &BitcoinGUI::show);
1252  e->ignore();
1253  }
1254  }
1255  }
1256 #endif
1257 }
1258 
1259 void BitcoinGUI::closeEvent(QCloseEvent *event) {
1260 #ifndef Q_OS_MAC // Ignored on Mac
1263  // close rpcConsole in case it was open to make some space for the
1264  // shutdown window
1265  rpcConsole->close();
1266 
1267  QApplication::quit();
1268  } else {
1269  QMainWindow::showMinimized();
1270  event->ignore();
1271  }
1272  }
1273 #else
1274  QMainWindow::closeEvent(event);
1275 #endif
1276 }
1277 
1278 void BitcoinGUI::showEvent(QShowEvent *event) {
1279  // enable the debug window when the main window shows up
1280  openRPCConsoleAction->setEnabled(true);
1281  aboutAction->setEnabled(true);
1282  optionsAction->setEnabled(true);
1283 }
1284 
1285 #ifdef ENABLE_WALLET
1286 void BitcoinGUI::incomingTransaction(const QString &date, int unit,
1287  const Amount amount, const QString &type,
1288  const QString &address,
1289  const QString &label,
1290  const QString &walletName) {
1291  // On new transaction, make an info balloon
1292  QString msg = tr("Date: %1\n").arg(date) +
1293  tr("Amount: %1\n")
1294  .arg(BitcoinUnits::formatWithUnit(unit, amount, true));
1295  if (m_node.getWallets().size() > 1 && !walletName.isEmpty()) {
1296  msg += tr("Wallet: %1\n").arg(walletName);
1297  }
1298  msg += tr("Type: %1\n").arg(type);
1299  if (!label.isEmpty()) {
1300  msg += tr("Label: %1\n").arg(label);
1301  } else if (!address.isEmpty()) {
1302  msg += tr("Address: %1\n").arg(address);
1303  }
1304  message(amount < Amount::zero() ? tr("Sent transaction")
1305  : tr("Incoming transaction"),
1307 }
1308 #endif // ENABLE_WALLET
1309 
1310 void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event) {
1311  // Accept only URIs
1312  if (event->mimeData()->hasUrls()) {
1313  event->acceptProposedAction();
1314  }
1315 }
1316 
1317 void BitcoinGUI::dropEvent(QDropEvent *event) {
1318  if (event->mimeData()->hasUrls()) {
1319  for (const QUrl &uri : event->mimeData()->urls()) {
1320  Q_EMIT receivedURI(uri.toString());
1321  }
1322  }
1323  event->acceptProposedAction();
1324 }
1325 
1326 bool BitcoinGUI::eventFilter(QObject *object, QEvent *event) {
1327  // Catch status tip events
1328  if (event->type() == QEvent::StatusTip) {
1329  // Prevent adding text from setStatusTip(), if we currently use the
1330  // status bar for displaying other stuff
1331  if (progressBarLabel->isVisible() || progressBar->isVisible()) {
1332  return true;
1333  }
1334  }
1335  return QMainWindow::eventFilter(object, event);
1336 }
1337 
1338 #ifdef ENABLE_WALLET
1339 bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient &recipient) {
1340  // URI has to be valid
1341  if (walletFrame && walletFrame->handlePaymentRequest(recipient)) {
1343  gotoSendCoinsPage();
1344  return true;
1345  }
1346  return false;
1347 }
1348 
1349 void BitcoinGUI::setHDStatus(bool privkeyDisabled, int hdEnabled) {
1350  labelWalletHDStatusIcon->setPixmap(
1352  ->SingleColorIcon(privkeyDisabled
1353  ? ":/icons/eye"
1354  : hdEnabled ? ":/icons/hd_enabled"
1355  : ":/icons/hd_disabled")
1357  labelWalletHDStatusIcon->setToolTip(
1358  privkeyDisabled
1359  ? tr("Private key <b>disabled</b>")
1360  : hdEnabled ? tr("HD key generation is <b>enabled</b>")
1361  : tr("HD key generation is <b>disabled</b>"));
1362  labelWalletHDStatusIcon->show();
1363  // eventually disable the QLabel to set its opacity to 50%
1364  labelWalletHDStatusIcon->setEnabled(hdEnabled);
1365 }
1366 
1367 void BitcoinGUI::setEncryptionStatus(int status) {
1368  switch (status) {
1370  labelWalletEncryptionIcon->hide();
1371  encryptWalletAction->setChecked(false);
1372  changePassphraseAction->setEnabled(false);
1373  encryptWalletAction->setEnabled(true);
1374  break;
1375  case WalletModel::Unlocked:
1376  labelWalletEncryptionIcon->show();
1377  labelWalletEncryptionIcon->setPixmap(
1378  platformStyle->SingleColorIcon(":/icons/lock_open")
1380  labelWalletEncryptionIcon->setToolTip(
1381  tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
1382  encryptWalletAction->setChecked(true);
1383  changePassphraseAction->setEnabled(true);
1384  encryptWalletAction->setEnabled(
1385  false); // TODO: decrypt currently not supported
1386  break;
1387  case WalletModel::Locked:
1388  labelWalletEncryptionIcon->show();
1389  labelWalletEncryptionIcon->setPixmap(
1390  platformStyle->SingleColorIcon(":/icons/lock_closed")
1392  labelWalletEncryptionIcon->setToolTip(
1393  tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
1394  encryptWalletAction->setChecked(true);
1395  changePassphraseAction->setEnabled(true);
1396  encryptWalletAction->setEnabled(
1397  false); // TODO: decrypt currently not supported
1398  break;
1399  }
1400 }
1401 
1402 void BitcoinGUI::updateWalletStatus() {
1403  if (!walletFrame) {
1404  return;
1405  }
1406  WalletView *const walletView = walletFrame->currentWalletView();
1407  if (!walletView) {
1408  return;
1409  }
1410  WalletModel *const walletModel = walletView->getWalletModel();
1411  setEncryptionStatus(walletModel->getEncryptionStatus());
1412  setHDStatus(walletModel->wallet().privateKeysDisabled(),
1413  walletModel->wallet().hdEnabled());
1414 }
1415 #endif // ENABLE_WALLET
1416 
1418  std::string ip_port;
1419  bool proxy_enabled = clientModel->getProxyInfo(ip_port);
1420 
1421  if (proxy_enabled) {
1422  if (!labelProxyIcon->hasPixmap()) {
1423  QString ip_port_q = QString::fromStdString(ip_port);
1424  labelProxyIcon->setPixmap(
1425  platformStyle->SingleColorIcon(":/icons/proxy")
1427  labelProxyIcon->setToolTip(
1428  tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
1429  } else {
1430  labelProxyIcon->show();
1431  }
1432  } else {
1433  labelProxyIcon->hide();
1434  }
1435 }
1436 
1438  QString window_title = PACKAGE_NAME;
1439 #ifdef ENABLE_WALLET
1440  if (walletFrame) {
1441  WalletModel *const wallet_model = walletFrame->currentWalletModel();
1442  if (wallet_model && !wallet_model->getWalletName().isEmpty()) {
1443  window_title += " - " + wallet_model->getDisplayName();
1444  }
1445  }
1446 #endif
1447  if (!m_network_style->getTitleAddText().isEmpty()) {
1448  window_title += " - " + m_network_style->getTitleAddText();
1449  }
1450  setWindowTitle(window_title);
1451 }
1452 
1453 void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) {
1454  if (!clientModel) {
1455  return;
1456  }
1457 
1458  if (!isHidden() && !isMinimized() && !GUIUtil::isObscured(this) &&
1459  fToggleHidden) {
1460  hide();
1461  } else {
1462  GUIUtil::bringToFront(this);
1463  }
1464 }
1465 
1467  showNormalIfMinimized(true);
1468 }
1469 
1471  if (m_node.shutdownRequested()) {
1472  if (rpcConsole) {
1473  rpcConsole->hide();
1474  }
1475  qApp->quit();
1476  }
1477 }
1478 
1479 void BitcoinGUI::showProgress(const QString &title, int nProgress) {
1480  if (nProgress == 0) {
1481  progressDialog = new QProgressDialog(title, QString(), 0, 100);
1483  progressDialog->setWindowModality(Qt::ApplicationModal);
1484  progressDialog->setMinimumDuration(0);
1485  progressDialog->setAutoClose(false);
1486  progressDialog->setValue(0);
1487  } else if (nProgress == 100) {
1488  if (progressDialog) {
1489  progressDialog->close();
1490  progressDialog->deleteLater();
1491  progressDialog = nullptr;
1492  }
1493  } else if (progressDialog) {
1494  progressDialog->setValue(nProgress);
1495  }
1496 }
1497 
1498 void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon) {
1499  if (trayIcon) {
1500  trayIcon->setVisible(!fHideTrayIcon);
1501  }
1502 }
1503 
1505  if (modalOverlay &&
1506  (progressBar->isVisible() || modalOverlay->isLayerVisible())) {
1508  }
1509 }
1510 
1512  const std::string &caption,
1513  unsigned int style) {
1514  bool modal = (style & CClientUIInterface::MODAL);
1515  // The SECURE flag has no effect in the Qt GUI.
1516  // bool secure = (style & CClientUIInterface::SECURE);
1517  style &= ~CClientUIInterface::SECURE;
1518  bool ret = false;
1519  // This is original message, in English, for googling and referencing.
1520  QString detailed_message;
1521  if (message.original != message.translated) {
1522  detailed_message = BitcoinGUI::tr("Original message:") + "\n" +
1523  QString::fromStdString(message.original);
1524  }
1525 
1526  // In case of modal message, use blocking connection to wait for user to
1527  // click a button
1528  bool invoked = QMetaObject::invokeMethod(
1529  gui, "message",
1530  modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
1531  Q_ARG(QString, QString::fromStdString(caption)),
1532  Q_ARG(QString, QString::fromStdString(message.translated)),
1533  Q_ARG(unsigned int, style), Q_ARG(bool *, &ret),
1534  Q_ARG(QString, detailed_message));
1535  assert(invoked);
1536  return ret;
1537 }
1538 
1540  // Connect signals to client
1542  std::bind(ThreadSafeMessageBox, this, std::placeholders::_1,
1543  std::placeholders::_2, std::placeholders::_3));
1545  std::bind(ThreadSafeMessageBox, this, std::placeholders::_1,
1546  std::placeholders::_3, std::placeholders::_4));
1547 }
1548 
1550  // Disconnect signals from client
1551  m_handler_message_box->disconnect();
1552  m_handler_question->disconnect();
1553 }
1554 
1557  : optionsModel(nullptr), menu(nullptr) {
1559  setToolTip(tr("Unit to show amounts in. Click to select another unit."));
1560  QList<BitcoinUnits::Unit> units = BitcoinUnits::availableUnits();
1561  int max_width = 0;
1562  const QFontMetrics fm(font());
1563  for (const BitcoinUnits::Unit unit : units) {
1564  max_width = qMax(max_width,
1566  }
1567  setMinimumSize(max_width, 0);
1568  setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1569  setStyleSheet(QString("QLabel { color : %1 }")
1570  .arg(platformStyle->SingleColor().name()));
1571 }
1572 
1575  onDisplayUnitsClicked(event->pos());
1576 }
1577 
1581  menu = new QMenu(this);
1583  QAction *menuAction =
1584  new QAction(QString(BitcoinUnits::longName(u)), this);
1585  menuAction->setData(QVariant(u));
1586  menu->addAction(menuAction);
1587  }
1588  connect(menu, &QMenu::triggered, this,
1590 }
1591 
1594  if (_optionsModel) {
1595  this->optionsModel = _optionsModel;
1596 
1597  // be aware of a display unit change reported by the OptionsModel
1598  // object.
1599  connect(_optionsModel, &OptionsModel::displayUnitChanged, this,
1601 
1602  // initialize the display units label with the current value in the
1603  // model.
1604  updateDisplayUnit(_optionsModel->getDisplayUnit());
1605  }
1606 }
1607 
1611  setText(BitcoinUnits::longName(newUnits));
1612 }
1613 
1616  QPoint globalPos = mapToGlobal(point);
1617  menu->exec(globalPos);
1618 }
1619 
1622  if (action) {
1623  optionsModel->setDisplayUnit(action->data());
1624  }
1625 }
virtual bool privateKeysDisabled()=0
void subscribeToCoreSignals()
Connect core signals to GUI client.
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
void showEvent(QShowEvent *event) override
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
static UniValue help(Config &config, const JSONRPCRequest &jsonRequest)
Definition: server.cpp:175
static QString formatWithUnit(int unit, const Amount amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
void message(const QString &title, const QString &message, unsigned int style)
Fired when a message should be reported to the user.
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
void addWallet(WalletModel *const walletModel)
WalletModel * currentWalletModel() const
WalletView class.
Definition: walletview.h:34
QAction * receiveCoinsAction
Definition: bitcoingui.h:149
UnitDisplayStatusBarControl * unitDisplayControl
Definition: bitcoingui.h:126
int getNumConnections(NumConnections flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:66
Local Bitcoin RPC console.
Definition: rpcconsole.h:36
QMenuBar * appMenuBar
Definition: bitcoingui.h:136
bool hasPixmap() const
Definition: guiutil.cpp:839
Unit
Bitcoin units (Bitcoin Cash unit work the same as Bitoin).
Definition: bitcoinunits.h:43
interfaces::Wallet & wallet() const
Definition: walletmodel.h:150
static constexpr Amount zero()
Definition: amount.h:35
QAction * signMessageAction
Definition: bitcoingui.h:145
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
SynchronizationState
Current sync state passed to tip changed callbacks.
Definition: validation.h:167
QAction * aboutAction
Definition: bitcoingui.h:148
virtual bool getNetworkActive()=0
Get network active.
void updateNetworkState()
Update UI with latest network info from model.
Definition: bitcoingui.cpp:969
QLabel * labelWalletHDStatusIcon
Definition: bitcoingui.h:128
void showNormalIfMinimized()
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
Definition: bitcoingui.h:321
UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
QProgressDialog * progressDialog
Definition: bitcoingui.h:134
static bool isWalletEnabled()
void hideTrayIconChanged(bool)
void consoleShown(RPCConsole *console)
Signal raised when RPC console shown.
void createTrayIcon()
Create system tray icon and notification.
Definition: bitcoingui.cpp:818
Bilingual messages:
Definition: translation.h:17
void showDebugWindow()
Show debug window.
Definition: bitcoingui.cpp:901
GUIUtil::ClickableLabel * labelProxyIcon
Definition: bitcoingui.h:129
virtual double getVerificationProgress()=0
Get verification progress.
ClientModel * clientModel
Definition: bitcoingui.h:123
void createToolBars()
Create the toolbars.
Definition: bitcoingui.cpp:595
int TextWidth(const QFontMetrics &fm, const QString &text)
Returns the distance in pixels appropriate for drawing a subsequent character after text...
Definition: guiutil.cpp:877
NodeContext & m_node
Definition: chain.cpp:442
void setCurrentWallet(WalletModel *wallet_model)
Definition: walletframe.cpp:84
QAction * m_load_psbt_action
Definition: bitcoingui.h:147
ModalOverlay * modalOverlay
Definition: bitcoingui.h:175
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
Definition: bitcoingui.cpp:832
RPCConsole * rpcConsole
Definition: bitcoingui.h:173
QAction * m_wallet_selector_action
Definition: bitcoingui.h:165
QAction * overviewAction
Definition: bitcoingui.h:138
void opened(WalletModel *wallet_model)
QAction * verifyMessageAction
Definition: bitcoingui.h:146
QAction * quitAction
Definition: bitcoingui.h:140
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:13
QAction * m_open_wallet_action
Definition: bitcoingui.h:161
BitcoinGUI(interfaces::Node &node, const Config *, const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent=nullptr)
Definition: bitcoingui.cpp:75
void usedReceivingAddresses()
Show used receiving addresses.
QAction * m_close_wallet_action
Definition: bitcoingui.h:163
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const bilingual_str &message, const std::string &caption, unsigned int style)
Definition: amount.h:17
QAction * historyAction
Definition: bitcoingui.h:139
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:345
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
Definition: bitcoingui.cpp:800
void networkActiveChanged(bool networkActive)
QAction * aboutQtAction
Definition: bitcoingui.h:156
Controller between interfaces::Node, WalletModel instances and the GUI.
OptionsModel * getOptionsModel()
QIcon SingleColorIcon(const QString &filename) const
Colorize an icon (given filename) with the icon color.
void encryptWallet(bool status)
Encrypt the wallet.
std::string translated
Definition: translation.h:19
const Config * config
Definition: bitcoingui.h:185
QMenu * m_open_wallet_menu
Definition: bitcoingui.h:162
macOS-specific Dock icon handler.
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated...
Definition: ui_interface.h:58
Bitcoin GUI main class.
Definition: bitcoingui.h:67
bool isLayerVisible() const
Definition: modaloverlay.h:36
HelpMessageDialog * helpMessageDialog
Definition: bitcoingui.h:174
QLabel * progressBarLabel
Definition: bitcoingui.h:132
QSystemTrayIcon * trayIcon
Definition: bitcoingui.h:170
void numBlocksChanged(int count, const QDateTime &blockDate, double nVerificationProgress, bool header, SynchronizationState sync_state)
virtual std::vector< std::unique_ptr< Wallet > > getWallets()=0
Return interfaces for accessing wallets (if any).
QAction * showHelpMessageAction
Definition: bitcoingui.h:159
Notify user of potential problem.
Definition: notificator.h:38
Modal overlay to display information about the chain-sync state.
Definition: modaloverlay.h:20
const QString & getTitleAddText() const
Definition: networkstyle.h:23
void changeEvent(QEvent *e) override
static QString longName(int unit)
Long name.
void numConnectionsChanged(int count)
Signals for UI communication.
Definition: ui_interface.h:24
void removeAllWallets()
GUIUtil::ClickableLabel * connectionsControl
Definition: bitcoingui.h:130
QAction * backupWalletAction
Definition: bitcoingui.h:154
virtual const CChainParams & GetChainParams() const =0
void setOptionsModel(OptionsModel *optionsModel)
Lets the control know about the Options Model (and its signals)
void dropEvent(QDropEvent *event) override
void bringToFront(QWidget *w)
Definition: guiutil.cpp:369
std::map< std::string, bool > listWalletDir() const
Returns all wallet names in the wallet dir mapped to whether the wallet is loaded.
QString tabTitle(TabTypes tab_type) const
void openOptionsDialogWithTab(OptionsDialog::Tab tab)
Open the OptionsDialog on the specified tab index.
EncryptionStatus getEncryptionStatus() const
int getDisplayUnit() const
Definition: optionsmodel.h:96
virtual std::unique_ptr< Handler > handleMessageBox(MessageBoxFn fn)=0
Force blocking, modal message box dialog (not just OS notification)
Definition: ui_interface.h:65
void showOutOfSyncWarning(bool fShow)
void setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:647
void gotoHistoryPage()
Switch to history (transactions) page.
QAction * usedReceivingAddressesAction
Definition: bitcoingui.h:144
void setClientModel(ClientModel *clientModel)
Set the client model.
Definition: bitcoingui.cpp:634
WalletModel * getWalletModel()
Definition: walletview.h:48
void showModalOverlay()
const NetworkStyle *const m_network_style
Definition: bitcoingui.h:187
WalletController * m_wallet_controller
Definition: bitcoingui.h:120
void gotoOverviewPage()
Switch to overview (home) page.
const PlatformStyle * platformStyle
Definition: bitcoingui.h:186
QAction * toggleHideAction
Definition: bitcoingui.h:152
virtual bool hdEnabled()=0
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:32
Definition: config.h:19
bool isObscured(QWidget *w)
Definition: guiutil.cpp:361
QAction * m_wallet_selector_label_action
Definition: bitcoingui.h:164
OptionsModel * optionsModel
Definition: bitcoingui.h:352
void created(WalletModel *wallet_model)
QLabel * m_wallet_selector_label
Definition: bitcoingui.h:167
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
void setKnownBestHeight(int count, const QDateTime &blockDate)
void optionsClicked()
Show configuration dialog.
Definition: bitcoingui.cpp:888
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, bool headers, SynchronizationState sync_state)
Set number of blocks and last block date shown in the UI.
void closeWallet(WalletModel *wallet_model, QWidget *parent=nullptr)
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.
const char * name
Definition: rest.cpp:43
QToolBar * appToolBar
Definition: bitcoingui.h:137
BlockSource
Definition: clientmodel.h:31
WalletFrame * walletFrame
Definition: bitcoingui.h:124
void updateDisplayUnit(int newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
WalletView * currentWalletView() const
QAction * usedSendingAddressesAction
Definition: bitcoingui.h:143
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
int64_t nPowTargetSpacing
Definition: params.h:104
void setTrayIconVisible(bool)
When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly.
void toggleVisibility()
bool enableWallet
Definition: bitcoingui.h:99
void setModel(OptionsModel *model)
QAction * openRPCConsoleAction
Definition: bitcoingui.h:157
std::vector< TabTypes > tabs() const
Definition: rpcconsole.h:66
void detectShutdown()
called by a timer to check if ShutdownRequested() has been set
Cross-platform desktop notification client.
Definition: notificator.h:24
void clicked(const QPoint &point)
Emitted when the label is clicked.
QLabel * labelWalletEncryptionIcon
Definition: bitcoingui.h:127
GUIUtil::ClickableLabel * labelBlocksIcon
Definition: bitcoingui.h:131
void setCurrentTab(OptionsDialog::Tab tab)
Informational message.
Definition: notificator.h:37
GUIUtil::ClickableProgressBar * progressBar
Definition: bitcoingui.h:133
void updateWindowTitle()
void showHelpMessageClicked()
Show help message dialog.
Definition: bitcoingui.cpp:911
QString getWalletName() const
void walletAdded(WalletModel *wallet_model)
Notificator * notificator
Definition: bitcoingui.h:172
void displayUnitChanged(int unit)
void PolishProgressDialog(QProgressDialog *dialog)
Definition: guiutil.cpp:885
void changePassphrase()
Change encrypted wallet passphrase.
Model for Bitcoin network client.
Definition: clientmodel.h:34
An error occurred.
Definition: notificator.h:39
const QIcon & getTrayAndWindowIcon() const
Definition: networkstyle.h:22
void mousePressEvent(QMouseEvent *event) override
So that it responds to left-button clicks.
QAction * receiveCoinsMenuAction
Definition: bitcoingui.h:150
ClickableProgressBar ProgressBar
Definition: guiutil.h:284
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
virtual bool shutdownRequested()=0
Return whether shutdown was requested.
QAction * sendCoinsAction
Definition: bitcoingui.h:141
void showHide(bool hide=false, bool userRequested=false)
QAction * m_create_wallet_action
Definition: bitcoingui.h:160
QKeySequence tabShortcut(TabTypes tab_type) const
static const int STATUSBAR_ICONSIZE
Definition: guiconstants.h:17
void message(const QString &title, QString message, unsigned int style, bool *ret=nullptr, const QString &detailed_message=QString())
Notify the user of an event from the core network or transaction handling code.
QColor SingleColor() const
Definition: platformstyle.h:24
void requestedSyncWarningInfo()
Notify that the user has requested more information about the out-of-sync warning.
QAction * openAction
Definition: bitcoingui.h:158
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
Definition: bitcoingui.cpp:875
void gotoLoadPSBT()
Load Partially Signed Bitcoin Transaction.
bool getMinimizeOnClose() const
Definition: optionsmodel.h:95
void updateProxyIcon()
Set the proxy-enabled icon as shown in the UI.
QAction * changePassphraseAction
Definition: bitcoingui.h:155
virtual int64_t getLastBlockTime()=0
Get last block time.
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
virtual std::unique_ptr< Handler > handleQuestion(QuestionFn fn)=0
void gotoReceiveCoinsPage()
Switch to receive coins page.
std::vector< WalletModel * > getOpenWallets() const
Returns wallet models currently open.
const std::unique_ptr< QMenu > trayIconMenu
Definition: bitcoingui.h:171
std::string original
Definition: translation.h:18
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:48
std::unique_ptr< interfaces::Handler > m_handler_question
Definition: bitcoingui.h:122
bool getMinimizeToTray() const
Definition: optionsmodel.h:94
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:47
QAction * sendCoinsMenuAction
Definition: bitcoingui.h:142
bool eventFilter(QObject *object, QEvent *event) override
int prevBlocks
Keep track of previous number of blocks, to detect progress.
Definition: bitcoingui.h:182
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
interfaces::Node & m_node
Definition: bitcoingui.h:119
int spinnerFrame
Definition: bitcoingui.h:183
void walletRemoved(WalletModel *wallet_model)
void removeWallet(WalletModel *const walletModel)
static int count
Definition: tests.c:35
const std::string & CashAddrPrefix() const
Definition: chainparams.h:92
bool addWallet(WalletModel *walletModel)
Definition: walletframe.cpp:41
void setNumConnections(int count)
Set number of connections shown in the UI.
QString getDisplayName() const
"Help message" dialog box
Definition: utilitydialog.h:20
void backupWallet()
Backup the wallet.
void closeEvent(QCloseEvent *event) override
QComboBox * m_wallet_selector
Definition: bitcoingui.h:168
Preferences dialog.
Definition: optionsdialog.h:33
void clicked(const QPoint &point)
Emitted when the progressbar is clicked.
virtual int getNumBlocks()=0
Get num blocks.
QString formatNiceTimeOffset(qint64 secs)
Definition: guiutil.cpp:796
void createContextMenu()
Creates context menu, its actions, and wires up all the relevant signals for mouse events...
void showDebugWindowActivateConsole()
Show debug window and set focus to the console.
Definition: bitcoingui.cpp:906
void createActions()
Create the main UI actions.
Definition: bitcoingui.cpp:242
QAction * optionsAction
Definition: bitcoingui.h:151
QAction * encryptWalletAction
Definition: bitcoingui.h:153
void aboutClicked()
Show about dialog.
Definition: bitcoingui.cpp:892
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:59
void removeWallet(WalletModel *wallet_model)
Definition: walletframe.cpp:95
int getHeaderTipHeight() const
Definition: clientmodel.cpp:80
void updateHeadersSyncProgressLabel()
int64_t GetTime()
Return system time (or mocked time, if set)
Definition: time.cpp:27
static const std::string DEFAULT_UIPLATFORM
Definition: bitcoingui.h:71
virtual void setNetworkActive(bool active)=0
Set network active.
int64_t getHeaderTipTime() const
Definition: clientmodel.cpp:94
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:45
static constexpr int64_t MAX_BLOCK_TIME_GAP
Maximum gap between node time and block time used for the "Catching up..." mode in GUI...
Definition: chain.h:44
A container for embedding all wallet-related controls into BitcoinGUI.
Definition: walletframe.h:29
void showProgress(const QString &title, int nProgress)
void usedSendingAddresses()
Show used sending addresses.
bool getHideTrayIcon() const
Definition: optionsmodel.h:93
void onDisplayUnitsClicked(const QPoint &point)
Shows context menu with Display Unit options by the mouse coordinates.
void createMenuBar()
Create the menu bar and sub-menus.
Definition: bitcoingui.cpp:500
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
std::unique_ptr< interfaces::Handler > m_handler_message_box
Definition: bitcoingui.h:121
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:71
#define SPINNER_FRAMES
Definition: guiconstants.h:43
void dragEnterEvent(QDragEnterEvent *event) override
bool getProxyInfo(std::string &ip_port) const