Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
751unitDisplayControl->setOptionsModel(nullptr);752// Disable top bar menu actions753appMenuBar->clear();754}755}757#ifdef ENABLE_WALLET758void BitcoinGUI::enableHistoryAction(bool privacy)759{760if (walletFrame->currentWalletModel()) {761historyAction->setEnabled(!privacy);762if (historyAction->isChecked()) gotoOverviewPage();763}764}766void BitcoinGUI::setWalletController(WalletController* wallet_controller, bool show_loading_minimized)767{768assert(!m_wallet_controller);769assert(wallet_controller);771m_wallet_controller = wallet_controller;773m_create_wallet_action->setEnabled(true);774m_open_wallet_action->setEnabled(true);775m_open_wallet_action->setMenu(m_open_wallet_menu);776m_restore_wallet_action->setEnabled(true);777m_migrate_wallet_action->setEnabled(true);778m_migrate_wallet_action->setMenu(m_migrate_wallet_menu);780GUIUtil::ExceptionSafeConnect(wallet_controller, &WalletController::walletAdded, this, &BitcoinGUI::addWallet);781connect(wallet_controller, &WalletController::walletRemoved, this, &BitcoinGUI::removeWallet);782connect(wallet_controller, &WalletController::destroyed, this, [this] {783// wallet_controller gets destroyed manually, but it leaves our member copy dangling784m_wallet_controller = nullptr;785});787auto activity = new LoadWalletsActivity(m_wallet_controller, this);788activity->load(show_loading_minimized);789}791WalletController* BitcoinGUI::getWalletController()792{793return m_wallet_controller;794}796void BitcoinGUI::addWallet(WalletModel* walletModel)797{798if (!walletFrame || !m_wallet_controller) return;800WalletView* wallet_view = new WalletView(walletModel, platformStyle, walletFrame);801if (!walletFrame->addView(wallet_view)) return;803rpcConsole->addWallet(walletModel);804if (m_wallet_selector->count() == 0) {805setWalletActionsEnabled(true);806} else if (m_wallet_selector->count() == 1) {807m_wallet_selector_label_action->setVisible(true);808m_wallet_selector_action->setVisible(true);809}811connect(wallet_view, &WalletView::outOfSyncWarningClicked, this, &BitcoinGUI::showModalOverlay);812connect(wallet_view, &WalletView::transactionClicked, this, &BitcoinGUI::gotoHistoryPage);813connect(wallet_view, &WalletView::coinsSent, this, &BitcoinGUI::gotoHistoryPage);814connect(wallet_view, &WalletView::message, [this](const QString& title, const QString& message, unsigned int style) {815this->message(title, message, style);816});817connect(wallet_view, &WalletView::encryptionStatusChanged, this, &BitcoinGUI::updateWalletStatus);818connect(wallet_view, &WalletView::incomingTransaction, this, &BitcoinGUI::incomingTransaction);819connect(this, &BitcoinGUI::setPrivacy, wallet_view, &WalletView::setPrivacy);820wallet_view->setPrivacy(isPrivacyModeActivated());821const QString display_name = walletModel->getDisplayName();822m_wallet_selector->addItem(display_name, QVariant::fromValue(walletModel));823}825void BitcoinGUI::removeWallet(WalletModel* walletModel)826{827if (!walletFrame) return;829labelWalletHDStatusIcon->hide();830labelWalletEncryptionIcon->hide();832int index = m_wallet_selector->findData(QVariant::fromValue(walletModel));833m_wallet_selector->removeItem(index);834if (m_wallet_selector->count() == 0) {835setWalletActionsEnabled(false);836overviewAction->setChecked(true);837} else if (m_wallet_selector->count() == 1) {838m_wallet_selector_label_action->setVisible(false);839m_wallet_selector_action->setVisible(false);840}841rpcConsole->removeWallet(walletModel);842walletFrame->removeWallet(walletModel);843updateWindowTitle();844}846void BitcoinGUI::setCurrentWallet(WalletModel* wallet_model)847{848if (!walletFrame || !m_wallet_controller) return;849walletFrame->setCurrentWallet(wallet_model);850for (int index = 0; index < m_wallet_selector->count(); ++index) {851if (m_wallet_selector->itemData(index).value<WalletModel*>() == wallet_model) {852m_wallet_selector->setCurrentIndex(index);853break;854}855}856m_export_watchonly_action->setEnabled(!wallet_model->wallet().privateKeysDisabled());857updateWindowTitle();858}860void BitcoinGUI::setCurrentWalletBySelectorIndex(int index)861{862WalletModel* wallet_model = m_wallet_selector->itemData(index).value<WalletModel*>();863if (wallet_model) setCurrentWallet(wallet_model);864}866void BitcoinGUI::removeAllWallets()867{868if(!walletFrame)869return;870setWalletActionsEnabled(false);871walletFrame->removeAllWallets();872}873#endif // ENABLE_WALLET875void BitcoinGUI::setWalletActionsEnabled(bool enabled)876{877overviewAction->setEnabled(enabled);878sendCoinsAction->setEnabled(enabled);879receiveCoinsAction->setEnabled(enabled);880historyAction->setEnabled(enabled && !isPrivacyModeActivated());881encryptWalletAction->setEnabled(enabled);882backupWalletAction->setEnabled(enabled);883changePassphraseAction->setEnabled(enabled);884signMessageAction->setEnabled(enabled);885verifyMessageAction->setEnabled(enabled);886usedSendingAddressesAction->setEnabled(enabled);887usedReceivingAddressesAction->setEnabled(enabled);888openAction->setEnabled(enabled);889m_close_wallet_action->setEnabled(enabled);890m_close_all_wallets_action->setEnabled(enabled);891m_export_watchonly_action->setEnabled(enabled);892}894void BitcoinGUI::createTrayIcon()895{896assert(QSystemTrayIcon::isSystemTrayAvailable());898#ifndef Q_OS_MACOS899if (QSystemTrayIcon::isSystemTrayAvailable()) {900trayIcon = new QSystemTrayIcon(m_network_style->getTrayAndWindowIcon(), this);901QString toolTip = tr("%1 client").arg(CLIENT_NAME) + " " + m_network_style->getTitleAddText();902trayIcon->setToolTip(toolTip);903}904#endif905}907void BitcoinGUI::createTrayIconMenu()908{909#ifndef Q_OS_MACOS910if (!trayIcon) return;911#endif // Q_OS_MACOS913// Configuration of the tray icon (or Dock icon) menu.914QAction* show_hide_action{nullptr};915#ifndef Q_OS_MACOS916// Note: On macOS, the Dock icon's menu already has Show / Hide action.917show_hide_action = trayIconMenu->addAction(QString(), this, &BitcoinGUI::toggleHidden);918trayIconMenu->addSeparator();919#endif // Q_OS_MACOS921QAction* send_action{nullptr};922QAction* receive_action{nullptr};923QAction* sign_action{nullptr};924QAction* verify_action{nullptr};925if (enableWallet) {926send_action = trayIconMenu->addAction(sendCoinsAction->text(), sendCoinsAction, &QAction::trigger);927receive_action = trayIconMenu->addAction(receiveCoinsAction->text(), receiveCoinsAction, &QAction::trigger);928trayIconMenu->addSeparator();929sign_action = trayIconMenu->addAction(signMessageAction->text(), signMessageAction, &QAction::trigger);930verify_action = trayIconMenu->addAction(verifyMessageAction->text(), verifyMessageAction, &QAction::trigger);931trayIconMenu->addSeparator();932}933QAction* options_action = trayIconMenu->addAction(optionsAction->text(), optionsAction, &QAction::trigger);934options_action->setMenuRole(QAction::PreferencesRole);935QAction* node_window_action = trayIconMenu->addAction(openRPCConsoleAction->text(), openRPCConsoleAction, &QAction::trigger);936QAction* quit_action{nullptr};937#ifndef Q_OS_MACOS938// Note: On macOS, the Dock icon's menu already has Quit action.939trayIconMenu->addSeparator();940quit_action = trayIconMenu->addAction(quitAction->text(), quitAction, &QAction::trigger);942trayIcon->setContextMenu(trayIconMenu.get());943connect(trayIcon, &QSystemTrayIcon::activated, [this](QSystemTrayIcon::ActivationReason reason) {944if (reason == QSystemTrayIcon::Trigger) {945// Click on system tray icon triggers show/hide of the main window946toggleHidden();947}948});949#else950// Note: On macOS, the Dock icon is used to provide the tray's functionality.951MacDockIconHandler* dockIconHandler = MacDockIconHandler::instance();952connect(dockIconHandler, &MacDockIconHandler::dockIconClicked, [this] {953if (m_node.shutdownRequested()) return; // nothing to show, node is shutting down.954show();955activateWindow();956});957trayIconMenu->setAsDockMenu();958#endif // Q_OS_MACOS960connect(961// Using QSystemTrayIcon::Context is not reliable.962// See https://bugreports.qt.io/browse/QTBUG-91697963trayIconMenu.get(), &QMenu::aboutToShow,964[this, show_hide_action, send_action, receive_action, sign_action, verify_action, options_action, node_window_action, quit_action] {965if (m_node.shutdownRequested()) return; // nothing to do, node is shutting down.967if (show_hide_action) show_hide_action->setText(968(!isHidden() && !isMinimized() && !GUIUtil::isObscured(this)) ?969tr("&Hide") :970tr("S&how"));971if (QApplication::activeModalWidget()) {972for (QAction* a : trayIconMenu.get()->actions()) {973a->setEnabled(false);974}975} else {976if (show_hide_action) show_hide_action->setEnabled(true);977if (enableWallet) {978send_action->setEnabled(sendCoinsAction->isEnabled());979receive_action->setEnabled(receiveCoinsAction->isEnabled());980sign_action->setEnabled(signMessageAction->isEnabled());981verify_action->setEnabled(verifyMessageAction->isEnabled());982}983options_action->setEnabled(optionsAction->isEnabled());984node_window_action->setEnabled(openRPCConsoleAction->isEnabled());985if (quit_action) quit_action->setEnabled(true);986}987});988}990void BitcoinGUI::optionsClicked()991{992openOptionsDialogWithTab(OptionsDialog::TAB_MAIN);993}995void BitcoinGUI::aboutClicked()996{997if(!clientModel)998return;1000auto dlg = new HelpMessageDialog(this, /*about=*/true);
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.