5#if defined(HAVE_CONFIG_H)
6#include <config/bitcoin-config.h>
12#include <qt/forms/ui_intro.h>
57#include <qt/intro.moc>
88 if (fs::is_directory(dataDir)) {
90 tr(
"name") +
"</code>";
93 "intend to create a new directory here.")
98 tr(
"Path already exists, and is not a directory.");
101 }
catch (
const fs::filesystem_error &) {
130 ui->lblExplanation1->setText(
ui->lblExplanation1->text()
134 .arg(
tr(
"Bitcoin")));
135 ui->lblExplanation2->setText(
ui->lblExplanation2->text().arg(
PACKAGE_NAME));
139 ui->prune->setChecked(
true);
140 ui->prune->setEnabled(
false);
142 ui->prune->setText(
tr(
"Discard blocks after verification, except most "
143 "recent %1 GB (prune)")
148 UpdatePruneLabels(prune_checked);
149 UpdateFreeSpaceLabel();
163 return ui->dataDirectory->text();
167 ui->dataDirectory->setText(dataDir);
169 ui->dataDirDefault->setChecked(
true);
170 ui->dataDirectory->setEnabled(
false);
171 ui->ellipsisButton->setEnabled(
false);
173 ui->dataDirCustom->setChecked(
true);
174 ui->dataDirectory->setEnabled(
true);
175 ui->ellipsisButton->setEnabled(
true);
191 dataDir =
settings.value(
"strDataDir", dataDir).toString();
195 settings.value(
"fReset",
false).toBool() ||
203 }
catch (
const std::exception &) {
215 intro.setWindowIcon(
QIcon(
":icons/bitcoin"));
233 }
catch (
const fs::filesystem_error &) {
235 tr(
"Error: Specified data directory "
236 "\"%1\" cannot be created.")
243 prune = intro.
ui->prune->isChecked();
245 settings.setValue(
"strDataDir", dataDir);
265 ui->errorMessage->setText(message);
266 ui->errorMessage->setStyleSheet(
"");
269 ui->errorMessage->setText(
tr(
"Error") +
": " + message);
270 ui->errorMessage->setStyleSheet(
"QLabel { color: #800000 }");
275 ui->freeSpace->setText(
"");
278 if (
ui->prune->isEnabled()) {
279 ui->prune->setChecked(
286 ui->buttonBox->button(QDialogButtonBox::Ok)
295 ui->freeSpace->setStyleSheet(
"QLabel { color: #800000 }");
299 ui->freeSpace->setStyleSheet(
"QLabel { color: #999900 }");
301 ui->freeSpace->setStyleSheet(
"");
308 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
313 QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(
314 nullptr,
"Choose data directory",
ui->dataDirectory->text()));
315 if (!
dir.isEmpty()) {
316 ui->dataDirectory->setText(
dir);
325 ui->dataDirectory->setEnabled(
true);
326 ui->ellipsisButton->setEnabled(
true);
364 tr(
"At least %1 GB of data will be stored in this directory, and it "
365 "will grow over time.");
369 tr(
"Approximately %1 GB of data will be stored in this directory.");
372 ui->sizeWarningLabel->setText(
373 tr(
"%1 will download and store a copy of the Bitcoin block chain.")
376 tr(
"The wallet will also be stored in this directory."));
void SelectParams(const std::string &network)
Sets the params returned by Params() to those for the given BIP70 chain name.
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const
Return integer argument or default value.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const
Return string argument or default value.
bool GetBoolArg(const std::string &strArg, bool fDefault) const
Return boolean argument or default value.
std::string GetChainName() const
Looks for -regtest, -testnet and returns the appropriate BIP70 chain name.
CChainParams defines various tweakable parameters of a given instance of the Bitcoin system.
uint64_t AssumedBlockchainSize() const
Minimum free space (in GB) needed for data directory.
uint64_t AssumedChainStateSize() const
Minimum free space (in GB) needed for data directory when pruned; Does not include prune target.
virtual const CChainParams & GetChainParams() const =0
FreespaceChecker(Intro *intro)
void reply(int status, const QString &message, quint64 available)
Introduction screen (pre-GUI startup).
void setStatus(int status, const QString &message, quint64 bytesAvailable)
void on_ellipsisButton_clicked()
void UpdatePruneLabels(bool prune_checked)
const int64_t m_blockchain_size_gb
void setDataDirectory(const QString &dataDir)
static bool showIfNeeded(bool &did_show_intro, bool &prune)
Determine data directory.
uint64_t m_bytes_available
friend class FreespaceChecker
void on_dataDirectory_textChanged(const QString &arg1)
int64_t m_required_space_gb
Total required space (in GB) depending on user choice (prune or not prune).
void UpdateFreeSpaceLabel()
Intro(QWidget *parent=nullptr, int64_t blockchain_size_gb=0, int64_t chain_state_size_gb=0)
const int64_t m_chain_state_size_gb
QString getDataDirectory()
void checkPath(const QString &dataDir)
void on_dataDirDefault_clicked()
const int64_t m_prune_target_gb
void on_dataDirCustom_clicked()
Path class wrapper to block calls to the fs::path(std::string) implicit constructor and the fs::path:...
const Config & GetConfig()
bool TryCreateDirectories(const fs::path &p)
Ignores exceptions thrown by create_directories if the requested directory exists.
static constexpr int DEFAULT_PRUNE_TARGET_GB
static constexpr uint64_t GB_BYTES
static const bool DEFAULT_CHOOSE_DATADIR
fs::path qstringToBoostPath(const QString &path)
Convert QString to OS specific boost path through UTF-8.
QString getDefaultDataDirectory()
Determine default data directory for operating system.
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to byte string.
static int PruneMiBtoGB(int64_t mib)
Convert configured prune target MiB to displayed GB.
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...