Anoncoin  0.9.4
P2P Digital Currency
anoncoingui.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2014 The Bitcoin developers
2 // Copyright (c) 2013-2015 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 #include "anoncoingui.h"
7 
8 #include "anoncoinunits.h"
9 #include "clientmodel.h"
10 #include "guiconstants.h"
11 #include "guiutil.h"
12 #include "notificator.h"
13 #include "openuridialog.h"
14 #include "optionsdialog.h"
15 #include "optionsmodel.h"
16 #include "rpcconsole.h"
17 #include "utilitydialog.h"
18 #ifdef ENABLE_WALLET
19 #include "walletframe.h"
20 #include "walletmodel.h"
21 #endif
22 
23 #ifdef Q_OS_MAC
24 #include "macdockiconhandler.h"
25 #endif
26 
27 #include "init.h"
28 #include "ui_interface.h"
29 
30 #include <iostream>
31 
32 #include <QAction>
33 #include <QApplication>
34 #include <QDateTime>
35 #include <QDesktopWidget>
36 #include <QDragEnterEvent>
37 #include <QIcon>
38 #include <QLabel>
39 #include <QListWidget>
40 #include <QMenu>
41 #include <QMenuBar>
42 #include <QMessageBox>
43 #include <QMimeData>
44 #include <QPoint>
45 #include <QProgressBar>
46 #include <QSettings>
47 #include <QStackedWidget>
48 #include <QStatusBar>
49 #include <QStyle>
50 #include <QTimer>
51 #include <QToolBar>
52 #include <QVBoxLayout>
53 
54 #ifdef ENABLE_I2PSAM
55 #include "i2pshowaddresses.h"
56 #endif // ENABLE_I2PSAM
57 
58 #if QT_VERSION < 0x050000
59 #include <QUrl>
60 #include <QTextDocument>
61 #else
62 #include <QUrlQuery>
63 #endif
64 
65 const QString AnoncoinGUI::DEFAULT_WALLET = "~Default";
66 
67 AnoncoinGUI::AnoncoinGUI(bool fIsTestnet, QWidget *parent) :
68  QMainWindow(parent),
69  clientModel(0),
70  walletFrame(0),
71  encryptWalletAction(0),
72  changePassphraseAction(0),
73  aboutQtAction(0),
74  trayIcon(0),
75  notificator(0),
76  rpcConsole(0),
77  prevBlocks(0),
78  spinnerFrame(0)
79 {
80  GUIUtil::restoreWindowGeometry("nWindow", QSize(850, 550), this);
81 
82  QString windowTitle = tr("Anoncoin Core") + " - ";
83 #ifdef ENABLE_WALLET
84  /* if compiled with wallet support, -disablewallet can still disable the wallet */
85  bool enableWallet = !GetBoolArg("-disablewallet", false);
86 #else
87  bool enableWallet = false;
88 #endif
89  if(enableWallet)
90  {
91  windowTitle += tr("Wallet");
92  } else {
93  windowTitle += tr("Node");
94  }
95 
96  if (!fIsTestnet)
97  {
98 #ifndef Q_OS_MAC
99  QApplication::setWindowIcon(QIcon(":icons/anoncoin"));
100  setWindowIcon(QIcon(":icons/anoncoin"));
101 #else
102  MacDockIconHandler::instance()->setIcon(QIcon(":icons/anoncoin"));
103 #endif
104  }
105  else
106  {
107  windowTitle += " " + tr("[testnet]");
108 #ifndef Q_OS_MAC
109  QApplication::setWindowIcon(QIcon(":icons/anoncoin_testnet"));
110  setWindowIcon(QIcon(":icons/anoncoin_testnet"));
111 #else
112  MacDockIconHandler::instance()->setIcon(QIcon(":icons/anoncoin_testnet"));
113 #endif
114  }
115  setWindowTitle(windowTitle);
116 
117 #if defined(Q_OS_MAC) && QT_VERSION < 0x050000
118  // This property is not implemented in Qt 5. Setting it has no effect.
119  // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
120  setUnifiedTitleAndToolBarOnMac(true);
121 #endif
122 
123  rpcConsole = new RPCConsole(enableWallet ? this : 0);
124 #ifdef ENABLE_WALLET
125  if(enableWallet)
126  {
128  walletFrame = new WalletFrame(this);
129  setCentralWidget(walletFrame);
130  } else
131 #endif
132  {
133  /* When compiled without wallet or -disablewallet is provided,
134  * the central widget is the rpc console.
135  */
136  setCentralWidget(rpcConsole);
137  }
138 
139  // Accept D&D of URIs
140  setAcceptDrops(true);
141 
142  // Create actions for the toolbar, menu bar and tray/dock icon
143  // Needs walletFrame to be initialized
144  createActions(fIsTestnet);
145 
146  // Create application menu bar
147  createMenuBar();
148 
149  // Create the toolbars
150  createToolBars();
151 
152  // Create system tray icon and notification
153  createTrayIcon(fIsTestnet);
154 
155  // Create status bar
156  statusBar();
157 
158  // Status bar notification icons
159  QFrame *frameBlocks = new QFrame();
160  frameBlocks->setContentsMargins(0,0,0,0);
161  frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
162  QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
163  frameBlocksLayout->setContentsMargins(3,0,3,0);
164  frameBlocksLayout->setSpacing(3);
166  labelEncryptionIcon = new QLabel();
167  labelConnectionsIcon = new QLabel();
168  labelBlocksIcon = new QLabel();
169 #ifdef ENABLE_I2PSAM
170  labelI2PConnections = new QLabel();
171  labelI2POnly = new QLabel();
172  labelI2PGenerated = new QLabel();
173 
174  frameBlocksLayout->addStretch();
175  frameBlocksLayout->addWidget(labelI2PGenerated);
176  frameBlocksLayout->addStretch();
177  frameBlocksLayout->addWidget(labelI2POnly);
178  frameBlocksLayout->addStretch();
179  frameBlocksLayout->addWidget(labelI2PConnections);
180 #endif
181  frameBlocksLayout->addStretch();
182  frameBlocksLayout->addWidget(unitDisplayControl);
183  frameBlocksLayout->addStretch();
184  frameBlocksLayout->addWidget(labelEncryptionIcon);
185  frameBlocksLayout->addStretch();
186  frameBlocksLayout->addWidget(labelConnectionsIcon);
187  frameBlocksLayout->addStretch();
188  frameBlocksLayout->addWidget(labelBlocksIcon);
189  frameBlocksLayout->addStretch();
190 
191  // Progress bar and label for blocks download
192  progressBarLabel = new QLabel();
193  progressBarLabel->setVisible(false);
194  progressBar = new QProgressBar();
195  progressBar->setAlignment(Qt::AlignCenter);
196  progressBar->setVisible(false);
197 
198  // Override style sheet for progress bar for styles that have a segmented progress bar,
199  // as they make the text unreadable (workaround for issue #1071)
200  // See https://qt-project.org/doc/qt-4.8/gallery.html
201  QString curStyle = QApplication::style()->metaObject()->className();
202  if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
203  {
204  progressBar->setStyleSheet("QProgressBar { background-color: #e8e8e8; border: 1px solid grey; border-radius: 7px; padding: 1px; text-align: center; } QProgressBar::chunk { background: QLinearGradient(x1: 0, y1: 0, x2: 1, y2: 0, stop: 0 #FF8000, stop: 1 orange); border-radius: 7px; margin: 0px; }");
205  }
206 
207  statusBar()->addWidget(progressBarLabel);
208  statusBar()->addWidget(progressBar);
209  statusBar()->addPermanentWidget(frameBlocks);
210 
211  connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));
212 
213  // prevents an oben debug window from becoming stuck/unusable on client shutdown
214  connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
215 
216  // Install event filter to be able to catch status tip events (QEvent::StatusTip)
217  this->installEventFilter(this);
218 
219  // Initially wallet actions should be disabled
221 
222  // Subscribe to notifications from core
224 }
225 
227 {
228  // Unsubscribe from notifications from core
230 
231  GUIUtil::saveWindowGeometry("nWindow", this);
232  if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
233  trayIcon->hide();
234 #ifdef Q_OS_MAC
235  delete appMenuBar;
237 #endif
238 }
239 
240 void AnoncoinGUI::createActions(bool fIsTestnet)
241 {
242  QActionGroup *tabGroup = new QActionGroup(this);
243 
244  overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
245  overviewAction->setStatusTip(tr("Show general overview of wallet"));
246  overviewAction->setToolTip(overviewAction->statusTip());
247  overviewAction->setCheckable(true);
248  overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
249  tabGroup->addAction(overviewAction);
250 
251  sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send"), this);
252  sendCoinsAction->setStatusTip(tr("Send coins to a Anoncoin address"));
253  sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
254  sendCoinsAction->setCheckable(true);
255  sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
256  tabGroup->addAction(sendCoinsAction);
257 
258  receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
259  receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and anoncoin: URIs)"));
260  receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
261  receiveCoinsAction->setCheckable(true);
262  receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
263  tabGroup->addAction(receiveCoinsAction);
264 
265  historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
266  historyAction->setStatusTip(tr("Browse transaction history"));
267  historyAction->setToolTip(historyAction->statusTip());
268  historyAction->setCheckable(true);
269  historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
270  tabGroup->addAction(historyAction);
271 
272  // These showNormalIfMinimized are needed because Send Coins and Receive Coins
273  // can be triggered from the tray menu, and need to show the GUI to be useful.
274  connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
275  connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
276  connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
277  connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
278  connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
279  connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
280  connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
281  connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
282 
283  quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
284  quitAction->setStatusTip(tr("Quit application"));
285  quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
286  quitAction->setMenuRole(QAction::QuitRole);
287  if (!fIsTestnet)
288  aboutAction = new QAction(QIcon(":/icons/anoncoin"), tr("&About Anoncoin Core"), this);
289  else
290  aboutAction = new QAction(QIcon(":/icons/anoncoin_testnet"), tr("&About Anoncoin Core"), this);
291  aboutAction->setStatusTip(tr("Show information about Anoncoin"));
292  aboutAction->setMenuRole(QAction::AboutRole);
293 #if QT_VERSION < 0x050000
294  aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
295 #else
296  aboutQtAction = new QAction(QIcon(":/qt-project.org/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
297 #endif
298  aboutQtAction->setStatusTip(tr("Show information about Qt"));
299  aboutQtAction->setMenuRole(QAction::AboutQtRole);
300  optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
301  optionsAction->setStatusTip(tr("Modify configuration options for Anoncoin"));
302  optionsAction->setMenuRole(QAction::PreferencesRole);
303  if (!fIsTestnet)
304  toggleHideAction = new QAction(QIcon(":/icons/anoncoin"), tr("&Show / Hide"), this);
305  else
306  toggleHideAction = new QAction(QIcon(":/icons/anoncoin_testnet"), tr("&Show / Hide"), this);
307  toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
308 
309  encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this);
310  encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
311  encryptWalletAction->setCheckable(true);
312  backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
313  backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
314  changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase..."), this);
315  changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
316  signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this);
317  signMessageAction->setStatusTip(tr("Sign messages with your Anoncoin addresses to prove you own them"));
318  verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this);
319  verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Anoncoin addresses"));
320 
321  openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
322  openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
323 
324  usedSendingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
325  usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
326  usedReceivingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Receiving addresses..."), this);
327  usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
328 
329  openAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_FileIcon), tr("Open &URI..."), this);
330  openAction->setStatusTip(tr("Open a anoncoin: URI or payment request"));
331 
332  showHelpMessageAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation), tr("&Command-line options"), this);
333  showHelpMessageAction->setStatusTip(tr("Show the Anoncoin Core help message to get a list with possible Anoncoin command-line options"));
334 
335  connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
336  connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
337  connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
338  connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
339  connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
340  connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked()));
341 #ifdef ENABLE_WALLET
342  if(walletFrame)
343  {
344  connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
345  connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
346  connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
347  connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
348  connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
349  connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
350  connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
351  connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
352  }
353 #endif
354 }
355 
357 {
358 #ifdef Q_OS_MAC
359  // Create a decoupled menu bar on Mac which stays even if the window is closed
360  appMenuBar = new QMenuBar();
361 #else
362  // Get the main window's menu bar on other platforms
363  appMenuBar = menuBar();
364 #endif
365 
366  // Configure the menus
367  QMenu *file = appMenuBar->addMenu(tr("&File"));
368  if(walletFrame)
369  {
370  file->addAction(openAction);
371  file->addAction(backupWalletAction);
372  file->addAction(signMessageAction);
373  file->addAction(verifyMessageAction);
374  file->addSeparator();
375  file->addAction(usedSendingAddressesAction);
376  file->addAction(usedReceivingAddressesAction);
377  file->addSeparator();
378  }
379  file->addAction(quitAction);
380 
381  QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
382  if(walletFrame)
383  {
384  settings->addAction(encryptWalletAction);
385  settings->addAction(changePassphraseAction);
386  settings->addSeparator();
387  }
388  settings->addAction(optionsAction);
389 
390  QMenu *help = appMenuBar->addMenu(tr("&Help"));
391  if(walletFrame)
392  {
393  help->addAction(openRPCConsoleAction);
394  }
395  help->addAction(showHelpMessageAction);
396  help->addSeparator();
397  help->addAction(aboutAction);
398  help->addAction(aboutQtAction);
399 }
400 
402 {
403  if(walletFrame)
404  {
405  QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
406  toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
407  toolbar->addAction(overviewAction);
408  toolbar->addAction(sendCoinsAction);
409  toolbar->addAction(receiveCoinsAction);
410  toolbar->addAction(historyAction);
411  overviewAction->setChecked(true);
412  }
413 }
414 
416 {
417  this->clientModel = clientModel;
418  if(clientModel)
419  {
420  // Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
421  // while the client has not yet fully loaded
423 
424  // Keep up to date with client
425  setNumConnections(clientModel->getNumConnections());
426  connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
427 
428 #ifdef ENABLE_I2PSAM
429  setNumI2PConnections(clientModel->getNumI2PConnections());
430  connect(clientModel, SIGNAL(numI2PConnectionsChanged(int)), this, SLOT(setNumI2PConnections(int)));
431 
432  if (clientModel->isI2POnly()) {
433  labelI2POnly->setText("I2P");
434  labelI2POnly->setToolTip(tr("Wallet is using I2P-network only!"));
435  }
436  else if (clientModel->isTorOnly()) {
437  labelI2POnly->setText("TOR");
438  labelI2POnly->setToolTip(tr("Wallet is using Tor-network only"));
439  }
440  else if (clientModel->isDarknetOnly()) {
441  labelI2POnly->setText("I&T");
442  labelI2POnly->setToolTip(tr("Wallet is using I2P and Tor networks (Darknet mode)"));
443  }
444  else if (clientModel->isBehindDarknet()) {
445  labelI2POnly->setText("ICT");
446  labelI2POnly->setToolTip(tr("Wallet is using I2P and Tor networks, also Tor as a proxy"));
447  }
448  else {
449  labelI2POnly->setText("CLR");
450  labelI2POnly->setToolTip(tr("Wallet is using mixed or non-I2P (clear) network"));
451  }
452 
453  if (clientModel->isI2PAddressGenerated()) {
454  labelI2PGenerated->setText("DYN");
455  labelI2PGenerated->setToolTip(tr("Wallet is running with a random generated I2P-address"));
456  }
457  else {
458  labelI2PGenerated->setText("STA");
459  labelI2PGenerated->setToolTip(tr("Wallet is running with a static I2P-address"));
460  }
461 #endif // ENABLE_I2PSAM
462 
463  setNumBlocks(clientModel->getNumBlocks());
464  connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
465 
466  // Receive and report messages from client model
467  connect(clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
468 
469  rpcConsole->setClientModel(clientModel);
470 #ifdef ENABLE_WALLET
471  if(walletFrame)
472  {
473  walletFrame->setClientModel(clientModel);
474  }
475 #endif
476 
477  this->unitDisplayControl->setOptionsModel(clientModel->getOptionsModel());
478  }
479 }
480 
481 #ifdef ENABLE_WALLET
482 bool AnoncoinGUI::addWallet(const QString& name, WalletModel *walletModel)
483 {
484  if(!walletFrame)
485  return false;
487  return walletFrame->addWallet(name, walletModel);
488 }
489 
490 bool AnoncoinGUI::setCurrentWallet(const QString& name)
491 {
492  if(!walletFrame)
493  return false;
494  return walletFrame->setCurrentWallet(name);
495 }
496 
497 void AnoncoinGUI::removeAllWallets()
498 {
499  if(!walletFrame)
500  return;
503 }
504 #endif
505 
507 {
508  overviewAction->setEnabled(enabled);
509  sendCoinsAction->setEnabled(enabled);
510  receiveCoinsAction->setEnabled(enabled);
511  historyAction->setEnabled(enabled);
512  encryptWalletAction->setEnabled(enabled);
513  backupWalletAction->setEnabled(enabled);
514  changePassphraseAction->setEnabled(enabled);
515  signMessageAction->setEnabled(enabled);
516  verifyMessageAction->setEnabled(enabled);
517  usedSendingAddressesAction->setEnabled(enabled);
518  usedReceivingAddressesAction->setEnabled(enabled);
519  openAction->setEnabled(enabled);
520 }
521 
522 void AnoncoinGUI::createTrayIcon(bool fIsTestnet)
523 {
524 #ifndef Q_OS_MAC
525  trayIcon = new QSystemTrayIcon(this);
526 
527  if (!fIsTestnet)
528  {
529  trayIcon->setToolTip(tr("Anoncoin client"));
530  trayIcon->setIcon(QIcon(":/icons/toolbar"));
531  }
532  else
533  {
534  trayIcon->setToolTip(tr("Anoncoin client") + " " + tr("[testnet]"));
535  trayIcon->setIcon(QIcon(":/icons/toolbar_testnet"));
536  }
537 
538  trayIcon->show();
539 #endif
540 
541  notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
542 }
543 
545 {
546  QMenu *trayIconMenu;
547 #ifndef Q_OS_MAC
548  // return if trayIcon is unset (only on non-Mac OSes)
549  if (!trayIcon)
550  return;
551 
552  trayIconMenu = new QMenu(this);
553  trayIcon->setContextMenu(trayIconMenu);
554 
555  connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
556  this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
557 #else
558  // Note: On Mac, the dock icon is used to provide the tray's functionality.
560  dockIconHandler->setMainWindow((QMainWindow *)this);
561  trayIconMenu = dockIconHandler->dockMenu();
562 #endif
563 
564  // Configuration of the tray icon (or dock icon) icon menu
565  trayIconMenu->addAction(toggleHideAction);
566  trayIconMenu->addSeparator();
567  trayIconMenu->addAction(sendCoinsAction);
568  trayIconMenu->addAction(receiveCoinsAction);
569  trayIconMenu->addSeparator();
570  trayIconMenu->addAction(signMessageAction);
571  trayIconMenu->addAction(verifyMessageAction);
572  trayIconMenu->addSeparator();
573  trayIconMenu->addAction(optionsAction);
574  trayIconMenu->addAction(openRPCConsoleAction);
575 #ifndef Q_OS_MAC // This is built-in on Mac
576  trayIconMenu->addSeparator();
577  trayIconMenu->addAction(quitAction);
578 #endif
579 }
580 
581 #ifndef Q_OS_MAC
582 void AnoncoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
583 {
584  if(reason == QSystemTrayIcon::Trigger)
585  {
586  // Click on system tray icon triggers show/hide of the main window
587  toggleHideAction->trigger();
588  }
589 }
590 #endif
591 
593 {
595  return;
596 
597  OptionsDialog dlg(this);
599 #ifdef ENABLE_I2PSAM
601 #endif
602  dlg.exec();
603 }
604 
606 {
607  if(!clientModel)
608  return;
609 
610  AboutDialog dlg(this);
611  dlg.setModel(clientModel);
612  dlg.exec();
613 }
614 
616 {
618  help->setAttribute(Qt::WA_DeleteOnClose);
619  help->show();
620 }
621 
622 #ifdef ENABLE_WALLET
623 void AnoncoinGUI::openClicked()
624 {
625  OpenURIDialog dlg(this);
626  if(dlg.exec())
627  {
628  emit receivedURI(dlg.getURI());
629  }
630 }
631 
632 void AnoncoinGUI::gotoOverviewPage()
633 {
634  overviewAction->setChecked(true);
636 }
637 
638 void AnoncoinGUI::gotoHistoryPage()
639 {
640  historyAction->setChecked(true);
642 }
643 
644 void AnoncoinGUI::gotoReceiveCoinsPage()
645 {
646  receiveCoinsAction->setChecked(true);
648 }
649 
650 void AnoncoinGUI::gotoSendCoinsPage(QString addr)
651 {
652  sendCoinsAction->setChecked(true);
654 }
655 
656 void AnoncoinGUI::gotoSignMessageTab(QString addr)
657 {
659 }
660 
661 void AnoncoinGUI::gotoVerifyMessageTab(QString addr)
662 {
664 }
665 #endif
666 
668 {
669  QString icon;
670 #ifdef ENABLE_I2PSAM
671  // Real count is minus the i2p connections we're showing that in another icon
672  int realcount = count - i2pConnectCount;
673  // ToDo: Having a bug here while testing I2P onlynet and binding my port in the anoncoin.conf file to 192.168.xx.xx.
674  // The realcount is getting a negative value for awhile, if nodes are found pretty fast on startup, not sure why.
675  // Added conditional below, so the user doesn't see that at least
676  if( realcount < 0 ) realcount = 0;
677 #else
678  int realcount = count;
679 #endif
680  switch(realcount)
681  {
682  case 0: icon = ":/icons/connect_0"; break;
683  case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
684  case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
685  case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
686  default: icon = ":/icons/connect_4"; break;
687  }
688  labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
689  labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Anoncoin clearnet peers", "", realcount));
690 }
691 
692 #ifdef ENABLE_I2PSAM
693 void AnoncoinGUI::setNumI2PConnections(int count)
694 {
695  QString i2pIcon;
696  // See the anoncoin.qrc file for icon files below & their associated alias name
697  switch(count) {
698  case 0: i2pIcon = ":/icons/i2pconnect_0"; break;
699  case 1: case 2: case 3: i2pIcon = ":/icons/i2pconnect_1"; break;
700  case 4: case 5: case 6: i2pIcon = ":/icons/i2pconnect_2"; break;
701  case 7: case 8: case 9: i2pIcon = ":/icons/i2pconnect_3"; break;
702  default: i2pIcon = ":/icons/i2pconnect_4"; break;
703  }
704  labelI2PConnections->setPixmap(QIcon(i2pIcon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
705  labelI2PConnections->setToolTip(tr("%n active connection(s) to I2P-Anoncoin network", "", count));
706  i2pConnectCount = count;
707 }
708 #endif // ENABLE_I2PSAM
709 
711 {
712  // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbelled text)
713  statusBar()->clearMessage();
714 
715  // Acquire current block source
716  enum BlockSource blockSource = clientModel->getBlockSource();
717  switch (blockSource) {
719  progressBarLabel->setText(tr("Synchronizing with network..."));
720  break;
721  case BLOCK_SOURCE_DISK:
722  progressBarLabel->setText(tr("Importing blocks from disk..."));
723  break;
725  progressBarLabel->setText(tr("Reindexing blocks on disk..."));
726  break;
727  case BLOCK_SOURCE_NONE:
728  // Case: not Importing, not Reindexing and no network connection
729  progressBarLabel->setText(tr("No block source available..."));
730  break;
731  }
732 
733  QString tooltip;
734 
735  QDateTime lastBlockDate = clientModel->getLastBlockDate();
736  QDateTime currentDate = QDateTime::currentDateTime();
737  int secs = lastBlockDate.secsTo(currentDate);
738 
739  tooltip = tr("Processed %1 blocks of transaction history.").arg(count);
740 
741  // Set icon state: spinning if catching up, tick otherwise
742  if(secs < 90*60)
743  {
744  tooltip = tr("Up to date") + QString(".<br>") + tooltip;
745  labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
746 
747 #ifdef ENABLE_WALLET
748  if(walletFrame)
750 #endif
751 
752  progressBarLabel->setVisible(false);
753  progressBar->setVisible(false);
754  }
755  else
756  {
757  // Represent time from last generated block in human readable text
758  QString timeBehindText;
759  const int HOUR_IN_SECONDS = 60*60;
760  const int DAY_IN_SECONDS = 24*60*60;
761  const int WEEK_IN_SECONDS = 7*24*60*60;
762  const int YEAR_IN_SECONDS = 31556952; // Average length of year in Gregorian calendar
763  if(secs < 2*DAY_IN_SECONDS)
764  {
765  timeBehindText = tr("%n hour(s)","",secs/HOUR_IN_SECONDS);
766  }
767  else if(secs < 2*WEEK_IN_SECONDS)
768  {
769  timeBehindText = tr("%n day(s)","",secs/DAY_IN_SECONDS);
770  }
771  else if(secs < YEAR_IN_SECONDS)
772  {
773  timeBehindText = tr("%n week(s)","",secs/WEEK_IN_SECONDS);
774  }
775  else
776  {
777  int years = secs / YEAR_IN_SECONDS;
778  int remainder = secs % YEAR_IN_SECONDS;
779  timeBehindText = tr("%1 and %2").arg(tr("%n year(s)", "", years)).arg(tr("%n week(s)","", remainder/WEEK_IN_SECONDS));
780  }
781 
782  progressBarLabel->setVisible(true);
783  progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
784  progressBar->setMaximum(1000000000);
785  progressBar->setValue(clientModel->getVerificationProgress() * 1000000000.0 + 0.5);
786  progressBar->setVisible(true);
787 
788  tooltip = tr("Catching up...") + QString("<br>") + tooltip;
789  if(count != prevBlocks)
790  {
791  labelBlocksIcon->setPixmap(QIcon(QString(
792  ":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
793  .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
795  }
796  prevBlocks = count;
797 
798 #ifdef ENABLE_WALLET
799  if(walletFrame)
801 #endif
802 
803  tooltip += QString("<br>");
804  tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
805  tooltip += QString("<br>");
806  tooltip += tr("Transactions after this will not yet be visible.");
807  }
808 
809  // Don't word-wrap this (fixed-width) tooltip
810  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
811 
812  labelBlocksIcon->setToolTip(tooltip);
813  progressBarLabel->setToolTip(tooltip);
814  progressBar->setToolTip(tooltip);
815 }
816 
817 void AnoncoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
818 {
819  QString strTitle = tr("Anoncoin"); // default title
820  // Default to information icon
821  int nMBoxIcon = QMessageBox::Information;
822  int nNotifyIcon = Notificator::Information;
823 
824  QString msgType;
825 
826  // Prefer supplied title over style based title
827  if (!title.isEmpty()) {
828  msgType = title;
829  }
830  else {
831  switch (style) {
833  msgType = tr("Error");
834  break;
836  msgType = tr("Warning");
837  break;
839  msgType = tr("Information");
840  break;
841  default:
842  break;
843  }
844  }
845  // Append title to "Anoncoin - "
846  if (!msgType.isEmpty())
847  strTitle += " - " + msgType;
848 
849  // Check for error/warning icon
850  if (style & CClientUIInterface::ICON_ERROR) {
851  nMBoxIcon = QMessageBox::Critical;
852  nNotifyIcon = Notificator::Critical;
853  }
854  else if (style & CClientUIInterface::ICON_WARNING) {
855  nMBoxIcon = QMessageBox::Warning;
856  nNotifyIcon = Notificator::Warning;
857  }
858 
859  // Display message
860  if (style & CClientUIInterface::MODAL) {
861  // Check for buttons, use OK as default, if none was supplied
862  QMessageBox::StandardButton buttons;
863  if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
864  buttons = QMessageBox::Ok;
865 
866  // Ensure we get users attention, but only if main window is visible
867  // as we don't want to pop up the main window for messages that happen before
868  // initialization is finished.
869  if(!(style & CClientUIInterface::NOSHOWGUI))
871  QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
872  int r = mBox.exec();
873  if (ret != NULL)
874  *ret = r == QMessageBox::Ok;
875  }
876  else
877  notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
878 }
879 
881 {
882  QMainWindow::changeEvent(e);
883 #ifndef Q_OS_MAC // Ignored on Mac
884  if(e->type() == QEvent::WindowStateChange)
885  {
887  {
888  QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
889  if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
890  {
891  QTimer::singleShot(0, this, SLOT(hide()));
892  e->ignore();
893  }
894  }
895  }
896 #endif
897 }
898 
899 void AnoncoinGUI::closeEvent(QCloseEvent *event)
900 {
901  if(clientModel)
902  {
903 #ifndef Q_OS_MAC // Ignored on Mac
906  {
907  QApplication::quit();
908  }
909 #endif
910  }
911  QMainWindow::closeEvent(event);
912 }
913 
914 #ifdef ENABLE_WALLET
915 void AnoncoinGUI::incomingTransaction(const QString& date, int unit, qint64 amount, const QString& type, const QString& address)
916 {
917  // On new transaction, make an info balloon
918  message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
919  tr("Date: %1\n"
920  "Amount: %2\n"
921  "Type: %3\n"
922  "Address: %4\n")
923  .arg(date)
924  .arg(AnoncoinUnits::formatWithUnit(unit, amount, true))
925  .arg(type)
926  .arg(address), CClientUIInterface::MSG_INFORMATION);
927 }
928 #endif
929 
930 void AnoncoinGUI::dragEnterEvent(QDragEnterEvent *event)
931 {
932  // Accept only URIs
933  if(event->mimeData()->hasUrls())
934  event->acceptProposedAction();
935 }
936 
937 void AnoncoinGUI::dropEvent(QDropEvent *event)
938 {
939  if(event->mimeData()->hasUrls())
940  {
941  foreach(const QUrl &uri, event->mimeData()->urls())
942  {
943  emit receivedURI(uri.toString());
944  }
945  }
946  event->acceptProposedAction();
947 }
948 
949 bool AnoncoinGUI::eventFilter(QObject *object, QEvent *event)
950 {
951  // Catch status tip events
952  if (event->type() == QEvent::StatusTip)
953  {
954  // Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
955  if (progressBarLabel->isVisible() || progressBar->isVisible())
956  return true;
957  }
958  return QMainWindow::eventFilter(object, event);
959 }
960 
961 #ifdef ENABLE_WALLET
962 bool AnoncoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
963 {
964  // URI has to be valid
965  if (walletFrame && walletFrame->handlePaymentRequest(recipient))
966  {
968  gotoSendCoinsPage();
969  return true;
970  }
971  else
972  return false;
973 }
974 
975 void AnoncoinGUI::setEncryptionStatus(int status)
976 {
977  switch(status)
978  {
980  labelEncryptionIcon->hide();
981  encryptWalletAction->setChecked(false);
982  changePassphraseAction->setEnabled(false);
983  encryptWalletAction->setEnabled(true);
984  break;
986  labelEncryptionIcon->show();
987  labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
988  labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
989  encryptWalletAction->setChecked(true);
990  changePassphraseAction->setEnabled(true);
991  encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
992  break;
993  case WalletModel::Locked:
994  labelEncryptionIcon->show();
995  labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
996  labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
997  encryptWalletAction->setChecked(true);
998  changePassphraseAction->setEnabled(true);
999  encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
1000  break;
1001  }
1002 }
1003 #endif
1004 
1005 void AnoncoinGUI::showNormalIfMinimized(bool fToggleHidden)
1006 {
1007  // activateWindow() (sometimes) helps with keyboard focus on Windows
1008  if (isHidden())
1009  {
1010  show();
1011  activateWindow();
1012  }
1013  else if (isMinimized())
1014  {
1015  showNormal();
1016  activateWindow();
1017  }
1018  else if (GUIUtil::isObscured(this))
1019  {
1020  raise();
1021  activateWindow();
1022  }
1023  else if(fToggleHidden)
1024  hide();
1025 }
1026 
1028 {
1029  showNormalIfMinimized(true);
1030 }
1031 
1033 {
1034  if (ShutdownRequested())
1035  {
1036  if(rpcConsole)
1037  rpcConsole->hide();
1038  qApp->quit();
1039  }
1040 }
1041 
1042 static bool ThreadSafeMessageBox(AnoncoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
1043 {
1044  bool modal = (style & CClientUIInterface::MODAL);
1045  bool ret = false;
1046  // In case of modal message, use blocking connection to wait for user to click a button
1047  QMetaObject::invokeMethod(gui, "message",
1048  modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
1049  Q_ARG(QString, QString::fromStdString(caption)),
1050  Q_ARG(QString, QString::fromStdString(message)),
1051  Q_ARG(unsigned int, style),
1052  Q_ARG(bool*, &ret));
1053  return ret;
1054 }
1055 
1056 #ifdef ENABLE_I2PSAM
1057 // ToDo: Check me
1058 // This code ported from 0.8.5.6 didn't work as is, had to rework (see the anoncoin.cpp file in old codebase). Removed all the printf's and msg strings,
1059 // they should go somewhere else (see noui.cpp for anoncoind operation), from what I (GR) could tell they would never have executed.
1060 // The 'guiref' value (old code) here is called 'gui', changed that. Need to confirm this is a blockingGUI thread.....Think I've fixed this.
1061 // This function now returns a true/false value, that was changed here, but never crossed checked that the caller would process such a thing...
1062 // Ok think I got all the issues addressed and ready for testing...
1063 static bool ThreadSafeShowGeneratedI2PAddress(AnoncoinGUI *gui,
1064  const std::string& caption,
1065  const std::string& pub,
1066  const std::string& priv,
1067  const std::string& b32,
1068  const std::string& configFileName)
1069 {
1070  bool ret = false;
1071 
1072 // ShowI2PAddresses i2pAddrDialog( QString::fromStdString(caption),
1073 // QString::fromStdString(pub),
1074 // QString::fromStdString(priv),
1075 // QString::fromStdString(b32),
1076 // QString::fromStdString(configFileName),
1077 // gui );
1078 // Latest thoughts, we need to get the clientmodel for a gui parent, and use new to create the dialog here now...
1079 
1080 // i2pAddrDialog.show();
1081  ret = true;
1082 // unsigned int style = CClientUIInterface::BTN_ABORT | CClientUIInterface::MSG_INFORMATION;
1083 // bool modal = (style & CClientUIInterface::MODAL);
1084 
1085 // QString pubkey = QString::fromStdString(pub);
1086 // QString privkey = QString::fromStdString(priv);
1087 
1088  // http://qt-project.org/doc/qt-4.8/qmetaobject.html
1089  // Invokes the member (a signal or a slot name) on the object obj. Returns true if the member could be invoked.
1090  // Returns false if there is no such member or the parameters did not match.
1091  // If type is Qt::BlockingQueuedConnection, the method will be invoked in the same way as for Qt::QueuedConnection,
1092  // except that the current thread will block until the event is delivered. Using this connection type to communicate
1093  // between objects in the same thread will lead to deadlocks....
1094 // QMetaObject::invokeMethod(gui, "message",
1095 // modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
1096 // Q_ARG(QString, QString::fromStdString(caption)),
1097 // pubkey,
1098 // privkey,
1099 // Q_ARG(QString, QString::fromStdString(b32)),
1100 // Q_ARG(QString, QString::fromStdString(configFileName)),
1101 // Q_ARG(unsigned int, style),
1102 // Q_ARG(bool*, &ret));
1103 
1104  return ret;
1105 }
1106 #endif // ENABLE_I2PSAM
1107 
1109 {
1110  // Connect signals to client
1111  uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
1112 #ifdef ENABLE_I2PSAM
1113  uiInterface.ThreadSafeShowGeneratedI2PAddress.connect(boost::bind(ThreadSafeShowGeneratedI2PAddress, this, _1, _2, _3, _4, _5));
1114 #endif
1115 }
1116 
1118 {
1119  // Disconnect signals from client
1120  uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
1121 #ifdef ENABLE_I2PSAM
1122  uiInterface.ThreadSafeShowGeneratedI2PAddress.disconnect(boost::bind(ThreadSafeShowGeneratedI2PAddress, this, _1, _2, _3, _4, _5));
1123 #endif
1124 }
1125 
1127 {
1128  optionsModel = 0;
1130  setStyleSheet("font:11pt; color: #333333");
1131  setToolTip(tr("Unit to show amounts in. Click to select another unit."));
1132 }
1133 
1136 {
1137  onDisplayUnitsClicked(event->pos());
1138 }
1139 
1142 {
1143  menu = new QMenu();
1145  {
1146  QAction *menuAction = new QAction(QString(AnoncoinUnits::name(u)), this);
1147  menuAction->setData(QVariant(u));
1148  menu->addAction(menuAction);
1149  }
1150  connect(menu,SIGNAL(triggered(QAction*)),this,SLOT(onMenuSelection(QAction*)));
1151 
1152  // what happens on right click.
1153  setContextMenuPolicy(Qt::CustomContextMenu);
1154  connect(this,SIGNAL(customContextMenuRequested(const QPoint&)),this,SLOT(onDisplayUnitsClicked(const QPoint&)));
1155 }
1156 
1159 {
1160  if (optionsModel)
1161  {
1162  this->optionsModel = optionsModel;
1163 
1164  // be aware of a display unit change reported by the OptionsModel object.
1165  connect(optionsModel,SIGNAL(displayUnitChanged(int)),this,SLOT(updateDisplayUnit(int)));
1166 
1167  // initialize the display units label with the current value in the model.
1168  updateDisplayUnit(optionsModel->getDisplayUnit());
1169  }
1170 }
1171 
1174 {
1175  setText(AnoncoinUnits::name(newUnits));
1176 }
1177 
1180 {
1181  QPoint globalPos = mapToGlobal(point);
1182  menu->exec(globalPos);
1183 }
1184 
1187 {
1188  if (action)
1189  {
1190  optionsModel->setDisplayUnit(action->data());
1191  }
1192 }
1193 
1194 #ifdef ENABLE_I2PSAM
1195 void AnoncoinGUI::showGeneratedI2PAddr(const QString& caption, const QString& pub, const QString& priv, const QString& b32, const QString& configFileName)
1196 {
1197  ShowI2PAddresses i2pDialog(caption, pub, priv, b32, configFileName, this);
1198  i2pDialog.exec();
1199 }
1200 #endif // ENABLE_I2PSAM
int prevBlocks
Keep track of previous number of blocks, to detect progress.
Definition: anoncoingui.h:121
CClientUIInterface uiInterface
Definition: util.cpp:100
void detectShutdown()
called by a timer to check if fRequestShutdown has been set
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
Definition: walletframe.cpp:92
bool setCurrentWallet(const QString &name)
Definition: walletframe.cpp:63
QLabel * labelEncryptionIcon
Definition: anoncoingui.h:84
QLabel * labelConnectionsIcon
Definition: anoncoingui.h:85
bool getMinimizeOnClose()
Definition: optionsmodel.h:86
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
Local Anoncoin RPC console.
Definition: rpcconsole.h:26
QAction * encryptWalletAction
Definition: anoncoingui.h:108
Value help(const Array &params, bool fHelp)
Definition: rpcserver.cpp:190
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.
bool ShutdownRequested()
Definition: init.cpp:107
static QString formatWithUnit(int unit, qint64 amount, bool plussign=false)
Format as string (with unit)
QAction * verifyMessageAction
Definition: anoncoingui.h:103
Unit
Anoncoin units.
Definition: anoncoinunits.h:25
QAction * changePassphraseAction
Definition: anoncoingui.h:110
QAction * historyAction
Definition: anoncoingui.h:97
static QString name(int unit)
Short name.
QAction * openAction
Definition: anoncoingui.h:113
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:51
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
Definition: guiutil.cpp:345
Anoncoin GUI main class.
Definition: anoncoingui.h:47
UnitDisplayStatusBarControl * unitDisplayControl
Definition: anoncoingui.h:83
OptionsModel * getOptionsModel()
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
Macintosh-specific dock icon handler.
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated...
Definition: ui_interface.h:66
Don't bring GUI to foreground.
Definition: ui_interface.h:72
Notify user of potential problem.
Definition: notificator.h:40
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
WalletFrame * walletFrame
Definition: anoncoingui.h:81
void removeAllWallets()
Definition: walletframe.cpp:84
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 saveWindowGeometry(const QString &strSetting, QWidget *parent)
Save window size and position.
Definition: guiutil.cpp:738
void optionsClicked()
Show configuration dialog.
Force blocking, modal message box dialog (not just OS notification)
Definition: ui_interface.h:70
void showOutOfSyncWarning(bool fShow)
void setIcon(const QIcon &icon)
void setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:292
void gotoHistoryPage()
Switch to history (transactions) page.
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
RPCConsole * rpcConsole
Definition: anoncoingui.h:118
Notificator * notificator
Definition: anoncoingui.h:117
void gotoOverviewPage()
Switch to overview (home) page.
QMenuBar * appMenuBar
Definition: anoncoingui.h:95
double getVerificationProgress() const
Definition: clientmodel.cpp:96
void setNumConnections(int count)
Set number of connections shown in the UI.
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
Definition: util.cpp:520
static MacDockIconHandler * instance()
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void setClientModel(ClientModel *clientModel)
Definition: walletframe.cpp:36
void setMainWindow(QMainWindow *window)
bool isObscured(QWidget *w)
Definition: guiutil.cpp:364
OptionsModel * optionsModel
Definition: anoncoingui.h:236
void createMenuBar()
Create the menu bar and sub-menus.
"About" dialog box
Definition: utilitydialog.h:21
static const QString DEFAULT_WALLET
Definition: anoncoingui.h:52
void gotoVerifyMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to verify message tab.
void notify(Class cls, const QString &title, const QString &text, const QIcon &icon=QIcon(), int millisTimeout=10000)
Show notification message.
bool addWallet(const QString &name, WalletModel *walletModel)
Definition: walletframe.cpp:41
QDateTime getLastBlockDate() const
Definition: clientmodel.cpp:87
QAction * receiveCoinsAction
Definition: anoncoingui.h:105
BlockSource
Definition: clientmodel.h:30
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
void setModel(OptionsModel *model)
QAction * usedSendingAddressesAction
Definition: anoncoingui.h:100
void createActions(bool fIsTestnet)
Create the main UI actions.
Cross-platform desktop notification client.
Definition: notificator.h:25
Informational message.
Definition: notificator.h:39
int getDisplayUnit()
Definition: optionsmodel.h:87
void restoreWindowGeometry(const QString &strSetting, const QSize &defaultSize, QWidget *parent)
Restore window size and position.
Definition: guiutil.cpp:745
Model for Anoncoin network client.
Definition: clientmodel.h:45
An error occurred.
Definition: notificator.h:41
QLabel * progressBarLabel
Definition: anoncoingui.h:92
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
void dropEvent(QDropEvent *event)
int getNumBlocks() const
Definition: clientmodel.cpp:65
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)
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
void gotoReceiveCoinsPage()
Switch to receive coins page.
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.
QAction * sendCoinsAction
Definition: anoncoingui.h:99
boost::signals2::signal< bool(const std::string &message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeMessageBox
Show message box.
Definition: ui_interface.h:81
QLabel * labelBlocksIcon
Definition: anoncoingui.h:86
ClientModel * clientModel
Definition: anoncoingui.h:80
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
"Help message" dialog box
Definition: utilitydialog.h:39
void changeEvent(QEvent *e)
QAction * signMessageAction
Definition: anoncoingui.h:102
Preferences dialog.
Definition: optionsdialog.h:22
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
void setClientModel(ClientModel *clientModel)
QAction * toggleHideAction
Definition: anoncoingui.h:107
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
bool getMinimizeToTray()
Definition: optionsmodel.h:85
void subscribeToCoreSignals()
Connect core signals to GUI client.
QAction * openRPCConsoleAction
Definition: anoncoingui.h:112
enum BlockSource getBlockSource() const
Return true if core is importing blocks.
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.
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:75
#define SPINNER_FRAMES
Definition: guiconstants.h:49
QSystemTrayIcon * trayIcon
Definition: anoncoingui.h:116
void setModel(ClientModel *model)