1 // Copyright (c) 2016-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_MODALOVERLAY_H
6 #define BITCOIN_QT_MODALOVERLAY_H
7 
8 #include <QDateTime>
9 #include <QWidget>
10 
11 //! The required delta of headers to the estimated number of available headers until we show the IBD progress
12 static constexpr int HEADER_HEIGHT_DELTA_SYNC = 24;
13 
14 namespace Ui {
15     class ModalOverlay;
16 }
17 
18 /** Modal overlay to display information about the chain-sync state */
19 class ModalOverlay : public QWidget
20 {
21     Q_OBJECT
22 
23 public:
24     enum OverlayType
25     {
26         Sync = 0,
27         Backup = 1
28     };
29     explicit ModalOverlay(bool enable_wallet, QWidget *parent, OverlayType _type = OverlayType::Sync);
30     ~ModalOverlay();
31 
32 public Q_SLOTS:
33     void tipUpdate(int count, const QDateTime& blockDate, double nVerificationProgress);
34     void setKnownBestHeight(int count, const QDateTime& blockDate);
35 
36     void toggleVisibility();
37     // will show or hide the modal layer
38     void showHide(bool hide = false, bool userRequested = false);
39     void closeClicked();
40     void backupWalletClicked();
isLayerVisible()41     bool isLayerVisible() const { return layerIsVisible; }
42 
43 Q_SIGNALS:
44     void backupWallet();
45 
46 protected:
47     bool eventFilter(QObject * obj, QEvent * ev);
48     bool event(QEvent* ev);
49 
50 private:
51     Ui::ModalOverlay *ui;
52     int bestHeaderHeight; //best known height (based on the headers)
53     QDateTime bestHeaderDate;
54     QVector<QPair<qint64, double> > blockProcessTime;
55     bool layerIsVisible;
56     bool userClosed;
57     void UpdateHeaderSyncLabel();
58     OverlayType type;
59 };
60 
61 #endif // BITCOIN_QT_MODALOVERLAY_H
62