Fabcoin Core  0.16.2
P2P Digital Currency
fabcoingui.cpp
Go to the documentation of this file.
1 // Copyright (c) 2011-2017 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 #if defined(HAVE_CONFIG_H)
7 #endif
8 
9 #include <fabcoingui.h>
10 
11 #include <fabcoinunits.h>
12 #include <clientmodel.h>
13 #include <guiconstants.h>
14 #include <guiutil.h>
15 #include <modaloverlay.h>
16 #include <networkstyle.h>
17 #include <notificator.h>
18 #include <openuridialog.h>
19 #include <optionsdialog.h>
20 #include <optionsmodel.h>
21 #include <platformstyle.h>
22 #include <rpcconsole.h>
23 #include <utilitydialog.h>
24 #include <validation.h>
25 #include <rpc/server.h>
26 #include <navigationbar.h>
27 #include <titlebar.h>
28 #include <fabcoinversionchecker.h>
29 
30 #ifdef ENABLE_WALLET
31 #include <walletframe.h>
32 #include <walletmodel.h>
33 #include <wallet/wallet.h>
34 #endif // ENABLE_WALLET
35 
36 #ifdef Q_OS_MAC
37 #include <macdockiconhandler.h>
38 #endif
39 
40 #include <chainparams.h>
41 #include <init.h>
42 #include <ui_interface.h>
43 #include <util.h>
44 
45 #include <iostream>
46 
47 #include <QAction>
48 #include <QApplication>
49 #include <QDateTime>
50 #include <QDesktopWidget>
51 #include <QDragEnterEvent>
52 #include <QListWidget>
53 #include <QMenuBar>
54 #include <QMessageBox>
55 #include <QMimeData>
56 #include <QProgressDialog>
57 #include <QSettings>
58 #include <QShortcut>
59 #include <QStackedWidget>
60 #include <QStatusBar>
61 #include <QStyle>
62 #include <QTimer>
63 #include <QToolBar>
64 #include <QVBoxLayout>
65 #include <QDockWidget>
66 #include <QSizeGrip>
67 
68 #if QT_VERSION < 0x050000
69 #include <QTextDocument>
70 #include <QUrl>
71 #else
72 #include <QUrlQuery>
73 #endif
74 
75 const std::string FabcoinGUI::DEFAULT_UIPLATFORM =
76 #if defined(Q_OS_MAC)
77  "macosx"
78 #elif defined(Q_OS_WIN)
79  "windows"
80 #else
81  "other"
82 #endif
83  ;
84 
87 const QString FabcoinGUI::DEFAULT_WALLET = "~Default";
88 
90 bool showBackupOverlay = false;
91 
92 FabcoinGUI::FabcoinGUI(const PlatformStyle *_platformStyle, const NetworkStyle *networkStyle, QWidget *parent) :
93  QMainWindow(parent),
94  enableWallet(false),
95  clientModel(0),
96  walletFrame(0),
97  unitDisplayControl(0),
98  labelWalletEncryptionIcon(0),
99  labelWalletHDStatusIcon(0),
100  connectionsControl(0),
101  labelBlocksIcon(0),
102  progressBarLabel(0),
103  progressBar(0),
104  progressDialog(0),
105  appMenuBar(0),
106  appTitleBar(0),
107  appNavigationBar(0),
108  overviewAction(0),
109  historyAction(0),
110  quitAction(0),
111  sendCoinsAction(0),
112  sendCoinsMenuAction(0),
113  usedSendingAddressesAction(0),
114  usedReceivingAddressesAction(0),
115  signMessageAction(0),
116  verifyMessageAction(0),
117  aboutAction(0),
118  receiveCoinsAction(0),
119  receiveCoinsMenuAction(0),
120  optionsAction(0),
121  toggleHideAction(0),
122  encryptWalletAction(0),
123  backupWalletAction(0),
124  restoreWalletAction(0),
125  changePassphraseAction(0),
126  unlockWalletAction(0),
127  lockWalletAction(0),
128  aboutQtAction(0),
129  openRPCConsoleAction(0),
130  openAction(0),
131  showHelpMessageAction(0),
132  smartContractAction(0),
133  createContractAction(0),
134  sendToContractAction(0),
135  callContractAction(0),
136  QRCTokenAction(0),
137  sendTokenAction(0),
138  receiveTokenAction(0),
139  addTokenAction(0),
140  trayIcon(0),
141  trayIconMenu(0),
142  notificator(0),
143  rpcConsole(0),
144  helpMessageDialog(0),
145  modalOverlay(0),
146  fabcoinVersionChecker(0),
147  modalBackupOverlay(0),
148  prevBlocks(0),
149  spinnerFrame(0),
150  platformStyle(_platformStyle)
151 {
152  QSettings settings;
153  if (!restoreGeometry(settings.value("MainWindowGeometry").toByteArray())) {
154  // Restore failed (perhaps missing setting), center the window
155  move(QApplication::desktop()->availableGeometry().center() - frameGeometry().center());
156  }
157 
158  QString windowTitle = tr(PACKAGE_NAME) + " - ";
159 #ifdef ENABLE_WALLET
161 #endif // ENABLE_WALLET
162  if(enableWallet)
163  {
164  windowTitle += tr("Wallet");
165  } else {
166  windowTitle += tr("Node");
167  }
168  windowTitle += " " + networkStyle->getTitleAddText();
169 #ifndef Q_OS_MAC
170  QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon());
171  setWindowIcon(networkStyle->getTrayAndWindowIcon());
172 #else
173  MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon());
174 #endif
175  setWindowTitle(windowTitle);
176 
177 #if defined(Q_OS_MAC) && QT_VERSION < 0x050000
178  // This property is not implemented in Qt 5. Setting it has no effect.
179  // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras.
180  setUnifiedTitleAndToolBarOnMac(true);
181 #endif
182 
183  rpcConsole = new RPCConsole(_platformStyle, 0);
184  helpMessageDialog = new HelpMessageDialog(this, false);
185 #ifdef ENABLE_WALLET
186  if(enableWallet)
187  {
189  walletFrame = new WalletFrame(_platformStyle, this);
190  setCentralWidget(walletFrame);
191  } else
192 #endif // ENABLE_WALLET
193  {
194  /* When compiled without wallet or -disablewallet is provided,
195  * the central widget is the rpc console.
196  */
197  setCentralWidget(rpcConsole);
198  }
199 
200  // Accept D&D of URIs
201  setAcceptDrops(true);
202 
203  // Create actions for the toolbar, menu bar and tray/dock icon
204  // Needs walletFrame to be initialized
205  createActions();
206 
207  // Create application menu bar
208  createMenuBar();
209 
210  // Create the toolbars
211  createToolBars();
212 
213  // Create the title bar
214  createTitleBars();
215 
216  // Create system tray icon and notification
217  createTrayIcon(networkStyle);
218 
219  // Create status bar
220  statusBar();
221 
222  // Enable the size grip (right size grip), add new size grip (left size grip) and set the status bar style
223  statusBar()->setSizeGripEnabled(true);
224  statusBar()->addWidget(new QSizeGrip(statusBar()));
225  statusBar()->setStyleSheet("QSizeGrip { width: 3px; height: 25px; border: 0px solid black; } \n QStatusBar::item { border: 0px solid black; }");
226 
227  // Status bar notification icons
228  QFrame *frameBlocks = new QFrame();
229  frameBlocks->setContentsMargins(0,0,0,0);
230  frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
231  QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
232  frameBlocksLayout->setContentsMargins(3,0,0,0);
233  frameBlocksLayout->setSpacing(3);
235  labelWalletEncryptionIcon = new QLabel();
236  labelWalletHDStatusIcon = new QLabel();
239  labelStakingIcon = new QLabel();
240  if(enableWallet)
241  {
242  frameBlocksLayout->addStretch();
243  frameBlocksLayout->addWidget(unitDisplayControl);
244  frameBlocksLayout->addStretch();
245  frameBlocksLayout->addWidget(labelWalletEncryptionIcon);
246  frameBlocksLayout->addWidget(labelWalletHDStatusIcon);
247  }
248  frameBlocksLayout->addStretch();
249  frameBlocksLayout->addWidget(labelStakingIcon);
250  frameBlocksLayout->addStretch();
251  frameBlocksLayout->addWidget(connectionsControl);
252  frameBlocksLayout->addStretch();
253  frameBlocksLayout->addWidget(labelBlocksIcon);
254  frameBlocksLayout->addStretch();
255 
256  if (gArgs.GetBoolArg("-staking", true))
257  {
258  QTimer *timerStakingIcon = new QTimer(labelStakingIcon);
259  connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(updateStakingIcon()));
260  timerStakingIcon->start(1000);
261 
263  }
264 
265  // Progress bar and label for blocks download
266  progressBarLabel = new QLabel();
267  progressBarLabel->setVisible(false);
269  progressBar->setAlignment(Qt::AlignCenter);
270  progressBar->setVisible(false);
271 
272  // Override style sheet for progress bar for styles that have a segmented progress bar,
273  // as they make the text unreadable (workaround for issue #1071)
274  // See https://qt-project.org/doc/qt-4.8/gallery.html
275  QString curStyle = QApplication::style()->metaObject()->className();
276  if(curStyle == "QWindowsStyle" || curStyle == "QWindowsXPStyle")
277  {
278  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; }");
279  }
280 
281  statusBar()->addWidget(progressBarLabel);
282  statusBar()->addWidget(progressBar);
283  statusBar()->addPermanentWidget(frameBlocks);
284 
285  // Install event filter to be able to catch status tip events (QEvent::StatusTip)
286  this->installEventFilter(this);
287 
288  // Initially wallet actions should be disabled
290 
291  // Subscribe to notifications from core
293 
294  connect(connectionsControl, SIGNAL(clicked(QPoint)), this, SLOT(toggleNetworkActive()));
295 
296  modalOverlay = new ModalOverlay(this->centralWidget());
299 
301  {
302  QString link = QString("<a href=%1>%2</a>").arg(FABCOIN_RELEASES, FABCOIN_RELEASES);
303  QString message(tr("New version of Fabcoin wallet is available on the Fabcoin source code repository: <br /> %1. <br />It is recommended to download it and update this application").arg(link));
304  QMessageBox::information(this, tr("Check for updates"), message);
305  }
306 
307 #ifdef ENABLE_WALLET
308  if(enableWallet) {
309  connect(walletFrame, SIGNAL(requestedSyncWarningInfo()), this, SLOT(showModalOverlay()));
310  connect(labelBlocksIcon, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
311  connect(progressBar, SIGNAL(clicked(QPoint)), this, SLOT(showModalOverlay()));
312  connect(modalBackupOverlay, SIGNAL(backupWallet()), walletFrame, SLOT(backupWallet()));
313  }
314 #endif
315 
316  setStyleSheet("QMainWindow::separator { width: 1px; height: 1px; margin: 0px; padding: 0px; }");
317 }
318 
320 {
321  // Unsubscribe from notifications from core
323 
324  QSettings settings;
325  settings.setValue("MainWindowGeometry", saveGeometry());
326  if(trayIcon) // Hide tray icon, as deleting will let it linger until quit (on Ubuntu)
327  trayIcon->hide();
328 #ifdef Q_OS_MAC
329  delete appMenuBar;
331 #endif
332 
333  delete rpcConsole;
334 }
335 
337 {
338  QActionGroup *tabGroup = new QActionGroup(this);
339 
340  overviewAction = new QAction(platformStyle->MultiStatesIcon(":/icons/overview"), tr("My &wallet"), this);
341  overviewAction->setStatusTip(tr("Show general overview of wallet"));
342  overviewAction->setToolTip(overviewAction->statusTip());
343  overviewAction->setCheckable(true);
344  overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
345  tabGroup->addAction(overviewAction);
346 
347  sendCoinsAction = new QAction(platformStyle->MultiStatesIcon(":/icons/send_to"), tr("&Send"), this);
348  sendCoinsAction->setStatusTip(tr("Send coins to a Fabcoin address"));
349  sendCoinsAction->setToolTip(sendCoinsAction->statusTip());
350  sendCoinsAction->setCheckable(true);
351  sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
352  tabGroup->addAction(sendCoinsAction);
353 
354  sendCoinsMenuAction = new QAction(platformStyle->MenuColorIcon(":/icons/send"), sendCoinsAction->text(), this);
355  sendCoinsMenuAction->setStatusTip(sendCoinsAction->statusTip());
356  sendCoinsMenuAction->setToolTip(sendCoinsMenuAction->statusTip());
357 
358  receiveCoinsAction = new QAction(platformStyle->MultiStatesIcon(":/icons/receive_from"), tr("&Receive"), this);
359  receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and fabcoin: URIs)"));
360  receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
361  receiveCoinsAction->setCheckable(true);
362  receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
363  tabGroup->addAction(receiveCoinsAction);
364 
365  receiveCoinsMenuAction = new QAction(platformStyle->MenuColorIcon(":/icons/receiving_addresses"), receiveCoinsAction->text(), this);
366  receiveCoinsMenuAction->setStatusTip(receiveCoinsAction->statusTip());
367  receiveCoinsMenuAction->setToolTip(receiveCoinsMenuAction->statusTip());
368 
369  smartContractAction = new QAction(platformStyle->MultiStatesIcon(":/icons/smart_contract"), tr("Smart &Contracts"), this);
370  smartContractAction->setStatusTip(tr("Smart contracts"));
371  smartContractAction->setToolTip(smartContractAction->statusTip());
372  smartContractAction->setCheckable(true);
373  smartContractAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
374  tabGroup->addAction(smartContractAction);
375 
376  createContractAction = new QAction(tr("Create"), this);
377  sendToContractAction = new QAction(tr("Send To"), this);
378  callContractAction = new QAction(tr("Call"), this);
379 
380  historyAction = new QAction(platformStyle->MultiStatesIcon(":/icons/history"), tr("&Transactions"), this);
381  historyAction->setStatusTip(tr("Browse transaction history"));
382  historyAction->setToolTip(historyAction->statusTip());
383  historyAction->setCheckable(true);
384  historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
385  tabGroup->addAction(historyAction);
386 
387  QRCTokenAction = new QAction(platformStyle->MultiStatesIcon(":/icons/qrctoken"), tr("&FRC Tokens"), this);
388  QRCTokenAction->setStatusTip(tr("FRC Tokens (send, receive or add Tokens in list)"));
389  QRCTokenAction->setToolTip(QRCTokenAction->statusTip());
390  QRCTokenAction->setCheckable(true);
391  QRCTokenAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_6));
392  tabGroup->addAction(QRCTokenAction);
393 
394  sendTokenAction = new QAction(tr("Send"), this);
395  receiveTokenAction = new QAction(tr("Receive"), this);
396  addTokenAction = new QAction(tr("Add Token"), this);
397 
398 #ifdef ENABLE_WALLET
399  // These showNormalIfMinimized are needed because Send Coins and Receive Coins
400  // can be triggered from the tray menu, and need to show the GUI to be useful.
401  connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
402  connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
403  connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
404  connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
405  connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
406  connect(sendCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
407  connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
408  connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
409  connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
410  connect(receiveCoinsMenuAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
411  connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
412  connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
413  connect(createContractAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
414  connect(createContractAction, SIGNAL(triggered()), this, SLOT(gotoCreateContractPage()));
415  connect(sendToContractAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
416  connect(sendToContractAction, SIGNAL(triggered()), this, SLOT(gotoSendToContractPage()));
417  connect(callContractAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
418  connect(callContractAction, SIGNAL(triggered()), this, SLOT(gotoCallContractPage()));
419  connect(sendTokenAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
420  connect(sendTokenAction, SIGNAL(triggered()), this, SLOT(gotoSendTokenPage()));
421  connect(receiveTokenAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
422  connect(receiveTokenAction, SIGNAL(triggered()), this, SLOT(gotoReceiveTokenPage()));
423  connect(addTokenAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
424  connect(addTokenAction, SIGNAL(triggered()), this, SLOT(gotoAddTokenPage()));
425 #endif // ENABLE_WALLET
426 
427  quitAction = new QAction(platformStyle->MenuColorIcon(":/icons/quit"), tr("E&xit"), this);
428  quitAction->setStatusTip(tr("Quit application"));
429  quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
430  quitAction->setMenuRole(QAction::QuitRole);
431  aboutAction = new QAction(platformStyle->MenuColorIcon(":/icons/about"), tr("&About %1").arg(tr(PACKAGE_NAME)), this);
432  aboutAction->setStatusTip(tr("Show information about %1").arg(tr(PACKAGE_NAME)));
433  aboutAction->setMenuRole(QAction::AboutRole);
434  aboutAction->setEnabled(false);
435  aboutQtAction = new QAction(platformStyle->MenuColorIcon(":/icons/about_qt"), tr("About &Qt"), this);
436  aboutQtAction->setStatusTip(tr("Show information about Qt"));
437  aboutQtAction->setMenuRole(QAction::AboutQtRole);
438  optionsAction = new QAction(platformStyle->MenuColorIcon(":/icons/options"), tr("&Options..."), this);
439  optionsAction->setStatusTip(tr("Modify configuration options for %1").arg(tr(PACKAGE_NAME)));
440  optionsAction->setMenuRole(QAction::PreferencesRole);
441  optionsAction->setEnabled(false);
442  toggleHideAction = new QAction(platformStyle->MenuColorIcon(":/icons/about"), tr("&Show / Hide"), this);
443  toggleHideAction->setStatusTip(tr("Show or hide the main Window"));
444 
445  encryptWalletAction = new QAction(platformStyle->MenuColorIcon(":/icons/encrypt"), tr("&Encrypt Wallet..."), this);
446  encryptWalletAction->setStatusTip(tr("Encrypt the private keys that belong to your wallet"));
447  encryptWalletAction->setCheckable(true);
448  backupWalletAction = new QAction(platformStyle->MenuColorIcon(":/icons/filesave"), tr("&Backup Wallet..."), this);
449  backupWalletAction->setStatusTip(tr("Backup wallet to another location"));
450  restoreWalletAction = new QAction(platformStyle->MenuColorIcon(":/icons/restore"), tr("&Restore Wallet..."), this);
451  restoreWalletAction->setStatusTip(tr("Restore wallet from another location"));
452  changePassphraseAction = new QAction(platformStyle->MenuColorIcon(":/icons/key"), tr("&Change Passphrase..."), this);
453  changePassphraseAction->setStatusTip(tr("Change the passphrase used for wallet encryption"));
454  unlockWalletAction = new QAction(platformStyle->MenuColorIcon(":/icons/lock_open"), tr("&Unlock Wallet..."), this);
455  unlockWalletAction->setToolTip(tr("Unlock wallet"));
456  unlockWalletAction->setObjectName("unlockWalletAction");
457  lockWalletAction = new QAction(platformStyle->MenuColorIcon(":/icons/lock_closed"), tr("&Lock Wallet"), this);
458  lockWalletAction->setToolTip(tr("Lock wallet"));
459  signMessageAction = new QAction(platformStyle->MenuColorIcon(":/icons/edit"), tr("Sign &message..."), this);
460  signMessageAction->setStatusTip(tr("Sign messages with your Fabcoin addresses to prove you own them"));
461  verifyMessageAction = new QAction(platformStyle->MenuColorIcon(":/icons/verify"), tr("&Verify message..."), this);
462  verifyMessageAction->setStatusTip(tr("Verify messages to ensure they were signed with specified Fabcoin addresses"));
463 
464  openRPCConsoleAction = new QAction(platformStyle->MenuColorIcon(":/icons/debugwindow"), tr("&Debug window"), this);
465  openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
466  // initially disable the debug window menu item
467  openRPCConsoleAction->setEnabled(false);
468 
469  usedSendingAddressesAction = new QAction(platformStyle->MenuColorIcon(":/icons/address-book"), tr("&Sending addresses..."), this);
470  usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
471  usedReceivingAddressesAction = new QAction(platformStyle->MenuColorIcon(":/icons/address-book"), tr("&Receiving addresses..."), this);
472  usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
473 
474  openAction = new QAction(platformStyle->MenuColorIcon(":/icons/open"), tr("Open &URI..."), this);
475  openAction->setStatusTip(tr("Open a fabcoin: URI or payment request"));
476 
477  showHelpMessageAction = new QAction(platformStyle->MenuColorIcon(":/icons/info"), tr("&Command-line options"), this);
478  showHelpMessageAction->setMenuRole(QAction::NoRole);
479  showHelpMessageAction->setStatusTip(tr("Show the %1 help message to get a list with possible Fabcoin command-line options").arg(tr(PACKAGE_NAME)));
480 
481  connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
482  connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
483  connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
484  connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
485  connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden()));
486  connect(showHelpMessageAction, SIGNAL(triggered()), this, SLOT(showHelpMessageClicked()));
487  connect(openRPCConsoleAction, SIGNAL(triggered()), this, SLOT(showDebugWindow()));
488  // prevents an open debug window from becoming stuck/unusable on client shutdown
489  connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
490 
491 #ifdef ENABLE_WALLET
492  if(walletFrame)
493  {
494  connect(encryptWalletAction, SIGNAL(triggered(bool)), walletFrame, SLOT(encryptWallet(bool)));
495  connect(backupWalletAction, SIGNAL(triggered()), walletFrame, SLOT(backupWallet()));
496  connect(restoreWalletAction, SIGNAL(triggered()), walletFrame, SLOT(restoreWallet()));
497  connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
498  connect(unlockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(unlockWallet()));
499  connect(lockWalletAction, SIGNAL(triggered()), walletFrame, SLOT(lockWallet()));
500  connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
501  connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
502  connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
503  connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
504  connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
505  }
506 #endif // ENABLE_WALLET
507 
508  new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_C), this, SLOT(showDebugWindowActivateConsole()));
509  new QShortcut(QKeySequence(Qt::CTRL + Qt::SHIFT + Qt::Key_D), this, SLOT(showDebugWindow()));
510 }
511 
513 {
514 #ifdef Q_OS_MAC
515  // Create a decoupled menu bar on Mac which stays even if the window is closed
516  appMenuBar = new QMenuBar();
517 #else
518  // Get the main window's menu bar on other platforms
519  appMenuBar = menuBar();
520 #endif
521 
522  // Configure the menus
523  QMenu *file = appMenuBar->addMenu(tr("&File"));
524  if(walletFrame)
525  {
526  file->addAction(openAction);
527  file->addAction(backupWalletAction);
528  file->addAction(restoreWalletAction);
529  file->addAction(signMessageAction);
530  file->addAction(verifyMessageAction);
531  file->addSeparator();
532  file->addAction(usedSendingAddressesAction);
533  file->addAction(usedReceivingAddressesAction);
534  file->addSeparator();
535  }
536  file->addAction(quitAction);
537 
538  QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
539  if(walletFrame)
540  {
541  settings->addAction(encryptWalletAction);
542  settings->addAction(changePassphraseAction);
543  settings->addAction(unlockWalletAction);
544  settings->addAction(lockWalletAction);
545  settings->addSeparator();
546  }
547  settings->addAction(optionsAction);
548 
549  QMenu *help = appMenuBar->addMenu(tr("&Help"));
550  if(walletFrame)
551  {
552  help->addAction(openRPCConsoleAction);
553  }
554  help->addAction(showHelpMessageAction);
555  help->addSeparator();
556  help->addAction(aboutAction);
557  help->addAction(aboutQtAction);
558 }
559 
561 {
562  if(walletFrame)
563  {
564  // Create custom tool bar component
566  addDockWindows(Qt::LeftDockWidgetArea, appNavigationBar);
567 
568  // Fill the component with actions
573  QList<QAction*> contractActions;
574  contractActions.append(createContractAction);
575  contractActions.append(sendToContractAction);
576  contractActions.append(callContractAction);
577  appNavigationBar->mapGroup(smartContractAction, contractActions);
578  QList<QAction*> tokenActions;
579  tokenActions.append(sendTokenAction);
580  tokenActions.append(receiveTokenAction);
581  tokenActions.append(addTokenAction);
582  appNavigationBar->mapGroup(QRCTokenAction, tokenActions);
584  overviewAction->setChecked(true);
585  }
586 }
587 
589 {
590  if(walletFrame)
591  {
592  // Create custom title bar component
594  addDockWindows(Qt::TopDockWidgetArea, appTitleBar);
595  connect(appNavigationBar, SIGNAL(resized(QSize)), appTitleBar, SLOT(on_navigationResized(QSize)));
596  }
597 }
598 
600 {
601  this->clientModel = _clientModel;
602  if(_clientModel)
603  {
604  // Create system tray menu (or setup the dock menu) that late to prevent users from calling actions,
605  // while the client has not yet fully loaded
607 
608  // Keep up to date with client
610  connect(_clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
611  connect(_clientModel, SIGNAL(networkActiveChanged(bool)), this, SLOT(setNetworkActive(bool)));
612 
613  modalOverlay->setKnownBestHeight(_clientModel->getHeaderTipHeight(), QDateTime::fromTime_t(_clientModel->getHeaderTipTime()));
614  setNumBlocks(_clientModel->getNumBlocks(), _clientModel->getLastBlockDate(), _clientModel->getVerificationProgress(nullptr), false);
615  connect(_clientModel, SIGNAL(numBlocksChanged(int,QDateTime,double,bool)), this, SLOT(setNumBlocks(int,QDateTime,double,bool)));
616 
617  // Receive and report messages from client model
618  connect(_clientModel, SIGNAL(message(QString,QString,unsigned int)), this, SLOT(message(QString,QString,unsigned int)));
619 
620  // Show progress dialog
621  connect(_clientModel, SIGNAL(showProgress(QString,int)), this, SLOT(showProgress(QString,int)));
622 
623  rpcConsole->setClientModel(_clientModel);
624 #ifdef ENABLE_WALLET
625  if(walletFrame)
626  {
627  walletFrame->setClientModel(_clientModel);
628  }
629 #endif // ENABLE_WALLET
631 
632  OptionsModel* optionsModel = _clientModel->getOptionsModel();
633  if(optionsModel)
634  {
635  // be aware of the tray icon disable state change reported by the OptionsModel object.
636  connect(optionsModel,SIGNAL(hideTrayIconChanged(bool)),this,SLOT(setTrayIconVisible(bool)));
637 
638  // initialize the disable state of the tray icon with the current value in the model.
639  setTrayIconVisible(optionsModel->getHideTrayIcon());
640  }
641 
643  } else {
644  // Disable possibility to show main window via action
645  toggleHideAction->setEnabled(false);
646  if(trayIconMenu)
647  {
648  // Disable context menu on tray icon
649  trayIconMenu->clear();
650  }
651  // Propagate cleared model to child objects
652  rpcConsole->setClientModel(nullptr);
653 #ifdef ENABLE_WALLET
654  if (walletFrame)
655  {
656  walletFrame->setClientModel(nullptr);
657  }
658 #endif // ENABLE_WALLET
660  }
661 }
662 
663 #ifdef ENABLE_WALLET
664 bool FabcoinGUI::addWallet(const QString& name, WalletModel *walletModel)
665 {
666  if(!walletFrame)
667  return false;
669  appTitleBar->setModel(walletModel);
670  if(showBackupOverlay && walletModel && !(walletModel->hasWalletBackup()))
671  {
673  }
674  return walletFrame->addWallet(name, walletModel);
675 }
676 
677 bool FabcoinGUI::setCurrentWallet(const QString& name)
678 {
679  if(!walletFrame)
680  return false;
681  return walletFrame->setCurrentWallet(name);
682 }
683 
684 void FabcoinGUI::removeAllWallets()
685 {
686  if(!walletFrame)
687  return;
690 }
691 #endif // ENABLE_WALLET
692 
694 {
695  overviewAction->setEnabled(enabled);
696  sendCoinsAction->setEnabled(enabled);
697  sendCoinsMenuAction->setEnabled(enabled);
698  receiveCoinsAction->setEnabled(enabled);
699  receiveCoinsMenuAction->setEnabled(enabled);
700  historyAction->setEnabled(enabled);
701  encryptWalletAction->setEnabled(enabled);
702  backupWalletAction->setEnabled(enabled);
703  restoreWalletAction->setEnabled(enabled);
704  changePassphraseAction->setEnabled(enabled);
705  signMessageAction->setEnabled(enabled);
706  verifyMessageAction->setEnabled(enabled);
707  usedSendingAddressesAction->setEnabled(enabled);
708  usedReceivingAddressesAction->setEnabled(enabled);
709  openAction->setEnabled(enabled);
710 }
711 
712 void FabcoinGUI::createTrayIcon(const NetworkStyle *networkStyle)
713 {
714 #ifndef Q_OS_MAC
715  trayIcon = new QSystemTrayIcon(this);
716  QString toolTip = tr("%1 client").arg(tr(PACKAGE_NAME)) + " " + networkStyle->getTitleAddText();
717  trayIcon->setToolTip(toolTip);
718  trayIcon->setIcon(networkStyle->getTrayAndWindowIcon());
719  trayIcon->hide();
720 #endif
721 
722  notificator = new Notificator(QApplication::applicationName(), trayIcon, this);
723 }
724 
726 {
727 #ifndef Q_OS_MAC
728  // return if trayIcon is unset (only on non-Mac OSes)
729  if (!trayIcon)
730  return;
731 
732  trayIconMenu = new QMenu(this);
733  trayIcon->setContextMenu(trayIconMenu);
734 
735  connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
736  this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
737 #else
738  // Note: On Mac, the dock icon is used to provide the tray's functionality.
740  dockIconHandler->setMainWindow((QMainWindow *)this);
741  trayIconMenu = dockIconHandler->dockMenu();
742 #endif
743 
744  // Configuration of the tray icon (or dock icon) icon menu
745  trayIconMenu->addAction(toggleHideAction);
746  trayIconMenu->addSeparator();
747  trayIconMenu->addAction(sendCoinsMenuAction);
749  trayIconMenu->addSeparator();
750  trayIconMenu->addAction(signMessageAction);
751  trayIconMenu->addAction(verifyMessageAction);
752  trayIconMenu->addSeparator();
753  trayIconMenu->addAction(optionsAction);
755 #ifndef Q_OS_MAC // This is built-in on Mac
756  trayIconMenu->addSeparator();
757  trayIconMenu->addAction(quitAction);
758 #endif
759 }
760 
761 #ifndef Q_OS_MAC
762 void FabcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
763 {
764  if(reason == QSystemTrayIcon::Trigger)
765  {
766  // Click on system tray icon triggers show/hide of the main window
767  toggleHidden();
768  }
769 }
770 #endif
771 
773 {
775  return;
776 
777  OptionsDialog dlg(this, enableWallet);
779  dlg.exec();
780 }
781 
783 {
784  if(!clientModel)
785  return;
786 
787  HelpMessageDialog dlg(this, true);
788  dlg.exec();
789 }
790 
792 {
793  rpcConsole->showNormal();
794  rpcConsole->show();
795  rpcConsole->raise();
796  rpcConsole->activateWindow();
797 }
798 
800 {
802  showDebugWindow();
803 }
804 
806 {
807  helpMessageDialog->show();
808 }
809 
810 #ifdef ENABLE_WALLET
811 void FabcoinGUI::openClicked()
812 {
813  OpenURIDialog dlg(this);
814  if(dlg.exec())
815  {
816  Q_EMIT receivedURI(dlg.getURI());
817  }
818 }
819 
820 void FabcoinGUI::gotoOverviewPage()
821 {
822  overviewAction->setChecked(true);
824 }
825 
826 void FabcoinGUI::gotoHistoryPage()
827 {
828  historyAction->setChecked(true);
830 }
831 
832 void FabcoinGUI::gotoSendTokenPage()
833 {
834  sendTokenAction->setChecked(true);
835  QRCTokenAction->setChecked(true);
837 }
838 
839 void FabcoinGUI::gotoReceiveTokenPage()
840 {
841  receiveTokenAction->setChecked(true);
842  QRCTokenAction->setChecked(true);
844 }
845 
846 void FabcoinGUI::gotoAddTokenPage()
847 {
848  addTokenAction->setChecked(true);
849  QRCTokenAction->setChecked(true);
851 }
852 
853 void FabcoinGUI::gotoReceiveCoinsPage()
854 {
855  receiveCoinsAction->setChecked(true);
857 }
858 
859 void FabcoinGUI::gotoSendCoinsPage(QString addr)
860 {
861  sendCoinsAction->setChecked(true);
863 }
864 
865 void FabcoinGUI::gotoCreateContractPage()
866 {
868 }
869 
870 void FabcoinGUI::gotoSendToContractPage()
871 {
873 }
874 
875 void FabcoinGUI::gotoCallContractPage()
876 {
878 }
879 
880 void FabcoinGUI::gotoSignMessageTab(QString addr)
881 {
883 }
884 
885 void FabcoinGUI::gotoVerifyMessageTab(QString addr)
886 {
888 }
889 #endif // ENABLE_WALLET
890 
892 {
894  QString icon;
895  switch(count)
896  {
897  case 0: icon = ":/icons/connect_0"; break;
898  case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
899  case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
900  case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
901  default: icon = ":/icons/connect_4"; break;
902  }
903 
904  QString tooltip;
905 
906  if (clientModel->getNetworkActive()) {
907  tooltip = tr("%n active connection(s) to Fabcoin network", "", count) + QString(".<br>") + tr("Click to disable network activity.");
908  } else {
909  tooltip = tr("Network activity disabled.") + QString("<br>") + tr("Click to enable network activity again.");
910  icon = ":/icons/network_disabled";
911  }
912 
913  // Don't word-wrap this (fixed-width) tooltip
914  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
915  connectionsControl->setToolTip(tooltip);
916 
917  connectionsControl->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
918 }
919 
921 {
923 }
924 
925 void FabcoinGUI::setNetworkActive(bool networkActive)
926 {
928 }
929 
931 {
932  int64_t headersTipTime = clientModel->getHeaderTipTime();
933  int headersTipHeight = clientModel->getHeaderTipHeight();
934  int estHeadersLeft = (GetTime() - headersTipTime) / Params().GetnPowTargetSpacing(headersTipHeight);
935  if (estHeadersLeft > HEADER_HEIGHT_DELTA_SYNC)
936  progressBarLabel->setText(tr("Syncing Headers (%1%)...").arg(QString::number(100.0 / (headersTipHeight+estHeadersLeft)*headersTipHeight, 'f', 1)));
937 }
938 
939 void FabcoinGUI::setNumBlocks(int count, const QDateTime& blockDate, double nVerificationProgress, bool header)
940 {
941  if (modalOverlay)
942  {
943  if (header)
944  modalOverlay->setKnownBestHeight(count, blockDate);
945  else
946  modalOverlay->tipUpdate(count, blockDate, nVerificationProgress);
947  }
948  if (!clientModel)
949  return;
950 
951  // Prevent orphan statusbar messages (e.g. hover Quit in main menu, wait until chain-sync starts -> garbled text)
952  statusBar()->clearMessage();
953 
954  // Acquire current block source
955  enum BlockSource blockSource = clientModel->getBlockSource();
956  switch (blockSource) {
958  if (header) {
960  return;
961  }
962  progressBarLabel->setText(tr("Synchronizing with network..."));
964  break;
965  case BLOCK_SOURCE_DISK:
966  if (header) {
967  progressBarLabel->setText(tr("Indexing blocks on disk..."));
968  } else {
969  progressBarLabel->setText(tr("Processing blocks on disk..."));
970  }
971  break;
973  progressBarLabel->setText(tr("Reindexing blocks on disk..."));
974  break;
975  case BLOCK_SOURCE_NONE:
976  if (header) {
977  return;
978  }
979  progressBarLabel->setText(tr("Connecting to peers..."));
980  break;
981  }
982 
983  QString tooltip;
984 
985  QDateTime currentDate = QDateTime::currentDateTime();
986  qint64 secs = blockDate.secsTo(currentDate);
987 
988  tooltip = tr("Processed %n block(s) of transaction history.", "", count);
989 
990  // Set icon state: spinning if catching up, tick otherwise
991  if(secs < 90*60)
992  {
993  tooltip = tr("Up to date") + QString(".<br>") + tooltip;
994  labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
995 
996 #ifdef ENABLE_WALLET
997  if(walletFrame)
998  {
1000  modalOverlay->showHide(true, true);
1001  }
1002 #endif // ENABLE_WALLET
1003 
1004  progressBarLabel->setVisible(false);
1005  progressBar->setVisible(false);
1006 
1007  // notify tip changed when the sync is finished
1009  {
1010  fBatchProcessingMode = false;
1011  QMetaObject::invokeMethod(clientModel, "tipChanged", Qt::QueuedConnection);
1012  }
1013  }
1014  else
1015  {
1016  QString timeBehindText = GUIUtil::formatNiceTimeOffset(secs);
1017 
1018  progressBarLabel->setVisible(true);
1019  progressBar->setFormat(tr("%1 behind").arg(timeBehindText));
1020  progressBar->setMaximum(1000000000);
1021  progressBar->setValue(nVerificationProgress * 1000000000.0 + 0.5);
1022  progressBar->setVisible(true);
1023 
1024  tooltip = tr("Catching up...") + QString("<br>") + tooltip;
1025  if(count != prevBlocks)
1026  {
1027  labelBlocksIcon->setPixmap(QIcon(QString(
1028  ":/movies/spinner-%1").arg(spinnerFrame, 3, 10, QChar('0')))
1029  .pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1031  }
1032  prevBlocks = count;
1033 
1034 #ifdef ENABLE_WALLET
1035  if(walletFrame)
1036  {
1039  }
1040 #endif // ENABLE_WALLET
1041 
1042  tooltip += QString("<br>");
1043  tooltip += tr("Last received block was generated %1 ago.").arg(timeBehindText);
1044  tooltip += QString("<br>");
1045  tooltip += tr("Transactions after this will not yet be visible.");
1046  }
1047 
1048  // Don't word-wrap this (fixed-width) tooltip
1049  tooltip = QString("<nobr>") + tooltip + QString("</nobr>");
1050 
1051  labelBlocksIcon->setToolTip(tooltip);
1052  progressBarLabel->setToolTip(tooltip);
1053  progressBar->setToolTip(tooltip);
1054 }
1055 
1056 void FabcoinGUI::message(const QString &title, const QString &message, unsigned int style, bool *ret)
1057 {
1058  QString strTitle = tr("Fabcoin"); // default title
1059  // Default to information icon
1060  int nMBoxIcon = QMessageBox::Information;
1061  int nNotifyIcon = Notificator::Information;
1062 
1063  QString msgType;
1064 
1065  // Prefer supplied title over style based title
1066  if (!title.isEmpty()) {
1067  msgType = title;
1068  }
1069  else {
1070  switch (style) {
1072  msgType = tr("Error");
1073  break;
1075  msgType = tr("Warning");
1076  break;
1078  msgType = tr("Information");
1079  break;
1080  default:
1081  break;
1082  }
1083  }
1084  // Append title to "Fabcoin - "
1085  if (!msgType.isEmpty())
1086  strTitle += " - " + msgType;
1087 
1088  // Check for error/warning icon
1089  if (style & CClientUIInterface::ICON_ERROR) {
1090  nMBoxIcon = QMessageBox::Critical;
1091  nNotifyIcon = Notificator::Critical;
1092  }
1093  else if (style & CClientUIInterface::ICON_WARNING) {
1094  nMBoxIcon = QMessageBox::Warning;
1095  nNotifyIcon = Notificator::Warning;
1096  }
1097 
1098  // Display message
1099  if (style & CClientUIInterface::MODAL) {
1100  // Check for buttons, use OK as default, if none was supplied
1101  QMessageBox::StandardButton buttons;
1102  if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
1103  buttons = QMessageBox::Ok;
1104 
1106  QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
1107  int r = mBox.exec();
1108  if (ret != nullptr)
1109  *ret = r == QMessageBox::Ok;
1110  }
1111  else
1112  notificator->notify((Notificator::Class)nNotifyIcon, strTitle, message);
1113 }
1114 
1116 {
1117  QMainWindow::changeEvent(e);
1118 #ifndef Q_OS_MAC // Ignored on Mac
1119  if(e->type() == QEvent::WindowStateChange)
1120  {
1122  {
1123  QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
1124  if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
1125  {
1126  QTimer::singleShot(0, this, SLOT(hide()));
1127  e->ignore();
1128  }
1129  }
1130  }
1131 #endif
1132 }
1133 
1134 void FabcoinGUI::closeEvent(QCloseEvent *event)
1135 {
1136 #ifndef Q_OS_MAC // Ignored on Mac
1138  {
1140  {
1141  // close rpcConsole in case it was open to make some space for the shutdown window
1142  rpcConsole->close();
1143 
1144  QApplication::quit();
1145  }
1146  else
1147  {
1148  QMainWindow::showMinimized();
1149  event->ignore();
1150  }
1151  }
1152 #else
1153  QMainWindow::closeEvent(event);
1154 #endif
1155 }
1156 
1157 void FabcoinGUI::showEvent(QShowEvent *event)
1158 {
1159  // enable the debug window when the main window shows up
1160  openRPCConsoleAction->setEnabled(true);
1161  aboutAction->setEnabled(true);
1162  optionsAction->setEnabled(true);
1163 }
1164 
1165 #ifdef ENABLE_WALLET
1166 void FabcoinGUI::incomingTransaction(const QString& date, int unit, const CAmount& amount, const QString& type, const QString& address, const QString& label)
1167 {
1168  // On new transaction, make an info balloon
1169  QString msg = tr("Date: %1\n").arg(date) +
1170  tr("Amount: %1\n").arg(FabcoinUnits::formatWithUnit(unit, amount, true)) +
1171  tr("Type: %1\n").arg(type);
1172  if (!label.isEmpty())
1173  msg += tr("Label: %1\n").arg(label);
1174  else if (!address.isEmpty())
1175  msg += tr("Address: %1\n").arg(address);
1176  message((amount)<0 ? tr("Sent transaction") : tr("Incoming transaction"),
1178 }
1179 
1180 void FabcoinGUI::incomingTokenTransaction(const QString& date, const QString& amount, const QString& type, const QString& address, const QString& label, const QString& title)
1181 {
1182  // On new transaction, make an info balloon
1183  QString msg = tr("Date: %1\n").arg(date) +
1184  tr("Amount: %1\n").arg(amount) +
1185  tr("Type: %1\n").arg(type);
1186  if (!label.isEmpty())
1187  msg += tr("Label: %1\n").arg(label);
1188  else if (!address.isEmpty())
1189  msg += tr("Address: %1\n").arg(address);
1191 }
1192 #endif // ENABLE_WALLET
1193 
1194 void FabcoinGUI::dragEnterEvent(QDragEnterEvent *event)
1195 {
1196  // Accept only URIs
1197  if(event->mimeData()->hasUrls())
1198  event->acceptProposedAction();
1199 }
1200 
1201 void FabcoinGUI::dropEvent(QDropEvent *event)
1202 {
1203  if(event->mimeData()->hasUrls())
1204  {
1205  for (const QUrl &uri : event->mimeData()->urls())
1206  {
1207  Q_EMIT receivedURI(uri.toString());
1208  }
1209  }
1210  event->acceptProposedAction();
1211 }
1212 
1213 bool FabcoinGUI::eventFilter(QObject *object, QEvent *event)
1214 {
1215  // Catch status tip events
1216  if (event->type() == QEvent::StatusTip)
1217  {
1218  // Prevent adding text from setStatusTip(), if we currently use the status bar for displaying other stuff
1219  if (progressBarLabel->isVisible() || progressBar->isVisible())
1220  return true;
1221  }
1222  return QMainWindow::eventFilter(object, event);
1223 }
1224 
1225 #ifdef ENABLE_WALLET
1226 bool FabcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
1227 {
1228  // URI has to be valid
1229  if (walletFrame && walletFrame->handlePaymentRequest(recipient))
1230  {
1232  gotoSendCoinsPage();
1233  return true;
1234  }
1235  return false;
1236 }
1237 
1238 void FabcoinGUI::setHDStatus(int hdEnabled)
1239 {
1240  labelWalletHDStatusIcon->setPixmap(QIcon(hdEnabled ? ":/icons/hd_enabled" : ":/icons/hd_disabled").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1241  labelWalletHDStatusIcon->setToolTip(hdEnabled ? tr("HD key generation is <b>enabled</b>") : tr("HD key generation is <b>disabled</b>"));
1242 
1243  // eventually disable the QLabel to set its opacity to 50%
1244  labelWalletHDStatusIcon->setEnabled(hdEnabled);
1245 }
1246 
1247 void FabcoinGUI::setEncryptionStatus(int status)
1248 {
1249  switch(status)
1250  {
1252  labelWalletEncryptionIcon->hide();
1253  encryptWalletAction->setChecked(false);
1254  changePassphraseAction->setEnabled(false);
1255  unlockWalletAction->setVisible(false);
1256  lockWalletAction->setVisible(false);
1257  encryptWalletAction->setEnabled(true);
1258  break;
1259  case WalletModel::Unlocked:
1260  labelWalletEncryptionIcon->show();
1262  {
1263  labelWalletEncryptionIcon->setPixmap(QIcon(":/icons/lock_staking").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1264  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked for staking only</b>"));
1265  }
1266  else
1267  {
1268  labelWalletEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1269  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
1270  }
1271  encryptWalletAction->setChecked(true);
1272  changePassphraseAction->setEnabled(true);
1273  unlockWalletAction->setVisible(false);
1274  lockWalletAction->setVisible(true);
1275  encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
1276  break;
1277  case WalletModel::Locked:
1278  labelWalletEncryptionIcon->show();
1279  labelWalletEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
1280  labelWalletEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
1281  encryptWalletAction->setChecked(true);
1282  changePassphraseAction->setEnabled(true);
1283  unlockWalletAction->setVisible(true);
1284  lockWalletAction->setVisible(false);
1285  encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
1286  break;
1287  }
1288 }
1289 #endif // ENABLE_WALLET
1290 
1291 void FabcoinGUI::showNormalIfMinimized(bool fToggleHidden)
1292 {
1293  if(!clientModel)
1294  return;
1295 
1296  // activateWindow() (sometimes) helps with keyboard focus on Windows
1297  if (isHidden())
1298  {
1299  show();
1300  activateWindow();
1301  }
1302  else if (isMinimized())
1303  {
1304  showNormal();
1305  activateWindow();
1306  }
1307  else if (GUIUtil::isObscured(this))
1308  {
1309  raise();
1310  activateWindow();
1311  }
1312  else if(fToggleHidden)
1313  hide();
1314 }
1315 
1317 {
1318  showNormalIfMinimized(true);
1319 }
1320 
1322 {
1323  if(!pwalletMain)
1324  return;
1325 
1326  TRY_LOCK(cs_main, lockMain);
1327  if (!lockMain)
1328  return;
1329 
1330  TRY_LOCK(pwalletMain->cs_wallet, lockWallet);
1331  if (!lockWallet)
1332  return;
1333 
1334 #ifdef ENABLE_WALLET
1335  //if (pwalletMain)
1336  //nWeight = pwalletMain->GetStakeWeight();
1337 #endif
1338 }
1339 
1341 {
1342  if(ShutdownRequested())
1343  return;
1344 
1345  CWalletRef pwalletMain = vpwallets.empty() ? 0 : vpwallets[0];
1346  if(!pwalletMain)
1347  return;
1348 
1349  updateWeight(pwalletMain);
1350 
1351  int nLastCoinStakeSearchInterval =0;
1352  if (nLastCoinStakeSearchInterval && nWeight)
1353  {
1354  uint64_t nWeight = this->nWeight;
1355  uint64_t nNetworkWeight = 0 ;//GetPoSKernelPS();
1356  const Consensus::Params& consensusParams = Params().GetConsensus();
1357  int64_t nTargetSpacing = consensusParams.nPowTargetSpacing;
1358 
1359  unsigned nEstimateTime = nTargetSpacing * nNetworkWeight / nWeight;
1360 
1361  QString text;
1362  if (nEstimateTime < 60)
1363  {
1364  text = tr("%n second(s)", "", nEstimateTime);
1365  }
1366  else if (nEstimateTime < 60*60)
1367  {
1368  text = tr("%n minute(s)", "", nEstimateTime/60);
1369  }
1370  else if (nEstimateTime < 24*60*60)
1371  {
1372  text = tr("%n hour(s)", "", nEstimateTime/(60*60));
1373  }
1374  else
1375  {
1376  text = tr("%n day(s)", "", nEstimateTime/(60*60*24));
1377  }
1378 
1379  nWeight /= COIN;
1380  nNetworkWeight /= COIN;
1381 
1382  labelStakingIcon->setPixmap(QIcon(":/icons/staking_on").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1383  labelStakingIcon->setToolTip(tr("Staking.<br>Your weight is %1<br>Network weight is %2<br>Expected time to earn reward is %3").arg(nWeight).arg(nNetworkWeight).arg(text));
1384  }
1385  else
1386  {
1387  labelStakingIcon->setPixmap(QIcon(":/icons/staking_off").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE));
1388 
1389  if (g_connman == 0 || g_connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0)
1390  labelStakingIcon->setToolTip(tr("Not staking because wallet is offline"));
1391  else if (IsInitialBlockDownload())
1392  labelStakingIcon->setToolTip(tr("Not staking because wallet is syncing"));
1393  else if (!nWeight)
1394  labelStakingIcon->setToolTip(tr("Not staking because you don't have mature coins"));
1395  else if (pwalletMain && pwalletMain->IsLocked())
1396  labelStakingIcon->setToolTip(tr("Not staking because wallet is locked"));
1397  else
1398  labelStakingIcon->setToolTip(tr("Not staking"));
1399  }
1400 }
1401 
1403 {
1404  if (ShutdownRequested())
1405  {
1406  if(rpcConsole)
1407  rpcConsole->hide();
1408  qApp->quit();
1409  }
1410 }
1411 
1412 void FabcoinGUI::showProgress(const QString &title, int nProgress)
1413 {
1414  if (nProgress == 0)
1415  {
1416  progressDialog = new QProgressDialog(title, "", 0, 100);
1417  progressDialog->setWindowModality(Qt::ApplicationModal);
1418  progressDialog->setMinimumDuration(0);
1419  progressDialog->setCancelButton(0);
1420  progressDialog->setAutoClose(false);
1421  progressDialog->setValue(0);
1422  }
1423  else if (nProgress == 100)
1424  {
1425  if (progressDialog)
1426  {
1427  progressDialog->close();
1428  progressDialog->deleteLater();
1429  }
1430  }
1431  else if (progressDialog)
1432  progressDialog->setValue(nProgress);
1433 }
1434 
1435 void FabcoinGUI::setTrayIconVisible(bool fHideTrayIcon)
1436 {
1437  if (trayIcon)
1438  {
1439  trayIcon->setVisible(!fHideTrayIcon);
1440  }
1441 }
1442 
1444 {
1445  if (modalOverlay && (progressBar->isVisible() || modalOverlay->isLayerVisible()))
1447 }
1448 
1450 {
1451  if (modalBackupOverlay)
1453 }
1454 
1455 void FabcoinGUI::setTabBarInfo(QObject *into)
1456 {
1457  if(appTitleBar)
1458  {
1459  appTitleBar->setTabBarInfo(into);
1460  }
1461 }
1462 
1463 static bool ThreadSafeMessageBox(FabcoinGUI *gui, const std::string& message, const std::string& caption, unsigned int style)
1464 {
1465  bool modal = (style & CClientUIInterface::MODAL);
1466  // The SECURE flag has no effect in the Qt GUI.
1467  // bool secure = (style & CClientUIInterface::SECURE);
1468  style &= ~CClientUIInterface::SECURE;
1469  bool ret = false;
1470  // In case of modal message, use blocking connection to wait for user to click a button
1471  QMetaObject::invokeMethod(gui, "message",
1472  modal ? GUIUtil::blockingGUIThreadConnection() : Qt::QueuedConnection,
1473  Q_ARG(QString, QString::fromStdString(caption)),
1474  Q_ARG(QString, QString::fromStdString(message)),
1475  Q_ARG(unsigned int, style),
1476  Q_ARG(bool*, &ret));
1477  return ret;
1478 }
1479 
1481 {
1482  // Connect signals to client
1483  uiInterface.ThreadSafeMessageBox.connect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
1484  uiInterface.ThreadSafeQuestion.connect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
1485 }
1486 
1488 {
1489  // Disconnect signals from client
1490  uiInterface.ThreadSafeMessageBox.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _2, _3));
1491  uiInterface.ThreadSafeQuestion.disconnect(boost::bind(ThreadSafeMessageBox, this, _1, _3, _4));
1492 }
1493 
1495 {
1496  if (clientModel) {
1498  }
1499 }
1500 
1501 void FabcoinGUI::addDockWindows(Qt::DockWidgetArea area, QWidget* widget)
1502 {
1503  QDockWidget *dock = new QDockWidget(this);
1504  dock->setFeatures(QDockWidget::NoDockWidgetFeatures);
1505  dock->setAllowedAreas(area);
1506  QWidget* titleBar = new QWidget();
1507  titleBar->setMaximumSize(0, 0);
1508  dock->setTitleBarWidget(titleBar);
1509  dock->setWidget(widget);
1510  addDockWidget(area, dock);
1511 }
1512 
1514  optionsModel(0),
1515  menu(0)
1516 {
1518  setToolTip(tr("Unit to show amounts in. Click to select another unit."));
1519  QList<FabcoinUnits::Unit> units = FabcoinUnits::availableUnits();
1520  int max_width = 0;
1521  const QFontMetrics fm(font());
1522  for (const FabcoinUnits::Unit unit : units)
1523  {
1524  max_width = qMax(max_width, fm.width(FabcoinUnits::name(unit)));
1525  }
1526  setMinimumSize(max_width, 0);
1527  setAlignment(Qt::AlignRight | Qt::AlignVCenter);
1528 }
1529 
1532 {
1533  onDisplayUnitsClicked(event->pos());
1534 }
1535 
1538 {
1539  menu = new QMenu(this);
1541  {
1542  QAction *menuAction = new QAction(QString(FabcoinUnits::name(u)), this);
1543  menuAction->setData(QVariant(u));
1544  menu->addAction(menuAction);
1545  }
1546  connect(menu,SIGNAL(triggered(QAction*)),this,SLOT(onMenuSelection(QAction*)));
1547 }
1548 
1551 {
1552  if (_optionsModel)
1553  {
1554  this->optionsModel = _optionsModel;
1555 
1556  // be aware of a display unit change reported by the OptionsModel object.
1557  connect(_optionsModel,SIGNAL(displayUnitChanged(int)),this,SLOT(updateDisplayUnit(int)));
1558 
1559  // initialize the display units label with the current value in the model.
1560  updateDisplayUnit(_optionsModel->getDisplayUnit());
1561  }
1562 }
1563 
1566 {
1567  setText(FabcoinUnits::name(newUnits));
1568 }
1569 
1572 {
1573  QPoint globalPos = mapToGlobal(point);
1574  menu->exec(globalPos);
1575 }
1576 
1579 {
1580  if (action)
1581  {
1582  optionsModel->setDisplayUnit(action->data());
1583  }
1584 }
TitleBar * appTitleBar
Definition: fabcoingui.h:101
bool handlePaymentRequest(const SendCoinsRecipient &recipient)
Definition: walletframe.cpp:98
void unsubscribeFromCoreSignals()
Disconnect core signals from GUI client.
bool setCurrentWallet(const QString &name)
Definition: walletframe.cpp:69
void toggleNetworkActive()
Toggle networking.
bool getMinimizeOnClose()
Definition: optionsmodel.h:69
void createTitleBars()
Create title bar.
Definition: fabcoingui.cpp:588
void help()
Definition: main.cpp:39
Local Fabcoin RPC console.
Definition: rpcconsole.h:31
std::vector< CWalletRef > vpwallets
Definition: wallet.cpp:41
void showProgress(const QString &title, int nProgress)
Show progress dialog e.g.
void dropEvent(QDropEvent *event)
void mousePressEvent(QMouseEvent *event)
So that it responds to left-button clicks.
UnitDisplayStatusBarControl(const PlatformStyle *platformStyle)
void trayIconActivated(QSystemTrayIcon::ActivationReason reason)
Handle tray icon clicked.
Definition: fabcoingui.cpp:762
QAction * sendToContractAction
Definition: fabcoingui.h:129
#define TRY_LOCK(cs, name)
Definition: sync.h:177
static bool isWalletEnabled()
bool eventFilter(QObject *object, QEvent *event)
void gotoAddTokenPage()
Switch to Add Token page.
UnitDisplayStatusBarControl * unitDisplayControl
Definition: fabcoingui.h:90
#define PACKAGE_NAME
void updateNetworkState()
Update UI with latest network info from model.
Definition: fabcoingui.cpp:891
double getVerificationProgress(const CBlockIndex *tip) const
void closeEvent(QCloseEvent *event)
QAction * lockWalletAction
Definition: fabcoingui.h:122
CCriticalSection cs_wallet
Definition: wallet.h:748
void setClientModel(ClientModel *clientModel)
Set the client model.
Definition: fabcoingui.cpp:599
void setTabBarInfo(QObject *info)
setTabBarInfo Set the tab bar info
Definition: titlebar.cpp:44
QMenuBar * appMenuBar
Definition: fabcoingui.h:100
bool ShutdownRequested()
Definition: init.cpp:126
static const std::string DEFAULT_UIPLATFORM
Definition: fabcoingui.h:57
void createTrayIcon(const NetworkStyle *networkStyle)
Create system tray icon and notification.
Definition: fabcoingui.cpp:712
ClientModel * clientModel
Definition: fabcoingui.h:87
FabcoinVersionChecker * fabcoinVersionChecker
Definition: fabcoingui.h:142
QAction * createContractAction
Definition: fabcoingui.h:128
void gotoCreateContractPage()
Switch to create contract page.
void createToolBars()
Create the toolbars.
Definition: fabcoingui.cpp:560
QAction * aboutAction
Definition: fabcoingui.h:112
ModalOverlay * modalOverlay
Definition: fabcoingui.h:141
size_t count
Definition: ExecStats.cpp:37
bool getNetworkActive() const
Return true if network activity in core is enabled.
const Consensus::Params & GetConsensus() const
Definition: chainparams.h:60
CCriticalSection cs_main
Definition: validation.cpp:77
int prevBlocks
Keep track of previous number of blocks, to detect progress.
Definition: fabcoingui.h:146
QAction * optionsAction
Definition: fabcoingui.h:115
int getNumConnections(unsigned int flags=CONNECTIONS_ALL) const
Return number of connections, default is in- and outbound (total)
Definition: clientmodel.cpp:57
void tipUpdate(int count, const QDateTime &blockDate, double nVerificationProgress)
Qt::ConnectionType blockingGUIThreadConnection()
Get connection type to call object slot in GUI thread with invokeMethod.
Definition: guiutil.cpp:394
bool GetBoolArg(const std::string &strArg, bool fDefault)
Return boolean argument or default value.
Definition: util.cpp:520
QAction * changePassphraseAction
Definition: fabcoingui.h:120
void setNumConnections(int count)
Set number of connections shown in the UI.
Definition: fabcoingui.cpp:920
void toggleHidden()
Simply calls showNormalIfMinimized(true) for use in SLOT() macro.
OptionsModel * getOptionsModel()
bool IsLocked() const
Definition: crypter.h:145
Fabcoin GUI main class.
Definition: fabcoingui.h:51
ModalOverlay * modalBackupOverlay
Definition: fabcoingui.h:143
QAction * quitAction
Definition: fabcoingui.h:105
QAction * encryptWalletAction
Definition: fabcoingui.h:117
bool getHideTrayIcon()
Definition: optionsmodel.h:67
Macintosh-specific dock icon handler.
Mask of all available buttons in CClientUIInterface::MessageBoxFlags This needs to be updated...
Definition: ui_interface.h:59
void changeEvent(QEvent *e)
void aboutClicked()
Show about dialog.
Definition: fabcoingui.cpp:782
void showHelpMessageClicked()
Show help message dialog.
Definition: fabcoingui.cpp:805
QAction * smartContractAction
Definition: fabcoingui.h:127
void updateHeadersSyncProgressLabel()
Definition: fabcoingui.cpp:930
bool hasWalletBackup()
void buildUi()
buildUi Construct the layout of the composite GUI control
void addAction(QAction *action)
addAction Add action to the navigation bar
void gotoSendTokenPage()
Switch to Send Token page.
Notify user of potential problem.
Definition: notificator.h:39
NavigationBar * appNavigationBar
Definition: fabcoingui.h:102
void showDebugWindowActivateConsole()
Show debug window and set focus to the console.
Definition: fabcoingui.cpp:799
Modal overlay to display information about the chain-sync state.
Definition: modaloverlay.h:19
void showModalOverlay()
QAction * receiveCoinsMenuAction
Definition: fabcoingui.h:114
Signals for UI communication.
Definition: ui_interface.h:27
void removeAllWallets()
Definition: walletframe.cpp:90
FabcoinGUI(const PlatformStyle *platformStyle, const NetworkStyle *networkStyle, QWidget *parent=0)
Definition: fabcoingui.cpp:92
void setOptionsModel(OptionsModel *optionsModel)
Lets the control know about the Options Model (and its signals)
void gotoCallContractPage()
Switch to call contract page.
void showDebugWindow()
Show debug window.
Definition: fabcoingui.cpp:791
void addDockWindows(Qt::DockWidgetArea area, QWidget *widget)
Add docking windows to the main windows.
void receivedURI(const QString &uri)
Signal raised when a URI was entered or dragged to the GUI.
Force blocking, modal message box dialog (not just OS notification)
Definition: ui_interface.h:63
void showOutOfSyncWarning(bool fShow)
QAction * sendTokenAction
Definition: fabcoingui.h:132
void setIcon(const QIcon &icon)
void setWalletActionsEnabled(bool enabled)
Enable or disable all wallet-related actions.
Definition: fabcoingui.cpp:693
static QString formatWithUnit(int unit, const CAmount &amount, bool plussign=false, SeparatorStyle separators=separatorStandard)
Format as string (with unit)
void setClientModel(ClientModel *model)
Definition: rpcconsole.cpp:545
void gotoHistoryPage()
Switch to history (transactions) page.
QAction * addTokenAction
Definition: fabcoingui.h:134
int64_t CAmount
Amount in lius (Can be negative)
Definition: amount.h:15
int64_t GetnPowTargetSpacing(uint32_t nHeight=0) const
Definition: chainparams.h:74
bool fBatchProcessingMode
Definition: wallet.cpp:50
QLabel * labelWalletEncryptionIcon
Definition: fabcoingui.h:91
void gotoOverviewPage()
Switch to overview (home) page.
QAction * aboutQtAction
Definition: fabcoingui.h:123
static MacDockIconHandler * instance()
QLabel * labelBlocksIcon
Definition: fabcoingui.h:94
void setDisplayUnit(const QVariant &value)
Updates current unit in memory, settings and emits displayUnitChanged(newUnit) signal.
void setClientModel(ClientModel *clientModel)
Definition: walletframe.cpp:38
void setMainWindow(QMainWindow *window)
bool isObscured(QWidget *w)
Definition: guiutil.cpp:413
Notificator * notificator
Definition: fabcoingui.h:138
QAction * toggleHideAction
Definition: fabcoingui.h:116
OptionsModel * optionsModel
Definition: fabcoingui.h:316
void setKnownBestHeight(int count, const QDateTime &blockDate)
uint64_t nWeight
Current weight of the wallet.
Definition: fabcoingui.h:152
The TitleBar class Title bar widget.
Definition: titlebar.h:20
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.
const char * name
Definition: rest.cpp:36
bool addWallet(const QString &name, WalletModel *walletModel)
Definition: walletframe.cpp:43
QDateTime getLastBlockDate() const
boost::signals2::signal< bool(const std::string &message, const std::string &noninteractive_message, const std::string &caption, unsigned int style), boost::signals2::last_value< bool > > ThreadSafeQuestion
If possible, ask the user a question.
Definition: ui_interface.h:78
BlockSource
Definition: clientmodel.h:23
void updateDisplayUnit(int newUnits)
When Display Units are changed on OptionsModel it will refresh the display text of the control on the...
CWallet * pwalletMain
void createTrayIconMenu()
Create system tray menu (or setup the dock menu)
Definition: fabcoingui.cpp:725
QAction * receiveTokenAction
Definition: fabcoingui.h:133
Unit
Fabcoin units.
Definition: fabcoinunits.h:59
void setTabFocus(enum TabTypes tabType)
set which tab has the focus (is visible)
int64_t nPowTargetSpacing
Definition: params.h:82
QAction * showHelpMessageAction
Definition: fabcoingui.h:126
void toggleVisibility()
void optionsClicked()
Show configuration dialog.
Definition: fabcoingui.cpp:772
void subscribeToCoreSignals()
Connect core signals to GUI client.
void setModel(OptionsModel *model)
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network) ...
void message(const QString &title, const QString &message, unsigned int style, bool *ret=nullptr)
Notify the user of an event from the core network or transaction handling code.
void setNetworkActive(bool networkActive)
Set network state shown in the UI.
Definition: fabcoingui.cpp:925
void updateStakingIcon()
Update staking icon.
Cross-platform desktop notification client.
Definition: notificator.h:24
static const QString DEFAULT_WALLET
Display name for default wallet name.
Definition: fabcoingui.h:56
QAction * unlockWalletAction
Definition: fabcoingui.h:121
void createMenuBar()
Create the menu bar and sub-menus.
Definition: fabcoingui.cpp:512
int getHeaderTipHeight() const
Definition: clientmodel.cpp:79
QProgressBar * progressBar
Definition: fabcoingui.h:97
Informational message.
Definition: notificator.h:38
QAction * openRPCConsoleAction
Definition: fabcoingui.h:124
QSystemTrayIcon * trayIcon
Definition: fabcoingui.h:136
The NavigationBar class Custom control for navigation bar.
Definition: navigationbar.h:13
void mapGroup(QAction *action, QList< QAction * > list)
mapGroup Map the action with group
int getDisplayUnit()
Definition: optionsmodel.h:70
Parameters that influence chain consensus.
Definition: params.h:39
QAction * verifyMessageAction
Definition: fabcoingui.h:111
Model for Fabcoin network client.
Definition: clientmodel.h:38
An error occurred.
Definition: notificator.h:40
QAction * sendCoinsAction
Definition: fabcoingui.h:106
int spinnerFrame
Definition: fabcoingui.h:147
ClickableProgressBar ProgressBar
Definition: guiutil.h:247
void gotoSignMessageTab(QString addr="")
Show Sign/Verify Message dialog and switch to sign message tab.
QLabel * connectionsControl
Definition: fabcoingui.h:93
QAction * usedReceivingAddressesAction
Definition: fabcoingui.h:109
void showHide(bool hide=false, bool userRequested=false)
int getNumBlocks() const
Definition: clientmodel.cpp:73
bool fCheckForUpdates
Definition: wallet.cpp:49
QLabel * progressBarLabel
Definition: fabcoingui.h:95
const PlatformStyle * platformStyle
Definition: fabcoingui.h:149
void createActions()
Create the main UI actions.
Definition: fabcoingui.cpp:336
QAction * openAction
Definition: fabcoingui.h:125
bool isLayerVisible()
Definition: modaloverlay.h:42
ArgsManager gArgs
Definition: util.cpp:94
void gotoSendCoinsPage(QString addr="")
Switch to send coins page.
void updateWeight(CWalletRef pwalletMain)
Update the current weight of the wallet.
QAction * overviewAction
Definition: fabcoingui.h:103
void gotoReceiveCoinsPage()
Switch to receive coins page.
static QString name(int unit)
Short name.
QAction * signMessageAction
Definition: fabcoingui.h:110
void setTabBarInfo(QObject *into)
PlatformStyle::TableColorType type
Definition: rpcconsole.cpp:61
Interface from Qt to configuration data structure for Fabcoin client.
Definition: optionsmodel.h:22
void setTrayIconVisible(bool)
When hideTrayIcon setting is changed in OptionsModel hide or show the icon accordingly.
QIcon MultiStatesIcon(const QString &resourcename, StateType type=NavBar, QColor color=Qt::white, QColor colorAlt=0x2d2d2d) const
Get multi-states icon.
const CChainParams & Params()
Return the currently selected parameters.
QMenu * trayIconMenu
Definition: fabcoingui.h:137
Interface to Fabcoin wallet from Qt view code.
Definition: walletmodel.h:103
QString getURI()
bool fWalletUnlockStakingOnly
Definition: wallet.cpp:328
static QList< Unit > availableUnits()
Get list of units, for drop-down box.
QAction * historyAction
Definition: fabcoingui.h:104
QIcon MenuColorIcon(const QString &filename) const
Colorize an icon (given filename) with the menu text color.
WalletFrame * walletFrame
Definition: fabcoingui.h:88
int64_t getHeaderTipTime() const
Definition: clientmodel.cpp:93
QAction * receiveCoinsAction
Definition: fabcoingui.h:113
QLabel * labelWalletHDStatusIcon
Definition: fabcoingui.h:92
QLabel * labelStakingIcon
Definition: fabcoingui.h:96
A CWallet is an extension of a keystore, which also maintains a set of transactions and balances...
Definition: wallet.h:672
std::unique_ptr< CConnman > g_connman
Definition: init.cpp:75
const QIcon & getTrayAndWindowIcon() const
Definition: networkstyle.h:21
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:75
#define e(i)
Definition: sha.cpp:733
"Help message" dialog box
Definition: utilitydialog.h:18
RPCConsole * rpcConsole
Definition: fabcoingui.h:139
void gotoSendToContractPage()
Switch to send contract page.
QAction * QRCTokenAction
Definition: fabcoingui.h:131
QAction * callContractAction
Definition: fabcoingui.h:130
QAction * sendCoinsMenuAction
Definition: fabcoingui.h:107
void setNetworkActive(bool active)
Toggle network activity state in core.
Preferences dialog.
Definition: optionsdialog.h:35
HelpMessageDialog * helpMessageDialog
Definition: fabcoingui.h:140
QString formatNiceTimeOffset(qint64 secs)
Definition: guiutil.cpp:942
void createContextMenu()
Creates context menu, its actions, and wires up all the relevant signals for mouse events...
QProgressDialog * progressDialog
Definition: fabcoingui.h:98
int64_t GetTime()
GetTimeMicros() and GetTimeMillis() both return the system time, but in different units...
Definition: utiltime.cpp:19
struct evm_uint160be address(struct evm_env *env)
Definition: capi.c:13
void showEvent(QShowEvent *event)
const QIcon & getAppIcon() const
Definition: networkstyle.h:20
CClientUIInterface uiInterface
Definition: ui_interface.cpp:8
QAction * restoreWalletAction
Definition: fabcoingui.h:119
bool enableWallet
Definition: fabcoingui.h:76
#define FABCOIN_RELEASES
void setNumBlocks(int count, const QDateTime &blockDate, double nVerificationProgress, bool headers)
Set number of blocks and last block date shown in the UI.
Definition: fabcoingui.cpp:939
void showNormalIfMinimized(bool fToggleHidden=false)
Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHid...
bool getMinimizeToTray()
Definition: optionsmodel.h:68
void setModel(WalletModel *_model)
setModel Set wallet model
Definition: titlebar.cpp:34
bool showBackupOverlay
Switch for showing the backup overlay modal screen.
Definition: fabcoingui.cpp:90
QAction * usedSendingAddressesAction
Definition: fabcoingui.h:108
A container for embedding all wallet-related controls into FabcoinGUI.
Definition: walletframe.h:29
enum BlockSource getBlockSource() const
Returns enum BlockSource of the current importing/syncing state.
void onDisplayUnitsClicked(const QPoint &point)
Shows context menu with Display Unit options by the mouse coordinates.
void detectShutdown()
called by a timer to check if fRequestShutdown has been set
void dragEnterEvent(QDragEnterEvent *event)
void onMenuSelection(QAction *action)
Tells underlying optionsModel to update its current display unit.
void gotoReceiveTokenPage()
Switch to Receive Token page.
QAction * backupWalletAction
Definition: fabcoingui.h:118
Predefined combinations for certain default usage cases.
Definition: ui_interface.h:69
void showModalBackupOverlay()
vector< pair< u256, string > > const & units()
Get information concerning the currency denominations.
Definition: Common.cpp:74
#define SPINNER_FRAMES
Definition: guiconstants.h:49
const QString & getTitleAddText() const
Definition: networkstyle.h:22