qt: add Open URI dialog

This commit is contained in:
Wladimir J. van der Laan
2013-11-06 15:08:56 +01:00
parent 3a8915d9a8
commit 4c60358604
11 changed files with 289 additions and 19 deletions

View File

@@ -15,6 +15,7 @@
#include "rpcconsole.h"
#include "walletframe.h"
#include "walletmodel.h"
#include "openuridialog.h"
#ifdef Q_OS_MAC
#include "macdockiconhandler.h"
@@ -262,6 +263,9 @@ void BitcoinGUI::createActions(bool fIsTestnet)
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()));
@@ -274,6 +278,7 @@ void BitcoinGUI::createActions(bool fIsTestnet)
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()
@@ -288,6 +293,7 @@ void BitcoinGUI::createMenuBar()
// Configure the menus
QMenu *file = appMenuBar->addMenu(tr("&File"));
file->addAction(openAction);
file->addAction(backupWalletAction);
file->addAction(signMessageAction);
file->addAction(verifyMessageAction);
@@ -445,6 +451,15 @@ void BitcoinGUI::aboutClicked()
dlg.exec();
}
void BitcoinGUI::openClicked()
{
OpenURIDialog dlg;
if(dlg.exec())
{
emit receivedURI(dlg.getURI());
}
}
void BitcoinGUI::gotoOverviewPage()
{
overviewAction->setChecked(true);
@@ -720,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();
}