aboutsummaryrefslogtreecommitdiff
path: root/src/qt
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2019-12-08 17:18:15 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-01-14 18:53:08 +0200
commit4824a7d36cf47e766865e0fefe952ec860eb82dd (patch)
tree7a50b61ceac14aef96a03c4a0a92bd7009649c2a /src/qt
parentdaa3f3fa9071a229275dd6a1b8445237ddc3fa97 (diff)
gui: Add Intro::UpdateFreeSpaceLabel()
If a new custom datadir has enough free space, the prune checkbox gets unchecked, unless -prune=NNN command-line option is provided.
Diffstat (limited to 'src/qt')
-rw-r--r--src/qt/intro.cpp31
-rw-r--r--src/qt/intro.h2
2 files changed, 21 insertions, 12 deletions
diff --git a/src/qt/intro.cpp b/src/qt/intro.cpp
index a1a7c8ab8b..cb7b13260a 100644
--- a/src/qt/intro.cpp
+++ b/src/qt/intro.cpp
@@ -251,24 +251,31 @@ void Intro::setStatus(int status, const QString &message, quint64 bytesAvailable
{
ui->freeSpace->setText("");
} else {
- QString freeString = tr("%n GB of free space available", "", bytesAvailable/GB_BYTES);
- if (bytesAvailable < m_required_space_gb * GB_BYTES) {
- freeString += " " + tr("(of %n GB needed)", "", m_required_space_gb);
- ui->freeSpace->setStyleSheet("QLabel { color: #800000 }");
- ui->prune->setChecked(true);
- } else if (bytesAvailable / GB_BYTES - m_required_space_gb < 10) {
- freeString += " " + tr("(%n GB needed for full chain)", "", m_required_space_gb);
- ui->freeSpace->setStyleSheet("QLabel { color: #999900 }");
- ui->prune->setChecked(true);
- } else {
- ui->freeSpace->setStyleSheet("");
+ m_bytes_available = bytesAvailable;
+ if (ui->prune->isEnabled()) {
+ ui->prune->setChecked(m_bytes_available < (m_blockchain_size_gb + m_chain_state_size_gb + 10) * GB_BYTES);
}
- ui->freeSpace->setText(freeString + ".");
+ UpdateFreeSpaceLabel();
}
/* Don't allow confirm in ERROR state */
ui->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(status != FreespaceChecker::ST_ERROR);
}
+void Intro::UpdateFreeSpaceLabel()
+{
+ QString freeString = tr("%n GB of free space available", "", m_bytes_available / GB_BYTES);
+ if (m_bytes_available < m_required_space_gb * GB_BYTES) {
+ freeString += " " + tr("(of %n GB needed)", "", m_required_space_gb);
+ ui->freeSpace->setStyleSheet("QLabel { color: #800000 }");
+ } else if (m_bytes_available / GB_BYTES - m_required_space_gb < 10) {
+ freeString += " " + tr("(%n GB needed for full chain)", "", m_required_space_gb);
+ ui->freeSpace->setStyleSheet("QLabel { color: #999900 }");
+ } else {
+ ui->freeSpace->setStyleSheet("");
+ }
+ ui->freeSpace->setText(freeString + ".");
+}
+
void Intro::on_dataDirectory_textChanged(const QString &dataDirStr)
{
/* Disable OK button until check result comes in */
diff --git a/src/qt/intro.h b/src/qt/intro.h
index b4fd390006..8375847cc0 100644
--- a/src/qt/intro.h
+++ b/src/qt/intro.h
@@ -71,11 +71,13 @@ private:
const int64_t m_chain_state_size_gb;
//! Total required space (in GB) depending on user choice (prune or not prune).
int64_t m_required_space_gb{0};
+ uint64_t m_bytes_available{0};
void startThread();
void checkPath(const QString &dataDir);
QString getPathToCheck();
void UpdatePruneLabels(int64_t prune_target_gb);
+ void UpdateFreeSpaceLabel();
friend class FreespaceChecker;
};