5#include <bitcoin-build-config.h>
7#include <chainparams.h>
9#include <qt/forms/ui_intro.h>
23#include <validation.h>
43 QDialog(parent,
GUIUtil::dialog_flags),
53 ui->lblExplanation1->setText(
ui->lblExplanation1->text()
59 ui->lblExplanation2->setText(
ui->lblExplanation2->text().arg(
CLIENT_NAME));
65 ui->prune->setChecked(*arg >= 1);
66 ui->prune->setEnabled(
false);
69 ui->pruneGB->setToolTip(
ui->prune->toolTip());
70 ui->lblPruneSuffix->setToolTip(
ui->prune->toolTip());
74 m_prune_checkbox_is_default = false;
75 UpdatePruneLabels(prune_checked);
76 UpdateFreeSpaceLabel();
79 m_prune_target_gb = prune_GB;
80 UpdatePruneLabels(ui->prune->isChecked());
81 UpdateFreeSpaceLabel();
97 return ui->dataDirectory->text();
102 ui->dataDirectory->setText(dataDir);
105 ui->dataDirDefault->setChecked(
true);
106 ui->dataDirectory->setEnabled(
false);
107 ui->ellipsisButton->setEnabled(
false);
109 ui->dataDirCustom->setChecked(
true);
110 ui->dataDirectory->setEnabled(
true);
111 ui->ellipsisButton->setEnabled(
true);
117 switch (
ui->prune->checkState()) {
120 case Qt::Unchecked:
default:
137 dataDir =
settings.value(
"strDataDir", dataDir).toString();
144 }
catch (
const std::exception&
e) {
146 QMessageBox::critical(
nullptr,
CLIENT_NAME, QObject::tr(
"Error: %1").arg(
QString(
e.what())));
151 Intro intro(
nullptr,
Params().AssumedBlockchainSize(),
Params().AssumedChainStateSize());
153 intro.setWindowIcon(
QIcon(
":icons/bitcoin"));
170 }
catch (
const fs::filesystem_error&) {
172 tr(
"Error: Specified data directory \"%1\" cannot be created.").arg(dataDir));
180 settings.setValue(
"strDataDir", dataDir);
198 ui->errorMessage->setText(message);
199 ui->errorMessage->setStyleSheet(
"");
202 ui->errorMessage->setText(
tr(
"Error") +
": " + message);
203 ui->errorMessage->setStyleSheet(
"QLabel { color: #800000 }");
209 ui->freeSpace->setText(
"");
226 ui->freeSpace->setStyleSheet(
"QLabel { color: #800000 }");
229 ui->freeSpace->setStyleSheet(
"QLabel { color: #999900 }");
231 ui->freeSpace->setStyleSheet(
"");
239 ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
245 QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(
nullptr,
tr(
"Choose data directory"),
ui->dataDirectory->text()));
247 ui->dataDirectory->setText(
dir);
257 ui->dataDirectory->setEnabled(
true);
258 ui->ellipsisButton->setEnabled(
true);
270 connect(
thread, &QThread::finished,
executor, &QObject::deleteLater);
307 static constexpr uint64_t nPowTargetSpacing = 10 * 60;
310 ui->lblPruneSuffix->setText(
313 ui->sizeWarningLabel->setText(
314 tr(
"%1 will download and store a copy of the Bitcoin block chain.").arg(
CLIENT_NAME) +
" " +
316 tr(
"The wallet will also be stored in this directory.")
void SelectParams(const ChainType chain)
Sets the params returned by Params() to those for the given chain type.
const CChainParams & Params()
Return the currently selected parameters.
ChainType GetChainType() const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Returns the appropriate chain type from the program arguments.
bool SoftSetArg(const std::string &strArg, const std::string &strValue) EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Set an argument if it doesn't already have a value.
std::string GetArg(const std::string &strArg, const std::string &strDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return string argument or default value.
int64_t GetIntArg(const std::string &strArg, int64_t nDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
bool GetBoolArg(const std::string &strArg, bool fDefault) const EXCLUSIVE_LOCKS_REQUIRED(!cs_args)
Return boolean argument or default value.
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)
int64_t m_prune_target_gb
bool m_prune_checkbox_is_default
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()
int64_t getPruneMiB() const
static bool showIfNeeded(bool &did_show_intro, int64_t &prune_MiB)
Determine data directory.
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)
QString getPathToCheck() override
void on_dataDirDefault_clicked()
void on_dataDirCustom_clicked()
static bool exists(const path &p)
static std::string PathToString(const path &path)
Convert path object to a byte string.
bool TryCreateDirectories(const fs::path &p)
Ignores exceptions thrown by create_directories if the requested directory exists.
constexpr int DEFAULT_PRUNE_TARGET_GB
constexpr uint64_t GB_BYTES
bool InitError(const bilingual_str &str)
Show error message.
constexpr bool DEFAULT_CHOOSE_DATADIR
Utility functions used by the Bitcoin Qt UI.
QString getDefaultDataDirectory()
Determine default data directory for operating system.
fs::path QStringToPath(const QString &path)
Convert QString to OS specific boost path through UTF-8.
static int PruneMiBtoGB(int64_t mib)
Convert configured prune target MiB to displayed GB.
static int64_t PruneGBtoMiB(int gb)
Convert displayed prune target GB to configured MiB.
bilingual_str Untranslated(std::string original)
Mark a bilingual_str as untranslated.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.
constexpr uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES