Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show First 20 Lines • Show All 63 Lines • ▼ Show 20 Lines | |||||
Q_DECLARE_METATYPE(bool *) | Q_DECLARE_METATYPE(bool *) | ||||
Q_DECLARE_METATYPE(Amount) | Q_DECLARE_METATYPE(Amount) | ||||
Q_DECLARE_METATYPE(SynchronizationState) | Q_DECLARE_METATYPE(SynchronizationState) | ||||
Q_DECLARE_METATYPE(uint256) | Q_DECLARE_METATYPE(uint256) | ||||
// Config is non-copyable so we can only register pointers to it | // Config is non-copyable so we can only register pointers to it | ||||
Q_DECLARE_METATYPE(Config *) | Q_DECLARE_METATYPE(Config *) | ||||
static void RegisterMetaTypes() { | |||||
// Register meta types used for QMetaObject::invokeMethod and | |||||
// Qt::QueuedConnection | |||||
qRegisterMetaType<bool *>(); | |||||
qRegisterMetaType<SynchronizationState>(); | |||||
#ifdef ENABLE_WALLET | |||||
qRegisterMetaType<WalletModel *>(); | |||||
#endif | |||||
qRegisterMetaType<Amount>(); | |||||
// Register typedefs (see | |||||
// http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType) | |||||
qRegisterMetaType<size_t>("size_t"); | |||||
qRegisterMetaType<std::function<void()>>("std::function<void()>"); | |||||
qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon"); | |||||
// Need to register any types Qt doesn't know about if you intend | |||||
// to use them with the signal/slot mechanism Qt provides. Even pointers. | |||||
// Note that class Config is noncopyable and so we can't register a | |||||
// non-pointer version of it with Qt, because Qt expects to be able to | |||||
// copy-construct non-pointers to objects for invoking slots | |||||
// behind-the-scenes in the 'Queued' connection case. | |||||
qRegisterMetaType<Config *>(); | |||||
} | |||||
static QString GetLangTerritory() { | static QString GetLangTerritory() { | ||||
QSettings settings; | QSettings settings; | ||||
// Get desired locale (e.g. "de_DE") | // Get desired locale (e.g. "de_DE") | ||||
// 1) System default language | // 1) System default language | ||||
QString lang_territory = QLocale::system().name(); | QString lang_territory = QLocale::system().name(); | ||||
// 2) Language from QSettings | // 2) Language from QSettings | ||||
QString lang_territory_qsettings = | QString lang_territory_qsettings = | ||||
settings.value("language", "").toString(); | settings.value("language", "").toString(); | ||||
▲ Show 20 Lines • Show All 105 Lines • ▼ Show 20 Lines | |||||
static int qt_argc = 1; | static int qt_argc = 1; | ||||
static const char *qt_argv = "bitcoin-qt"; | static const char *qt_argv = "bitcoin-qt"; | ||||
BitcoinApplication::BitcoinApplication() | BitcoinApplication::BitcoinApplication() | ||||
: QApplication(qt_argc, const_cast<char **>(&qt_argv)), coreThread(nullptr), | : QApplication(qt_argc, const_cast<char **>(&qt_argv)), coreThread(nullptr), | ||||
optionsModel(nullptr), clientModel(nullptr), window(nullptr), | optionsModel(nullptr), clientModel(nullptr), window(nullptr), | ||||
pollShutdownTimer(nullptr), returnValue(0), platformStyle(nullptr) { | pollShutdownTimer(nullptr), returnValue(0), platformStyle(nullptr) { | ||||
RegisterMetaTypes(); | |||||
setQuitOnLastWindowClosed(false); | setQuitOnLastWindowClosed(false); | ||||
} | } | ||||
void BitcoinApplication::setupPlatformStyle() { | void BitcoinApplication::setupPlatformStyle() { | ||||
// UI per-platform customization | // UI per-platform customization | ||||
// This must be done inside the BitcoinApplication constructor, or after it, | // This must be done inside the BitcoinApplication constructor, or after it, | ||||
// because PlatformStyle::instantiate requires a QApplication. | // because PlatformStyle::instantiate requires a QApplication. | ||||
std::string platformName; | std::string platformName; | ||||
▲ Show 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | #endif | ||||
Q_INIT_RESOURCE(bitcoin_locale); | Q_INIT_RESOURCE(bitcoin_locale); | ||||
// Generate high-dpi pixmaps | // Generate high-dpi pixmaps | ||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); | QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); | ||||
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); | QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); | ||||
BitcoinApplication app; | BitcoinApplication app; | ||||
// 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 Amount is no longer a typedef use the normal variant above | |||||
// (see https://doc.qt.io/qt-5/qmetatype.html#qRegisterMetaType-1) | |||||
qRegisterMetaType<Amount>("Amount"); | |||||
qRegisterMetaType<size_t>("size_t"); | |||||
qRegisterMetaType<std::function<void()>>("std::function<void()>"); | |||||
qRegisterMetaType<QMessageBox::Icon>("QMessageBox::Icon"); | |||||
// Need to register any types Qt doesn't know about if you intend | |||||
// to use them with the signal/slot mechanism Qt provides. Even pointers. | |||||
// Note that class Config is noncopyable and so we can't register a | |||||
// non-pointer version of it with Qt, because Qt expects to be able to | |||||
// copy-construct non-pointers to objects for invoking slots | |||||
// behind-the-scenes in the 'Queued' connection case. | |||||
qRegisterMetaType<Config *>(); | |||||
/// 2. Parse command-line options. We do this after qt in order to show an | /// 2. Parse command-line options. We do this after qt in order to show an | ||||
/// error if there are problems parsing these | /// error if there are problems parsing these | ||||
// Command-line options take precedence: | // Command-line options take precedence: | ||||
SetupServerArgs(node_context); | SetupServerArgs(node_context); | ||||
SetupUIArgs(gArgs); | SetupUIArgs(gArgs); | ||||
std::string error; | std::string error; | ||||
if (!gArgs.ParseParameters(argc, argv, error)) { | if (!gArgs.ParseParameters(argc, argv, error)) { | ||||
InitError(strprintf( | InitError(strprintf( | ||||
▲ Show 20 Lines • Show All 208 Lines • Show Last 20 Lines |