mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
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:
parent
a9e1361fc2
commit
7e9ad0e26c
@ -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;
|
||||
|
@ -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 */
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user