Changeset View
Changeset View
Standalone View
Standalone View
src/qt/intro.cpp
Show First 20 Lines • Show All 166 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
QString Intro::getDataDirectory() { | QString Intro::getDataDirectory() { | ||||
return ui->dataDirectory->text(); | return ui->dataDirectory->text(); | ||||
} | } | ||||
void Intro::setDataDirectory(const QString &dataDir) { | void Intro::setDataDirectory(const QString &dataDir) { | ||||
ui->dataDirectory->setText(dataDir); | ui->dataDirectory->setText(dataDir); | ||||
if (dataDir == getDefaultDataDirectory()) { | if (dataDir == GUIUtil::getDefaultDataDirectory()) { | ||||
ui->dataDirDefault->setChecked(true); | ui->dataDirDefault->setChecked(true); | ||||
ui->dataDirectory->setEnabled(false); | ui->dataDirectory->setEnabled(false); | ||||
ui->ellipsisButton->setEnabled(false); | ui->ellipsisButton->setEnabled(false); | ||||
} else { | } else { | ||||
ui->dataDirCustom->setChecked(true); | ui->dataDirCustom->setChecked(true); | ||||
ui->dataDirectory->setEnabled(true); | ui->dataDirectory->setEnabled(true); | ||||
ui->ellipsisButton->setEnabled(true); | ui->ellipsisButton->setEnabled(true); | ||||
} | } | ||||
} | } | ||||
QString Intro::getDefaultDataDirectory() { | |||||
return GUIUtil::boostPathToQString(GetDefaultDataDir()); | |||||
} | |||||
bool Intro::showIfNeeded(bool &did_show_intro, bool &prune) { | bool Intro::showIfNeeded(bool &did_show_intro, bool &prune) { | ||||
did_show_intro = false; | did_show_intro = false; | ||||
QSettings settings; | QSettings settings; | ||||
/* If data directory provided on command line, no need to look at settings | /* If data directory provided on command line, no need to look at settings | ||||
or show a picking dialog */ | or show a picking dialog */ | ||||
if (!gArgs.GetArg("-datadir", "").empty()) { | if (!gArgs.GetArg("-datadir", "").empty()) { | ||||
return true; | return true; | ||||
} | } | ||||
/* 1) Default data directory for operating system */ | /* 1) Default data directory for operating system */ | ||||
QString dataDir = getDefaultDataDirectory(); | QString dataDir = GUIUtil::getDefaultDataDirectory(); | ||||
/* 2) Allow QSettings to override default dir */ | /* 2) Allow QSettings to override default dir */ | ||||
dataDir = settings.value("strDataDir", dataDir).toString(); | dataDir = settings.value("strDataDir", dataDir).toString(); | ||||
if (!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || | if (!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || | ||||
gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || | gArgs.GetBoolArg("-choosedatadir", DEFAULT_CHOOSE_DATADIR) || | ||||
settings.value("fReset", false).toBool() || | settings.value("fReset", false).toBool() || | ||||
gArgs.GetBoolArg("-resetguisettings", false)) { | gArgs.GetBoolArg("-resetguisettings", false)) { | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | if (!fs::exists(GUIUtil::qstringToBoostPath(dataDir)) || | ||||
settings.setValue("strDataDir", dataDir); | settings.setValue("strDataDir", dataDir); | ||||
settings.setValue("fReset", false); | settings.setValue("fReset", false); | ||||
} | } | ||||
/* Only override -datadir if different from the default, to make it possible | /* Only override -datadir if different from the default, to make it possible | ||||
* to | * to | ||||
* override -datadir in the bitcoin.conf file in the default data directory | * override -datadir in the bitcoin.conf file in the default data directory | ||||
* (to be consistent with bitcoind behavior) | * (to be consistent with bitcoind behavior) | ||||
*/ | */ | ||||
if (dataDir != getDefaultDataDirectory()) { | if (dataDir != GUIUtil::getDefaultDataDirectory()) { | ||||
// use OS locale for path setting | // use OS locale for path setting | ||||
gArgs.SoftSetArg("-datadir", | gArgs.SoftSetArg("-datadir", | ||||
GUIUtil::qstringToBoostPath(dataDir).string()); | GUIUtil::qstringToBoostPath(dataDir).string()); | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
void Intro::setStatus(int status, const QString &message, | void Intro::setStatus(int status, const QString &message, | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | void Intro::on_ellipsisButton_clicked() { | ||||
QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory( | QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory( | ||||
nullptr, "Choose data directory", ui->dataDirectory->text())); | nullptr, "Choose data directory", ui->dataDirectory->text())); | ||||
if (!dir.isEmpty()) { | if (!dir.isEmpty()) { | ||||
ui->dataDirectory->setText(dir); | ui->dataDirectory->setText(dir); | ||||
} | } | ||||
} | } | ||||
void Intro::on_dataDirDefault_clicked() { | void Intro::on_dataDirDefault_clicked() { | ||||
setDataDirectory(getDefaultDataDirectory()); | setDataDirectory(GUIUtil::getDefaultDataDirectory()); | ||||
} | } | ||||
void Intro::on_dataDirCustom_clicked() { | void Intro::on_dataDirCustom_clicked() { | ||||
ui->dataDirectory->setEnabled(true); | ui->dataDirectory->setEnabled(true); | ||||
ui->ellipsisButton->setEnabled(true); | ui->ellipsisButton->setEnabled(true); | ||||
} | } | ||||
void Intro::startThread() { | void Intro::startThread() { | ||||
Show All 30 Lines |