4 * W.J. van der Laan 2011
5 * The Bitcoin Developers 2011
7 #include "bitcoingui.h"
8 #include "transactiontablemodel.h"
9 #include "addressbookpage.h"
10 #include "sendcoinsdialog.h"
11 #include "optionsdialog.h"
12 #include "aboutdialog.h"
13 #include "clientmodel.h"
14 #include "walletmodel.h"
15 #include "editaddressdialog.h"
16 #include "optionsmodel.h"
17 #include "transactiondescdialog.h"
18 #include "addresstablemodel.h"
19 #include "transactionview.h"
20 #include "overviewpage.h"
21 #include "bitcoinunits.h"
22 #include "guiconstants.h"
23 #include "askpassphrasedialog.h"
24 #include "notificator.h"
27 #include "macdockiconhandler.h"
31 #include <QApplication>
32 #include <QMainWindow>
37 #include <QVBoxLayout>
42 #include <QPushButton>
44 #include <QMessageBox>
45 #include <QProgressBar>
46 #include <QStackedWidget>
50 #include <QDragEnterEvent>
55 BitcoinGUI::BitcoinGUI(QWidget *parent):
59 encryptWalletAction(0),
60 changePassphraseAction(0),
66 setWindowTitle(tr("Bitcoin Wallet"));
68 setWindowIcon(QIcon(":icons/bitcoin"));
70 setUnifiedTitleAndToolBarOnMac(true);
71 QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
76 // Create actions for the toolbar, menu bar and tray/dock icon
79 // Create application menu bar
82 // Create the toolbars
85 // Create the tray icon (or setup the dock icon)
89 overviewPage = new OverviewPage();
91 transactionsPage = new QWidget(this);
92 QVBoxLayout *vbox = new QVBoxLayout();
93 transactionView = new TransactionView(this);
94 vbox->addWidget(transactionView);
95 transactionsPage->setLayout(vbox);
97 addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
99 receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);
101 sendCoinsPage = new SendCoinsDialog(this);
103 centralWidget = new QStackedWidget(this);
104 centralWidget->addWidget(overviewPage);
105 centralWidget->addWidget(transactionsPage);
106 centralWidget->addWidget(addressBookPage);
107 centralWidget->addWidget(receiveCoinsPage);
108 centralWidget->addWidget(sendCoinsPage);
109 setCentralWidget(centralWidget);
114 // Status bar notification icons
115 QFrame *frameBlocks = new QFrame();
116 //frameBlocks->setFrameStyle(QFrame::Panel | QFrame::Sunken);
117 frameBlocks->setContentsMargins(0,0,0,0);
118 frameBlocks->setMinimumWidth(56);
119 frameBlocks->setMaximumWidth(56);
120 QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
121 frameBlocksLayout->setContentsMargins(3,0,3,0);
122 frameBlocksLayout->setSpacing(3);
123 labelEncryptionIcon = new QLabel();
124 labelConnectionsIcon = new QLabel();
125 labelBlocksIcon = new QLabel();
126 frameBlocksLayout->addStretch();
127 frameBlocksLayout->addWidget(labelEncryptionIcon);
128 frameBlocksLayout->addStretch();
129 frameBlocksLayout->addWidget(labelConnectionsIcon);
130 frameBlocksLayout->addStretch();
131 frameBlocksLayout->addWidget(labelBlocksIcon);
132 frameBlocksLayout->addStretch();
134 // Progress bar for blocks download
135 progressBarLabel = new QLabel(tr("Synchronizing with network..."));
136 progressBarLabel->setVisible(false);
137 progressBar = new QProgressBar();
138 progressBar->setToolTip(tr("Block chain synchronization in progress"));
139 progressBar->setVisible(false);
141 statusBar()->addWidget(progressBarLabel);
142 statusBar()->addWidget(progressBar);
143 statusBar()->addPermanentWidget(frameBlocks);
145 syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);
147 // Clicking on a transaction on the overview page simply sends you to transaction history page
148 connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
150 // Doubleclicking on a transaction on the transaction history page shows details
151 connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
156 BitcoinGUI::~BitcoinGUI()
163 void BitcoinGUI::createActions()
165 QActionGroup *tabGroup = new QActionGroup(this);
167 overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
168 overviewAction->setToolTip(tr("Show general overview of wallet"));
169 overviewAction->setCheckable(true);
170 overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
171 tabGroup->addAction(overviewAction);
173 historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
174 historyAction->setToolTip(tr("Browse transaction history"));
175 historyAction->setCheckable(true);
176 historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
177 tabGroup->addAction(historyAction);
179 addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
180 addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels"));
181 addressBookAction->setCheckable(true);
182 addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
183 tabGroup->addAction(addressBookAction);
185 receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
186 receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
187 receiveCoinsAction->setCheckable(true);
188 receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
189 tabGroup->addAction(receiveCoinsAction);
191 sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
192 sendCoinsAction->setToolTip(tr("Send coins to a bitcoin address"));
193 sendCoinsAction->setCheckable(true);
194 sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
195 tabGroup->addAction(sendCoinsAction);
197 connect(overviewAction, SIGNAL(triggered()), this, SLOT(show()));
198 connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
199 connect(historyAction, SIGNAL(triggered()), this, SLOT(show()));
200 connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
201 connect(addressBookAction, SIGNAL(triggered()), this, SLOT(show()));
202 connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
203 connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(show()));
204 connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
205 connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(show()));
206 connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
208 quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
209 quitAction->setToolTip(tr("Quit application"));
210 quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
211 quitAction->setMenuRole(QAction::QuitRole);
212 aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About %1").arg(qApp->applicationName()), this);
213 aboutAction->setToolTip(tr("Show information about Bitcoin"));
214 aboutAction->setMenuRole(QAction::AboutRole);
215 aboutQtAction = new QAction(tr("About &Qt"), this);
216 aboutQtAction->setToolTip(tr("Show information about Qt"));
217 aboutQtAction->setMenuRole(QAction::AboutQtRole);
218 optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
219 optionsAction->setToolTip(tr("Modify configuration options for bitcoin"));
220 optionsAction->setMenuRole(QAction::PreferencesRole);
221 openBitcoinAction = new QAction(QIcon(":/icons/bitcoin"), tr("Open &Bitcoin"), this);
222 openBitcoinAction->setToolTip(tr("Show the Bitcoin window"));
223 exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
224 exportAction->setToolTip(tr("Export the current view to a file"));
225 encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet"), this);
226 encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
227 encryptWalletAction->setCheckable(true);
228 changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase"), this);
229 changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
231 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
232 connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
233 connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
234 connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
235 connect(openBitcoinAction, SIGNAL(triggered()), this, SLOT(showNormal()));
236 connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
237 connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
240 void BitcoinGUI::createMenuBar()
243 // Create a decoupled menu bar on Mac which stays even if the window is closed
244 appMenuBar = new QMenuBar();
246 // Get the main window's menu bar on other platforms
247 appMenuBar = menuBar();
250 // Configure the menus
251 QMenu *file = appMenuBar->addMenu(tr("&File"));
252 file->addAction(quitAction);
254 QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
255 settings->addAction(encryptWalletAction);
256 settings->addAction(changePassphraseAction);
257 settings->addSeparator();
258 settings->addAction(optionsAction);
260 QMenu *help = appMenuBar->addMenu(tr("&Help"));
261 help->addAction(aboutAction);
262 help->addAction(aboutQtAction);
265 void BitcoinGUI::createToolBars()
267 QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
268 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
269 toolbar->addAction(overviewAction);
270 toolbar->addAction(sendCoinsAction);
271 toolbar->addAction(receiveCoinsAction);
272 toolbar->addAction(historyAction);
273 toolbar->addAction(addressBookAction);
275 QToolBar *toolbar2 = addToolBar(tr("Actions toolbar"));
276 toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
277 toolbar2->addAction(exportAction);
280 void BitcoinGUI::setClientModel(ClientModel *clientModel)
282 this->clientModel = clientModel;
285 if(clientModel->isTestNet())
287 QString title_testnet = windowTitle() + QString(" ") + tr("[testnet]");
288 setWindowTitle(title_testnet);
290 setWindowIcon(QIcon(":icons/bitcoin_testnet"));
292 MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
296 trayIcon->setToolTip(title_testnet);
297 trayIcon->setIcon(QIcon(":/icons/toolbar_testnet"));
301 // Keep up to date with client
302 setNumConnections(clientModel->getNumConnections());
303 connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
305 setNumBlocks(clientModel->getNumBlocks());
306 connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
308 // Report errors from network/worker thread
309 connect(clientModel, SIGNAL(error(QString,QString)), this, SLOT(error(QString,QString)));
313 void BitcoinGUI::setWalletModel(WalletModel *walletModel)
315 this->walletModel = walletModel;
318 // Report errors from wallet thread
319 connect(walletModel, SIGNAL(error(QString,QString)), this, SLOT(error(QString,QString)));
321 // Put transaction list in tabs
322 transactionView->setModel(walletModel);
324 overviewPage->setModel(walletModel);
325 addressBookPage->setModel(walletModel->getAddressTableModel());
326 receiveCoinsPage->setModel(walletModel->getAddressTableModel());
327 sendCoinsPage->setModel(walletModel);
329 setEncryptionStatus(walletModel->getEncryptionStatus());
330 connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int)));
332 // Balloon popup for new transaction
333 connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
334 this, SLOT(incomingTransaction(QModelIndex,int,int)));
336 // Ask for passphrase if needed
337 connect(walletModel, SIGNAL(requireUnlock()), this, SLOT(unlockWallet()));
341 void BitcoinGUI::createTrayIcon()
345 trayIcon = new QSystemTrayIcon(this);
346 trayIconMenu = new QMenu(this);
347 trayIcon->setContextMenu(trayIconMenu);
348 trayIcon->setToolTip("Bitcoin client");
349 trayIcon->setIcon(QIcon(":/icons/toolbar"));
350 connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
351 this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
354 // Note: On Mac, the dock icon is used to provide the tray's functionality.
355 MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
356 connect(dockIconHandler, SIGNAL(dockIconClicked()), openBitcoinAction, SLOT(trigger()));
357 trayIconMenu = dockIconHandler->dockMenu();
360 // Configuration of the tray icon (or dock icon) icon menu
361 trayIconMenu->addAction(openBitcoinAction);
362 trayIconMenu->addSeparator();
363 trayIconMenu->addAction(receiveCoinsAction);
364 trayIconMenu->addAction(sendCoinsAction);
365 trayIconMenu->addSeparator();
366 trayIconMenu->addAction(optionsAction);
367 #ifndef Q_WS_MAC // This is built-in on Mac
368 trayIconMenu->addSeparator();
369 trayIconMenu->addAction(quitAction);
372 notificator = new Notificator(tr("bitcoin-qt"), trayIcon);
376 void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
378 if(reason == QSystemTrayIcon::Trigger)
380 // Click on system tray icon triggers "open bitcoin"
381 openBitcoinAction->trigger();
387 void BitcoinGUI::optionsClicked()
389 if(!clientModel || !clientModel->getOptionsModel())
392 dlg.setModel(clientModel->getOptionsModel());
396 void BitcoinGUI::aboutClicked()
399 dlg.setModel(clientModel);
403 void BitcoinGUI::setNumConnections(int count)
408 case 0: icon = ":/icons/connect_0"; break;
409 case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
410 case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
411 case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
412 default: icon = ":/icons/connect_4"; break;
414 labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
415 labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count));
418 void BitcoinGUI::setNumBlocks(int count)
422 int initTotal = clientModel->getNumBlocksAtStartup();
423 int total = clientModel->getNumBlocksOfPeers();
428 if (clientModel->getStatusBarWarnings() == "")
430 progressBarLabel->setVisible(true);
431 progressBarLabel->setText(tr("Synchronizing with network..."));
432 progressBar->setVisible(true);
433 progressBar->setMaximum(total - initTotal);
434 progressBar->setValue(count - initTotal);
438 progressBarLabel->setText(clientModel->getStatusBarWarnings());
439 progressBarLabel->setVisible(true);
440 progressBar->setVisible(false);
442 tooltip = tr("Downloaded %1 of %2 blocks of transaction history.").arg(count).arg(total);
446 if (clientModel->getStatusBarWarnings() == "")
447 progressBarLabel->setVisible(false);
450 progressBarLabel->setText(clientModel->getStatusBarWarnings());
451 progressBarLabel->setVisible(true);
453 progressBar->setVisible(false);
454 tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
457 QDateTime now = QDateTime::currentDateTime();
458 QDateTime lastBlockDate = clientModel->getLastBlockDate();
459 int secs = lastBlockDate.secsTo(now);
462 // Represent time from last generated block in human readable text
465 text = tr("%n second(s) ago","",secs);
467 else if(secs < 60*60)
469 text = tr("%n minute(s) ago","",secs/60);
471 else if(secs < 24*60*60)
473 text = tr("%n hour(s) ago","",secs/(60*60));
477 text = tr("%n day(s) ago","",secs/(60*60*24));
480 // Set icon state: spinning if catching up, tick otherwise
483 tooltip = tr("Up to date") + QString("\n") + tooltip;
484 labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
488 tooltip = tr("Catching up...") + QString("\n") + tooltip;
489 labelBlocksIcon->setMovie(syncIconMovie);
490 syncIconMovie->start();
493 tooltip += QString("\n");
494 tooltip += tr("Last received block was generated %1.").arg(text);
496 labelBlocksIcon->setToolTip(tooltip);
497 progressBarLabel->setToolTip(tooltip);
498 progressBar->setToolTip(tooltip);
501 void BitcoinGUI::refreshStatusBar()
503 /* Might display multiple times in the case of multiple alerts
504 static QString prevStatusBar;
505 QString newStatusBar = clientModel->getStatusBarWarnings();
506 if (prevStatusBar != newStatusBar)
508 prevStatusBar = newStatusBar;
509 error(tr("Network Alert"), newStatusBar);
511 setNumBlocks(clientModel->getNumBlocks());
514 void BitcoinGUI::error(const QString &title, const QString &message)
516 // Report errors from network/worker thread
517 notificator->notify(Notificator::Critical, title, message);
520 void BitcoinGUI::changeEvent(QEvent *e)
522 #ifndef Q_WS_MAC // Ignored on Mac
523 if(e->type() == QEvent::WindowStateChange)
525 if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray())
540 QMainWindow::changeEvent(e);
543 void BitcoinGUI::closeEvent(QCloseEvent *event)
547 #ifndef Q_WS_MAC // Ignored on Mac
548 if(!clientModel->getOptionsModel()->getMinimizeToTray() &&
549 !clientModel->getOptionsModel()->getMinimizeOnClose())
555 QMainWindow::closeEvent(event);
558 void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
561 tr("This transaction is over the size limit. You can still send it for a fee of %1, "
562 "which goes to the nodes that process your transaction and helps to support the network. "
563 "Do you want to pay the fee?").arg(
564 BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nFeeRequired));
565 QMessageBox::StandardButton retval = QMessageBox::question(
566 this, tr("Sending..."), strMessage,
567 QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
568 *payFee = (retval == QMessageBox::Yes);
571 void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end)
573 if(!walletModel || !clientModel)
575 TransactionTableModel *ttm = walletModel->getTransactionTableModel();
576 qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent)
577 .data(Qt::EditRole).toULongLong();
578 if(!clientModel->inInitialBlockDownload())
580 // On new transaction, make an info balloon
581 // Unless the initial block download is in progress, to prevent balloon-spam
582 QString date = ttm->index(start, TransactionTableModel::Date, parent)
584 QString type = ttm->index(start, TransactionTableModel::Type, parent)
586 QString address = ttm->index(start, TransactionTableModel::ToAddress, parent)
588 QIcon icon = qvariant_cast<QIcon>(ttm->index(start,
589 TransactionTableModel::ToAddress, parent)
590 .data(Qt::DecorationRole));
592 notificator->notify(Notificator::Information,
593 (amount)<0 ? tr("Sent transaction") :
594 tr("Incoming transaction"),
600 .arg(BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true))
602 .arg(address), icon);
606 void BitcoinGUI::gotoOverviewPage()
608 overviewAction->setChecked(true);
609 centralWidget->setCurrentWidget(overviewPage);
611 exportAction->setEnabled(false);
612 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
615 void BitcoinGUI::gotoHistoryPage()
617 historyAction->setChecked(true);
618 centralWidget->setCurrentWidget(transactionsPage);
620 exportAction->setEnabled(true);
621 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
622 connect(exportAction, SIGNAL(triggered()), transactionView, SLOT(exportClicked()));
625 void BitcoinGUI::gotoAddressBookPage()
627 addressBookAction->setChecked(true);
628 centralWidget->setCurrentWidget(addressBookPage);
630 exportAction->setEnabled(true);
631 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
632 connect(exportAction, SIGNAL(triggered()), addressBookPage, SLOT(exportClicked()));
635 void BitcoinGUI::gotoReceiveCoinsPage()
637 receiveCoinsAction->setChecked(true);
638 centralWidget->setCurrentWidget(receiveCoinsPage);
640 exportAction->setEnabled(true);
641 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
642 connect(exportAction, SIGNAL(triggered()), receiveCoinsPage, SLOT(exportClicked()));
645 void BitcoinGUI::gotoSendCoinsPage()
647 sendCoinsAction->setChecked(true);
648 centralWidget->setCurrentWidget(sendCoinsPage);
650 exportAction->setEnabled(false);
651 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
654 void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
657 if(event->mimeData()->hasUrls())
658 event->acceptProposedAction();
661 void BitcoinGUI::dropEvent(QDropEvent *event)
663 if(event->mimeData()->hasUrls())
666 QList<QUrl> urls = event->mimeData()->urls();
667 foreach(const QUrl &url, urls)
669 sendCoinsPage->handleURL(&url);
673 event->acceptProposedAction();
676 void BitcoinGUI::setEncryptionStatus(int status)
680 case WalletModel::Unencrypted:
681 labelEncryptionIcon->hide();
682 encryptWalletAction->setChecked(false);
683 changePassphraseAction->setEnabled(false);
684 encryptWalletAction->setEnabled(true);
686 case WalletModel::Unlocked:
687 labelEncryptionIcon->show();
688 labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
689 labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
690 encryptWalletAction->setChecked(true);
691 changePassphraseAction->setEnabled(true);
692 encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
694 case WalletModel::Locked:
695 labelEncryptionIcon->show();
696 labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
697 labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
698 encryptWalletAction->setChecked(true);
699 changePassphraseAction->setEnabled(true);
700 encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
705 void BitcoinGUI::encryptWallet(bool status)
709 AskPassphraseDialog dlg(status ? AskPassphraseDialog::Encrypt:
710 AskPassphraseDialog::Decrypt, this);
711 dlg.setModel(walletModel);
714 setEncryptionStatus(walletModel->getEncryptionStatus());
717 void BitcoinGUI::changePassphrase()
719 AskPassphraseDialog dlg(AskPassphraseDialog::ChangePass, this);
720 dlg.setModel(walletModel);
724 void BitcoinGUI::unlockWallet()
728 // Unlock wallet when requested by wallet model
729 if(walletModel->getEncryptionStatus() == WalletModel::Locked)
731 AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this);
732 dlg.setModel(walletModel);