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