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