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.
252class ThemedLabel : public QLabel253{254Q_OBJECT256public:257explicit ThemedLabel(const PlatformStyle* platform_style, QWidget* parent = nullptr);258void setThemedPixmap(const QString& image_filename, int width, int height);260protected:261void changeEvent(QEvent* e) override;263private:264const PlatformStyle* m_platform_style;265QString m_image_filename;266int m_pixmap_width;267int m_pixmap_height;268void updateThemedPixmap();269};271class ClickableLabel : public ThemedLabel272{273Q_OBJECT275public:276explicit ClickableLabel(const PlatformStyle* platform_style, QWidget* parent = nullptr);278Q_SIGNALS:279/** Emitted when the label is clicked. The relative mouse coordinates of the click are280* passed to the signal.281*/282void clicked(const QPoint& point);283protected:284void mouseReleaseEvent(QMouseEvent *event) override;285};287class ClickableProgressBar : public QProgressBar288{289Q_OBJECT291Q_SIGNALS:292/** Emitted when the progressbar is clicked. The relative mouse coordinates of the click are293* passed to the signal.294*/295void clicked(const QPoint& point);296protected:297void mouseReleaseEvent(QMouseEvent *event) override;298};300typedef ClickableProgressBar ProgressBar;302class ItemDelegate : public QItemDelegate303{304Q_OBJECT305public:306ItemDelegate(QObject* parent) : QItemDelegate(parent) {}308Q_SIGNALS:309void keyEscapePressed();311private:312bool eventFilter(QObject *object, QEvent *event) override;313};315// Fix known bugs in QProgressDialog class.316void PolishProgressDialog(QProgressDialog* dialog);318/**319* Returns the distance in pixels appropriate for drawing a subsequent character after text.320*321* In Qt 5.12 and before the QFontMetrics::width() is used and it is deprecated since Qt 5.13.322* In Qt 5.11 the QFontMetrics::horizontalAdvance() was introduced.323*/324int TextWidth(const QFontMetrics& fm, const QString& text);326/**327* Writes to debug.log short info about the used Qt and the host system.328*/329void LogQtInfo();331/**332* Call QMenu::popup() only on supported QT_QPA_PLATFORM.333*/334void PopupMenu(QMenu* menu, const QPoint& point, QAction* at_action = nullptr);336/**337* Returns the start-moment of the day in local time.338*339* QDateTime::QDateTime(const QDate& date) is deprecated since Qt 5.15.340* QDate::startOfDay() was introduced in Qt 5.14.341*/342QDateTime StartOfDay(const QDate& date);344/**345* Returns true if pixmap has been set.346*347* QPixmap* QLabel::pixmap() is deprecated since Qt 5.15.348*/349bool HasPixmap(const QLabel* label);351/**352* Replaces a plain text link with an HTML tagged one.353*/354QString MakeHtmlLink(const QString& source, const QString& link);356void PrintSlotException(357const std::exception* exception,358const QObject* sender,359const QObject* receiver);361/**362* A drop-in replacement of QObject::connect function363* (see: https://doc.qt.io/qt-5/qobject.html#connect-3), that364* guaranties that all exceptions are handled within the slot.365*366* NOTE: This function is incompatible with Qt private signals.367*/368template <typename Sender, typename Signal, typename Receiver, typename Slot>369auto ExceptionSafeConnect(370Sender sender, Signal signal, Receiver receiver, Slot method,371Qt::ConnectionType type = Qt::AutoConnection)372{373return QObject::connect(374sender, signal, receiver,375[sender, receiver, method](auto&&... args) {376bool ok{true};377try {378(receiver->*method)(std::forward<decltype(args)>(args)...);379} catch (const NonFatalCheckError& e) {380PrintSlotException(&e, sender, receiver);381ok = QMetaObject::invokeMethod(382qApp, "handleNonFatalException",383blockingGUIThreadConnection(),384Q_ARG(QString, QString::fromStdString(e.what())));385} catch (const std::exception& e) {386PrintSlotException(&e, sender, receiver);387ok = QMetaObject::invokeMethod(388qApp, "handleRunawayException",389blockingGUIThreadConnection(),390Q_ARG(QString, QString::fromStdString(e.what())));391} catch (...) {392PrintSlotException(nullptr, sender, receiver);393ok = QMetaObject::invokeMethod(394qApp, "handleRunawayException",395blockingGUIThreadConnection(),396Q_ARG(QString, "Unknown failure occurred."));397}398assert(ok);399},400type);401}402template <typename Sender, typename Signal, typename Slot>403auto ExceptionSafeConnect(404Sender sender, Signal signal, Slot method)405{406return QObject::connect(407sender, signal,408[sender, method](auto&&... args) {409bool ok{true};410try {411method(std::forward<decltype(args)>(args)...);412} catch (const NonFatalCheckError& e) {413PrintSlotException(&e, sender, nullptr);414ok = QMetaObject::invokeMethod(415qApp, "handleNonFatalException",416blockingGUIThreadConnection(),417Q_ARG(QString, QString::fromStdString(e.what())));418} catch (const std::exception& e) {419PrintSlotException(&e, sender, nullptr);420ok = QMetaObject::invokeMethod(421qApp, "handleRunawayException",422blockingGUIThreadConnection(),423Q_ARG(QString, QString::fromStdString(e.what())));424} catch (...) {425PrintSlotException(nullptr, sender, nullptr);426ok = QMetaObject::invokeMethod(427qApp, "handleRunawayException",428blockingGUIThreadConnection(),429Q_ARG(QString, "Unknown failure occurred."));430}431assert(ok);432});433}435/**436* Shows a QDialog instance asynchronously, and deletes it on close.437*/438void ShowModalDialogAsynchronously(QDialog* dialog);440inline bool IsEscapeOrBack(int key)441{442if (key == Qt::Key_Escape) return true;443#ifdef Q_OS_ANDROID444if (key == Qt::Key_Back) return true;445#endif // Q_OS_ANDROID446return false;447}449QString WalletDisplayName(const std::string& name);450QString WalletDisplayName(const QString& name);452} // namespace GUIUtil454#endif // BITCOIN_QT_GUIUTIL_H
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.