Bitcoin Core  0.20.99
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(node, 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(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime()));
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);
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 void BitcoinGUI::addWallet(WalletModel* walletModel)
664 {
665  if (!walletFrame) return;
666  if (!walletFrame->addWallet(walletModel)) return;
667  const QString display_name = walletModel->getDisplayName();
669  rpcConsole->addWallet(walletModel);
670  m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));
671  if (m_wallet_selector->count() == 2) {
672  m_wallet_selector_label_action->setVisible(true);
673  m_wallet_selector_action->setVisible(true);
674  }
675 }
676 
677 void BitcoinGUI::removeWallet(WalletModel* walletModel)
678 {
679  if (!walletFrame) return;
680 
681  labelWalletHDStatusIcon->hide();
683 
684  int index = m_wallet_selector->findData(QVariant::fromValue(walletModel));
685  m_wallet_selector->removeItem(index);
686  if (m_wallet_selector->count() == 0) {
688  overviewAction->setChecked(true);
689  } else if (m_wallet_selector->count() == 1) {
690  m_wallet_selector_label_action->setVisible(false);
691  m_wallet_selector_action->setVisible(false);
692  }
693  rpcConsole->removeWallet(walletModel);
694  walletFrame->removeWallet(walletModel);
696 }
697 
698 void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)
699 {
700  if (!walletFrame) return;
701  walletFrame->setCurrentWallet(wallet_model);
702  for (int index = 0; index < m_wallet_selector->count(); ++index) {
703  if (m_wallet_selector->itemData(index).value<WalletModel*>() == wallet_model) {
704  m_wallet_selector->setCurrentIndex(index);
705  break;
706  }
707  }
709 }
710 
711 void BitcoinGUI::setCurrentWalletBySelectorIndex(int index)
712 {
713  WalletModel* wallet_model = m_wallet_selector->itemData(index).value<WalletModel*>();
714  if (wallet_model) setCurrentWallet(wallet_model);
715 }
716 
717 void BitcoinGUI::removeAllWallets()
718 {
719  if(!walletFrame)
720  return;
723 }
724 #endif // ENABLE_WALLET
725 
727 {
728  overviewAction->setEnabled(enabled);
729  sendCoinsAction->setEnabled(enabled);
730  sendCoinsMenuAction->setEnabled(enabled);
731  receiveCoinsAction->setEnabled(enabled);
732  receiveCoinsMenuAction->setEnabled(enabled);
733  historyAction->setEnabled(enabled);
734  encryptWalletAction->setEnabled(enabled);
735  backupWalletAction->setEnabled(enabled);
736  changePassphraseAction->setEnabled(enabled);
737  signMessageAction->setEnabled(enabled);
738  verifyMessageAction->setEnabled(enabled);
739  usedSendingAddressesAction->setEnabled(enabled);
740  usedReceivingAddressesAction->setEnabled(enabled);
741  openAction->setEnabled(enabled);
742  m_close_wallet_action->setEnabled(enabled);
743  m_close_all_wallets_action->setEnabled(enabled);
744 }
745 
747 {
748  assert(QSystemTrayIcon::isSystemTrayAvailable());
749 
750 #ifndef Q_OS_MAC
751  if (QSystemTrayIcon::isSystemTrayAvailable()) {
752  trayIcon = new QSystemTrayIcon(m_network_style->getTrayAndWindowIcon(), this);
753  QString toolTip = tr("%1 client").arg(PACKAGE_NAME) + " " + m_network_style->getTitleAddText();
754  trayIcon->setToolTip(toolTip);
755  }
756 #endif
757 }
758 
760 {
761 #ifndef Q_OS_MAC
762  // return if trayIcon is unset (only on non-macOSes)
763  if (!trayIcon)
764  return;
765 
766  trayIcon->setContextMenu(trayIconMenu.get());
767  connect(trayIcon, &QSystemTrayIcon::activated, this, &BitcoinGUI::trayIconActivated);
768 #else
769  // Note: On macOS, the Dock icon is used to provide the tray's functionality.
771  connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, this, &BitcoinGUI::macosDockIconActivated);
772  trayIconMenu->setAsDockMenu();
773 #endif
774 
775  // Configuration of the tray icon (or Dock icon) menu
776 #ifndef Q_OS_MAC
777  // Note: On macOS, the Dock icon's menu already has Show / Hide action.
778  trayIconMenu->addAction(toggleHideAction);
779  trayIconMenu->addSeparator();
780 #endif
781  if (enableWallet) {
782  trayIconMenu->addAction(sendCoinsMenuAction);
784  trayIconMenu->addSeparator();
785  trayIconMenu->addAction(signMessageAction);
786  trayIconMenu->addAction(verifyMessageAction);
787  trayIconMenu->addSeparator();
788  }
789  trayIconMenu->addAction(optionsAction);
791 #ifndef Q_OS_MAC // This is built-in on macOS
792  trayIconMenu->addSeparator();
793  trayIconMenu->addAction(quitAction);
794 #endif
795 }
796 
797 #ifndef Q_OS_MAC
798 void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
799 {
800  if(reason == QSystemTrayIcon::Trigger)
801  {
802  // Click on system tray icon triggers show/hide of the main window
803  toggleHidden();
804  }
805 }
806 #else
807 void BitcoinGUI::macosDockIconActivated()
808 {
809  show();
810  activateWindow();
811 }
812 #endif
813 
815 {
817 }
818 
820 {
821  if(!clientModel)
822  return;
823 
824  HelpMessageDialog dlg(m_node, this, true);
825  dlg.exec();
826 }
827 
829 {
831  Q_EMIT consoleShown(rpcConsole);
832 }
833 
835 {
837  showDebugWindow();
838 }
839 
841 {
842  helpMessageDialog->show();
843 }
844 
845 #ifdef ENABLE_WALLET
846 void BitcoinGUI::openClicked()
847 {
848  OpenURIDialog dlg(this);
849  if(dlg.exec())
850  {
851  Q_EMIT receivedURI(dlg.getURI());
852  }
853 }
854 
855 void BitcoinGUI::gotoOverviewPage()
856 {
857  overviewAction->setChecked(true);
859 }
860 
861 void BitcoinGUI::gotoHistoryPage()
862 {
863  historyAction->setChecked(true);
865 }
866 
867 void BitcoinGUI::gotoReceiveCoinsPage()
868 {
869  receiveCoinsAction->setChecked(true);
871 }
872 
873 void BitcoinGUI::gotoSendCoinsPage(QString addr)
874 {
875  sendCoinsAction->setChecked(true);
877 }
878 
879 void BitcoinGUI::gotoSignMessageTab(QString addr)
880 {
882 }
883 
884 void BitcoinGUI::gotoVerifyMessageTab(QString addr)
885 {
887 }
888 void BitcoinGUI::gotoLoadPSBT(bool from_clipboard)
889 {
890  if (walletFrame) walletFrame->gotoLoadPSBT(from_clipboard);
891 }
892 #endif // ENABLE_WALLET
893 
895 {
897  QString icon;
898  switch(count)
899  {
900  case 0: icon = ":/icons/connect_0"; break;
901  case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
902  case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
903  case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
904  default: icon = ":/icons/connect_4"; break;
905  }
906 
907  QString tooltip;
908 
909  if (m_node.getNetworkActive()) {
910  tooltip = tr("%n active connection(s) to Bitcoin network", "", count) + QString(".<br>") + tr("Click to disable network activity.");
911  } else {
912  tooltip = tr("Network activity disabled.") + QString("<br>") + tr("Click to enable network activity again.");
913  icon = ":/icons/network_disabled";
914  }
915 
916  // Don't word-wrap this (fixed-width) tooltip
917  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
918  connectionsControl->setToolTip(tooltip);
919 
921 }
922 
924 {
926 }
927 
928 void BitcoinGUI::setNetworkActive(bool networkActive)
929 {
931 }
932 
934 {
935  int64_t headersTipTime = clientModel->getHeaderTipTime();
936  int headersTipHeight = clientModel->getHeaderTipHeight();
937  int estHeadersLeft = (GetTime() - headersTipTime) / Params().GetConsensus().nPowTargetSpacing;
938  if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
939  progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
940 }
941 
943 {
945  return;
946 
947  OptionsDialog dlg(this, enableWallet);
948  dlg.setCurrentTab(tab);
950  dlg.exec();
951 }
952 
953 void BitcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header, SynchronizationState sync_state)
954 {
955 // Disabling macOS App Nap on initial sync, disk and reindex operations.
956 #ifdef Q_OS_MAC
957  if (sync_state == SynchronizationState::POST_INIT) {
958  m_app_nap_inhibitor->enableAppNap();
959  } else {
960  m_app_nap_inhibitor->disableAppNap();
961  }
962 #endif
963 
964  if (modalOverlay)
965  {
966  if (header)
967  modalOverlay->setKnownBestHeight(count, blockDate);
968  else
969  modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
970  }
971  if (!clientModel)
972  return;
973 
974  // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbled text)
975  statusBar()->clearMessage();
976 
977  // Acquire current block source
978  enum BlockSource blockSource = clientModel->getBlockSource();
979  switch (blockSource) {
981  if (header) {
983  return;
984  }
985  progressBarLabel->setText(tr("Synchronizing with network..."));
987  break;
988  case BlockSource::DISK:
989  if (header) {
990  progressBarLabel->setText(tr("Indexing blocks on disk..."));
991  } else {
992  progressBarLabel->setText(tr("Processing blocks on disk..."));
993  }
994  break;
996  progressBarLabel->setText(tr("Reindexing blocks on disk..."));
997  break;
998  case BlockSource::NONE:
999  if (header) {
1000  return;
1001  }
1002  progressBarLabel->setText(tr("Connecting to peers..."));
1003  break;
1004  }
1005 
1006  QString tooltip;
1007 
1008  QDateTime currentDate = QDateTime::currentDateTime();
1009  qint64 secs = blockDate.secsTo(currentDate);
1010 
1011  tooltip = tr("Processed %n block(s) of transaction history.", "", count);
1012 
1013  // Set icon state: spinning if catching up, tick otherwise
1014  if (secs < MAX_BLOCK_TIME_GAP) {
1015  tooltip = tr("Up to date") + QString(".<br>") + tooltip;
1016  labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1017 
1018 #ifdef ENABLE_WALLET
1019  if(walletFrame)
1020  {
1022  modalOverlay->showHide(true, true);
1023  }
1024 #endif // ENABLE_WALLET
1025 
1026  progressBarLabel->setVisible(false);
1027  progressBar->setVisible(false);
1028  }
1029  else
1030  {
1031  QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);
1032 
1033  progressBarLabel->setVisible(true);
1034  progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
1035  progressBar->setMaximum(1000000000);
1036  progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
1037  progressBar->setVisible(true);
1038 
1039  tooltip = tr("Catching up...") + QString("<br>") + tooltip;
1040  if(count != prevBlocks)
1041  {
1042  labelBlocksIcon->setPixmap(platformStyle->SingleColorIcon(QString(
1043  ":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
1046  }
1047  prevBlocks = count;
1048 
1049 #ifdef ENABLE_WALLET
1050  if(walletFrame)
1051  {
1054  }
1055 #endif // ENABLE_WALLET
1056 
1057  tooltip += QString("<br>");
1058  tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
1059  tooltip += QString("<br>");
1060  tooltip += tr("Transactions after this will not yet be visible.");
1061  }
1062 
1063  // Don't word-wrap this (fixed-width) tooltip
1064  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
1065 
1066  labelBlocksIcon->setToolTip(tooltip);
1067  progressBarLabel->setToolTip(tooltip);
1068  progressBar->setToolTip(tooltip);
1069 }
1070 
1071 void BitcoinGUI::message(const QString& title, QString message, unsigned int style, bool* ret, const QString& detailed_message)
1072 {
1073  // Default title. On macOS, the window title is ignored (as required by the macOS Guidelines).
1074  QString strTitle{PACKAGE_NAME};
1075  // Default to information icon
1076  int nMBoxIcon = QMessageBox::Information;
1077  int nNotifyIcon = Notificator::Information;
1078 
1079  QString msgType;
1080  if (!title.isEmpty()) {
1081  msgType = title;
1082  } else {
1083  switch (style) {
1085  msgType = tr("Error");
1086  message = tr("Error: %1").arg(message);
1087  break;
1089  msgType = tr("Warning");
1090  message = tr("Warning: %1").arg(message);
1091  break;
1093  msgType = tr("Information");
1094  // No need to prepend the prefix here.
1095  break;
1096  default:
1097  break;
1098  }
1099  }
1100 
1101  if (!msgType.isEmpty()) {
1102  strTitle += " - " + msgType;
1103  }
1104 
1105  if (style & CClientUIInterface::ICON_ERROR) {
1106  nMBoxIcon = QMessageBox::Critical;
1107  nNotifyIcon = Notificator::Critical;
1108  } else if (style & CClientUIInterface::ICON_WARNING) {
1109  nMBoxIcon = QMessageBox::Warning;
1110  nNotifyIcon = Notificator::Warning;
1111  }
1112 
1113  if (style & CClientUIInterface::MODAL) {
1114  // Check for buttons, use OK as default, if none was supplied
1115  QMessageBox::StandardButton buttons;
1116  if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
1117  buttons = QMessageBox::Ok;
1118 
1120  QMessageBox mBox(static_cast<QMessageBox::Icon>(nMBoxIcon), strTitle, message, buttons, this);
1121  mBox.setTextFormat(Qt::PlainText);
1122  mBox.setDetailedText(detailed_message);
1123  int r = mBox.exec();
1124  if (ret != nullptr)
1125  *ret = r == QMessageBox::Ok;
1126  } else {
1127  notificator->notify(static_cast<Notificator::Class>(nNotifyIcon), strTitle, message);
1128  }
1129 }
1130 
1132 {
1133  QMainWindow::changeEvent(e);
1134 #ifndef Q_OS_MAC // Ignored on Mac
1135  if(e->type() == QEvent::WindowStateChange)
1136  {
1138  {
1139  QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
1140  if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
1141  {
1142  QTimer::singleShot(0, this, &BitcoinGUI::hide);
1143  e->ignore();
1144  }
1145  else if((wsevt->oldState() & Qt::WindowMinimized) && !isMinimized())
1146  {
1147  QTimer::singleShot(0, this, &BitcoinGUI::show);
1148  e->ignore();
1149  }
1150  }
1151  }
1152 #endif
1153 }
1154 
1155 void BitcoinGUI::closeEvent(QCloseEvent *event)
1156 {
1157 #ifndef Q_OS_MAC // Ignored on Mac
1159  {
1161  {
1162  // close rpcConsole in case it was open to make some space for the shutdown window
1163  rpcConsole->close();
1164 
1165  QApplication::quit();
1166  }
1167  else
1168  {
1169  QMainWindow::showMinimized();
1170  event->ignore();
1171  }
1172  }
1173 #else
1174  QMainWindow::closeEvent(event);
1175 #endif
1176 }
1177 
1178 void BitcoinGUI::showEvent(QShowEvent *event)
1179 {
1180  // enable the debug window when the main window shows up
1181  openRPCConsoleAction->setEnabled(true);
1182  aboutAction->setEnabled(true);
1183  optionsAction->setEnabled(true);
1184 }
1185 
1186 #ifdef ENABLE_WALLET
1187 void BitcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label, const QString& walletName)
1188 {
1189  // On new transaction, make an info balloon
1190  QString msg = tr("Date: %1\n").arg(date) +
1191  tr("Amount: %1\n").arg(BitcoinUnits::formatWithUnit(unit, amount, true));
1192  if (m_node.getWallets().size() > 1 && !walletName.isEmpty()) {
1193  msg += tr("Wallet: %1\n").arg(walletName);
1194  }
1195  msg += tr("Type: %1\n").arg(type);
1196  if (!label.isEmpty())
1197  msg += tr("Label: %1\n").arg(label);
1198  else if (!address.isEmpty())
1199  msg += tr("Address: %1\n").arg(address);
1200  message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
1202 }
1203 #endif // ENABLE_WALLET
1204 
1205 void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
1206 {
1207  // Accept only URIs
1208  if(event->mimeData()->hasUrls())
1209  event->acceptProposedAction();
1210 }
1211 
1212 void BitcoinGUI::dropEvent(QDropEvent *event)
1213 {
1214  if(event->mimeData()->hasUrls())
1215  {
1216  for (const QUrl &uri : event->mimeData()->urls())
1217  {
1218  Q_EMIT receivedURI(uri.toString());
1219  }
1220  }
1221  event->acceptProposedAction();
1222 }
1223 
1224 bool BitcoinGUI::eventFilter(QObject *object, QEvent *event)
1225 {
1226  // Catch status tip events
1227  if (event->type() == QEvent::StatusTip)
1228  {
1229  // Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
1230  if (progressBarLabel->isVisible() || progressBar->isVisible())
1231  return true;
1232  }
1233  return QMainWindow::eventFilter(object, event);
1234 }
1235 
1236 #ifdef ENABLE_WALLET
1237 bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
1238 {
1239  // URI has to be valid
1240  if (walletFrame && walletFrame->handlePaymentRequest(recipient))
1241  {
1243  gotoSendCoinsPage();
1244  return true;
1245  }
1246  return false;
1247 }
1248 
1249 void BitcoinGUI::setHDStatus(bool privkeyDisabled, int hdEnabled)
1250 {
1251  labelWalletHDStatusIcon->setPixmap(platformStyle->SingleColorIcon(privkeyDisabled ? ":/icons/eye" : hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1252  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>"));
1253  labelWalletHDStatusIcon->show();
1254  // eventually disable the QLabel to set its opacity to 50%
1255  labelWalletHDStatusIcon->setEnabled(hdEnabled);
1256 }
1257 
1258 void BitcoinGUI::setEncryptionStatus(int status)
1259 {
1260  switch(status)
1261  {
1263  labelWalletEncryptionIcon->hide();
1264  encryptWalletAction->setChecked(false);
1265  changePassphraseAction->setEnabled(false);
1266  encryptWalletAction->setEnabled(true);
1267  break;
1268  case WalletModel::Unlocked:
1269  labelWalletEncryptionIcon->show();
1271  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
1272  encryptWalletAction->setChecked(true);
1273  changePassphraseAction->setEnabled(true);
1274  encryptWalletAction->setEnabled(false);
1275  break;
1276  case WalletModel::Locked:
1277  labelWalletEncryptionIcon->show();
1279  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
1280  encryptWalletAction->setChecked(true);
1281  changePassphraseAction->setEnabled(true);
1282  encryptWalletAction->setEnabled(false);
1283  break;
1284  }
1285 }
1286 
1287 void BitcoinGUI::updateWalletStatus()
1288 {
1289  if (!walletFrame) {
1290  return;
1291  }
1292  WalletView * const walletView = walletFrame->currentWalletView();
1293  if (!walletView) {
1294  return;
1295  }
1296  WalletModel * const walletModel = walletView->getWalletModel();
1297  setEncryptionStatus(walletModel->getEncryptionStatus());
1298  setHDStatus(walletModel->wallet().privateKeysDisabled(), walletModel->wallet().hdEnabled());
1299 }
1300 #endif // ENABLE_WALLET
1301 
1303 {
1304  std::string ip_port;
1305  bool proxy_enabled = clientModel->getProxyInfo(ip_port);
1306 
1307  if (proxy_enabled) {
1308  if (labelProxyIcon->pixmap() == nullptr) {
1309  QString ip_port_q = QString::fromStdString(ip_port);
1310  labelProxyIcon->setPixmap(platformStyle->SingleColorIcon(":/icons/proxy").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1311  labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));
1312  } else {
1313  labelProxyIcon->show();
1314  }
1315  } else {
1316  labelProxyIcon->hide();
1317  }
1318 }
1319 
1321 {
1322  QString window_title = PACKAGE_NAME;
1323 #ifdef ENABLE_WALLET
1324  if (walletFrame) {
1325  WalletModel* const wallet_model = walletFrame->currentWalletModel();
1326  if (wallet_model && !wallet_model->getWalletName().isEmpty()) {
1327  window_title += " - " + wallet_model->getDisplayName();
1328  }
1329  }
1330 #endif
1331  if (!m_network_style->getTitleAddText().isEmpty()) {
1332  window_title += " - " + m_network_style->getTitleAddText();
1333  }
1334  setWindowTitle(window_title);
1335 }
1336 
1337 void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)
1338 {
1339  if(!clientModel)
1340  return;
1341 
1342  if (!isHidden() && !isMinimized() && !GUIUtil::isObscured(this) && fToggleHidden) {
1343  hide();
1344  } else {
1345  GUIUtil::bringToFront(this);
1346  }
1347 }
1348 
1350 {
1351  showNormalIfMinimized(true);
1352 }
1353 
1355 {
1356  if (m_node.shutdownRequested())
1357  {
1358  if(rpcConsole)
1359  rpcConsole->hide();
1360  qApp->quit();
1361  }
1362 }
1363 
1364 void BitcoinGUI::showProgress(const QString &title, int nProgress)
1365 {
1366  if (nProgress == 0) {
1367  progressDialog = new QProgressDialog(title, QString(), 0, 100);
1369  progressDialog->setWindowModality(Qt::ApplicationModal);
1370  progressDialog->setMinimumDuration(0);
1371  progressDialog->setAutoClose(false);
1372  progressDialog->setValue(0);
1373  } else if (nProgress == 100) {
1374  if (progressDialog) {
1375  progressDialog->close();
1376  progressDialog->deleteLater();
1377  progressDialog = nullptr;
1378  }
1379  } else if (progressDialog) {
1380  progressDialog->setValue(nProgress);
1381  }
1382 }
1383 
1384 void BitcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
1385 {
1386  if (trayIcon)
1387  {
1388  trayIcon->setVisible(!fHideTrayIcon);
1389  }
1390 }
1391 
1393 {
1394  if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))
1396 }
1397 
1398 static bool ThreadSafeMessageBox(BitcoinGUI* gui, const bilingual_str& message, const std::string& caption, unsigned int style)
1399 {
1400  bool modal = (style & CClientUIInterface::MODAL);
1401  // The SECURE flag has no effect in the Qt GUI.
1402  // bool secure = (style & CClientUIInterface::SECURE);
1403  style &= ~CClientUIInterface::SECURE;
1404  bool ret = false;
1405 
1406  QString detailed_message; // This is original message, in English, for googling and referencing.
1407  if (message.original != message.translated) {
1408  detailed_message = BitcoinGUI::tr("Original message:") + "\n" + QString::fromStdString(message.original);
1409  }
1410 
1411  // In case of modal message, use blocking connection to wait for user to click a button
1412  bool invoked = QMetaObject::invokeMethod(gui, "message",
1413  modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
1414  Q_ARG(QString, QString::fromStdString(caption)),
1415  Q_ARG(QString, QString::fromStdString(message.translated)),
1416  Q_ARG(unsigned int, style),
1417  Q_ARG(bool*, &ret),
1418  Q_ARG(QString, detailed_message));
1419  assert(invoked);
1420  return ret;
1421 }
1422 
1424 {
1425  // Connect signals to client
1426  m_handler_message_box = m_node.handleMessageBox(std::bind(ThreadSafeMessageBox, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
1427  m_handler_question = m_node.handleQuestion(std::bind(ThreadSafeMessageBox, this, std::placeholders::_1, std::placeholders::_3, std::placeholders::_4));
1428 }
1429 
1431 {
1432  // Disconnect signals from client
1433  m_handler_message_box->disconnect();
1434  m_handler_question->disconnect();
1435 }
1436 
1438 {
1439  assert(m_mask_values_action);
1440  return m_mask_values_action->isChecked();
1441 }
1442 
1444  optionsModel(nullptr),
1445  menu(nullptr)
1446 {
1448  setToolTip(tr("Unit to show amounts in. Click to select another unit."));
1449  QList<BitcoinUnits::Unit> units = BitcoinUnits::availableUnits();
1450  int max_width = 0;
1451  const QFontMetrics fm(font());
1452  for (const BitcoinUnits::Unit unit : units)
1453  {
1454  max_width = qMax(max_width, GUIUtil::TextWidth(fm, BitcoinUnits::longName(unit)));
1455  }
1456  setMinimumSize(max_width, 0);
1457  setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1458  setStyleSheet(QString("QLabel { color : %1 }").arg(platformStyle->SingleColor().name()));
1459 }
1460 
1463 {
1464  onDisplayUnitsClicked(event->pos());
1465 }
1466 
1469 {
1470  menu = new QMenu(this);
1472  {
1473  QAction *menuAction = new QAction(QString(BitcoinUnits::longName(u)), this);
1474  menuAction->setData(QVariant(u));
1475  menu->addAction(menuAction);
1476  }
1477  connect(menu, &QMenu::triggered, this, &UnitDisplayStatusBarControl::onMenuSelection);
1478 }
1479 
1482 {
1483  if (_optionsModel)
1484  {
1485  this->optionsModel = _optionsModel;
1486 
1487  // be aware of a display unit change reported by the OptionsModel object.
1489 
1490  // initialize the display units label with the current value in the model.
1491  updateDisplayUnit(_optionsModel->getDisplayUnit());
1492  }
1493 }
1494 
1497 {
1498  setText(BitcoinUnits::longName(newUnits));
1499 }
1500 
1503 {
1504  QPoint globalPos = mapToGlobal(point);
1505  menu->exec(globalPos);
1506 }
1507 
1510 {
1511  if (action)
1512  {
1513  optionsModel->setDisplayUnit(action->data());
1514  }
1515 }
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)
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.
Definition: bitcoingui.cpp:928
void addWallet(WalletModel *const walletModel)
WalletModel * currentWalletModel() const
QAction * receiveCoinsAction
Definition: bitcoingui.h:144
UnitDisplayStatusBarControl * unitDisplayControl
Definition: bitcoingui.h:120
Local Bitcoin RPC console.
Definition: rpcconsole.h:36
QMenuBar * appMenuBar
Definition: bitcoingui.h:130
Unit
Bitcoin units.
Definition: bitcoinunits.h:41
interfaces::Wallet & wallet() const
Definition: walletmodel.h:146
QAction * m_mask_values_action
Definition: bitcoingui.h:162
QAction * signMessageAction
Definition: bitcoingui.h:139
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:108
QAction * aboutAction
Definition: bitcoingui.h:143
virtual bool getNetworkActive()=0
Get network active.
void updateNetworkState()
Update UI with latest network info from model.
Definition: bitcoingui.cpp:894
QLabel * labelWalletHDStatusIcon
Definition: bitcoingui.h:122
void showNormalIfMinimized()
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
Definition: bitcoingui.h:307
UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
QProgressDialog * progressDialog
Definition: bitcoingui.h:128
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:746
Bilingual messages:
Definition: translation.h:16
void showDebugWindow()
Show debug window.
Definition: bitcoingui.cpp:828
GUIUtil::ClickableLabel * labelProxyIcon
Definition: bitcoingui.h:123
virtual double getVerificationProgress()=0
Get verification progress.
ClientModel * clientModel
Definition: bitcoingui.h:117
void createToolBars()
Create the toolbars.
Definition: bitcoingui.cpp:540
int TextWidth(const QFontMetrics &fm, const QString &text)
Returns the distance in pixels appropriate for drawing a subsequent character after text...
Definition: guiutil.cpp:893
NodeContext & m_node
Definition: chain.cpp:382
void setCurrentWallet(WalletModel *wallet_model)
Definition: walletframe.cpp:82
QAction * m_load_psbt_action
Definition: bitcoingui.h:141
void closeAllWallets(QWidget *parent=nullptr)
ModalOverlay * modalOverlay
Definition: bitcoingui.h:172
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
Definition: bitcoingui.cpp:759
RPCConsole * rpcConsole
Definition: bitcoingui.h:170
QAction * m_wallet_selector_action
Definition: bitcoingui.h:161
QAction * overviewAction
Definition: bitcoingui.h:132
void opened(WalletModel *wallet_model)
QAction * verifyMessageAction
Definition: bitcoingui.h:140
QAction * quitAction
Definition: bitcoingui.h:134
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:156
void triggered(bool hidden)
void usedReceivingAddresses()
Show used receiving addresses.
QAction * m_close_wallet_action
Definition: bitcoingui.h:158
static bool ThreadSafeMessageBox(BitcoinGUI *gui, const bilingual_str &message, const std::string &caption, unsigned int style)
QAction * historyAction
Definition: bitcoingui.h:133
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:344
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
Definition: bitcoingui.cpp:726
void networkActiveChanged(bool networkActive)
QAction * aboutQtAction
Definition: bitcoingui.h:151
#define PACKAGE_NAME
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:18
QMenu * m_open_wallet_menu
Definition: bitcoingui.h:157
macOS-specific Dock icon handler.
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated...
Definition: ui_interface.h:56
Bitcoin GUI main class.
Definition: bitcoingui.h:65
bool isLayerVisible() const
Definition: modaloverlay.h:33
HelpMessageDialog * helpMessageDialog
Definition: bitcoingui.h:171
QLabel * progressBarLabel
Definition: bitcoingui.h:126
QSystemTrayIcon * trayIcon
Definition: bitcoingui.h:167
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:154
Notify user of potential problem.
Definition: notificator.h:39
Modal overlay to display information about the chain-sync state.
Definition: modaloverlay.h:20
bool isPrivacyModeActivated() const
const QString & getTitleAddText() const
Definition: networkstyle.h:22
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:124
QAction * backupWalletAction
Definition: bitcoingui.h:149
QAction * m_load_psbt_clipboard_action
Definition: bitcoingui.h:142
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:372
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.
Definition: bitcoingui.cpp:942
EncryptionStatus getEncryptionStatus() const
int getDisplayUnit() const
Definition: optionsmodel.h:82
virtual std::unique_ptr< Handler > handleMessageBox(MessageBoxFn fn)=0
Force blocking, modal message box dialog (not just OS notification)
Definition: ui_interface.h:60
void showOutOfSyncWarning(bool fShow)
void setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:560
void gotoHistoryPage()
Switch to history (transactions) page.
QAction * usedReceivingAddressesAction
Definition: bitcoingui.h:138
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
void setClientModel(ClientModel *clientModel)
Set the client model.
Definition: bitcoingui.cpp:577
WalletModel * getWalletModel()
Definition: walletview.h:45
void showModalOverlay()
const NetworkStyle *const m_network_style
Definition: bitcoingui.h:183
WalletController * m_wallet_controller
Definition: bitcoingui.h:114
void gotoOverviewPage()
Switch to overview (home) page.
const PlatformStyle * platformStyle
Definition: bitcoingui.h:182
QAction * toggleHideAction
Definition: bitcoingui.h:147
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:37
bool isObscured(QWidget *w)
Definition: guiutil.cpp:363
QAction * m_wallet_selector_label_action
Definition: bitcoingui.h:160
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:67
OptionsModel * optionsModel
Definition: bitcoingui.h:338
void created(WalletModel *wallet_model)
QLabel * m_wallet_selector_label
Definition: bitcoingui.h:164
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:814
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:953
void closeWallet(WalletModel *wallet_model, QWidget *parent=nullptr)
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
void handleCloseWindowShortcut(QWidget *w)
Definition: guiutil.cpp:390
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:41
QToolBar * appToolBar
Definition: bitcoingui.h:131
BlockSource
Definition: clientmodel.h:31
WalletFrame * walletFrame
Definition: bitcoingui.h:118
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:137
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
int64_t nPowTargetSpacing
Definition: params.h:78
BitcoinGUI(interfaces::Node &node, const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent=nullptr)
Definition: bitcoingui.cpp:77
void setTrayIconVisible(bool)
When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly.
void toggleVisibility()
bool enableWallet
Definition: bitcoingui.h:92
void setModel(OptionsModel *model)
QAction * openRPCConsoleAction
Definition: bitcoingui.h:152
QAction * m_close_all_wallets_action
Definition: bitcoingui.h:159
std::vector< TabTypes > tabs() const
Definition: rpcconsole.h:68
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=SeparatorStyle::STANDARD)
Format as string (with unit)
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:121
GUIUtil::ClickableLabel * labelBlocksIcon
Definition: bitcoingui.h:125
void setCurrentTab(OptionsDialog::Tab tab)
Informational message.
Definition: notificator.h:38
GUIUtil::ClickableProgressBar * progressBar
Definition: bitcoingui.h:127
void updateWindowTitle()
void showHelpMessageClicked()
Show help message dialog.
Definition: bitcoingui.cpp:840
QString getWalletName() const
void walletAdded(WalletModel *wallet_model)
Notificator * notificator
Definition: bitcoingui.h:169
void displayUnitChanged(int unit)
void PolishProgressDialog(QProgressDialog *dialog)
Definition: guiutil.cpp:881
void changePassphrase()
Change encrypted wallet passphrase.
Model for Bitcoin network client.
Definition: clientmodel.h:46
An error occurred.
Definition: notificator.h:40
const QIcon & getTrayAndWindowIcon() const
Definition: networkstyle.h:21
void mousePressEvent(QMouseEvent *event) override
So that it responds to left-button clicks.
QAction * receiveCoinsMenuAction
Definition: bitcoingui.h:145
ClickableProgressBar ProgressBar
Definition: guiutil.h:271
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:135
void showHide(bool hide=false, bool userRequested=false)
QAction * m_create_wallet_action
Definition: bitcoingui.h:155
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:25
void requestedSyncWarningInfo()
Notify that the user has requested more information about the out-of-sync warning.
QAction * openAction
Definition: bitcoingui.h:153
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
Definition: bitcoingui.cpp:798
bool getMinimizeOnClose() const
Definition: optionsmodel.h:81
void updateProxyIcon()
Set the proxy-enabled icon as shown in the UI.
QAction * changePassphraseAction
Definition: bitcoingui.h:150
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:168
void setPrivacy(bool privacy)
std::string original
Definition: translation.h:17
Interface from Qt to configuration data structure for Bitcoin client.
Definition: optionsmodel.h:37
std::unique_ptr< interfaces::Handler > m_handler_question
Definition: bitcoingui.h:116
const CChainParams & Params()
Return the currently selected parameters.
bool getMinimizeToTray() const
Definition: optionsmodel.h:80
Interface to Bitcoin wallet from Qt view code.
Definition: walletmodel.h:51
QString getURI()
QAction * sendCoinsMenuAction
Definition: bitcoingui.h:136
bool eventFilter(QObject *object, QEvent *event) override
int prevBlocks
Keep track of previous number of blocks, to detect progress.
Definition: bitcoingui.h:179
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
interfaces::Node & m_node
Definition: bitcoingui.h:113
int spinnerFrame
Definition: bitcoingui.h:180
void walletRemoved(WalletModel *wallet_model)
void removeWallet(WalletModel *const walletModel)
static int count
Definition: tests.c:35
bool addWallet(WalletModel *walletModel)
Definition: walletframe.cpp:46
void setNumConnections(int count)
Set number of connections shown in the UI.
Definition: bitcoingui.cpp:923
QString getDisplayName() const
"Help message" dialog box
Definition: utilitydialog.h:24
void backupWallet()
Backup the wallet.
void closeEvent(QCloseEvent *event) override
QComboBox * m_wallet_selector
Definition: bitcoingui.h:165
Preferences dialog.
Definition: optionsdialog.h:35
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:800
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:834
void createActions()
Create the main UI actions.
Definition: bitcoingui.cpp:239
QAction * optionsAction
Definition: bitcoingui.h:146
QAction * encryptWalletAction
Definition: bitcoingui.h:148
void aboutClicked()
Show about dialog.
Definition: bitcoingui.cpp:819
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:60
void removeWallet(WalletModel *wallet_model)
Definition: walletframe.cpp:92
int getHeaderTipHeight() const
Definition: clientmodel.cpp:81
void updateHeadersSyncProgressLabel()
Definition: bitcoingui.cpp:933
void gotoLoadPSBT(bool from_clipboard=false)
Load Partially Signed Bitcoin Transaction.
int64_t GetTime()
Return system time (or mocked time, if set)
Definition: time.cpp:23
static const std::string DEFAULT_UIPLATFORM
Definition: bitcoingui.h:70
virtual void setNetworkActive(bool active)=0
Set network active.
int64_t getHeaderTipTime() const
Definition: clientmodel.cpp:96
static RPCHelpMan help()
Definition: server.cpp:133
Top-level interface for a bitcoin node (bitcoind process).
Definition: node.h:43
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
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:79
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:443
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:115
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:66
#define SPINNER_FRAMES
Definition: guiconstants.h:43
void dragEnterEvent(QDragEnterEvent *event) override
bool getProxyInfo(std::string &ip_port) const