Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intro: Never change the prune checkbox after the user has touched it #658

Merged
merged 2 commits into from
Feb 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/qt/intro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si

const int min_prune_target_GB = std::ceil(MIN_DISK_SPACE_FOR_BLOCK_FILES / 1e9);
ui->pruneGB->setRange(min_prune_target_GB, std::numeric_limits<int>::max());
if (gArgs.GetIntArg("-prune", 0) > 1) { // -prune=1 means enabled, above that it's a size in MiB
ui->prune->setChecked(true);
if (gArgs.IsArgSet("-prune")) {
m_prune_checkbox_is_default = false;
ui->prune->setChecked(gArgs.GetIntArg("-prune", 0) >= 1);
ui->prune->setEnabled(false);
}
ui->pruneGB->setValue(m_prune_target_gb);
Expand All @@ -151,6 +152,7 @@ Intro::Intro(QWidget *parent, int64_t blockchain_size_gb, int64_t chain_state_si
UpdatePruneLabels(ui->prune->isChecked());

connect(ui->prune, &QCheckBox::toggled, [this](bool prune_checked) {
m_prune_checkbox_is_default = false;
UpdatePruneLabels(prune_checked);
UpdateFreeSpaceLabel();
});
Expand Down Expand Up @@ -286,7 +288,7 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
ui->freeSpace->setText("");
} else {
m_bytes_available = bytesAvailable;
if (ui->prune->isEnabled() && !(gArgs.IsArgSet("-prune") && gArgs.GetIntArg("-prune", 0) == 0)) {
if (ui->prune->isEnabled() && m_prune_checkbox_is_default) {
ui->prune->setChecked(m_bytes_available < (m_blockchain_size_gb + m_chain_state_size_gb + 10) * GB_BYTES);
}
UpdateFreeSpaceLabel();
Expand Down
1 change: 1 addition & 0 deletions src/qt/intro.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private Q_SLOTS:

private:
Ui::Intro *ui;
bool m_prune_checkbox_is_default{true};
QThread* thread{nullptr};
QMutex mutex;
bool signalled{false};
Expand Down