git / moonbite-core / src/qt/bitcoin.cpp · raw
// Copyright (c) 2011-2020 The Bitcoin Core developers// Distributed under the MIT software license, see the accompanying// file COPYING or http://www.opensource.org/licenses/mit-license.php.#if defined(HAVE_CONFIG_H)#include <config/bitcoin-config.h>#endif#include <qt/bitcoin.h>#include <qt/bitcoingui.h>#include <chainparams.h>#include <qt/clientmodel.h>#include <qt/guiconstants.h>#include <qt/guiutil.h>#include <qt/intro.h>#include <qt/networkstyle.h>#include <qt/optionsmodel.h>#include <qt/platformstyle.h>#include <qt/splashscreen.h>#include <qt/utilitydialog.h>#include <qt/winshutdownmonitor.h>#ifdef ENABLE_WALLET#include <qt/paymentserver.h>#include <qt/walletcontroller.h>#include <qt/walletmodel.h>#endif // ENABLE_WALLET#include <init.h>#include <interfaces/handler.h>#include <interfaces/node.h>#include <node/context.h>#include <node/ui_interface.h>#include <noui.h>#include <uint256.h>#include <util/system.h>#include <util/threadnames.h>#include <util/translation.h>#include <validation.h>#include <boost/signals2/connection.hpp>#include <memory>#include <QApplication>#include <QColor>#include <QDebug>#include <QLibraryInfo>#include <QLocale>#include <QMessageBox>#include <QPalette>#include <QSettings>#include <QThread>#include <QTimer>#include <QTranslator>#if defined(QT_STATICPLUGIN)#include <QtPlugin>#if defined(QT_QPA_PLATFORM_XCB)Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);#elif defined(QT_QPA_PLATFORM_WINDOWS)Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);#elif defined(QT_QPA_PLATFORM_COCOA)Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);#endif#endif// Declare meta types used for QMetaObject::invokeMethodQ_DECLARE_METATYPE(bool*)Q_DECLARE_METATYPE(CAmount)Q_DECLARE_METATYPE(SynchronizationState)Q_DECLARE_METATYPE(uint256)static void RegisterMetaTypes(){ // Register meta types used for QMetaObject::invokeMethod and Qt::QueuedConnection qRegisterMetaType<bool*>(); qRegisterMetaType<SynchronizationState>(); #ifdef ENABLE_WALLET qRegisterMetaType<WalletModel*>(); #endif // Register typedefs (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType) // IMPORTANT: if CAmount is no longer a typedef use the normal variant above (see https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1) qRegisterMetaType<CAmount>("CAmount"); qRegisterMetaType<size_t>("size_t"); qRegisterMetaType<std::function<void()>>("std::function<void()>"); qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon"); qRegisterMetaType<interfaces::BlockAndHeaderTipInfo>("interfaces::BlockAndHeaderTipInfo");}static QString GetLangTerritory(){ QSettings settings; // Get desired locale (e.g. "de_DE") // 1) System default language QString lang_territory = QLocale::system().name(); // 2) Language from QSettings QString lang_territory_qsettings = settings.value("language", "").toString(); if(!lang_territory_qsettings.isEmpty()) lang_territory = lang_territory_qsettings; // 3) -lang command line argument lang_territory = QString::fromStdString(gArgs.GetArg("-lang", lang_territory.toStdString())); return lang_territory;}/** Set up translations */static void initTranslations(QTranslator &qtTranslatorBase, QTranslator &qtTranslator, QTranslator &translatorBase, QTranslator &translator){ // Remove old translators QApplication::removeTranslator(&qtTranslatorBase); QApplication::removeTranslator(&qtTranslator); QApplication::removeTranslator(&translatorBase); QApplication::removeTranslator(&translator); // Get desired locale (e.g. "de_DE") // 1) System default language QString lang_territory = GetLangTerritory(); // Convert to "de" only by truncating "_DE" QString lang = lang_territory; lang.truncate(lang_territory.lastIndexOf('_')); // Load language files for configured locale: // - First load the translator for the base language, without territory // - Then load the more specific locale translator // Load e.g. qt_de.qm if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) QApplication::installTranslator(&qtTranslatorBase); // Load e.g. qt_de_DE.qm if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) QApplication::installTranslator(&qtTranslator); // Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc) if (translatorBase.load(lang, ":/translations/")) QApplication::installTranslator(&translatorBase); // Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc) if (translator.load(lang_territory, ":/translations/")) QApplication::installTranslator(&translator);}/* qDebug() message handler --> debug.log */void DebugMessageHandler(QtMsgType type, const QMessageLogContext& context, const QString &msg){ Q_UNUSED(context); if (type == QtDebugMsg) { LogPrint(BCLog::QT, "GUI: %s\n", msg.toStdString()); } else { LogPrintf("GUI: %s\n", msg.toStdString()); }}BitcoinCore::BitcoinCore(interfaces::Node& node) : QObject(), m_node(node){}void BitcoinCore::handleRunawayException(const std::exception *e){ PrintExceptionContinue(e, "Runaway exception"); Q_EMIT runawayException(QString::fromStdString(m_node.getWarnings().translated));}void BitcoinCore::initialize(){ try { util::ThreadRename("qt-init"); qDebug() << __func__ << ": Running initialization in thread"; interfaces::BlockAndHeaderTipInfo tip_info; bool rv = m_node.appInitMain(&tip_info); Q_EMIT initializeResult(rv, tip_info); } catch (const std::exception& e) { handleRunawayException(&e); } catch (...) { handleRunawayException(nullptr); }}void BitcoinCore::shutdown(){ try { qDebug() << __func__ << ": Running Shutdown in thread"; m_node.appShutdown(); qDebug() << __func__ << ": Shutdown finished"; Q_EMIT shutdownResult(); } catch (const std::exception& e) { handleRunawayException(&e); } catch (...) { handleRunawayException(nullptr); }}static int qt_argc = 1;static const char* qt_argv = "litecoin-qt";BitcoinApplication::BitcoinApplication(): QApplication(qt_argc, const_cast<char **>(&qt_argv)), coreThread(nullptr), optionsModel(nullptr), clientModel(nullptr), window(nullptr), pollShutdownTimer(nullptr), returnValue(0), platformStyle(nullptr){ // Qt runs setlocale(LC_ALL, "") on initialization. RegisterMetaTypes(); setQuitOnLastWindowClosed(false);}void BitcoinApplication::setupPlatformStyle(){ // UI per-platform customization // This must be done inside the BitcoinApplication constructor, or after it, because // PlatformStyle::instantiate requires a QApplication std::string platformName; platformName = gArgs.GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM); platformStyle = PlatformStyle::instantiate(QString::fromStdString(platformName)); if (!platformStyle) // Fall back to "other" if specified name not found platformStyle = PlatformStyle::instantiate("other"); assert(platformStyle);}BitcoinApplication::~BitcoinApplication(){ if(coreThread) { qDebug() << __func__ << ": Stopping thread"; coreThread->quit(); coreThread->wait(); qDebug() << __func__ << ": Stopped thread"; } delete window; window = nullptr; delete platformStyle; platformStyle = nullptr;}#ifdef ENABLE_WALLETvoid BitcoinApplication::createPaymentServer(){ paymentServer = new PaymentServer(this);}#endifvoid BitcoinApplication::createOptionsModel(bool resetSettings){ optionsModel = new OptionsModel(this, resetSettings);}void BitcoinApplication::createWindow(const NetworkStyle *networkStyle){ window = new BitcoinGUI(node(), platformStyle, networkStyle, nullptr); pollShutdownTimer = new QTimer(window); connect(pollShutdownTimer, &QTimer::timeout, window, &BitcoinGUI::detectShutdown);}void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle){ assert(!m_splash); m_splash = new SplashScreen(nullptr, networkStyle); // We don't hold a direct pointer to the splash screen after creation, but the splash // screen will take care of deleting itself when finish() happens. m_splash->show(); connect(this, &BitcoinApplication::requestedInitialize, m_splash, &SplashScreen::handleLoadWallet); connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish); connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close);}void BitcoinApplication::setNode(interfaces::Node& node){ assert(!m_node); m_node = &node; if (optionsModel) optionsModel->setNode(*m_node); if (m_splash) m_splash->setNode(*m_node);}bool BitcoinApplication::baseInitialize(){ return node().baseInitialize();}void BitcoinApplication::startThread(){ if(coreThread) return; coreThread = new QThread(this); BitcoinCore *executor = new BitcoinCore(node()); executor->moveToThread(coreThread); /* communication to and from thread */ connect(executor, &BitcoinCore::initializeResult, this, &BitcoinApplication::initializeResult); connect(executor, &BitcoinCore::shutdownResult, this, &BitcoinApplication::shutdownResult); connect(executor, &BitcoinCore::runawayException, this, &BitcoinApplication::handleRunawayException); connect(this, &BitcoinApplication::requestedInitialize, executor, &BitcoinCore::initialize); connect(this, &BitcoinApplication::requestedShutdown, executor, &BitcoinCore::shutdown); /* make sure executor object is deleted in its own thread */ connect(coreThread, &QThread::finished, executor, &QObject::deleteLater); coreThread->start();}void BitcoinApplication::parameterSetup(){ // Default printtoconsole to false for the GUI. GUI programs should not // print to the console unnecessarily. gArgs.SoftSetBoolArg("-printtoconsole", false); InitLogging(gArgs); InitParameterInteraction(gArgs);}void BitcoinApplication::InitializePruneSetting(bool prune){ // If prune is set, intentionally override existing prune size with // the default size since this is called when choosing a new datadir. optionsModel->SetPruneTargetGB(prune ? DEFAULT_PRUNE_TARGET_GB : 0, true);}void BitcoinApplication::requestInitialize(){ qDebug() << __func__ << ": Requesting initialize"; startThread(); Q_EMIT requestedInitialize();}void BitcoinApplication::requestShutdown(){ // Show a simple window indicating shutdown status // Do this first as some of the steps may take some time below, // for example the RPC console may still be executing a command. shutdownWindow.reset(ShutdownWindow::showShutdownWindow(window)); qDebug() << __func__ << ": Requesting shutdown"; startThread(); window->hide(); // Must disconnect node signals otherwise current thread can deadlock since // no event loop is running. window->unsubscribeFromCoreSignals(); // Request node shutdown, which can interrupt long operations, like // rescanning a wallet. node().startShutdown(); // Unsetting the client model can cause the current thread to wait for node // to complete an operation, like wait for a RPC execution to complete. window->setClientModel(nullptr); pollShutdownTimer->stop(); delete clientModel; clientModel = nullptr; // Request shutdown from core thread Q_EMIT requestedShutdown();}void BitcoinApplication::initializeResult(bool success, interfaces::BlockAndHeaderTipInfo tip_info){ qDebug() << __func__ << ": Initialization result: " << success; // Set exit result. returnValue = success ? EXIT_SUCCESS : EXIT_FAILURE; if(success) { // Log this only after AppInitMain finishes, as then logging setup is guaranteed complete qInfo() << "Platform customization:" << platformStyle->getName(); clientModel = new ClientModel(node(), optionsModel); window->setClientModel(clientModel, &tip_info);#ifdef ENABLE_WALLET if (WalletModel::isWalletEnabled()) { m_wallet_controller = new WalletController(*clientModel, platformStyle, this); window->setWalletController(m_wallet_controller); if (paymentServer) { paymentServer->setOptionsModel(optionsModel); } }#endif // ENABLE_WALLET // If -min option passed, start window minimized (iconified) or minimized to tray if (!gArgs.GetBoolArg("-min", false)) { window->show(); } else if (clientModel->getOptionsModel()->getMinimizeToTray() && window->hasTrayIcon()) { // do nothing as the window is managed by the tray icon } else { window->showMinimized(); } Q_EMIT splashFinished(); Q_EMIT windowShown(window);#ifdef ENABLE_WALLET // Now that initialization/startup is done, process any command-line // bitcoin: URIs or payment requests: if (paymentServer) { connect(paymentServer, &PaymentServer::receivedPaymentRequest, window, &BitcoinGUI::handlePaymentRequest); connect(window, &BitcoinGUI::receivedURI, paymentServer, &PaymentServer::handleURIOrFile); connect(paymentServer, &PaymentServer::message, [this](const QString& title, const QString& message, unsigned int style) { window->message(title, message, style); }); QTimer::singleShot(100, paymentServer, &PaymentServer::uiReady); }#endif pollShutdownTimer->start(200); } else { Q_EMIT splashFinished(); // Make sure splash screen doesn't stick around during shutdown quit(); // Exit first main loop invocation }}void BitcoinApplication::shutdownResult(){ quit(); // Exit second main loop invocation after shutdown finished}void BitcoinApplication::handleRunawayException(const QString &message){ QMessageBox::critical(nullptr, "Runaway exception", BitcoinGUI::tr("A fatal error occurred. %1 can no longer continue safely and will quit.").arg(PACKAGE_NAME) + QString("<br><br>") + message); ::exit(EXIT_FAILURE);}WId BitcoinApplication::getMainWinId() const{ if (!window) return 0; return window->winId();}static void SetupUIArgs(ArgsManager& argsman){ argsman.AddArg("-choosedatadir", strprintf("Choose data directory on startup (default: %u)", DEFAULT_CHOOSE_DATADIR), ArgsManager::ALLOW_ANY, OptionsCategory::GUI); argsman.AddArg("-lang=<lang>", "Set language, for example \"de_DE\" (default: system locale)", ArgsManager::ALLOW_ANY, OptionsCategory::GUI); argsman.AddArg("-min", "Start minimized", ArgsManager::ALLOW_ANY, OptionsCategory::GUI); argsman.AddArg("-resetguisettings", "Reset all settings changed in the GUI", ArgsManager::ALLOW_ANY, OptionsCategory::GUI); argsman.AddArg("-splash", strprintf("Show splash screen on startup (default: %u)", DEFAULT_SPLASHSCREEN), ArgsManager::ALLOW_ANY, OptionsCategory::GUI); argsman.AddArg("-uiplatform", strprintf("Select platform to customize UI for (one of windows, macosx, other; default: %s)", BitcoinGUI::DEFAULT_UIPLATFORM), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::GUI);}int GuiMain(int argc, char* argv[]){#ifdef WIN32 util::WinCmdLineArgs winArgs; std::tie(argc, argv) = winArgs.get();#endif SetupEnvironment(); util::ThreadSetInternalName("main"); NodeContext node_context; std::unique_ptr<interfaces::Node> node = interfaces::MakeNode(&node_context); // Subscribe to global signals from core boost::signals2::scoped_connection handler_message_box = ::uiInterface.ThreadSafeMessageBox_connect(noui_ThreadSafeMessageBox); boost::signals2::scoped_connection handler_question = ::uiInterface.ThreadSafeQuestion_connect(noui_ThreadSafeQuestion); boost::signals2::scoped_connection handler_init_message = ::uiInterface.InitMessage_connect(noui_InitMessage); // Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory /// 1. Basic Qt initialization (not dependent on parameters or configuration) Q_INIT_RESOURCE(bitcoin); Q_INIT_RESOURCE(bitcoin_locale); // Generate high-dpi pixmaps QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);#if QT_VERSION >= 0x050600 QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);#endif BitcoinApplication app; /// 2. Parse command-line options. We do this after qt in order to show an error if there are problems parsing these // Command-line options take precedence: SetupServerArgs(node_context); SetupUIArgs(gArgs); std::string error; if (!gArgs.ParseParameters(argc, argv, error)) { InitError(strprintf(Untranslated("Error parsing command line arguments: %s\n"), error)); // Create a message box, because the gui has neither been created nor has subscribed to core signals QMessageBox::critical(nullptr, PACKAGE_NAME, // message can not be translated because translations have not been initialized QString::fromStdString("Error parsing command line arguments: %1.").arg(QString::fromStdString(error))); return EXIT_FAILURE; } // MoonBite: seed the base palette with the "Cosmic Violet" accent BEFORE the // platform style is built, so runtime-colorized monochrome nav icons pick up // the theme's violet highlight instead of the default Qt blue. Cosmetic only. { QPalette moonPalette = app.palette(); moonPalette.setColor(QPalette::Highlight, QColor(0x7c, 0x5c, 0xff)); moonPalette.setColor(QPalette::HighlightedText, QColor(0xff, 0xff, 0xff)); app.setPalette(moonPalette); } // Now that the QApplication is setup and we have parsed our parameters, we can set the platform style app.setupPlatformStyle(); // MoonBite luxury theme ("Cosmic Violet") — a premium, token-driven dark skin // applied globally via a single Qt style sheet. Purely cosmetic (UI layer only; // no crypto/key/RPC logic touched). Matches the MoonBite web brand. // // ============================ DESIGN TOKENS ============================ // COLOR // bg gradient #080a16 -> #0c0f22 -> #10132b (page / windows) // surface (card) #12162c input elevated #161a34 // accent violet #7c5cff accent cyan #34d3ff // wealth gold #ffe8a3 / #f2d98a (balances, PREMIUM) // text primary #e8ecff muted #9aa3c7 on-accent #0b0e1c // positive #3ad29f negative #ff6b6b warning #ffcf6b // TYPE "Segoe UI"; display 30-38/800, title 22/700, section 16/600, // body 13/400, caption 11-12/600 uppercase tracked, mono for hashes. // SPACE 8px grid (4/8/12/16/24/32); dialog margins 24; card padding 22-28. // RADIUS inputs/buttons 9-11; cards 20-22; hero 22. // MOTION state-only :hover/:pressed/:checked/:focus (no per-frame animation). // ======================================================================= static const char* MOONBITE_QSS = R"QSS( /* ---- base ---- */ QWidget { color: #e8ecff; font-family: "Segoe UI", "Inter", "Helvetica Neue", sans-serif; font-size: 13px; } QMainWindow, QDialog, QStackedWidget, WalletFrame, WalletView, OverviewPage, QScrollArea { background-color: qlineargradient(x1:0, y1:0, x2:0.4, y2:1, stop:0 #080a16, stop:0.55 #0c0f22, stop:1 #10132b); } QToolTip { background-color: #161a30; color: #e8ecff; border: 1px solid rgba(124,92,255,0.45); border-radius: 6px; padding: 4px 8px; } /* ---- top menu bar ---- */ QMenuBar { background: transparent; border: none; padding: 2px 6px; } QMenuBar::item { background: transparent; padding: 6px 12px; border-radius: 8px; color: #c7cdf0; } QMenuBar::item:selected { background: rgba(124,92,255,0.22); color: #ffffff; } QMenu { background: #12152b; border: 1px solid rgba(124,92,255,0.30); border-radius: 10px; padding: 6px; } QMenu::item { padding: 7px 22px; border-radius: 6px; color: #c7cdf0; } QMenu::item:selected { background: qlineargradient(x1:0,y1:0,x2:1,y2:0, stop:0 rgba(124,92,255,0.35), stop:1 rgba(52,211,255,0.25)); color: #ffffff; } /* ---- left navigation toolbar ---- */ QToolBar { background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #0a0d1c, stop:1 #0e1230); border: none; border-right: 1px solid rgba(124,92,255,0.18); spacing: 6px; padding: 14px 10px; } QToolBar QToolButton { background: transparent; color: #aab2dd; border: none; border-radius: 12px; padding: 12px 18px; font-size: 14px; font-weight: 600; text-align: left; min-width: 150px; } QToolBar QToolButton:hover { background: rgba(124,92,255,0.16); color: #ffffff; } QToolBar QToolButton:checked { background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 rgba(124,92,255,0.55), stop:1 rgba(52,211,255,0.30)); color: #ffffff; border-left: 3px solid #34d3ff; } /* ---- glass cards on the overview page ---- */ QFrame#frame, QFrame#frame_2 { background: qlineargradient(x1:0, y1:0, x2:0.6, y2:1, stop:0 rgba(28,32,64,0.85), stop:1 rgba(16,19,43,0.92)); border: 1px solid rgba(124,92,255,0.28); border-radius: 20px; } /* section headers ("Balances", "Recent transactions") */ QLabel#label_5, QLabel#label_4 { color: #9aa3c7; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 2px; } /* muted descriptor labels */ QLabel#labelBalanceText, QLabel#labelPendingText, QLabel#labelImmatureText, QLabel#labelTotalText, QLabel#labelWatchonly, QLabel#labelSpendable { color: #8b93bd; font-size: 12px; font-weight: 600; } /* the amounts */ QLabel#labelUnconfirmed, QLabel#labelImmature { color: #cbd2f5; font-size: 15px; font-weight: 600; } /* hero: available balance + total — gold, oversized */ QLabel#labelBalance { color: #f2d98a; font-size: 30px; font-weight: 800; } QLabel#labelTotal { color: #ffe8a3; font-size: 22px; font-weight: 800; } /* ---- buttons ---- */ QPushButton { background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #7c5cff, stop:1 #34d3ff); color: #ffffff; border: none; border-radius: 11px; padding: 9px 20px; font-weight: 700; } QPushButton:hover { background: qlineargradient(x1:0, y1:0, x2:1, y2:0, stop:0 #8f74ff, stop:1 #5cdcff); } QPushButton:pressed { background: #6a4fe0; } QPushButton:disabled { background: #2a2e4a; color: #6c729a; } /* flat status buttons on cards */ QPushButton#labelWalletStatus, QPushButton#labelTransactionsStatus { background: transparent; border: none; padding: 0px; } /* ---- inputs ---- */ QLineEdit, QPlainTextEdit, QTextEdit, QAbstractSpinBox, QComboBox { background: #12162c; border: 1px solid rgba(124,92,255,0.30); border-radius: 9px; padding: 7px 10px; color: #e8ecff; selection-background-color: #7c5cff; } QLineEdit:focus, QAbstractSpinBox:focus, QComboBox:focus { border: 1px solid #34d3ff; } QComboBox QAbstractItemView { background: #12152b; border: 1px solid rgba(124,92,255,0.30); selection-background-color: rgba(124,92,255,0.40); border-radius: 8px; } /* ---- tables / lists ---- */ QTableView, QTreeView, QListView, TransactionOverviewWidget { background: rgba(10,13,28,0.6); border: none; gridline-color: rgba(124,92,255,0.12); selection-background-color: rgba(124,92,255,0.30); selection-color: #ffffff; alternate-background-color: rgba(124,92,255,0.05); } QHeaderView::section { background: #141833; color: #9aa3c7; border: none; padding: 8px 10px; font-weight: 700; } /* ---- tabs ---- */ QTabWidget::pane { border: 1px solid rgba(124,92,255,0.25); border-radius: 12px; top: -1px; } QTabBar::tab { background: transparent; color: #8b93bd; padding: 9px 18px; border-top-left-radius: 10px; border-top-right-radius: 10px; font-weight: 600; } QTabBar::tab:selected { background: qlineargradient(x1:0,y1:0,x2:0,y2:1, stop:0 rgba(124,92,255,0.30), stop:1 transparent); color: #ffffff; border-bottom: 2px solid #34d3ff; } /* ---- status / progress ---- */ QStatusBar { background: #0a0d1c; color: #8b93bd; border-top: 1px solid rgba(124,92,255,0.18); } QProgressBar { background: #141833; border: none; border-radius: 8px; text-align: center; color: #e8ecff; height: 14px; } QProgressBar::chunk { border-radius: 8px; background: qlineargradient(x1:0,y1:0,x2:1,y2:0, stop:0 #7c5cff, stop:1 #34d3ff); } /* ---- scrollbars ---- */ QScrollBar:vertical { background: transparent; width: 10px; margin: 2px; } QScrollBar::handle:vertical { background: rgba(124,92,255,0.45); border-radius: 5px; min-height: 30px; } QScrollBar::handle:vertical:hover { background: rgba(124,92,255,0.70); } QScrollBar:horizontal { background: transparent; height: 10px; margin: 2px; } QScrollBar::handle:horizontal { background: rgba(124,92,255,0.45); border-radius: 5px; min-width: 30px; } QScrollBar::add-line, QScrollBar::sub-line { background: none; border: none; height: 0; width: 0; } QScrollBar::add-page, QScrollBar::sub-page { background: none; } /* ---- group boxes (options, coin control) ---- */ QGroupBox { background: rgba(16,19,43,0.55); border: 1px solid rgba(124,92,255,0.22); border-radius: 14px; margin-top: 14px; padding: 14px 12px 12px 12px; font-weight: 700; color: #c7cdf0; } QGroupBox::title { subcontrol-origin: margin; subcontrol-position: top left; left: 14px; padding: 2px 8px; color: #9aa3c7; text-transform: uppercase; letter-spacing: 1px; font-size: 11px; } /* ---- dialog action buttons ---- */ QDialogButtonBox { button-layout: 2; } /* ================= per-screen polish ================= */ /* Send: coin-control frame + summary labels */ QFrame#frameCoinControl { background: rgba(16,19,43,0.55); border: 1px solid rgba(124,92,255,0.22); border-radius: 16px; } QLabel#labelCoinControlFeatures, QLabel#labelFeeHeadline, QLabel#labelBalanceName { color: #9aa3c7; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; } QLabel#labelCoinControlQuantityText, QLabel#labelCoinControlBytesText, QLabel#labelCoinControlAmountText, QLabel#labelCoinControlLowOutputText, QLabel#labelCoinControlFeeText, QLabel#labelCoinControlAfterFeeText, QLabel#labelCoinControlChangeText { color: #8b93bd; font-weight: 600; } QLabel#labelCoinControlQuantity, QLabel#labelCoinControlBytes, QLabel#labelCoinControlAmount, QLabel#labelCoinControlLowOutput, QLabel#labelCoinControlFee, QLabel#labelCoinControlAfterFee, QLabel#labelCoinControlChange { color: #cbd2f5; font-weight: 700; } /* send screen "Balance:" figure — gold like the hero */ QLabel#labelBalance { color: #ffe8a3; } /* recipient scroll area + entry frames must stay on-theme (no default grey) */ QScrollArea#scrollArea { background: transparent; border: none; } QWidget#scrollAreaWidgetContents { background: transparent; } QFrame#SendCoins, QFrame#SendCoins_UnauthenticatedPaymentRequest, QFrame#SendCoins_AuthenticatedPaymentRequest { background: rgba(16,19,43,0.45); border: 1px solid rgba(124,92,255,0.18); border-radius: 14px; } /* Receive: glass panels around the form + request list */ QFrame#frame, QFrame#frame2 { background: qlineargradient(x1:0, y1:0, x2:0.6, y2:1, stop:0 rgba(28,32,64,0.85), stop:1 rgba(16,19,43,0.92)); border: 1px solid rgba(124,92,255,0.28); border-radius: 18px; } /* Encrypt / Unlock passphrase dialog */ QLabel#warningLabel { color: #ffcf6b; font-weight: 600; background: rgba(255,207,107,0.08); border: 1px solid rgba(255,207,107,0.35); border-radius: 10px; padding: 10px 12px; } QLabel#capsLabel { color: #ff6b6b; font-weight: 700; } /* Sync / catch-up modal overlay */ QWidget#bgWidget { background: rgba(6,8,20,0.72); } QWidget#contentWidget { background: qlineargradient(x1:0, y1:0, x2:0.6, y2:1, stop:0 rgba(30,26,74,0.96), stop:1 rgba(14,19,46,0.98)); border: 1px solid rgba(124,92,255,0.35); border-radius: 20px; } QPushButton#warningIcon { background: transparent; border: none; padding: 0; } /* Console / debug: monospace terminal feel */ RPCConsole QTextEdit#messagesWidget { background: #0a0d1c; border: 1px solid rgba(124,92,255,0.22); border-radius: 12px; } RPCConsole QLineEdit#lineEdit { background: #0a0d1c; border: 1px solid rgba(124,92,255,0.30); border-radius: 9px; } /* ---- misc ---- */ QCheckBox, QRadioButton { color: #cbd2f5; spacing: 8px; } QCheckBox::indicator, QRadioButton::indicator { width: 16px; height: 16px; } Line, QFrame[frameShape="4"], QFrame[frameShape="5"] { color: rgba(124,92,255,0.20); } )QSS"; app.setStyleSheet(QString::fromUtf8(MOONBITE_QSS)); /// 3. Application identification // must be set before OptionsModel is initialized or translations are loaded, // as it is used to locate QSettings QApplication::setOrganizationName(QAPP_ORG_NAME); QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN); QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT); /// 4. Initialization of translations, so that intro dialog is in user's language // Now that QSettings are accessible, initialize translations QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator; initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator); // Show help message immediately after parsing command-line options (for "-lang") and setting locale, // but before showing splash screen. if (HelpRequested(gArgs) || gArgs.IsArgSet("-version")) { HelpMessageDialog help(nullptr, gArgs.IsArgSet("-version")); help.showOrPrint(); return EXIT_SUCCESS; } // Install global event filter that makes sure that long tooltips can be word-wrapped app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app)); /// 5. Now that settings and translations are available, ask user for data directory // User language is set up: pick a data directory bool did_show_intro = false; bool prune = false; // Intro dialog prune check box // Gracefully exit if the user cancels if (!Intro::showIfNeeded(did_show_intro, prune)) return EXIT_SUCCESS; /// 6. Determine availability of data directory and parse bitcoin.conf /// - Do not call GetDataDir(true) before this step finishes if (!CheckDataDirOption()) { InitError(strprintf(Untranslated("Specified data directory \"%s\" does not exist.\n"), gArgs.GetArg("-datadir", ""))); QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(gArgs.GetArg("-datadir", "")))); return EXIT_FAILURE; } if (!gArgs.ReadConfigFiles(error, true)) { InitError(strprintf(Untranslated("Error reading configuration file: %s\n"), error)); QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: Cannot parse configuration file: %1.").arg(QString::fromStdString(error))); return EXIT_FAILURE; } /// 7. Determine network (and switch to network specific options) // - Do not call Params() before this step // - Do this after parsing the configuration file, as the network can be switched there // - QSettings() will use the new application name after this, resulting in network-specific settings // - Needs to be done before createOptionsModel // Check for chain settings (Params() calls are only valid after this clause) try { SelectParams(gArgs.GetChainName()); } catch(std::exception &e) { InitError(Untranslated(strprintf("%s\n", e.what()))); QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error: %1").arg(e.what())); return EXIT_FAILURE; }#ifdef ENABLE_WALLET // Parse URIs on command line -- this can affect Params() PaymentServer::ipcParseCommandLine(argc, argv);#endif if (!gArgs.InitSettings(error)) { InitError(Untranslated(error)); QMessageBox::critical(nullptr, PACKAGE_NAME, QObject::tr("Error initializing settings: %1").arg(QString::fromStdString(error))); return EXIT_FAILURE; } QScopedPointer<const NetworkStyle> networkStyle(NetworkStyle::instantiate(Params().NetworkIDString())); assert(!networkStyle.isNull()); // Allow for separate UI settings for testnets QApplication::setApplicationName(networkStyle->getAppName()); // Re-initialize translations after changing application name (language in network-specific settings can be different) initTranslations(qtTranslatorBase, qtTranslator, translatorBase, translator);#ifdef ENABLE_WALLET /// 8. URI IPC sending // - Do this early as we don't want to bother initializing if we are just calling IPC // - Do this *after* setting up the data directory, as the data directory hash is used in the name // of the server. // - Do this after creating app and setting up translations, so errors are // translated properly. if (PaymentServer::ipcSendCommandLine()) exit(EXIT_SUCCESS); // Start up the payment server early, too, so impatient users that click on // bitcoin: links repeatedly have their payment requests routed to this process: if (WalletModel::isWalletEnabled()) { app.createPaymentServer(); }#endif // ENABLE_WALLET /// 9. Main GUI initialization // Install global event filter that makes sure that out-of-focus labels do not contain text cursor. app.installEventFilter(new GUIUtil::LabelOutOfFocusEventFilter(&app));#if defined(Q_OS_WIN) // Install global event filter for processing Windows session related Windows messages (WM_QUERYENDSESSION and WM_ENDSESSION) qApp->installNativeEventFilter(new WinShutdownMonitor());#endif // Install qDebug() message handler to route to debug.log qInstallMessageHandler(DebugMessageHandler); // Allow parameter interaction before we create the options model app.parameterSetup(); GUIUtil::LogQtInfo(); // Load GUI settings from QSettings app.createOptionsModel(gArgs.GetBoolArg("-resetguisettings", false)); if (did_show_intro) { // Store intro dialog settings other than datadir (network specific) app.InitializePruneSetting(prune); } if (gArgs.GetBoolArg("-splash", DEFAULT_SPLASHSCREEN) && !gArgs.GetBoolArg("-min", false)) app.createSplashScreen(networkStyle.data()); app.setNode(*node); int rv = EXIT_SUCCESS; try { app.createWindow(networkStyle.data()); // Perform base initialization before spinning up initialization/shutdown thread // This is acceptable because this function only contains steps that are quick to execute, // so the GUI thread won't be held up. if (app.baseInitialize()) { app.requestInitialize();#if defined(Q_OS_WIN) WinShutdownMonitor::registerShutdownBlockReason(QObject::tr("%1 didn't yet exit safely...").arg(PACKAGE_NAME), (HWND)app.getMainWinId());#endif app.exec(); app.requestShutdown(); app.exec(); rv = app.getReturnValue(); } else { // A dialog with detailed error will have been shown by InitError() rv = EXIT_FAILURE; } } catch (const std::exception& e) { PrintExceptionContinue(&e, "Runaway exception"); app.handleRunawayException(QString::fromStdString(app.node().getWarnings().translated)); } catch (...) { PrintExceptionContinue(nullptr, "Runaway exception"); app.handleRunawayException(QString::fromStdString(app.node().getWarnings().translated)); } return rv;}