5 #if defined(HAVE_CONFIG_H) 17 #include <QFileDialog> 19 #include <QMessageBox> 23 static const uint64_t GB_BYTES = 1000000000LL;
25 static const uint64_t BLOCK_CHAIN_SIZE = 1;
27 static const uint64_t CHAIN_STATE_SIZE = 1;
29 static uint64_t requiredSpace;
57 void reply(
int status,
const QString &message, quint64 available);
74 uint64_t freeBytesAvailable = 0;
75 int replyStatus =
ST_OK;
76 QString replyMessage = tr(
"A new data directory will be created.");
79 fs::path parentDir = dataDir;
80 fs::path parentDirOld = fs::path();
81 while(parentDir.has_parent_path() && !fs::exists(parentDir))
83 parentDir = parentDir.parent_path();
86 if (parentDirOld == parentDir)
89 parentDirOld = parentDir;
93 freeBytesAvailable = fs::space(parentDir).available;
94 if(fs::exists(dataDir))
96 if(fs::is_directory(dataDir))
98 QString separator =
"<code>" + QDir::toNativeSeparators(
"/") + tr(
"name") +
"</code>";
100 replyMessage = tr(
"Directory already exists. Add %1 if you intend to create a new directory here.").arg(separator);
103 replyMessage = tr(
"Path already exists, and is not a directory.");
106 }
catch (
const fs::filesystem_error&)
110 replyMessage = tr(
"Cannot create data directory here.");
112 Q_EMIT
reply(replyStatus, replyMessage, freeBytesAvailable);
128 .arg(BLOCK_CHAIN_SIZE)
134 uint64_t pruneTarget = std::max<int64_t>(0,
gArgs.
GetArg(
"-prune", 0));
135 requiredSpace = BLOCK_CHAIN_SIZE;
136 QString storageRequiresMsg = tr(
"At least %1 GB of data will be stored in this directory, and it will grow over time.");
138 uint64_t prunedGBs = std::ceil(pruneTarget * 1024 * 1024.0 / GB_BYTES);
139 if (prunedGBs <= requiredSpace) {
140 requiredSpace = prunedGBs;
141 storageRequiresMsg = tr(
"Approximately %1 GB of data will be stored in this directory.");
147 requiredSpace += CHAIN_STATE_SIZE;
149 tr(
"%1 will download and store a copy of the Fabcoin block chain.").arg(tr(
PACKAGE_NAME)) +
" " +
150 storageRequiresMsg.arg(requiredSpace) +
" " +
151 tr(
"The wallet will also be stored in this directory.")
199 dataDir = settings.value(
"strDataDir", dataDir).toString();
206 intro.setWindowIcon(QIcon(
":icons/fabcoin"));
219 }
catch (
const fs::filesystem_error&) {
221 tr(
"Error: Specified data directory \"%1\" cannot be created.").arg(dataDir));
226 settings.setValue(
"strDataDir", dataDir);
227 settings.setValue(
"fReset",
false);
256 QString freeString = tr(
"%n GB of free space available",
"", bytesAvailable/GB_BYTES);
257 if(bytesAvailable < requiredSpace * GB_BYTES)
259 freeString +=
" " + tr(
"(of %n GB needed)",
"", requiredSpace);
260 ui->
freeSpace->setStyleSheet(
"QLabel { color: #800000 }");
273 ui->
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
279 QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(0,
"Choose data directory",
ui->
dataDirectory->text()));
297 thread =
new QThread(
this);
299 executor->moveToThread(
thread);
301 connect(executor, SIGNAL(reply(
int,QString,quint64)),
this, SLOT(
setStatus(
int,QString,quint64)));
302 connect(
this, SIGNAL(
requestCheck()), executor, SLOT(check()));
304 connect(
this, SIGNAL(
stopThread()), executor, SLOT(deleteLater()));
void reply(int status, const QString &message, quint64 available)
QRadioButton * dataDirDefault
void on_dataDirCustom_clicked()
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
FreespaceChecker(Intro *intro)
void setupUi(QDialog *Intro)
QString getDataDirectory()
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
QRadioButton * dataDirCustom
static QString getDefaultDataDirectory()
Determine default data directory for operating system.
void on_dataDirectory_textChanged(const QString &arg1)
void setStatus(int status, const QString &message, quint64 bytesAvailable)
void checkPath(const QString &dataDir)
void on_ellipsisButton_clicked()
QDialogButtonBox * buttonBox
bool TryCreateDirectories(const fs::path &p)
Ignores exceptions thrown by Boost's create_directories if the requested directory exists...
void on_dataDirDefault_clicked()
QLineEdit * dataDirectory
fs::path GetDefaultDataDir()
friend class FreespaceChecker
void setDataDirectory(const QString &dataDir)
fs::path qstringToBoostPath(const QString &path)
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
QLabel * sizeWarningLabel
QString boostPathToQString(const fs::path &path)
static bool pickDataDirectory()
Determine data directory.
Introduction screen (pre-GUI startup).
QPushButton * ellipsisButton