Changeset View
Changeset View
Standalone View
Standalone View
src/qt/intro.cpp
Show First 20 Lines • Show All 80 Lines • ▼ Show 20 Lines | void FreespaceChecker::check() { | ||||
/* Find first parent that exists, so that fs::space does not fail */ | /* Find first parent that exists, so that fs::space does not fail */ | ||||
fs::path parentDir = dataDir; | fs::path parentDir = dataDir; | ||||
fs::path parentDirOld = fs::path(); | fs::path parentDirOld = fs::path(); | ||||
while (parentDir.has_parent_path() && !fs::exists(parentDir)) { | while (parentDir.has_parent_path() && !fs::exists(parentDir)) { | ||||
parentDir = parentDir.parent_path(); | parentDir = parentDir.parent_path(); | ||||
/* Check if we make any progress, break if not to prevent an infinite | /* Check if we make any progress, break if not to prevent an infinite | ||||
* loop here */ | * loop here */ | ||||
if (parentDirOld == parentDir) break; | if (parentDirOld == parentDir) { | ||||
break; | |||||
} | |||||
parentDirOld = parentDir; | parentDirOld = parentDir; | ||||
} | } | ||||
try { | try { | ||||
freeBytesAvailable = fs::space(parentDir).available; | freeBytesAvailable = fs::space(parentDir).available; | ||||
if (fs::exists(dataDir)) { | if (fs::exists(dataDir)) { | ||||
if (fs::is_directory(dataDir)) { | if (fs::is_directory(dataDir)) { | ||||
▲ Show 20 Lines • Show All 83 Lines • ▼ Show 20 Lines | |||||
QString Intro::getDefaultDataDirectory() { | QString Intro::getDefaultDataDirectory() { | ||||
return GUIUtil::boostPathToQString(GetDefaultDataDir()); | return GUIUtil::boostPathToQString(GetDefaultDataDir()); | ||||
} | } | ||||
bool Intro::pickDataDirectory(interfaces::Node &node) { | bool Intro::pickDataDirectory(interfaces::Node &node) { | ||||
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()) return true; | if (!gArgs.GetArg("-datadir", "").empty()) { | ||||
return true; | |||||
} | |||||
/* 1) Default data directory for operating system */ | /* 1) Default data directory for operating system */ | ||||
QString dataDir = getDefaultDataDirectory(); | QString dataDir = 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() || | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | void Intro::on_dataDirectory_textChanged(const QString &dataDirStr) { | ||||
/* Disable OK button until check result comes in */ | /* Disable OK button until check result comes in */ | ||||
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); | ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); | ||||
checkPath(dataDirStr); | checkPath(dataDirStr); | ||||
} | } | ||||
void Intro::on_ellipsisButton_clicked() { | void Intro::on_ellipsisButton_clicked() { | ||||
QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory( | QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory( | ||||
0, "Choose data directory", ui->dataDirectory->text())); | 0, "Choose data directory", ui->dataDirectory->text())); | ||||
if (!dir.isEmpty()) ui->dataDirectory->setText(dir); | if (!dir.isEmpty()) { | ||||
ui->dataDirectory->setText(dir); | |||||
} | |||||
} | } | ||||
void Intro::on_dataDirDefault_clicked() { | void Intro::on_dataDirDefault_clicked() { | ||||
setDataDirectory(getDefaultDataDirectory()); | setDataDirectory(getDefaultDataDirectory()); | ||||
} | } | ||||
void Intro::on_dataDirCustom_clicked() { | void Intro::on_dataDirCustom_clicked() { | ||||
ui->dataDirectory->setEnabled(true); | ui->dataDirectory->setEnabled(true); | ||||
Show All 35 Lines |