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