splashscreen.h raw

   1  // Copyright (c) 2011-present 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_SPLASHSCREEN_H
   6  #define BITCOIN_QT_SPLASHSCREEN_H
   7  
   8  #include <QWidget>
   9  
  10  #include <memory>
  11  
  12  class NetworkStyle;
  13  
  14  namespace interfaces {
  15  class Handler;
  16  class Node;
  17  class Wallet;
  18  };
  19  
  20  /** Class for the splashscreen with information of the running client.
  21   *
  22   * @note this is intentionally not a QSplashScreen. Bitcoin Core initialization
  23   * can take a long time, and in that case a progress window that cannot be
  24   * moved around and minimized has turned out to be frustrating to the user.
  25   */
  26  class SplashScreen : public QWidget
  27  {
  28      Q_OBJECT
  29  
  30  public:
  31      explicit SplashScreen(const NetworkStyle *networkStyle);
  32      ~SplashScreen();
  33      void setNode(interfaces::Node& node);
  34  
  35  protected:
  36      void paintEvent(QPaintEvent *event) override;
  37      void closeEvent(QCloseEvent *event) override;
  38  
  39  public Q_SLOTS:
  40      /** Show message and progress */
  41      void showMessage(const QString &message, int alignment, const QColor &color);
  42  
  43      /** Handle wallet load notifications. */
  44      void handleLoadWallet();
  45  
  46  protected:
  47      bool eventFilter(QObject * obj, QEvent * ev) override;
  48  
  49  private:
  50      /** Connect core signals to splash screen */
  51      void subscribeToCoreSignals();
  52      /** Disconnect core signals to splash screen */
  53      void unsubscribeFromCoreSignals();
  54      /** Initiate shutdown */
  55      void shutdown();
  56  
  57      QPixmap pixmap;
  58      QString curMessage;
  59      QColor curColor;
  60      int curAlignment{0};
  61  
  62      interfaces::Node* m_node = nullptr;
  63      bool m_shutdown = false;
  64      std::unique_ptr<interfaces::Handler> m_handler_init_message;
  65      std::unique_ptr<interfaces::Handler> m_handler_show_progress;
  66      std::unique_ptr<interfaces::Handler> m_handler_init_wallet;
  67      std::unique_ptr<interfaces::Handler> m_handler_load_wallet;
  68      std::list<std::unique_ptr<interfaces::Wallet>> m_connected_wallets;
  69      std::list<std::unique_ptr<interfaces::Handler>> m_connected_wallet_handlers;
  70  };
  71  
  72  #endif // BITCOIN_QT_SPLASHSCREEN_H
  73