LCOV - code coverage report
Current view: top level - src/qt - bitcoingui.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 0 3 0.0 %
Date: 2015-10-12 22:39:14 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2011-2014 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_BITCOINGUI_H
       6             : #define BITCOIN_QT_BITCOINGUI_H
       7             : 
       8             : #if defined(HAVE_CONFIG_H)
       9             : #include "config/bitcoin-config.h"
      10             : #endif
      11             : 
      12             : #include "amount.h"
      13             : 
      14             : #include <QLabel>
      15             : #include <QMainWindow>
      16             : #include <QMap>
      17             : #include <QMenu>
      18             : #include <QPoint>
      19             : #include <QSystemTrayIcon>
      20             : 
      21             : class ClientModel;
      22             : class NetworkStyle;
      23             : class Notificator;
      24             : class OptionsModel;
      25             : class PlatformStyle;
      26             : class RPCConsole;
      27             : class SendCoinsRecipient;
      28             : class UnitDisplayStatusBarControl;
      29             : class WalletFrame;
      30             : class WalletModel;
      31             : class HelpMessageDialog;
      32             : 
      33             : class CWallet;
      34             : 
      35             : QT_BEGIN_NAMESPACE
      36             : class QAction;
      37             : class QProgressBar;
      38             : class QProgressDialog;
      39             : QT_END_NAMESPACE
      40             : 
      41             : /**
      42             :   Bitcoin GUI main class. This class represents the main window of the Bitcoin UI. It communicates with both the client and
      43             :   wallet models to give the user an up-to-date view of the current core state.
      44             : */
      45             : class BitcoinGUI : public QMainWindow
      46             : {
      47           0 :     Q_OBJECT
      48             : 
      49             : public:
      50             :     static const QString DEFAULT_WALLET;
      51             : 
      52             :     explicit BitcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent = 0);
      53             :     ~BitcoinGUI();
      54             : 
      55             :     /** Set the client model.
      56             :         The client model represents the part of the core that communicates with the P2P network, and is wallet-agnostic.
      57             :     */
      58             :     void setClientModel(ClientModel *clientModel);
      59             : 
      60             : #ifdef ENABLE_WALLET
      61             :     /** Set the wallet model.
      62             :         The wallet model represents a bitcoin wallet, and offers access to the list of transactions, address book and sending
      63             :         functionality.
      64             :     */
      65             :     bool addWallet(const QString& name, WalletModel *walletModel);
      66             :     bool setCurrentWallet(const QString& name);
      67             :     void removeAllWallets();
      68             : #endif // ENABLE_WALLET
      69             :     bool enableWallet;
      70             : 
      71             : protected:
      72             :     void changeEvent(QEvent *e);
      73             :     void closeEvent(QCloseEvent *event);
      74             :     void dragEnterEvent(QDragEnterEvent *event);
      75             :     void dropEvent(QDropEvent *event);
      76             :     bool eventFilter(QObject *object, QEvent *event);
      77             : 
      78             : private:
      79             :     ClientModel *clientModel;
      80             :     WalletFrame *walletFrame;
      81             : 
      82             :     UnitDisplayStatusBarControl *unitDisplayControl;
      83             :     QLabel *labelEncryptionIcon;
      84             :     QLabel *labelConnectionsIcon;
      85             :     QLabel *labelBlocksIcon;
      86             :     QLabel *progressBarLabel;
      87             :     QProgressBar *progressBar;
      88             :     QProgressDialog *progressDialog;
      89             : 
      90             :     QMenuBar *appMenuBar;
      91             :     QAction *overviewAction;
      92             :     QAction *historyAction;
      93             :     QAction *quitAction;
      94             :     QAction *sendCoinsAction;
      95             :     QAction *sendCoinsMenuAction;
      96             :     QAction *usedSendingAddressesAction;
      97             :     QAction *usedReceivingAddressesAction;
      98             :     QAction *signMessageAction;
      99             :     QAction *verifyMessageAction;
     100             :     QAction *aboutAction;
     101             :     QAction *receiveCoinsAction;
     102             :     QAction *receiveCoinsMenuAction;
     103             :     QAction *optionsAction;
     104             :     QAction *toggleHideAction;
     105             :     QAction *encryptWalletAction;
     106             :     QAction *backupWalletAction;
     107             :     QAction *changePassphraseAction;
     108             :     QAction *aboutQtAction;
     109             :     QAction *openRPCConsoleAction;
     110             :     QAction *openAction;
     111             :     QAction *showHelpMessageAction;
     112             : 
     113             :     QSystemTrayIcon *trayIcon;
     114             :     QMenu *trayIconMenu;
     115             :     Notificator *notificator;
     116             :     RPCConsole *rpcConsole;
     117             :     HelpMessageDialog *helpMessageDialog;
     118             : 
     119             :     /** Keep track of previous number of blocks, to detect progress */
     120             :     int prevBlocks;
     121             :     int spinnerFrame;
     122             : 
     123             :     const PlatformStyle *platformStyle;
     124             : 
     125             :     /** Create the main UI actions. */
     126             :     void createActions();
     127             :     /** Create the menu bar and sub-menus. */
     128             :     void createMenuBar();
     129             :     /** Create the toolbars */
     130             :     void createToolBars();
     131             :     /** Create system tray icon and notification */
     132             :     void createTrayIcon(const NetworkStyle *networkStyle);
     133             :     /** Create system tray menu (or setup the dock menu) */
     134             :     void createTrayIconMenu();
     135             : 
     136             :     /** Enable or disable all wallet-related actions */
     137             :     void setWalletActionsEnabled(bool enabled);
     138             : 
     139             :     /** Connect core signals to GUI client */
     140             :     void subscribeToCoreSignals();
     141             :     /** Disconnect core signals from GUI client */
     142             :     void unsubscribeFromCoreSignals();
     143             : 
     144             : Q_SIGNALS:
     145             :     /** Signal raised when a URI was entered or dragged to the GUI */
     146             :     void receivedURI(const QString &uri);
     147             : 
     148             : public Q_SLOTS:
     149             :     /** Set number of connections shown in the UI */
     150             :     void setNumConnections(int count);
     151             :     /** Set number of blocks and last block date shown in the UI */
     152             :     void setNumBlocks(int count, const QDateTime& blockDate);
     153             : 
     154             :     /** Notify the user of an event from the core network or transaction handling code.
     155             :        @param[in] title     the message box / notification title
     156             :        @param[in] message   the displayed text
     157             :        @param[in] style     modality and style definitions (icon and used buttons - buttons only for message boxes)
     158             :                             @see CClientUIInterface::MessageBoxFlags
     159             :        @param[in] ret       pointer to a bool that will be modified to whether Ok was clicked (modal only)
     160             :     */
     161             :     void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL);
     162             : 
     163             : #ifdef ENABLE_WALLET
     164             :     /** Set the encryption status as shown in the UI.
     165             :        @param[in] status            current encryption status
     166             :        @see WalletModel::EncryptionStatus
     167             :     */
     168             :     void setEncryptionStatus(int status);
     169             : 
     170             :     bool handlePaymentRequest(const SendCoinsRecipient& recipient);
     171             : 
     172             :     /** Show incoming transaction notification for new transactions. */
     173             :     void incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label);
     174             : #endif // ENABLE_WALLET
     175             : 
     176             : private Q_SLOTS:
     177             : #ifdef ENABLE_WALLET
     178             :     /** Switch to overview (home) page */
     179             :     void gotoOverviewPage();
     180             :     /** Switch to history (transactions) page */
     181             :     void gotoHistoryPage();
     182             :     /** Switch to receive coins page */
     183             :     void gotoReceiveCoinsPage();
     184             :     /** Switch to send coins page */
     185             :     void gotoSendCoinsPage(QString addr = "");
     186             : 
     187             :     /** Show Sign/Verify Message dialog and switch to sign message tab */
     188             :     void gotoSignMessageTab(QString addr = "");
     189             :     /** Show Sign/Verify Message dialog and switch to verify message tab */
     190             :     void gotoVerifyMessageTab(QString addr = "");
     191             : 
     192             :     /** Show open dialog */
     193             :     void openClicked();
     194             : #endif // ENABLE_WALLET
     195             :     /** Show configuration dialog */
     196             :     void optionsClicked();
     197             :     /** Show about dialog */
     198             :     void aboutClicked();
     199             :     /** Show debug window */
     200             :     void showDebugWindow();
     201             :     /** Show help message dialog */
     202             :     void showHelpMessageClicked();
     203             : #ifndef Q_OS_MAC
     204             :     /** Handle tray icon clicked */
     205             :     void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
     206             : #endif
     207             : 
     208             :     /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */
     209             :     void showNormalIfMinimized(bool fToggleHidden = false);
     210             :     /** Simply calls showNormalIfMinimized(true) for use in SLOT() macro */
     211             :     void toggleHidden();
     212             : 
     213             :     /** called by a timer to check if fRequestShutdown has been set **/
     214             :     void detectShutdown();
     215             : 
     216             :     /** Show progress dialog e.g. for verifychain */
     217             :     void showProgress(const QString &title, int nProgress);
     218             : };
     219             : 
     220           0 : class UnitDisplayStatusBarControl : public QLabel
     221             : {
     222           0 :     Q_OBJECT
     223             : 
     224             : public:
     225             :     explicit UnitDisplayStatusBarControl(const PlatformStyle *platformStyle);
     226             :     /** Lets the control know about the Options Model (and its signals) */
     227             :     void setOptionsModel(OptionsModel *optionsModel);
     228             : 
     229             : protected:
     230             :     /** So that it responds to left-button clicks */
     231             :     void mousePressEvent(QMouseEvent *event);
     232             : 
     233             : private:
     234             :     OptionsModel *optionsModel;
     235             :     QMenu* menu;
     236             : 
     237             :     /** Shows context menu with Display Unit options by the mouse coordinates */
     238             :     void onDisplayUnitsClicked(const QPoint& point);
     239             :     /** Creates context menu, its actions, and wires up all the relevant signals for mouse events. */
     240             :     void createContextMenu();
     241             : 
     242             : private Q_SLOTS:
     243             :     /** When Display Units are changed on OptionsModel it will refresh the display text of the control on the status bar */
     244             :     void updateDisplayUnit(int newUnits);
     245             :     /** Tells underlying optionsModel to update its current display unit. */
     246             :     void onMenuSelection(QAction* action);
     247             : };
     248             : 
     249             : #endif // BITCOIN_QT_BITCOINGUI_H

Generated by: LCOV version 1.11