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