12 #include <boost/filesystem.hpp>
14 #include <QFileDialog>
16 #include <QMessageBox>
48 void reply(
int status,
const QString &message, quint64 available);
63 namespace fs = boost::filesystem;
66 uint64_t freeBytesAvailable = 0;
67 int replyStatus =
ST_OK;
68 QString replyMessage = tr(
"A new data directory will be created.");
71 fs::path parentDir = dataDir;
72 fs::path parentDirOld = fs::path();
73 while(parentDir.has_parent_path() && !fs::exists(parentDir))
75 parentDir = parentDir.parent_path();
78 if (parentDirOld == parentDir)
81 parentDirOld = parentDir;
85 freeBytesAvailable = fs::space(parentDir).available;
86 if(fs::exists(dataDir))
88 if(fs::is_directory(dataDir))
90 QString separator =
"<code>" + QDir::toNativeSeparators(
"/") + tr(
"name") +
"</code>";
92 replyMessage = tr(
"Directory already exists. Add %1 if you intend to create a new directory here.").arg(separator);
95 replyMessage = tr(
"Path already exists, and is not a directory.");
98 }
catch(fs::filesystem_error &e)
102 replyMessage = tr(
"Cannot create data directory here.");
104 emit
reply(replyStatus, replyMessage, freeBytesAvailable);
154 namespace fs = boost::filesystem;
158 if(!
GetArg(
"-datadir",
"").empty())
163 dataDir = settings.value(
"strDataDir", dataDir).toString();
170 intro.setWindowIcon(QIcon(
":icons/bitcoin"));
183 }
catch(fs::filesystem_error &e) {
184 QMessageBox::critical(0, tr(
"Bitcoin"),
185 tr(
"Error: Specified data directory \"%1\" can not be created.").arg(dataDir));
190 settings.setValue(
"strDataDir", dataDir);
218 QString freeString = QString::number(bytesAvailable/
GB_BYTES) + tr(
"GB of free space available");
222 ui->
freeSpace->setStyleSheet(
"QLabel { color: #800000 }");
235 ui->
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
241 QString dir = QDir::toNativeSeparators(QFileDialog::getExistingDirectory(0,
"Choose data directory",
ui->
dataDirectory->text()));
259 thread =
new QThread(
this);
261 executor->moveToThread(
thread);
263 connect(executor, SIGNAL(reply(
int,QString,quint64)),
this, SLOT(
setStatus(
int,QString,quint64)));
264 connect(
this, SIGNAL(
requestCheck()), executor, SLOT(check()));
266 connect(
this, SIGNAL(
stopThread()), executor, SLOT(deleteLater()));
void reply(int status, const QString &message, quint64 available)
QRadioButton * dataDirDefault
void on_dataDirCustom_clicked()
FreespaceChecker(Intro *intro)
static const uint64_t BLOCK_CHAIN_SIZE
void setupUi(QDialog *Intro)
QString getDataDirectory()
boost::filesystem::path qstringToBoostPath(const QString &path)
QRadioButton * dataDirCustom
static QString getDefaultDataDirectory()
Determine default data directory for operating system.
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
bool SoftSetArg(const std::string &strArg, const std::string &strValue)
Set an argument if it doesn't already have a value.
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
void on_dataDirDefault_clicked()
static const uint64_t GB_BYTES
bool TryCreateDirectory(const boost::filesystem::path &p)
QLineEdit * dataDirectory
friend class FreespaceChecker
void setDataDirectory(const QString &dataDir)
static void pickDataDirectory()
Determine data directory.
QLabel * sizeWarningLabel
std::string GetArg(const std::string &strArg, const std::string &strDefault)
Return string argument or default value.
QString boostPathToQString(const boost::filesystem::path &path)
Introduction screen (pre-GUI startup).
QPushButton * ellipsisButton
boost::filesystem::path GetDefaultDataDir()