aboutsummaryrefslogtreecommitdiff
path: root/src/qt/bitcoingui.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r--src/qt/bitcoingui.cpp191
1 files changed, 103 insertions, 88 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp
index bb9eb60e5b..8b0aba1b5b 100644
--- a/src/qt/bitcoingui.cpp
+++ b/src/qt/bitcoingui.cpp
@@ -1,57 +1,58 @@
-/*
- * Qt4 bitcoin GUI.
- *
- * W.J. van der Laan 2011-2012
- * The Bitcoin Developers 2011-2012
- */
+// Copyright (c) 2011-2013 The Bitcoin developers
+// Distributed under the MIT/X11 software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "bitcoingui.h"
-#include "transactiontablemodel.h"
-#include "optionsdialog.h"
#include "aboutdialog.h"
-#include "clientmodel.h"
-#include "walletmodel.h"
-#include "walletframe.h"
-#include "optionsmodel.h"
-#include "transactiondescdialog.h"
#include "bitcoinunits.h"
+#include "clientmodel.h"
#include "guiconstants.h"
-#include "notificator.h"
#include "guiutil.h"
+#include "notificator.h"
+#include "optionsdialog.h"
+#include "optionsmodel.h"
#include "rpcconsole.h"
-#include "ui_interface.h"
-#include "wallet.h"
-#include "init.h"
+#include "walletframe.h"
+#include "walletmodel.h"
+#include "openuridialog.h"
#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
#endif
+#include "init.h"
+#include "ui_interface.h"
+
+#include <iostream>
+
#include <QApplication>
-#include <QMenuBar>
-#include <QMenu>
+#include <QDateTime>
+#include <QDesktopWidget>
+#include <QDragEnterEvent>
#include <QIcon>
-#include <QVBoxLayout>
-#include <QToolBar>
-#include <QStatusBar>
#include <QLabel>
+#include <QListWidget>
+#include <QMenu>
+#include <QMenuBar>
#include <QMessageBox>
+#include <QMimeData>
+#include <QMovie>
#include <QProgressBar>
+#include <QSettings>
#include <QStackedWidget>
-#include <QDateTime>
-#include <QMovie>
+#include <QStatusBar>
+#include <QStyle>
#include <QTimer>
-#include <QDragEnterEvent>
+#include <QToolBar>
+#include <QVBoxLayout>
+
#if QT_VERSION < 0x050000
#include <QUrl>
#include <QTextDocument>
+#else
+#include <QUrlQuery>
#endif
-#include <QMimeData>
-#include <QStyle>
-#include <QListWidget>
-
-#include <iostream>
const QString BitcoinGUI::DEFAULT_WALLET = "~Default";
@@ -157,6 +158,8 @@ BitcoinGUI::BitcoinGUI(bool fIsTestnet, QWidget *parent) :
rpcConsole = new RPCConsole(this);
connect(openRPCConsoleAction, SIGNAL(triggered()), rpcConsole, SLOT(show()));
+ // prevents an oben debug window from becoming stuck/unusable on client shutdown
+ connect(quitAction, SIGNAL(triggered()), rpcConsole, SLOT(hide()));
// Install event filter to be able to catch status tip events (QEvent::StatusTip)
this->installEventFilter(this);
@@ -192,7 +195,7 @@ void BitcoinGUI::createActions(bool fIsTestnet)
tabGroup->addAction(sendCoinsAction);
receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive"), this);
- receiveCoinsAction->setStatusTip(tr("Show the list of addresses for receiving payments"));
+ receiveCoinsAction->setStatusTip(tr("Request payments (generates QR codes and bitcoin: URIs)"));
receiveCoinsAction->setToolTip(receiveCoinsAction->statusTip());
receiveCoinsAction->setCheckable(true);
receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3));
@@ -205,13 +208,6 @@ void BitcoinGUI::createActions(bool fIsTestnet)
historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4));
tabGroup->addAction(historyAction);
- addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Addresses"), this);
- addressBookAction->setStatusTip(tr("Edit the list of stored addresses and labels"));
- addressBookAction->setToolTip(addressBookAction->statusTip());
- addressBookAction->setCheckable(true);
- addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5));
- tabGroup->addAction(addressBookAction);
-
connect(overviewAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(overviewAction, SIGNAL(triggered()), this, SLOT(gotoOverviewPage()));
connect(sendCoinsAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
@@ -220,8 +216,6 @@ void BitcoinGUI::createActions(bool fIsTestnet)
connect(receiveCoinsAction, SIGNAL(triggered()), this, SLOT(gotoReceiveCoinsPage()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage()));
- connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized()));
- connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage()));
quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this);
quitAction->setStatusTip(tr("Quit application"));
@@ -233,7 +227,11 @@ void BitcoinGUI::createActions(bool fIsTestnet)
aboutAction = new QAction(QIcon(":/icons/bitcoin_testnet"), tr("&About Bitcoin"), this);
aboutAction->setStatusTip(tr("Show information about Bitcoin"));
aboutAction->setMenuRole(QAction::AboutRole);
+#if QT_VERSION < 0x050000
aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
+#else
+ aboutQtAction = new QAction(QIcon(":/qt-project.org/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this);
+#endif
aboutQtAction->setStatusTip(tr("Show information about Qt"));
aboutQtAction->setMenuRole(QAction::AboutQtRole);
optionsAction = new QAction(QIcon(":/icons/options"), tr("&Options..."), this);
@@ -260,6 +258,14 @@ void BitcoinGUI::createActions(bool fIsTestnet)
openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this);
openRPCConsoleAction->setStatusTip(tr("Open debugging and diagnostic console"));
+ usedSendingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("&Used sending addresses..."), this);
+ usedSendingAddressesAction->setStatusTip(tr("Show the list of used sending addresses and labels"));
+ usedReceivingAddressesAction = new QAction(QIcon(":/icons/address-book"), tr("Used &receiving addresses..."), this);
+ usedReceivingAddressesAction->setStatusTip(tr("Show the list of used receiving addresses and labels"));
+
+ openAction = new QAction(QApplication::style()->standardIcon(QStyle::SP_FileIcon), tr("Open URI..."), this);
+ openAction->setStatusTip(tr("Open a bitcoin: URI or payment request"));
+
connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked()));
connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt()));
@@ -270,6 +276,9 @@ void BitcoinGUI::createActions(bool fIsTestnet)
connect(changePassphraseAction, SIGNAL(triggered()), walletFrame, SLOT(changePassphrase()));
connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab()));
connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab()));
+ connect(usedSendingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedSendingAddresses()));
+ connect(usedReceivingAddressesAction, SIGNAL(triggered()), walletFrame, SLOT(usedReceivingAddresses()));
+ connect(openAction, SIGNAL(triggered()), this, SLOT(openClicked()));
}
void BitcoinGUI::createMenuBar()
@@ -284,10 +293,14 @@ void BitcoinGUI::createMenuBar()
// Configure the menus
QMenu *file = appMenuBar->addMenu(tr("&File"));
+ file->addAction(openAction);
file->addAction(backupWalletAction);
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
file->addSeparator();
+ file->addAction(usedSendingAddressesAction);
+ file->addAction(usedReceivingAddressesAction);
+ file->addSeparator();
file->addAction(quitAction);
QMenu *settings = appMenuBar->addMenu(tr("&Settings"));
@@ -311,7 +324,6 @@ void BitcoinGUI::createToolBars()
toolbar->addAction(sendCoinsAction);
toolbar->addAction(receiveCoinsAction);
toolbar->addAction(historyAction);
- toolbar->addAction(addressBookAction);
}
void BitcoinGUI::setClientModel(ClientModel *clientModel)
@@ -439,28 +451,36 @@ void BitcoinGUI::aboutClicked()
dlg.exec();
}
+void BitcoinGUI::openClicked()
+{
+ OpenURIDialog dlg;
+ if(dlg.exec())
+ {
+ emit receivedURI(dlg.getURI());
+ }
+}
+
void BitcoinGUI::gotoOverviewPage()
{
+ overviewAction->setChecked(true);
if (walletFrame) walletFrame->gotoOverviewPage();
}
void BitcoinGUI::gotoHistoryPage()
{
+ historyAction->setChecked(true);
if (walletFrame) walletFrame->gotoHistoryPage();
}
-void BitcoinGUI::gotoAddressBookPage()
-{
- if (walletFrame) walletFrame->gotoAddressBookPage();
-}
-
void BitcoinGUI::gotoReceiveCoinsPage()
{
+ receiveCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoReceiveCoinsPage();
}
void BitcoinGUI::gotoSendCoinsPage(QString addr)
{
+ sendCoinsAction->setChecked(true);
if (walletFrame) walletFrame->gotoSendCoinsPage(addr);
}
@@ -590,21 +610,28 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
int nMBoxIcon = QMessageBox::Information;
int nNotifyIcon = Notificator::Information;
- // Override title based on style
QString msgType;
- switch (style) {
- case CClientUIInterface::MSG_ERROR:
- msgType = tr("Error");
- break;
- case CClientUIInterface::MSG_WARNING:
- msgType = tr("Warning");
- break;
- case CClientUIInterface::MSG_INFORMATION:
- msgType = tr("Information");
- break;
- default:
- msgType = title; // Use supplied title
+
+ // Prefer supplied title over style based title
+ if (!title.isEmpty()) {
+ msgType = title;
+ }
+ else {
+ switch (style) {
+ case CClientUIInterface::MSG_ERROR:
+ msgType = tr("Error");
+ break;
+ case CClientUIInterface::MSG_WARNING:
+ msgType = tr("Warning");
+ break;
+ case CClientUIInterface::MSG_INFORMATION:
+ msgType = tr("Information");
+ break;
+ default:
+ break;
+ }
}
+ // Append title to "Bitcoin - "
if (!msgType.isEmpty())
strTitle += " - " + msgType;
@@ -625,7 +652,9 @@ void BitcoinGUI::message(const QString &title, const QString &message, unsigned
if (!(buttons = (QMessageBox::StandardButton)(style & CClientUIInterface::BTN_MASK)))
buttons = QMessageBox::Ok;
- QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons);
+ // Ensure we get users attention
+ showNormalIfMinimized();
+ QMessageBox mBox((QMessageBox::Icon)nMBoxIcon, strTitle, message, buttons, this);
int r = mBox.exec();
if (ret != NULL)
*ret = r == QMessageBox::Ok;
@@ -676,9 +705,8 @@ void BitcoinGUI::askFee(qint64 nFeeRequired, bool *payFee)
QString strMessage = tr("This transaction is over the size limit. You can still send it for a fee of %1, "
"which goes to the nodes that process your transaction and helps to support the network. "
"Do you want to pay the fee?").arg(BitcoinUnits::formatWithUnit(clientModel->getOptionsModel()->getDisplayUnit(), nFeeRequired));
- QMessageBox::StandardButton retval = QMessageBox::question(
- this, tr("Confirm transaction fee"), strMessage,
- QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Yes);
+ QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm transaction fee"), strMessage,
+ QMessageBox::Yes | QMessageBox::Cancel, QMessageBox::Yes);
*payFee = (retval == QMessageBox::Yes);
}
@@ -707,23 +735,11 @@ void BitcoinGUI::dropEvent(QDropEvent *event)
{
if(event->mimeData()->hasUrls())
{
- int nValidUrisFound = 0;
- QList<QUrl> uris = event->mimeData()->urls();
- foreach(const QUrl &uri, uris)
+ foreach(const QUrl &uri, event->mimeData()->urls())
{
- SendCoinsRecipient r;
- if (GUIUtil::parseBitcoinURI(uri, &r) && walletFrame->handlePaymentRequest(r))
- nValidUrisFound++;
+ emit receivedURI(uri.toString());
}
-
- // if valid URIs were found
- if (nValidUrisFound)
- walletFrame->gotoSendCoinsPage();
- else
- message(tr("URI handling"), tr("URI can not be parsed! This can be caused by an invalid Bitcoin address or malformed URI parameters."),
- CClientUIInterface::ICON_WARNING);
}
-
event->acceptProposedAction();
}
@@ -739,18 +755,17 @@ bool BitcoinGUI::eventFilter(QObject *object, QEvent *event)
return QMainWindow::eventFilter(object, event);
}
-void BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
+bool BitcoinGUI::handlePaymentRequest(const SendCoinsRecipient& recipient)
{
- walletFrame->handlePaymentRequest(recipient);
-}
-
-void BitcoinGUI::showPaymentACK(QString msg)
-{
-#if QT_VERSION < 0x050000
- message(tr("Payment acknowledged"), Qt::escape(msg), CClientUIInterface::MODAL);
-#else
- message(tr("Payment acknowledged"), msg.toHtmlEscaped(), CClientUIInterface::MODAL);
-#endif
+ // URI has to be valid
+ if (walletFrame->handlePaymentRequest(recipient))
+ {
+ showNormalIfMinimized();
+ gotoSendCoinsPage();
+ return true;
+ }
+ else
+ return false;
}
void BitcoinGUI::setEncryptionStatus(int status)