Line data Source code
1 : // Copyright (c) 2011-2019 The Bitcoin Core developers 2 : // Distributed under the MIT software license, see the accompanying 3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 : 5 : #ifndef BITCOIN_QT_INTRO_H 6 : #define BITCOIN_QT_INTRO_H 7 : 8 : #include <QDialog> 9 : #include <QMutex> 10 : #include <QThread> 11 : 12 : static const bool DEFAULT_CHOOSE_DATADIR = false; 13 : 14 : class FreespaceChecker; 15 : 16 : namespace interfaces { 17 : class Node; 18 : } 19 : 20 : namespace Ui { 21 : class Intro; 22 : } 23 : 24 : /** Introduction screen (pre-GUI startup). 25 : Allows the user to choose a data directory, 26 : in which the wallet and block chain will be stored. 27 : */ 28 : class Intro : public QDialog 29 : { 30 0 : Q_OBJECT 31 : 32 : public: 33 : explicit Intro(QWidget *parent = nullptr, 34 : int64_t blockchain_size_gb = 0, int64_t chain_state_size_gb = 0); 35 : ~Intro(); 36 : 37 : QString getDataDirectory(); 38 : void setDataDirectory(const QString &dataDir); 39 : 40 : /** 41 : * Determine data directory. Let the user choose if the current one doesn't exist. 42 : * Let the user configure additional preferences such as pruning. 43 : * 44 : * @returns true if a data directory was selected, false if the user cancelled the selection 45 : * dialog. 46 : * 47 : * @note do NOT call global GetDataDir() before calling this function, this 48 : * will cause the wrong path to be cached. 49 : */ 50 : static bool showIfNeeded(bool& did_show_intro, bool& prune); 51 : 52 : Q_SIGNALS: 53 : void requestCheck(); 54 : 55 : public Q_SLOTS: 56 : void setStatus(int status, const QString &message, quint64 bytesAvailable); 57 : 58 : private Q_SLOTS: 59 : void on_dataDirectory_textChanged(const QString &arg1); 60 : void on_ellipsisButton_clicked(); 61 : void on_dataDirDefault_clicked(); 62 : void on_dataDirCustom_clicked(); 63 : 64 : private: 65 : Ui::Intro *ui; 66 : QThread *thread; 67 : QMutex mutex; 68 : bool signalled; 69 : QString pathToCheck; 70 : const int64_t m_blockchain_size_gb; 71 : const int64_t m_chain_state_size_gb; 72 : //! Total required space (in GB) depending on user choice (prune or not prune). 73 : int64_t m_required_space_gb{0}; 74 : uint64_t m_bytes_available{0}; 75 : const int64_t m_prune_target_gb; 76 : 77 : void startThread(); 78 : void checkPath(const QString &dataDir); 79 : QString getPathToCheck(); 80 : void UpdatePruneLabels(bool prune_checked); 81 : void UpdateFreeSpaceLabel(); 82 : 83 : friend class FreespaceChecker; 84 : }; 85 : 86 : #endif // BITCOIN_QT_INTRO_H