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 "messagepage.h"
12 #include "optionsdialog.h"
13 #include "aboutdialog.h"
14 #include "clientmodel.h"
15 #include "walletmodel.h"
16 #include "editaddressdialog.h"
17 #include "optionsmodel.h"
18 #include "transactiondescdialog.h"
19 #include "addresstablemodel.h"
20 #include "transactionview.h"
21 #include "overviewpage.h"
22 #include "bitcoinunits.h"
23 #include "guiconstants.h"
24 #include "askpassphrasedialog.h"
25 #include "notificator.h"
28 #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 messagePage = new MessagePage(this);
105 centralWidget = new QStackedWidget(this);
106 centralWidget->addWidget(overviewPage);
107 centralWidget->addWidget(transactionsPage);
108 centralWidget->addWidget(addressBookPage);
109 centralWidget->addWidget(receiveCoinsPage);
110 centralWidget->addWidget(sendCoinsPage);
111 #ifdef FIRST_CLASS_MESSAGING
112 centralWidget->addWidget(messagePage);
114 setCentralWidget(centralWidget);
119 // Status bar notification icons
120 QFrame *frameBlocks = new QFrame();
121 frameBlocks->setContentsMargins(0,0,0,0);
122 frameBlocks->setMinimumWidth(56);
123 frameBlocks->setMaximumWidth(56);
124 QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
125 frameBlocksLayout->setContentsMargins(3,0,3,0);
126 frameBlocksLayout->setSpacing(3);
127 labelEncryptionIcon = new QLabel();
128 labelConnectionsIcon = new QLabel();
129 labelBlocksIcon = new QLabel();
130 frameBlocksLayout->addStretch();
131 frameBlocksLayout->addWidget(labelEncryptionIcon);
132 frameBlocksLayout->addStretch();
133 frameBlocksLayout->addWidget(labelConnectionsIcon);
134 frameBlocksLayout->addStretch();
135 frameBlocksLayout->addWidget(labelBlocksIcon);
136 frameBlocksLayout->addStretch();
138 // Progress bar for blocks download
139 progressBarLabel = new QLabel(tr("Synchronizing with network..."));
140 progressBarLabel->setVisible(false);
141 progressBar = new QProgressBar();
142 progressBar->setToolTip(tr("Block chain synchronization in progress"));
143 progressBar->setVisible(false);
145 statusBar()->addWidget(progressBarLabel);
146 statusBar()->addWidget(progressBar);
147 statusBar()->addPermanentWidget(frameBlocks);
149 syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this);
151 // Clicking on a transaction on the overview page simply sends you to transaction history page
152 connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage()));
154 // Doubleclicking on a transaction on the transaction history page shows details
155 connect(transactionView, SIGNAL(doubleClicked(QModelIndex)), transactionView, SLOT(showDetails()));
160 BitcoinGUI::~BitcoinGUI()
167 void BitcoinGUI::createActions()
169 QActionGroup *tabGroup = new QActionGroup(this);
171 overviewAction = new QAction(QIcon(":/icons/overview"), tr("&Overview"), this);
172 overviewAction->setToolTip(tr("Show general overview of wallet"));
173 overviewAction->setCheckable(true);
174 overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1));
175 tabGroup->addAction(overviewAction);
177 historyAction = new QAction(QIcon(":/icons/history"), tr("&Transactions"), this);
178 historyAction->setToolTip(tr("Browse transaction history"));
179 historyAction->setCheckable(true);
180 historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
181 tabGroup->addAction(historyAction);
183 addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this);
184 addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels"));
185 addressBookAction->setCheckable(true);
186 addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
187 tabGroup->addAction(addressBookAction);
189 receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this);
190 receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments"));
191 receiveCoinsAction->setCheckable(true);
192 receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
193 tabGroup->addAction(receiveCoinsAction);
195 sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this);
196 sendCoinsAction->setToolTip(tr("Send coins to a bitcoin address"));
197 sendCoinsAction->setCheckable(true);
198 sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2));
199 tabGroup->addAction(sendCoinsAction);
201 messageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message"), this);
202 messageAction->setToolTip(tr("Prove you control an address"));
203 #ifdef FIRST_CLASS_MESSAGING
204 messageAction->setCheckable(true);
206 tabGroup->addAction(messageAction);
208 connect(overviewAction, SIGNAL(triggered()), this, SLOT(show()));
209 connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
210 connect(historyAction, SIGNAL(triggered()), this, SLOT(show()));
211 connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
212 connect(addressBookAction, SIGNAL(triggered()), this, SLOT(show()));
213 connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
214 connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(show()));
215 connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
216 connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(show()));
217 connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(gotoSendCoinsPage()));
218 connect(messageAction, SIGNAL(triggered()), this, SLOT(show()));
219 connect(messageAction, SIGNAL(triggered()), this, SLOT(gotoMessagePage()));
221 quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
222 quitAction->setToolTip(tr("Quit application"));
223 quitAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_Q));
224 quitAction->setMenuRole(QAction::QuitRole);
225 aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About %1").arg(qApp->applicationName()), this);
226 aboutAction->setToolTip(tr("Show information about Bitcoin"));
227 aboutAction->setMenuRole(QAction::AboutRole);
228 aboutQtAction = new QAction(tr("About &Qt"), this);
229 aboutQtAction->setToolTip(tr("Show information about Qt"));
230 aboutQtAction->setMenuRole(QAction::AboutQtRole);
231 optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
232 optionsAction->setToolTip(tr("Modify configuration options for bitcoin"));
233 optionsAction->setMenuRole(QAction::PreferencesRole);
234 openBitcoinAction = new QAction(QIcon(":/icons/bitcoin"), tr("Open &Bitcoin"), this);
235 openBitcoinAction->setToolTip(tr("Show the Bitcoin window"));
236 exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this);
237 exportAction->setToolTip(tr("Export the current view to a file"));
238 encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet"), this);
239 encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet"));
240 encryptWalletAction->setCheckable(true);
241 changePassphraseAction = new QAction(QIcon(":/icons/key"), tr("&Change Passphrase"), this);
242 changePassphraseAction->setToolTip(tr("Change the passphrase used for wallet encryption"));
244 connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
245 connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked()));
246 connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
247 connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
248 connect(openBitcoinAction, SIGNAL(triggered()), this, SLOT(showNormal()));
249 connect(encryptWalletAction, SIGNAL(triggered(bool)), this, SLOT(encryptWallet(bool)));
250 connect(changePassphraseAction, SIGNAL(triggered()), this, SLOT(changePassphrase()));
253 void BitcoinGUI::createMenuBar()
256 // Create a decoupled menu bar on Mac which stays even if the window is closed
257 appMenuBar = new QMenuBar();
259 // Get the main window's menu bar on other platforms
260 appMenuBar = menuBar();
263 // Configure the menus
264 QMenu *file = appMenuBar->addMenu(tr("&File"));
265 #ifndef FIRST_CLASS_MESSAGING
266 file->addAction(messageAction);
267 file->addSeparator();
269 file->addAction(quitAction);
271 QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
272 settings->addAction(encryptWalletAction);
273 settings->addAction(changePassphraseAction);
274 settings->addSeparator();
275 settings->addAction(optionsAction);
277 QMenu *help = appMenuBar->addMenu(tr("&Help"));
278 help->addAction(aboutAction);
279 help->addAction(aboutQtAction);
282 void BitcoinGUI::createToolBars()
284 QToolBar *toolbar = addToolBar(tr("Tabs toolbar"));
285 toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
286 toolbar->addAction(overviewAction);
287 toolbar->addAction(sendCoinsAction);
288 toolbar->addAction(receiveCoinsAction);
289 toolbar->addAction(historyAction);
290 toolbar->addAction(addressBookAction);
291 #ifdef FIRST_CLASS_MESSAGING
292 toolbar->addAction(messageAction);
295 QToolBar *toolbar2 = addToolBar(tr("Actions toolbar"));
296 toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
297 toolbar2->addAction(exportAction);
300 void BitcoinGUI::setClientModel(ClientModel *clientModel)
302 this->clientModel = clientModel;
305 if(clientModel->isTestNet())
307 QString title_testnet = windowTitle() + QString(" ") + tr("[testnet]");
308 setWindowTitle(title_testnet);
310 setWindowIcon(QIcon(":icons/bitcoin_testnet"));
312 MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet"));
316 trayIcon->setToolTip(title_testnet);
317 trayIcon->setIcon(QIcon(":/icons/toolbar_testnet"));
321 // Keep up to date with client
322 setNumConnections(clientModel->getNumConnections());
323 connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int)));
325 setNumBlocks(clientModel->getNumBlocks());
326 connect(clientModel, SIGNAL(numBlocksChanged(int)), this, SLOT(setNumBlocks(int)));
328 // Report errors from network/worker thread
329 connect(clientModel, SIGNAL(error(QString,QString)), this, SLOT(error(QString,QString)));
333 void BitcoinGUI::setWalletModel(WalletModel *walletModel)
335 this->walletModel = walletModel;
338 // Report errors from wallet thread
339 connect(walletModel, SIGNAL(error(QString,QString)), this, SLOT(error(QString,QString)));
341 // Put transaction list in tabs
342 transactionView->setModel(walletModel);
344 overviewPage->setModel(walletModel);
345 addressBookPage->setModel(walletModel->getAddressTableModel());
346 receiveCoinsPage->setModel(walletModel->getAddressTableModel());
347 sendCoinsPage->setModel(walletModel);
348 messagePage->setModel(walletModel);
350 setEncryptionStatus(walletModel->getEncryptionStatus());
351 connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int)));
353 // Balloon popup for new transaction
354 connect(walletModel->getTransactionTableModel(), SIGNAL(rowsInserted(QModelIndex,int,int)),
355 this, SLOT(incomingTransaction(QModelIndex,int,int)));
357 // Ask for passphrase if needed
358 connect(walletModel, SIGNAL(requireUnlock()), this, SLOT(unlockWallet()));
362 void BitcoinGUI::createTrayIcon()
366 trayIcon = new QSystemTrayIcon(this);
367 trayIconMenu = new QMenu(this);
368 trayIcon->setContextMenu(trayIconMenu);
369 trayIcon->setToolTip("Bitcoin client");
370 trayIcon->setIcon(QIcon(":/icons/toolbar"));
371 connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)),
372 this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason)));
375 // Note: On Mac, the dock icon is used to provide the tray's functionality.
376 MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance();
377 connect(dockIconHandler, SIGNAL(dockIconClicked()), openBitcoinAction, SLOT(trigger()));
378 trayIconMenu = dockIconHandler->dockMenu();
381 // Configuration of the tray icon (or dock icon) icon menu
382 trayIconMenu->addAction(openBitcoinAction);
383 trayIconMenu->addSeparator();
384 trayIconMenu->addAction(messageAction);
385 #ifndef FIRST_CLASS_MESSAGING
386 trayIconMenu->addSeparator();
388 trayIconMenu->addAction(receiveCoinsAction);
389 trayIconMenu->addAction(sendCoinsAction);
390 trayIconMenu->addSeparator();
391 trayIconMenu->addAction(optionsAction);
392 #ifndef Q_WS_MAC // This is built-in on Mac
393 trayIconMenu->addSeparator();
394 trayIconMenu->addAction(quitAction);
397 notificator = new Notificator(tr("bitcoin-qt"), trayIcon);
401 void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason)
403 if(reason == QSystemTrayIcon::Trigger)
405 // Click on system tray icon triggers "open bitcoin"
406 openBitcoinAction->trigger();
412 void BitcoinGUI::optionsClicked()
414 if(!clientModel || !clientModel->getOptionsModel())
417 dlg.setModel(clientModel->getOptionsModel());
421 void BitcoinGUI::aboutClicked()
424 dlg.setModel(clientModel);
428 void BitcoinGUI::setNumConnections(int count)
433 case 0: icon = ":/icons/connect_0"; break;
434 case 1: case 2: case 3: icon = ":/icons/connect_1"; break;
435 case 4: case 5: case 6: icon = ":/icons/connect_2"; break;
436 case 7: case 8: case 9: icon = ":/icons/connect_3"; break;
437 default: icon = ":/icons/connect_4"; break;
439 labelConnectionsIcon->setPixmap(QIcon(icon).pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
440 labelConnectionsIcon->setToolTip(tr("%n active connection(s) to Bitcoin network", "", count));
443 void BitcoinGUI::setNumBlocks(int count)
447 int total = clientModel->getNumBlocksOfPeers();
452 if (clientModel->getStatusBarWarnings() == "")
454 progressBarLabel->setVisible(true);
455 progressBarLabel->setText(tr("Synchronizing with network..."));
456 progressBar->setVisible(true);
457 progressBar->setMaximum(total);
458 progressBar->setValue(count);
462 progressBarLabel->setText(clientModel->getStatusBarWarnings());
463 progressBarLabel->setVisible(true);
464 progressBar->setVisible(false);
466 tooltip = tr("Downloaded %1 of %2 blocks of transaction history.").arg(count).arg(total);
470 if (clientModel->getStatusBarWarnings() == "")
471 progressBarLabel->setVisible(false);
474 progressBarLabel->setText(clientModel->getStatusBarWarnings());
475 progressBarLabel->setVisible(true);
477 progressBar->setVisible(false);
478 tooltip = tr("Downloaded %1 blocks of transaction history.").arg(count);
481 QDateTime now = QDateTime::currentDateTime();
482 QDateTime lastBlockDate = clientModel->getLastBlockDate();
483 int secs = lastBlockDate.secsTo(now);
486 // Represent time from last generated block in human readable text
489 text = tr("%n second(s) ago","",secs);
491 else if(secs < 60*60)
493 text = tr("%n minute(s) ago","",secs/60);
495 else if(secs < 24*60*60)
497 text = tr("%n hour(s) ago","",secs/(60*60));
501 text = tr("%n day(s) ago","",secs/(60*60*24));
504 // Set icon state: spinning if catching up, tick otherwise
507 tooltip = tr("Up to date") + QString("\n") + tooltip;
508 labelBlocksIcon->setPixmap(QIcon(":/icons/synced").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
512 tooltip = tr("Catching up...") + QString("\n") + tooltip;
513 labelBlocksIcon->setMovie(syncIconMovie);
514 syncIconMovie->start();
517 tooltip += QString("\n");
518 tooltip += tr("Last received block was generated %1.").arg(text);
520 labelBlocksIcon->setToolTip(tooltip);
521 progressBarLabel->setToolTip(tooltip);
522 progressBar->setToolTip(tooltip);
525 void BitcoinGUI::refreshStatusBar()
527 /* Might display multiple times in the case of multiple alerts
528 static QString prevStatusBar;
529 QString newStatusBar = clientModel->getStatusBarWarnings();
530 if (prevStatusBar != newStatusBar)
532 prevStatusBar = newStatusBar;
533 error(tr("Network Alert"), newStatusBar);
535 setNumBlocks(clientModel->getNumBlocks());
538 void BitcoinGUI::error(const QString &title, const QString &message)
540 // Report errors from network/worker thread
541 notificator->notify(Notificator::Critical, title, message);
544 void BitcoinGUI::changeEvent(QEvent *e)
546 #ifndef Q_WS_MAC // Ignored on Mac
547 if(e->type() == QEvent::WindowStateChange)
549 if(clientModel && clientModel->getOptionsModel()->getMinimizeToTray())
564 QMainWindow::changeEvent(e);
567 void BitcoinGUI::closeEvent(QCloseEvent *event)
571 #ifndef Q_WS_MAC // Ignored on Mac
572 if(!clientModel->getOptionsModel()->getMinimizeToTray() &&
573 !clientModel->getOptionsModel()->getMinimizeOnClose())
579 QMainWindow::closeEvent(event);
582 void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
585 tr("This transaction is over the size limit. You can still send it for a fee of %1, "
586 "which goes to the nodes that process your transaction and helps to support the network. "
587 "Do you want to pay the fee?").arg(
588 BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, nFeeRequired));
589 QMessageBox::StandardButton retval = QMessageBox::question(
590 this, tr("Sending..."), strMessage,
591 QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
592 *payFee = (retval == QMessageBox::Yes);
595 void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int end)
597 if(!walletModel || !clientModel)
599 TransactionTableModel *ttm = walletModel->getTransactionTableModel();
600 qint64 amount = ttm->index(start, TransactionTableModel::Amount, parent)
601 .data(Qt::EditRole).toULongLong();
602 if(!clientModel->inInitialBlockDownload())
604 // On new transaction, make an info balloon
605 // Unless the initial block download is in progress, to prevent balloon-spam
606 QString date = ttm->index(start, TransactionTableModel::Date, parent)
608 QString type = ttm->index(start, TransactionTableModel::Type, parent)
610 QString address = ttm->index(start, TransactionTableModel::ToAddress, parent)
612 QIcon icon = qvariant_cast<QIcon>(ttm->index(start,
613 TransactionTableModel::ToAddress, parent)
614 .data(Qt::DecorationRole));
616 notificator->notify(Notificator::Information,
617 (amount)<0 ? tr("Sent transaction") :
618 tr("Incoming transaction"),
624 .arg(BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true))
626 .arg(address), icon);
630 void BitcoinGUI::gotoOverviewPage()
632 overviewAction->setChecked(true);
633 centralWidget->setCurrentWidget(overviewPage);
635 exportAction->setEnabled(false);
636 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
639 void BitcoinGUI::gotoHistoryPage()
641 historyAction->setChecked(true);
642 centralWidget->setCurrentWidget(transactionsPage);
644 exportAction->setEnabled(true);
645 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
646 connect(exportAction, SIGNAL(triggered()), transactionView, SLOT(exportClicked()));
649 void BitcoinGUI::gotoAddressBookPage()
651 addressBookAction->setChecked(true);
652 centralWidget->setCurrentWidget(addressBookPage);
654 exportAction->setEnabled(true);
655 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
656 connect(exportAction, SIGNAL(triggered()), addressBookPage, SLOT(exportClicked()));
659 void BitcoinGUI::gotoReceiveCoinsPage()
661 receiveCoinsAction->setChecked(true);
662 centralWidget->setCurrentWidget(receiveCoinsPage);
664 exportAction->setEnabled(true);
665 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
666 connect(exportAction, SIGNAL(triggered()), receiveCoinsPage, SLOT(exportClicked()));
669 void BitcoinGUI::gotoSendCoinsPage()
671 sendCoinsAction->setChecked(true);
672 centralWidget->setCurrentWidget(sendCoinsPage);
674 exportAction->setEnabled(false);
675 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
678 void BitcoinGUI::gotoMessagePage()
680 #ifdef FIRST_CLASS_MESSAGING
681 messageAction->setChecked(true);
682 centralWidget->setCurrentWidget(messagePage);
684 exportAction->setEnabled(false);
685 disconnect(exportAction, SIGNAL(triggered()), 0, 0);
688 messagePage->setFocus();
692 void BitcoinGUI::gotoMessagePage(QString addr)
695 messagePage->setAddress(addr);
698 void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event)
701 if(event->mimeData()->hasUrls())
702 event->acceptProposedAction();
705 void BitcoinGUI::dropEvent(QDropEvent *event)
707 if(event->mimeData()->hasUrls())
710 QList<QUrl> urls = event->mimeData()->urls();
711 foreach(const QUrl &url, urls)
713 sendCoinsPage->handleURL(&url);
717 event->acceptProposedAction();
720 void BitcoinGUI::handleURL(QString strURL)
723 QUrl url = QUrl(strURL);
724 sendCoinsPage->handleURL(&url);
727 void BitcoinGUI::setEncryptionStatus(int status)
731 case WalletModel::Unencrypted:
732 labelEncryptionIcon->hide();
733 encryptWalletAction->setChecked(false);
734 changePassphraseAction->setEnabled(false);
735 encryptWalletAction->setEnabled(true);
737 case WalletModel::Unlocked:
738 labelEncryptionIcon->show();
739 labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_open").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
740 labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>unlocked</b>"));
741 encryptWalletAction->setChecked(true);
742 changePassphraseAction->setEnabled(true);
743 encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
745 case WalletModel::Locked:
746 labelEncryptionIcon->show();
747 labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE));
748 labelEncryptionIcon->setToolTip(tr("Wallet is <b>encrypted</b> and currently <b>locked</b>"));
749 encryptWalletAction->setChecked(true);
750 changePassphraseAction->setEnabled(true);
751 encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported
756 void BitcoinGUI::encryptWallet(bool status)
760 AskPassphraseDialog dlg(status ? AskPassphraseDialog::Encrypt:
761 AskPassphraseDialog::Decrypt, this);
762 dlg.setModel(walletModel);
765 setEncryptionStatus(walletModel->getEncryptionStatus());
768 void BitcoinGUI::changePassphrase()
770 AskPassphraseDialog dlg(AskPassphraseDialog::ChangePass, this);
771 dlg.setModel(walletModel);
775 void BitcoinGUI::unlockWallet()
779 // Unlock wallet when requested by wallet model
780 if(walletModel->getEncryptionStatus() == WalletModel::Locked)
782 AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this);
783 dlg.setModel(walletModel);