4 * W.J. van der Laan 2011
5 * The Bitcoin Developers 2011
8 #include "checkpoints.h"
10 #include "bitcoingui.h"
11 #include "transactiontablemodel.h"
12 #include "addressbookpage.h"
13 #include "sendcoinsdialog.h"
14 #include "optionsdialog.h"
15 #include "aboutdialog.h"
16 #include "clientmodel.h"
17 #include "walletmodel.h"
18 #include "editaddressdialog.h"
19 #include "optionsmodel.h"
20 #include "transactiondescdialog.h"
21 #include "addresstablemodel.h"
22 #include "transactionview.h"
23 #include "overviewpage.h"
24 #include "bitcoinunits.h"
25 #include "guiconstants.h"
26 #include "askpassphrasedialog.h"
27 #include "notificator.h"
30 #include "macdockiconhandler.h"
33 #include <QApplication>
34 #include <QMainWindow>
39 #include <QVBoxLayout>
44 #include <QPushButton>
46 #include <QMessageBox>
47 #include <QProgressBar>
48 #include <QStackedWidget>
53 #include <QDragEnterEvent>
58 BitcoinGUI::BitcoinGUI(QWidget *parent):
62 encryptWalletAction(0),
63 changePassphraseAction(0),
69 setWindowTitle(tr("Bitcoin Wallet"));
71 setWindowIcon(QIcon(":icons/bitcoin"));
73 setUnifiedTitleAndToolBarOnMac(true);
74 QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
79 // Create actions for the toolbar, menu bar and tray/dock icon
82 // Create application menu bar
85 // Create the toolbars
88 // Create the tray icon (or setup the dock icon)
92 overviewPage = new OverviewPage();
94 transactionsPage = new QWidget(this);
95 QVBoxLayout *vbox = new QVBoxLayout();
96 transactionView = new TransactionView(this);
97 vbox->addWidget(transactionView);
98 transactionsPage->setLayout(vbox);
100 addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
102 receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);
104 sendCoinsPage = new SendCoinsDialog(this);
106 centralWidget = new QStackedWidget(this);
107 centralWidget->addWidget(overviewPage);
108 centralWidget->addWidget(transactionsPage);
109 centralWidget->addWidget(addressBookPage);
110 centralWidget->addWidget(receiveCoinsPage);
111 centralWidget->addWidget(sendCoinsPage);
112 setCentralWidget(centralWidget);
117 // Status bar notification icons
118 QFrame *frameBlocks = new QFrame();
119 //frameBlocks->setFrameStyle(QFrame::Panel | QFrame::Sunken);
120 frameBlocks->setContentsMargins(0,0,0,0);
121 frameBlocks->setMinimumWidth(56);
122 frameBlocks->setMaximumWidth(56);
123 QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
124 frameBlocksLayout->setContentsMargins(3,0,3,0);
125 frameBlocksLayout->setSpacing(3);
126 labelEncryptionIcon = new QLabel();
127 labelConnectionsIcon = new QLabel();
128 labelBlocksIcon = new QLabel();
129 frameBlocksLayout->addStretch();
130 frameBlocksLayout->addWidget(labelEncryptionIcon);
131 frameBlocksLayout->addStretch();
132 frameBlocksLayout->addWidget(labelConnectionsIcon);
133 frameBlocksLayout->addStretch();
134 frameBlocksLayout->addWidget(labelBlocksIcon);
135 frameBlocksLayout->addStretch();
137 // Progress bar for blocks download
138 progressBarLabel = new QLabel(tr("Synchronizing with network..."));
139 progressBarLabel->setVisible(false);
140 progressBar = new QProgressBar();
141 progressBar->setToolTip(tr("Block chain synchronization in progress"));
142 progressBar->setVisible(false);
144 statusBar()->addWidget(progressBarLabel);
145 statusBar()->addWidget(progressBar);
146 statusBar()->addPermanentWidget(frameBlocks);
148 syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);
150 // Clicking on a transaction on the overview page simply sends you to transaction history page
151 connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
153 // Doubleclicking on a transaction on the transaction history page shows details
154 connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
159 BitcoinGUI::~BitcoinGUI()
166 void BitcoinGUI::createActions()
168 QActionGroup *tabGroup = new QActionGroup(this);
170 overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
171 overviewAction->setToolTip(tr("Show general overview of wallet"));
172 overviewAction->setCheckable(true);
173 overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
174 tabGroup->addAction(overviewAction);
176 historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
177 historyAction->setToolTip(tr("Browse transaction history"));
178 historyAction->setCheckable(true);
179 historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
180 tabGroup->addAction(historyAction);
182 addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
183 addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels"));
184 addressBookAction->setCheckable(true);
185 addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
186 tabGroup->addAction(addressBookAction);
188 receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
189 receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
190 receiveCoinsAction->setCheckable(true);
191 receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
192 tabGroup->addAction(receiveCoinsAction);
194 sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
195 sendCoinsAction->setToolTip(tr("Send coins to a bitcoin address"));
196 sendCoinsAction->setCheckable(true);
197 sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
198 tabGroup->addAction(sendCoinsAction);
200 connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormal()));
201 connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
202 connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormal()));
203 connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
204 connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormal()));
205 connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
206 connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(showNormal()));
207 connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
208 connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormal()));
209 connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
211 quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
212 quitAction->setToolTip(tr("Quit application"));
213 quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
214 quitAction->setMenuRole(QAction::QuitRole);
215 aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About %1").arg(qApp->applicationName()), this);
216 aboutAction->setToolTip(tr("Show information about Bitcoin"));
217 aboutAction->setMenuRole(QAction::AboutRole);
218 aboutQtAction = new QAction(tr("About &Qt"), this);
219 aboutQtAction->setToolTip(tr("Show information about Qt"));
220 aboutQtAction->setMenuRole(QAction::AboutQtRole);
221 optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
222 optionsAction->setToolTip(tr("Modify configuration options for bitcoin"));
223 optionsAction->setMenuRole(QAction::PreferencesRole);
224 openBitcoinAction = new QAction(QIcon(":/icons/bitcoin"), tr("Open &Bitcoin"), this);
225 openBitcoinAction->setToolTip(tr("Show the Bitcoin window"));
226 exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
227 exportAction->setToolTip(tr("Export the current view to a file"));
228 encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet"), this);
229 encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
230 encryptWalletAction->setCheckable(true);
231 changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase"), this);
232 changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
234 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
235 connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
236 connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
237 connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
238 connect(openBitcoinAction, SIGNAL(triggered()), this, SLOT(showNormal()));
239 connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
240 connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
243 void BitcoinGUI::createMenuBar()
246 // Create a decoupled menu bar on Mac which stays even if the window is closed
247 appMenuBar = new QMenuBar();
249 // Get the main window's menu bar on other platforms
250 appMenuBar = menuBar();
253 // Configure the menus
254 QMenu *file = appMenuBar->addMenu(tr("&File"));
255 file->addAction(quitAction);
257 QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
258 settings->addAction(encryptWalletAction);
259 settings->addAction(changePassphraseAction);
260 settings->addSeparator();
261 settings->addAction(optionsAction);
263 QMenu *help = appMenuBar->addMenu(tr("&Help"));
264 help->addAction(aboutAction);
265 help->addAction(aboutQtAction);
268 void BitcoinGUI::createToolBars()
270 QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
271 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
272 toolbar->addAction(overviewAction);
273 toolbar->addAction(sendCoinsAction);
274 toolbar->addAction(receiveCoinsAction);
275 toolbar->addAction(historyAction);
276 toolbar->addAction(addressBookAction);
278 QToolBar *toolbar2 = addToolBar(tr("Actions toolbar"));
279 toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
280 toolbar2->addAction(exportAction);
283 void BitcoinGUI::setClientModel(ClientModel *clientModel)
285 this->clientModel = clientModel;
288 if(clientModel->isTestNet())
290 QString title_testnet = windowTitle() + QString(" ") + tr("[testnet]");
291 setWindowTitle(title_testnet);
293 setWindowIcon(QIcon(":icons/bitcoin_testnet"));
295 MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
299 trayIcon->setToolTip(title_testnet);
300 trayIcon->setIcon(QIcon(":/icons/toolbar_testnet"));
304 // Keep up to date with client
305 setNumConnections(clientModel->getNumConnections());
306 connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
308 setNumBlocks(clientModel->getNumBlocks());
309 connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
311 // Report errors from network/worker thread
312 connect(clientModel, SIGNAL(error(QString,QString)), this, SLOT(error(QString,QString)));
316 void BitcoinGUI::setWalletModel(WalletModel *walletModel)
318 this->walletModel = walletModel;
321 // Report errors from wallet thread
322 connect(walletModel, SIGNAL(error(QString,QString)), this, SLOT(error(QString,QString)));
324 // Put transaction list in tabs
325 transactionView->setModel(walletModel);
327 overviewPage->setModel(walletModel);
328 addressBookPage->setModel(walletModel->getAddressTableModel());
329 receiveCoinsPage->setModel(walletModel->getAddressTableModel());
330 sendCoinsPage->setModel(walletModel);
332 setEncryptionStatus(walletModel->getEncryptionStatus());
333 connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int)));
335 // Balloon popup for new transaction
336 connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
337 this, SLOT(incomingTransaction(QModelIndex,int,int)));
339 // Ask for passphrase if needed
340 connect(walletModel, SIGNAL(requireUnlock()), this, SLOT(unlockWallet()));
344 void BitcoinGUI::createTrayIcon()
348 trayIcon = new QSystemTrayIcon(this);
349 trayIconMenu = new QMenu(this);
350 trayIcon->setContextMenu(trayIconMenu);
351 trayIcon->setToolTip("Bitcoin client");
352 trayIcon->setIcon(QIcon(":/icons/toolbar"));
353 connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
354 this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
357 // Note: On Mac, the dock icon is used to provide the tray's functionality.
358 MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
359 connect(dockIconHandler, SIGNAL(dockIconClicked()), openBitcoinAction, SLOT(trigger()));
360 trayIconMenu = dockIconHandler->dockMenu();
363 // Configuration of the tray icon (or dock icon) icon menu
364 trayIconMenu->addAction(openBitcoinAction);
365 trayIconMenu->addSeparator();
366 trayIconMenu->addAction(receiveCoinsAction);
367 trayIconMenu->addAction(sendCoinsAction);
368 trayIconMenu->addSeparator();
369 trayIconMenu->addAction(optionsAction);
370 #ifndef Q_WS_MAC // This is built-in on Mac
371 trayIconMenu->addSeparator();
372 trayIconMenu->addAction(quitAction);
375 notificator = new Notificator(tr("bitcoin-qt"), trayIcon);
379 void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
381 if(reason == QSystemTrayIcon::Trigger)
383 // Click on system tray icon triggers "open bitcoin"
384 openBitcoinAction->trigger();
389 void BitcoinGUI::optionsClicked()
391 if(!clientModel || !clientModel->getOptionsModel())
394 dlg.setModel(clientModel->getOptionsModel());
398 void BitcoinGUI::aboutClicked()
401 dlg.setModel(clientModel);
405 void BitcoinGUI::setNumConnections(int count)
410 case 0: icon = ":/icons/connect_0"; break;
411 case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
412 case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
413 case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
414 default: icon = ":/icons/connect_4"; break;
416 labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
417 labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count));
420 void BitcoinGUI::setNumBlocks(int count)
424 int total = clientModel->getNumBlocksOfPeers();
429 if (clientModel->getStatusBarWarnings() == "")
431 progressBarLabel->setVisible(true);
432 progressBarLabel->setText(tr("Synchronizing with network..."));
433 progressBar->setVisible(true);
434 progressBar->setMaximum(total);
435 progressBar->setValue(count);
439 progressBarLabel->setText(clientModel->getStatusBarWarnings());
440 progressBarLabel->setVisible(true);
441 progressBar->setVisible(false);
443 tooltip = tr("Downloaded %1 of %2 blocks of transaction history.").arg(count).arg(total);
447 if (clientModel->getStatusBarWarnings() == "")
448 progressBarLabel->setVisible(false);
451 progressBarLabel->setText(clientModel->getStatusBarWarnings());
452 progressBarLabel->setVisible(true);
454 progressBar->setVisible(false);
455 tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
458 QDateTime now = QDateTime::currentDateTime();
459 QDateTime lastBlockDate = clientModel->getLastBlockDate();
460 int secs = lastBlockDate.secsTo(now);
463 // Represent time from last generated block in human readable text
466 // Fully up to date. Leave text empty.
470 text = tr("%n second(s) ago","",secs);
472 else if(secs < 60*60)
474 text = tr("%n minute(s) ago","",secs/60);
476 else if(secs < 24*60*60)
478 text = tr("%n hour(s) ago","",secs/(60*60));
482 text = tr("%n day(s) ago","",secs/(60*60*24));
485 // Set icon state: spinning if catching up, tick otherwise
486 if(secs < 90*60 && count >= Checkpoints::GetTotalBlocksEstimate())
488 tooltip = tr("Up to date") + QString(".\n") + tooltip;
489 labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
493 tooltip = tr("Catching up...") + QString("\n") + tooltip;
494 labelBlocksIcon->setMovie(syncIconMovie);
495 syncIconMovie->start();
500 tooltip += QString("\n");
501 tooltip += tr("Last received block was generated %1.").arg(text);
504 labelBlocksIcon->setToolTip(tooltip);
505 progressBarLabel->setToolTip(tooltip);
506 progressBar->setToolTip(tooltip);
509 void BitcoinGUI::refreshStatusBar()
511 /* Might display multiple times in the case of multiple alerts
512 static QString prevStatusBar;
513 QString newStatusBar = clientModel->getStatusBarWarnings();
514 if (prevStatusBar != newStatusBar)
516 prevStatusBar = newStatusBar;
517 error(tr("Network Alert"), newStatusBar);
519 setNumBlocks(clientModel->getNumBlocks());
522 void BitcoinGUI::error(const QString &title, const QString &message, bool modal)
524 // Report errors from network/worker thread
527 QMessageBox::critical(this, title, message, QMessageBox::Ok, QMessageBox::Ok);
529 notificator->notify(Notificator::Critical, title, message);
533 void BitcoinGUI::changeEvent(QEvent *e)
535 QMainWindow::changeEvent(e);
536 #ifndef Q_WS_MAC // Ignored on Mac
537 if(e->type() == QEvent::WindowStateChange)
539 if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray())
541 QWindowStateChangeEvent *wsevt = static_cast<QWindowStateChangeEvent*>(e);
542 if(!(wsevt->oldState() & Qt::WindowMinimized) && isMinimized())
544 QTimer::singleShot(0, this, SLOT(hide()));
552 void BitcoinGUI::closeEvent(QCloseEvent *event)
556 #ifndef Q_WS_MAC // Ignored on Mac
557 if(!clientModel->getOptionsModel()->getMinimizeToTray() &&
558 !clientModel->getOptionsModel()->getMinimizeOnClose())
564 QMainWindow::closeEvent(event);
567 void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
570 tr("This transaction is over the size limit. You can still send it for a fee of %1, "
571 "which goes to the nodes that process your transaction and helps to support the network. "
572 "Do you want to pay the fee?").arg(
573 BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nFeeRequired));
574 QMessageBox::StandardButton retval = QMessageBox::question(
575 this, tr("Sending..."), strMessage,
576 QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
577 *payFee = (retval == QMessageBox::Yes);
580 void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end)
582 if(!walletModel || !clientModel)
584 TransactionTableModel *ttm = walletModel->getTransactionTableModel();
585 qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent)
586 .data(Qt::EditRole).toULongLong();
587 if(!clientModel->inInitialBlockDownload())
589 // On new transaction, make an info balloon
590 // Unless the initial block download is in progress, to prevent balloon-spam
591 QString date = ttm->index(start, TransactionTableModel::Date, parent)
593 QString type = ttm->index(start, TransactionTableModel::Type, parent)
595 QString address = ttm->index(start, TransactionTableModel::ToAddress, parent)
597 QIcon icon = qvariant_cast<QIcon>(ttm->index(start,
598 TransactionTableModel::ToAddress, parent)
599 .data(Qt::DecorationRole));
601 notificator->notify(Notificator::Information,
602 (amount)<0 ? tr("Sent transaction") :
603 tr("Incoming transaction"),
609 .arg(BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true))
611 .arg(address), icon);
615 void BitcoinGUI::gotoOverviewPage()
617 overviewAction->setChecked(true);
618 centralWidget->setCurrentWidget(overviewPage);
620 exportAction->setEnabled(false);
621 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
624 void BitcoinGUI::gotoHistoryPage()
626 historyAction->setChecked(true);
627 centralWidget->setCurrentWidget(transactionsPage);
629 exportAction->setEnabled(true);
630 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
631 connect(exportAction, SIGNAL(triggered()), transactionView, SLOT(exportClicked()));
634 void BitcoinGUI::gotoAddressBookPage()
636 addressBookAction->setChecked(true);
637 centralWidget->setCurrentWidget(addressBookPage);
639 exportAction->setEnabled(true);
640 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
641 connect(exportAction, SIGNAL(triggered()), addressBookPage, SLOT(exportClicked()));
644 void BitcoinGUI::gotoReceiveCoinsPage()
646 receiveCoinsAction->setChecked(true);
647 centralWidget->setCurrentWidget(receiveCoinsPage);
649 exportAction->setEnabled(true);
650 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
651 connect(exportAction, SIGNAL(triggered()), receiveCoinsPage, SLOT(exportClicked()));
654 void BitcoinGUI::gotoSendCoinsPage()
656 sendCoinsAction->setChecked(true);
657 centralWidget->setCurrentWidget(sendCoinsPage);
659 exportAction->setEnabled(false);
660 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
663 void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
666 if(event->mimeData()->hasUrls())
667 event->acceptProposedAction();
670 void BitcoinGUI::dropEvent(QDropEvent *event)
672 if(event->mimeData()->hasUrls())
675 QList<QUrl> uris = event->mimeData()->urls();
676 foreach(const QUrl &uri, uris)
678 sendCoinsPage->handleURI(&uri);
682 event->acceptProposedAction();
685 void BitcoinGUI::setEncryptionStatus(int status)
689 case WalletModel::Unencrypted:
690 labelEncryptionIcon->hide();
691 encryptWalletAction->setChecked(false);
692 changePassphraseAction->setEnabled(false);
693 encryptWalletAction->setEnabled(true);
695 case WalletModel::Unlocked:
696 labelEncryptionIcon->show();
697 labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
698 labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
699 encryptWalletAction->setChecked(true);
700 changePassphraseAction->setEnabled(true);
701 encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
703 case WalletModel::Locked:
704 labelEncryptionIcon->show();
705 labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
706 labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
707 encryptWalletAction->setChecked(true);
708 changePassphraseAction->setEnabled(true);
709 encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
714 void BitcoinGUI::encryptWallet(bool status)
718 AskPassphraseDialog dlg(status ? AskPassphraseDialog::Encrypt:
719 AskPassphraseDialog::Decrypt, this);
720 dlg.setModel(walletModel);
723 setEncryptionStatus(walletModel->getEncryptionStatus());
726 void BitcoinGUI::changePassphrase()
728 AskPassphraseDialog dlg(AskPassphraseDialog::ChangePass, this);
729 dlg.setModel(walletModel);
733 void BitcoinGUI::unlockWallet()
737 // Unlock wallet when requested by wallet model
738 if(walletModel->getEncryptionStatus() == WalletModel::Locked)
740 AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this);
741 dlg.setModel(walletModel);