Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show First 20 Lines • Show All 213 Lines • ▼ Show 20 Lines | #endif | ||||
void requestShutdown(Config &config); | void requestShutdown(Config &config); | ||||
/// Get process return value | /// Get process return value | ||||
int getReturnValue() const { return returnValue; } | int getReturnValue() const { return returnValue; } | ||||
/// Get window identifier of QMainWindow (BitcoinGUI) | /// Get window identifier of QMainWindow (BitcoinGUI) | ||||
WId getMainWinId() const; | WId getMainWinId() const; | ||||
/// Setup platform style | |||||
void setupPlatformStyle(); | |||||
public Q_SLOTS: | public Q_SLOTS: | ||||
void initializeResult(bool success); | void initializeResult(bool success); | ||||
void shutdownResult(); | void shutdownResult(); | ||||
/// Handle runaway exceptions. Shows a message box with the problem and | /// Handle runaway exceptions. Shows a message box with the problem and | ||||
/// quits the program. | /// quits the program. | ||||
void handleRunawayException(const QString &message); | void handleRunawayException(const QString &message); | ||||
Q_SIGNALS: | Q_SIGNALS: | ||||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | |||||
BitcoinApplication::BitcoinApplication(interfaces::Node &node, int &argc, | BitcoinApplication::BitcoinApplication(interfaces::Node &node, int &argc, | ||||
char **argv) | char **argv) | ||||
: QApplication(argc, argv), coreThread(0), m_node(node), optionsModel(0), | : QApplication(argc, argv), coreThread(0), m_node(node), optionsModel(0), | ||||
clientModel(0), window(0), pollShutdownTimer(0), | clientModel(0), window(0), pollShutdownTimer(0), | ||||
#ifdef ENABLE_WALLET | #ifdef ENABLE_WALLET | ||||
paymentServer(0), m_wallet_models(), | paymentServer(0), m_wallet_models(), | ||||
#endif | #endif | ||||
returnValue(0) { | returnValue(0), platformStyle(0) { | ||||
setQuitOnLastWindowClosed(false); | setQuitOnLastWindowClosed(false); | ||||
} | |||||
// UI per-platform customization. | void BitcoinApplication::setupPlatformStyle() { | ||||
// 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; | ||||
platformName = gArgs.GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM); | platformName = gArgs.GetArg("-uiplatform", BitcoinGUI::DEFAULT_UIPLATFORM); | ||||
platformStyle = | platformStyle = | ||||
PlatformStyle::instantiate(QString::fromStdString(platformName)); | PlatformStyle::instantiate(QString::fromStdString(platformName)); | ||||
// Fall back to "other" if specified name not found. | // Fall back to "other" if specified name not found. | ||||
if (!platformStyle) { | if (!platformStyle) { | ||||
▲ Show 20 Lines • Show All 311 Lines • ▼ Show 20 Lines | #endif | ||||
} | } | ||||
} | } | ||||
int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | ||||
SetupEnvironment(); | SetupEnvironment(); | ||||
std::unique_ptr<interfaces::Node> node = interfaces::MakeNode(); | std::unique_ptr<interfaces::Node> node = interfaces::MakeNode(); | ||||
/// 1. Parse command-line options. These take precedence over anything else. | |||||
// Command-line options take precedence: | |||||
node->setupServerArgs(); | |||||
SetupUIArgs(); | |||||
node->parseParameters(argc, argv); | |||||
// Do not refer to data directory yet, this can be overridden by | // Do not refer to data directory yet, this can be overridden by | ||||
// Intro::pickDataDirectory | // Intro::pickDataDirectory | ||||
/// 2. Basic Qt initialization (not dependent on parameters or | /// 1. Basic Qt initialization (not dependent on parameters or | ||||
/// configuration) | /// configuration) | ||||
Q_INIT_RESOURCE(bitcoin); | Q_INIT_RESOURCE(bitcoin); | ||||
Q_INIT_RESOURCE(bitcoin_locale); | Q_INIT_RESOURCE(bitcoin_locale); | ||||
BitcoinApplication app(*node, argc, argv); | BitcoinApplication app(*node, argc, argv); | ||||
#if QT_VERSION > 0x050100 | #if QT_VERSION > 0x050100 | ||||
// Generate high-dpi pixmaps | // Generate high-dpi pixmaps | ||||
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); | QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); | ||||
Show All 16 Lines | #endif | ||||
// Need to register any types Qt doesn't know about if you intend | // 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. | // 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 | // 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 | // non-pointer version of it with Qt, because Qt expects to be able to | ||||
// copy-construct non-pointers to objects for invoking slots | // copy-construct non-pointers to objects for invoking slots | ||||
// behind-the-scenes in the 'Queued' connection case. | // behind-the-scenes in the 'Queued' connection case. | ||||
qRegisterMetaType<Config *>(); | qRegisterMetaType<Config *>(); | ||||
/// 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: | |||||
node->setupServerArgs(); | |||||
SetupUIArgs(); | |||||
std::string error; | |||||
if (!node->parseParameters(argc, argv, error)) { | |||||
QMessageBox::critical( | |||||
0, QObject::tr(PACKAGE_NAME), | |||||
QObject::tr("Error parsing command line arguments: %1.") | |||||
.arg(QString::fromStdString(error))); | |||||
return EXIT_FAILURE; | |||||
} | |||||
// Now that the QApplication is setup and we have parsed our parameters, we | |||||
// can set the platform style | |||||
app.setupPlatformStyle(); | |||||
/// 3. Application identification | /// 3. Application identification | ||||
// must be set before OptionsModel is initialized or translations are | // must be set before OptionsModel is initialized or translations are | ||||
// loaded, as it is used to locate QSettings. | // loaded, as it is used to locate QSettings. | ||||
// Note: If you move these calls somewhere else, be sure to bring | // Note: If you move these calls somewhere else, be sure to bring | ||||
// MigrateSettings() below along for the ride. | // MigrateSettings() below along for the ride. | ||||
QApplication::setOrganizationName(QAPP_ORG_NAME); | QApplication::setOrganizationName(QAPP_ORG_NAME); | ||||
QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN); | QApplication::setOrganizationDomain(QAPP_ORG_DOMAIN); | ||||
QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT); | QApplication::setApplicationName(QAPP_APP_NAME_DEFAULT); | ||||
Show All 32 Lines | #endif | ||||
if (!fs::is_directory(GetDataDir(false))) { | if (!fs::is_directory(GetDataDir(false))) { | ||||
QMessageBox::critical( | QMessageBox::critical( | ||||
0, QObject::tr(PACKAGE_NAME), | 0, QObject::tr(PACKAGE_NAME), | ||||
QObject::tr( | QObject::tr( | ||||
"Error: Specified data directory \"%1\" does not exist.") | "Error: Specified data directory \"%1\" does not exist.") | ||||
.arg(QString::fromStdString(gArgs.GetArg("-datadir", "")))); | .arg(QString::fromStdString(gArgs.GetArg("-datadir", "")))); | ||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
try { | if (!node->readConfigFiles(error)) { | ||||
node->readConfigFiles(); | |||||
} catch (const std::exception &e) { | |||||
QMessageBox::critical( | QMessageBox::critical( | ||||
0, QObject::tr(PACKAGE_NAME), | 0, QObject::tr(PACKAGE_NAME), | ||||
QObject::tr("Error: Cannot parse configuration file: %1. Only use " | QObject::tr("Error: Cannot parse configuration file: %1.") | ||||
"key=value syntax.") | .arg(QString::fromStdString(error))); | ||||
.arg(e.what())); | |||||
return EXIT_FAILURE; | return EXIT_FAILURE; | ||||
} | } | ||||
/// 7. Determine network (and switch to network specific options) | /// 7. Determine network (and switch to network specific options) | ||||
// - Do not call Params() before this step. | // - Do not call Params() before this step. | ||||
// - Do this after parsing the configuration file, as the network can be | // - Do this after parsing the configuration file, as the network can be | ||||
// switched there. | // switched there. | ||||
// - QSettings() will use the new application name after this, resulting in | // - QSettings() will use the new application name after this, resulting in | ||||
▲ Show 20 Lines • Show All 111 Lines • Show Last 20 Lines |