Migration fixes (#1247)

* clean some network specific qt settings on migration

* ask user to choose datadir if default dir is not the one we expected
This commit is contained in:
UdjinM6 2017-01-04 21:47:50 +04:00 committed by GitHub
parent a9e1361fc2
commit 7e9ad0e26c
4 changed files with 26 additions and 6 deletions

View File

@ -864,6 +864,18 @@ bool SetStartOnSystemStartup(bool fAutoStart) { return false; }
#endif
void migrateQtSettings()
{
// Migration (12.1)
QSettings settings;
if(!settings.value("fMigrationDone121", false).toBool()) {
settings.remove("theme");
settings.remove("nWindowPos");
settings.remove("nWindowSize");
settings.setValue("fMigrationDone121", true);
}
}
void saveWindowGeometry(const QString& strSetting, QWidget *parent)
{
QSettings settings;

View File

@ -186,6 +186,9 @@ namespace GUIUtil
bool GetStartOnSystemStartup();
bool SetStartOnSystemStartup(bool fAutoStart);
/** Modify Qt network specific settings on migration */
void migrateQtSettings();
/** Save window size and position */
void saveWindowGeometry(const QString& strSetting, QWidget *parent);
/** Restore window size and position */

View File

@ -169,15 +169,17 @@ void Intro::pickDataDirectory()
if(!GetArg("-datadir", "").empty())
return;
/* 1) Default data directory for operating system */
QString dataDir = getDefaultDataDirectory();
QString dataDirDefaultCurrent = getDefaultDataDirectory();
/* 2) Allow QSettings to override default dir */
dataDir = settings.value("strDataDir", dataDir).toString();
QString dataDir = settings.value("strDataDir", dataDirDefaultCurrent).toString();
/* 3) Check to see if default datadir is the one we expect */
QString dataDirDefaultSettings = settings.value("strDataDirDefault", dataDirDefaultCurrent).toString();
if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR))
if(!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || dataDirDefaultCurrent != dataDirDefaultSettings)
{
/* If current default data directory does not exist, let the user choose one */
/* Let the user choose one */
Intro intro;
intro.setDataDirectory(dataDir);
intro.setDataDirectory(dataDirDefaultCurrent);
intro.setWindowIcon(QIcon(":icons/bitcoin"));
while(true)
@ -199,12 +201,13 @@ void Intro::pickDataDirectory()
}
settings.setValue("strDataDir", dataDir);
settings.setValue("strDataDirDefault", dataDirDefaultCurrent);
}
/* Only override -datadir if different from the default, to make it possible to
* override -datadir in the dash.conf file in the default data directory
* (to be consistent with dashd behavior)
*/
if(dataDir != getDefaultDataDirectory())
if(dataDir != dataDirDefaultCurrent)
SoftSetArg("-datadir", GUIUtil::qstringToBoostPath(dataDir).string()); // use OS locale for path setting
}

View File

@ -64,6 +64,8 @@ NetworkStyle::NetworkStyle(const QString &appName, const int iconColorHueShift,
{
// Allow for separate UI settings for testnets
QApplication::setApplicationName(appName);
// Make sure settings migrated properly
GUIUtil::migrateQtSettings();
// Grab theme from settings
QString theme = GUIUtil::getThemeName();
// load pixmap