Changeset View
Changeset View
Standalone View
Standalone View
src/qt/bitcoin.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | |||||
#include <QApplication> | #include <QApplication> | ||||
#include <QDebug> | #include <QDebug> | ||||
#include <QLibraryInfo> | #include <QLibraryInfo> | ||||
#include <QLocale> | #include <QLocale> | ||||
#include <QMessageBox> | #include <QMessageBox> | ||||
#include <QSettings> | #include <QSettings> | ||||
#include <QSslConfiguration> | #include <QSslConfiguration> | ||||
#include <QStringList> | |||||
#include <QThread> | #include <QThread> | ||||
#include <QTimer> | #include <QTimer> | ||||
#include <QTranslator> | #include <QTranslator> | ||||
#if defined(QT_STATICPLUGIN) | #if defined(QT_STATICPLUGIN) | ||||
#include <QtPlugin> | #include <QtPlugin> | ||||
#if QT_VERSION < 0x050000 | #if QT_VERSION < 0x050000 | ||||
Q_IMPORT_PLUGIN(qcncodecs) | Q_IMPORT_PLUGIN(qcncodecs) | ||||
▲ Show 20 Lines • Show All 475 Lines • ▼ Show 20 Lines | |||||
WId BitcoinApplication::getMainWinId() const { | WId BitcoinApplication::getMainWinId() const { | ||||
if (!window) return 0; | if (!window) return 0; | ||||
return window->winId(); | return window->winId(); | ||||
} | } | ||||
#ifndef BITCOIN_QT_TEST | #ifndef BITCOIN_QT_TEST | ||||
static void MigrateSettings() { | |||||
assert(!QApplication::applicationName().isEmpty()); | |||||
static const QString legacyAppName("Bitcoin-Qt"), | |||||
#ifdef Q_OS_DARWIN | |||||
// Macs and/or iOS et al use a domain-style name for Settings | |||||
// files. All other platforms use a simple orgname. This | |||||
// difference is documented in the QSettings class documentation. | |||||
legacyOrg("bitcoin.org"); | |||||
#else | |||||
legacyOrg("Bitcoin"); | |||||
#endif | |||||
QSettings | |||||
// below picks up settings file location based on orgname,appname | |||||
legacy(legacyOrg, legacyAppName), | |||||
// default c'tor below picks up settings file location based on | |||||
// QApplication::applicationName(), et al -- which was already set | |||||
// in main() | |||||
abc; | |||||
#ifdef Q_OS_DARWIN | |||||
// Disable bogus OSX keys from MacOS system-wide prefs that may cloud our | |||||
// judgement ;) (this behavior is also documented in QSettings docs) | |||||
legacy.setFallbacksEnabled(false); | |||||
abc.setFallbacksEnabled(false); | |||||
#endif | |||||
const QStringList legacyKeys(legacy.allKeys()); | |||||
// We only migrate settings if we have Core settings but no Bitcoin-ABC | |||||
// settings | |||||
if (!legacyKeys.isEmpty() && abc.allKeys().isEmpty()) { | |||||
for (const QString &key : legacyKeys) { | |||||
// now, copy settings over | |||||
abc.setValue(key, legacy.value(key)); | |||||
} | |||||
} | |||||
} | |||||
int main(int argc, char *argv[]) { | int main(int argc, char *argv[]) { | ||||
SetupEnvironment(); | SetupEnvironment(); | ||||
/// 1. Parse command-line options. These take precedence over anything else. | /// 1. Parse command-line options. These take precedence over anything else. | ||||
// Command-line options take precedence: | // Command-line options take precedence: | ||||
ParseParameters(argc, argv); | 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 | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | #endif | ||||
// 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 *>(); | ||||
/// 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 | |||||
// 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); | ||||
// Migrate settings from core's/our old GUI settings to Bitcoin ABC | |||||
// only if core's exist but Bitcoin ABC's doesn't. | |||||
// NOTE -- this function needs to be called *after* the above 3 lines | |||||
// that set the app orgname and app name! If you move the above 3 lines | |||||
// to elsewhere, take this call with you! | |||||
MigrateSettings(); | |||||
GUIUtil::SubstituteFonts(GetLangTerritory()); | GUIUtil::SubstituteFonts(GetLangTerritory()); | ||||
/// 4. Initialization of translations, so that intro dialog is in user's | /// 4. Initialization of translations, so that intro dialog is in user's | ||||
/// language. Now that QSettings are accessible, initialize translations. | /// language. Now that QSettings are accessible, initialize translations. | ||||
QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator; | QTranslator qtTranslatorBase, qtTranslator, translatorBase, translator; | ||||
initTranslations(qtTranslatorBase, qtTranslator, translatorBase, | initTranslations(qtTranslatorBase, qtTranslator, translatorBase, | ||||
translator); | translator); | ||||
translationInterface.Translate.connect(Translate); | translationInterface.Translate.connect(Translate); | ||||
▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines |