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.
1501encryptWalletAction->setEnabled(false);1502break;1503case WalletModel::Locked:1504labelWalletEncryptionIcon->show();1505labelWalletEncryptionIcon->setThemedPixmap(QStringLiteral(":/icons/lock_closed"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);1506labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));1507encryptWalletAction->setChecked(true);1508changePassphraseAction->setEnabled(true);1509encryptWalletAction->setEnabled(false);1510break;1511}1512}1514void BitcoinGUI::updateWalletStatus()1515{1516assert(walletFrame);1518WalletView * const walletView = walletFrame->currentWalletView();1519if (!walletView) {1520return;1521}1522WalletModel * const walletModel = walletView->getWalletModel();1523setEncryptionStatus(walletModel->getEncryptionStatus());1524setHDStatus(walletModel->wallet().privateKeysDisabled(), walletModel->wallet().hdEnabled());1525}1526#endif // ENABLE_WALLET1528void BitcoinGUI::updateProxyIcon()1529{1530std::string ip_port;1531bool proxy_enabled = clientModel->getProxyInfo(ip_port);1533if (proxy_enabled) {1534if (!GUIUtil::HasPixmap(labelProxyIcon)) {1535QString ip_port_q = QString::fromStdString(ip_port);1536labelProxyIcon->setThemedPixmap((":/icons/proxy"), STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE);1537labelProxyIcon->setToolTip(tr("Proxy is <b>enabled</b>: %1").arg(ip_port_q));1538} else {1539labelProxyIcon->show();1540}1541} else {1542labelProxyIcon->hide();1543}1544}1546void BitcoinGUI::updateWindowTitle()1547{1548QString window_title = CLIENT_NAME;1549#ifdef ENABLE_WALLET1550if (walletFrame) {1551WalletModel* const wallet_model = walletFrame->currentWalletModel();1552if (wallet_model && !wallet_model->getWalletName().isEmpty()) {1553window_title += " - " + wallet_model->getDisplayName();1554}1555}1556#endif1557if (!m_network_style->getTitleAddText().isEmpty()) {1558window_title += " - " + m_network_style->getTitleAddText();1559}1560setWindowTitle(window_title);1561}1563void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden)1564{1565if(!clientModel)1566return;1568if (!isHidden() && !isMinimized() && !GUIUtil::isObscured(this) && fToggleHidden) {1569hide();1570} else {1571GUIUtil::bringToFront(this);1572}1573}1575void BitcoinGUI::toggleHidden()1576{1577showNormalIfMinimized(true);1578}1580void BitcoinGUI::detectShutdown()1581{1582if (m_node.shutdownRequested())1583{1584if(rpcConsole)1585rpcConsole->hide();1586Q_EMIT quitRequested();1587}1588}1590void BitcoinGUI::showProgress(const QString &title, int nProgress)1591{1592if (nProgress == 0) {1593progressDialog = new QProgressDialog(title, QString(), 0, 100);1594GUIUtil::PolishProgressDialog(progressDialog);1595progressDialog->setWindowModality(Qt::ApplicationModal);1596progressDialog->setAutoClose(false);1597progressDialog->setValue(0);1598} else if (nProgress == 100) {1599if (progressDialog) {1600progressDialog->close();1601progressDialog->deleteLater();1602progressDialog = nullptr;1603}1604} else if (progressDialog) {1605progressDialog->setValue(nProgress);1606}1607}1609void BitcoinGUI::showModalOverlay()1610{1611if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))1612modalOverlay->toggleVisibility();1613}1615[[nodiscard]] static bool ThreadSafeMessageBox(BitcoinGUI* gui, const bilingual_str& message, unsigned int style)1616{1617bool modal = (style & CClientUIInterface::MODAL);1618// The SECURE flag has no effect in the Qt GUI.1619// bool secure = (style & CClientUIInterface::SECURE);1620style &= ~CClientUIInterface::SECURE;1621bool ret = false;1623QString detailed_message; // This is original message, in English, for googling and referencing.1624if (message.original != message.translated) {1625detailed_message = BitcoinGUI::tr("Original message:") + "\n" + QString::fromStdString(message.original);1626}1627// The title is empty for node messages. The fallback title is usually set1628// by `style`.1629const QString title{};1631// In case of modal message, use blocking connection to wait for user to click a button1632bool invoked = QMetaObject::invokeMethod(gui, "message",1633modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,1634Q_ARG(QString, title),1635Q_ARG(QString, QString::fromStdString(message.translated)),1636Q_ARG(unsigned int, style),1637Q_ARG(bool*, &ret),1638Q_ARG(QString, detailed_message));1639assert(invoked);1640return ret;1641}1643void BitcoinGUI::subscribeToCoreSignals()1644{1645// Connect signals to client1646m_handler_message_box = m_node.handleMessageBox([this](const bilingual_str& message, unsigned int style) {1647(void)ThreadSafeMessageBox(this, message, style);1648});1649m_handler_question = m_node.handleQuestion([this](const bilingual_str& message, const std::string& /*non_interactive_message*/, unsigned int style) {1650return ThreadSafeMessageBox(this, message, style);1651});1652}1654void BitcoinGUI::unsubscribeFromCoreSignals()1655{1656// Disconnect signals from client1657m_handler_message_box->disconnect();1658m_handler_question->disconnect();1659}1661bool BitcoinGUI::isPrivacyModeActivated() const1662{1663assert(m_mask_values_action);1664return m_mask_values_action->isChecked();1665}1667UnitDisplayStatusBarControl::UnitDisplayStatusBarControl(const PlatformStyle* platformStyle)1668: m_platform_style{platformStyle}1669{1670createContextMenu();1671setToolTip(tr("Unit to show amounts in. Click to select another unit."));1672QList<BitcoinUnit> units = BitcoinUnits::availableUnits();1673int max_width = 0;1674const QFontMetrics fm(font());1675for (const BitcoinUnit unit : units) {1676max_width = qMax(max_width, GUIUtil::TextWidth(fm, BitcoinUnits::longName(unit)));1677}1678setMinimumSize(max_width, 0);1679setAlignment(Qt::AlignRight | Qt::AlignVCenter);1680setStyleSheet(QString("QLabel { color : %1 }").arg(m_platform_style->SingleColor().name()));1681}1683/** So that it responds to button clicks */1684void UnitDisplayStatusBarControl::mousePressEvent(QMouseEvent *event)1685{1686onDisplayUnitsClicked(event->pos());1687}1689void UnitDisplayStatusBarControl::changeEvent(QEvent* e)1690{1691if (e->type() == QEvent::PaletteChange) {1692QString style = QString("QLabel { color : %1 }").arg(m_platform_style->SingleColor().name());1693if (style != styleSheet()) {1694setStyleSheet(style);1695}1696}1698QLabel::changeEvent(e);1699}1701/** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */1702void UnitDisplayStatusBarControl::createContextMenu()1703{1704menu = new QMenu(this);1705for (const BitcoinUnit u : BitcoinUnits::availableUnits()) {1706menu->addAction(BitcoinUnits::longName(u))->setData(QVariant::fromValue(u));1707}1708connect(menu, &QMenu::triggered, this, &UnitDisplayStatusBarControl::onMenuSelection);1709}1711/** Lets the control know about the Options Model (and its signals) */1712void UnitDisplayStatusBarControl::setOptionsModel(OptionsModel *_optionsModel)1713{1714if (_optionsModel)1715{1716this->optionsModel = _optionsModel;1718// be aware of a display unit change reported by the OptionsModel object.1719connect(_optionsModel, &OptionsModel::displayUnitChanged, this, &UnitDisplayStatusBarControl::updateDisplayUnit);1721// initialize the display units label with the current value in the model.1722updateDisplayUnit(_optionsModel->getDisplayUnit());1723}1724}1726/** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */1727void UnitDisplayStatusBarControl::updateDisplayUnit(BitcoinUnit newUnits)1728{1729setText(BitcoinUnits::longName(newUnits));1730}1732/** Shows context menu with Display Unit options by the mouse coordinates */1733void UnitDisplayStatusBarControl::onDisplayUnitsClicked(const QPoint& point)1734{1735QPoint globalPos = mapToGlobal(point);1736menu->exec(globalPos);1737}1739/** Tells underlying optionsModel to update its current display unit. */1740void UnitDisplayStatusBarControl::onMenuSelection(QAction* action)1741{1742if (action)1743{1744optionsModel->setDisplayUnit(action->data());1745}1746}1748#include <moc_bitcoingui.cpp>
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.