Anoncoin  0.9.4
P2P Digital Currency
anoncoingui.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Copyright (c) 2013-2014 The Anoncoin Core developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef ANONCOINGUI_H
7 #define ANONCOINGUI_H
8 
9 // Many builder specific things set in the config file, for any source files where we rely on moc_xxx files being generated
10 // it is best to include the anoncoin-config.h in the header file itself. Not the .cpp src file, because otherwise any
11 // conditional compilation guidelines, which rely on the build configuration, will not be present in the moc_xxx files.
12 #if defined(HAVE_CONFIG_H)
13 #include "config/anoncoin-config.h"
14 #endif
15 
16 #include <QLabel>
17 #include <QMainWindow>
18 #include <QMap>
19 #include <QMenu>
20 #include <QPoint>
21 #include <QSystemTrayIcon>
22 
23 class ClientModel;
24 class Notificator;
25 class OptionsModel;
26 class RPCConsole;
27 class SendCoinsRecipient;
28 class WalletFrame;
29 class WalletModel;
30 
31 class CWallet;
32 
34 
35 QT_BEGIN_NAMESPACE
36 class QAction;
37 class QLabel;
38 class QMenu;
39 class QPoint;
40 class QProgressBar;
41 QT_END_NAMESPACE
42 
47 class AnoncoinGUI : public QMainWindow
48 {
49  Q_OBJECT
50 
51 public:
52  static const QString DEFAULT_WALLET;
53 
54  explicit AnoncoinGUI(bool fIsTestnet = false, QWidget *parent = 0);
55  ~AnoncoinGUI();
56 
61 
62 #ifdef ENABLE_WALLET
63 
67  bool addWallet(const QString& name, WalletModel *walletModel);
68  bool setCurrentWallet(const QString& name);
69  void removeAllWallets();
70 #endif
71 
72 protected:
73  void changeEvent(QEvent *e);
74  void closeEvent(QCloseEvent *event);
75  void dragEnterEvent(QDragEnterEvent *event);
76  void dropEvent(QDropEvent *event);
77  bool eventFilter(QObject *object, QEvent *event);
78 
79 private:
82 
86  QLabel *labelBlocksIcon;
87 #ifdef ENABLE_I2PSAM
88  QLabel* labelI2PConnections;
89  QLabel* labelI2POnly;
90  QLabel* labelI2PGenerated;
91 #endif // ENABLE_I2PSAM
93  QProgressBar *progressBar;
94 
95  QMenuBar *appMenuBar;
96  QAction *overviewAction;
97  QAction *historyAction;
98  QAction *quitAction;
99  QAction *sendCoinsAction;
104  QAction *aboutAction;
106  QAction *optionsAction;
111  QAction *aboutQtAction;
113  QAction *openAction;
115 
116  QSystemTrayIcon *trayIcon;
119 
123 #ifdef ENABLE_I2PSAM
124  int i2pConnectCount; // Keep track of the number of I2P connections, so we can remove them from the clearnet amount
125 #endif
126 
127  void createActions(bool fIsTestnet);
129  void createMenuBar();
131  void createToolBars();
133  void createTrayIcon(bool fIsTestnet);
135  void createTrayIconMenu();
136 
138  void setWalletActionsEnabled(bool enabled);
139 
141  void subscribeToCoreSignals();
144 
145 signals:
147  void receivedURI(const QString &uri);
148 
149 public slots:
151  void setNumConnections(int count);
153  void setNumBlocks(int count);
154 
162  void message(const QString &title, const QString &message, unsigned int style, bool *ret = NULL);
163 
164 #ifdef ENABLE_WALLET
165 
169  void setEncryptionStatus(int status);
170 
171  bool handlePaymentRequest(const SendCoinsRecipient& recipient);
172 
174  void incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address);
175 #endif
176 
177 #ifdef ENABLE_I2PSAM
178 
179  void setNumI2PConnections(int count);
180  void showGeneratedI2PAddr(const QString& caption, const QString& pub, const QString& priv, const QString& b32, const QString& configFileName);
181 #endif // ENABLE_I2PSAM
182 
183 private slots:
184 #ifdef ENABLE_WALLET
185 
186  void gotoOverviewPage();
188  void gotoHistoryPage();
190  void gotoReceiveCoinsPage();
192  void gotoSendCoinsPage(QString addr = "");
193 
195  void gotoSignMessageTab(QString addr = "");
197  void gotoVerifyMessageTab(QString addr = "");
198 
200  void openClicked();
201 #endif
202 
203  void optionsClicked();
205  void aboutClicked();
207  void showHelpMessageClicked();
208 #ifndef Q_OS_MAC
209 
210  void trayIconActivated(QSystemTrayIcon::ActivationReason reason);
211 #endif
212 
214  void showNormalIfMinimized(bool fToggleHidden = false);
216  void toggleHidden();
217 
219  void detectShutdown();
220 };
221 
222 class UnitDisplayStatusBarControl : public QLabel
223 {
224  Q_OBJECT
225 
226 public:
227  explicit UnitDisplayStatusBarControl();
230 
231 protected:
233  void mousePressEvent(QMouseEvent *event);
234 
235 private:
237  QMenu* menu;
239  void onDisplayUnitsClicked(const QPoint& point);
241  void createContextMenu();
242 
243 private slots:
245  void updateDisplayUnit(int newUnits);
247  void onMenuSelection(QAction* action);
248 };
249 
250 #endif // ANONCOINGUI_H
int prevBlocks
Keep track of previous number of blocks, to detect progress.
Definition: anoncoingui.h:121
void detectShutdown()
called by a timer to check if fRequestShutdown has been set
QLabel * labelEncryptionIcon
Definition: anoncoingui.h:84
QLabel * labelConnectionsIcon
Definition: anoncoingui.h:85
Local Anoncoin RPC console.
Definition: rpcconsole.h:26
QAction * encryptWalletAction
Definition: anoncoingui.h:108
void mousePressEvent(QMouseEvent *event)
So that it responds to left-button clicks.
void aboutClicked()
Show about dialog.
QProgressBar * progressBar
Definition: anoncoingui.h:93
void createTrayIcon(bool fIsTestnet)
Create system tray icon and notification.
QAction * verifyMessageAction
Definition: anoncoingui.h:103
QAction * changePassphraseAction
Definition: anoncoingui.h:110
QAction * historyAction
Definition: anoncoingui.h:97
QAction * openAction
Definition: anoncoingui.h:113
Anoncoin GUI main class.
Definition: anoncoingui.h:47
UnitDisplayStatusBarControl * unitDisplayControl
Definition: anoncoingui.h:83
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
WalletFrame * walletFrame
Definition: anoncoingui.h:81
QAction * usedReceivingAddressesAction
Definition: anoncoingui.h:101
void message(const QString &title, const QString &message, unsigned int style, bool *ret=NULL)
Notify the user of an event from the core network or transaction handling code.
void setOptionsModel(OptionsModel *optionsModel)
Lets the control know about the Options Model (and its signals)
QAction * aboutAction
Definition: anoncoingui.h:104
QAction * aboutQtAction
Definition: anoncoingui.h:111
void optionsClicked()
Show configuration dialog.
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
RPCConsole * rpcConsole
Definition: anoncoingui.h:118
Notificator * notificator
Definition: anoncoingui.h:117
QMenuBar * appMenuBar
Definition: anoncoingui.h:95
void setNumConnections(int count)
Set number of connections shown in the UI.
OptionsModel * optionsModel
Definition: anoncoingui.h:236
void createMenuBar()
Create the menu bar and sub-menus.
static const QString DEFAULT_WALLET
Definition: anoncoingui.h:52
QAction * receiveCoinsAction
Definition: anoncoingui.h:105
void updateDisplayUnit(int newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
void showNormalIfMinimized(bool fToggleHidden=false)
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
QAction * backupWalletAction
Definition: anoncoingui.h:109
void closeEvent(QCloseEvent *event)
AnoncoinGUI(bool fIsTestnet=false, QWidget *parent=0)
Definition: anoncoingui.cpp:67
QAction * usedSendingAddressesAction
Definition: anoncoingui.h:100
void createActions(bool fIsTestnet)
Create the main UI actions.
Cross-platform desktop notification client.
Definition: notificator.h:25
Model for Anoncoin network client.
Definition: clientmodel.h:45
QLabel * progressBarLabel
Definition: anoncoingui.h:92
void dropEvent(QDropEvent *event)
void showHelpMessageClicked()
Show help message dialog.
QAction * overviewAction
Definition: anoncoingui.h:96
bool eventFilter(QObject *object, QEvent *event)
QAction * optionsAction
Definition: anoncoingui.h:106
void dragEnterEvent(QDragEnterEvent *event)
Interface from Qt to configuration data structure for Anoncoin client.
Definition: optionsmodel.h:27
QAction * quitAction
Definition: anoncoingui.h:98
Interface to Anoncoin wallet from Qt view code.
Definition: walletmodel.h:97
void setClientModel(ClientModel *clientModel)
Set the client model.
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:101
QAction * sendCoinsAction
Definition: anoncoingui.h:99
QLabel * labelBlocksIcon
Definition: anoncoingui.h:86
ClientModel * clientModel
Definition: anoncoingui.h:80
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
void changeEvent(QEvent *e)
QAction * signMessageAction
Definition: anoncoingui.h:102
void createContextMenu()
Creates context menu, its actions, and wires up all the relevant signals for mouse events...
void createToolBars()
Create the toolbars.
void setNumBlocks(int count)
Set number of blocks shown in the UI.
int spinnerFrame
Definition: anoncoingui.h:122
QAction * toggleHideAction
Definition: anoncoingui.h:107
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
void subscribeToCoreSignals()
Connect core signals to GUI client.
QAction * openRPCConsoleAction
Definition: anoncoingui.h:112
void onDisplayUnitsClicked(const QPoint &point)
Shows context menu with Display Unit options by the mouse coordinates.
QAction * showHelpMessageAction
Definition: anoncoingui.h:114
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
QSystemTrayIcon * trayIcon
Definition: anoncoingui.h:116