2019-12-30 22:39:22 +13:00
|
|
|
// Copyright (c) 2011-2019 The Bitcoin Core developers
|
2014-12-13 12:09:33 +08:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-04 16:20:43 +01:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#ifndef BITCOIN_QT_INTRO_H
|
|
|
|
#define BITCOIN_QT_INTRO_H
|
2013-05-19 17:36:01 +02:00
|
|
|
|
|
|
|
#include <QDialog>
|
|
|
|
#include <QMutex>
|
2013-04-13 00:13:08 -05:00
|
|
|
#include <QThread>
|
|
|
|
|
2015-11-09 19:23:46 +01:00
|
|
|
static const bool DEFAULT_CHOOSE_DATADIR = false;
|
|
|
|
|
2013-04-13 00:13:08 -05:00
|
|
|
class FreespaceChecker;
|
2013-05-19 17:36:01 +02:00
|
|
|
|
2018-04-07 03:42:02 -04:00
|
|
|
namespace interfaces {
|
2017-04-17 15:44:10 -04:00
|
|
|
class Node;
|
|
|
|
}
|
|
|
|
|
2013-05-19 17:36:01 +02:00
|
|
|
namespace Ui {
|
2014-09-05 13:18:35 +02:00
|
|
|
class Intro;
|
2013-05-19 17:36:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/** Introduction screen (pre-GUI startup).
|
|
|
|
Allows the user to choose a data directory,
|
|
|
|
in which the wallet and block chain will be stored.
|
|
|
|
*/
|
|
|
|
class Intro : public QDialog
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2018-07-30 12:37:09 +02:00
|
|
|
explicit Intro(QWidget *parent = nullptr,
|
2019-11-12 14:25:43 +02:00
|
|
|
int64_t blockchain_size_gb = 0, int64_t chain_state_size_gb = 0);
|
2013-05-19 17:36:01 +02:00
|
|
|
~Intro();
|
|
|
|
|
|
|
|
QString getDataDirectory();
|
|
|
|
void setDataDirectory(const QString &dataDir);
|
2020-11-19 03:19:30 +00:00
|
|
|
int64_t getPruneMiB() const;
|
2013-05-19 17:36:01 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine data directory. Let the user choose if the current one doesn't exist.
|
2019-08-24 19:13:04 +02:00
|
|
|
* Let the user configure additional preferences such as pruning.
|
2013-05-19 17:36:01 +02:00
|
|
|
*
|
2016-08-18 16:58:04 +02:00
|
|
|
* @returns true if a data directory was selected, false if the user cancelled the selection
|
|
|
|
* dialog.
|
|
|
|
*
|
2021-05-04 13:00:25 +02:00
|
|
|
* @note do NOT call global gArgs.GetDataDirNet() before calling this function, this
|
2013-05-19 17:36:01 +02:00
|
|
|
* will cause the wrong path to be cached.
|
|
|
|
*/
|
2020-04-20 14:42:52 +00:00
|
|
|
static bool showIfNeeded(bool& did_show_intro, int64_t& prune_MiB);
|
2013-05-19 17:36:01 +02:00
|
|
|
|
2015-07-14 13:59:05 +02:00
|
|
|
Q_SIGNALS:
|
2013-05-19 17:36:01 +02:00
|
|
|
void requestCheck();
|
|
|
|
|
2015-07-14 13:59:05 +02:00
|
|
|
public Q_SLOTS:
|
2013-05-19 17:36:01 +02:00
|
|
|
void setStatus(int status, const QString &message, quint64 bytesAvailable);
|
|
|
|
|
2015-07-14 13:59:05 +02:00
|
|
|
private Q_SLOTS:
|
2013-05-19 17:36:01 +02:00
|
|
|
void on_dataDirectory_textChanged(const QString &arg1);
|
|
|
|
void on_ellipsisButton_clicked();
|
|
|
|
void on_dataDirDefault_clicked();
|
|
|
|
void on_dataDirCustom_clicked();
|
|
|
|
|
|
|
|
private:
|
|
|
|
Ui::Intro *ui;
|
|
|
|
QThread *thread;
|
|
|
|
QMutex mutex;
|
|
|
|
bool signalled;
|
|
|
|
QString pathToCheck;
|
2019-11-12 14:25:43 +02:00
|
|
|
const int64_t m_blockchain_size_gb;
|
|
|
|
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};
|
2019-12-08 17:18:15 +02:00
|
|
|
uint64_t m_bytes_available{0};
|
2020-04-21 21:14:11 +00:00
|
|
|
int64_t m_prune_target_gb;
|
2013-05-19 17:36:01 +02:00
|
|
|
|
|
|
|
void startThread();
|
|
|
|
void checkPath(const QString &dataDir);
|
|
|
|
QString getPathToCheck();
|
2019-12-08 23:28:50 +02:00
|
|
|
void UpdatePruneLabels(bool prune_checked);
|
2019-12-08 17:18:15 +02:00
|
|
|
void UpdateFreeSpaceLabel();
|
2013-05-19 17:36:01 +02:00
|
|
|
|
|
|
|
friend class FreespaceChecker;
|
|
|
|
};
|
|
|
|
|
2014-11-03 16:16:40 +01:00
|
|
|
#endif // BITCOIN_QT_INTRO_H
|