diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-08-07 16:04:48 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-08-07 16:04:48 +0200 |
commit | db7f023417eeeb96eed35c9d06541544abcd7033 (patch) | |
tree | 2f10b47a3090b5a7b1ae2c54342d0a7ed70b6d3e /src/qt/bitcoingui.cpp | |
parent | 330c190958a31a126de7a7b12124070300b1567b (diff) |
Accept "bitcoin:" URL drops from browsers
Diffstat (limited to 'src/qt/bitcoingui.cpp')
-rw-r--r-- | src/qt/bitcoingui.cpp | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 84d8fe4635..b20f633ffd 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -38,6 +38,9 @@ #include <QDateTime> #include <QMovie> +#include <QDragEnterEvent> +#include <QUrl> + #include <QDebug> #include <iostream> @@ -143,7 +146,9 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Clicking on a transaction simply sends you to transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage())); - gotoOverviewPage(); + setAcceptDrops(true); + + gotoOverviewPage(); } void BitcoinGUI::createActions() @@ -502,10 +507,36 @@ void BitcoinGUI::gotoReceiveCoinsPage() void BitcoinGUI::gotoSendCoinsPage() { sendCoinsAction->setChecked(true); - sendCoinsPage->clear(); + if(centralWidget->currentWidget() != sendCoinsPage) + { + // Clear the current contents if we arrived from another tab + sendCoinsPage->clear(); + } centralWidget->setCurrentWidget(sendCoinsPage); exportAction->setEnabled(false); disconnect(exportAction, SIGNAL(triggered()), 0, 0); } +void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event) +{ + // Accept only URLs + if(event->mimeData()->hasUrls()) + event->acceptProposedAction(); +} + +void BitcoinGUI::dropEvent(QDropEvent *event) +{ + if(event->mimeData()->hasUrls()) + { + gotoSendCoinsPage(); + QList<QUrl> urls = event->mimeData()->urls(); + foreach(const QUrl &url, urls) + { + sendCoinsPage->handleURL(&url); + } + } + + event->acceptProposedAction(); +} + |