diff --git a/share/qt/Info.plist.in b/share/qt/Info.plist.in --- a/share/qt/Info.plist.in +++ b/share/qt/Info.plist.in @@ -38,7 +38,7 @@ CFBundleIdentifier - org.bitcoincash.BitcoinABC-Qt + org.bitcoinabc.BitcoinABC-Qt CFBundleURLTypes diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -540,6 +541,44 @@ } #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[]) { SetupEnvironment(); @@ -597,9 +636,17 @@ /// 3. Application identification // must be set before OptionsModel is initialized or translations are // 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::setOrganizationDomain(QAPP_ORG_DOMAIN); 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()); /// 4. Initialization of translations, so that intro dialog is in user's diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -48,9 +48,9 @@ /* Number of frames in spinner animation */ #define SPINNER_FRAMES 36 -#define QAPP_ORG_NAME "Bitcoin" -#define QAPP_ORG_DOMAIN "bitcoin.org" -#define QAPP_APP_NAME_DEFAULT "Bitcoin-Qt" -#define QAPP_APP_NAME_TESTNET "Bitcoin-Qt-testnet" +#define QAPP_ORG_NAME "BitcoinABC" +#define QAPP_ORG_DOMAIN "bitcoinabc.org" +#define QAPP_APP_NAME_DEFAULT "BitcoinABC-Qt" +#define QAPP_APP_NAME_TESTNET "BitcoinABC-Qt-testnet" #endif // BITCOIN_QT_GUICONSTANTS_H diff --git a/src/qt/macnotificationhandler.mm b/src/qt/macnotificationhandler.mm --- a/src/qt/macnotificationhandler.mm +++ b/src/qt/macnotificationhandler.mm @@ -13,7 +13,7 @@ - (NSString *)__bundleIdentifier { if (self == [NSBundle mainBundle]) { - return @"org.bitcoincash.BitcoinABC-Qt"; + return @"org.bitcoinabc.BitcoinABC-Qt"; } else { return [self __bundleIdentifier]; } diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -46,7 +46,7 @@ // Don't remove this, it's needed to access // QCoreApplication:: in the tests QCoreApplication app(argc, argv); - app.setApplicationName("Bitcoin-Qt-test"); + app.setApplicationName("BitcoinABC-Qt-test"); SSL_library_init();