modaloverlay.h raw

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