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