diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 03007cdd9..cdbec9e59 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #if QT_VERSION < 0x050000 #include #endif @@ -109,6 +110,13 @@ PaymentServer::PaymentServer(QApplication* parent) : QObject(parent), saveURIs(t qDebug() << tr("Cannot start dogecoin: click-to-pay handler"); else connect(uriServer, SIGNAL(newConnection()), this, SLOT(handleURIConnection())); + + QDesktopServices::setUrlHandler("dogecoin", this, SLOT(handleDogeURI)); +} + +void PaymentServer::handleDogeURI(const QUrl &url) +{ + emit receivedURI(url.toString()); } bool PaymentServer::eventFilter(QObject *object, QEvent *event) @@ -121,9 +129,8 @@ bool PaymentServer::eventFilter(QObject *object, QEvent *event) { // WTF Qt? QString url = fileEvent->url().toString(); - if ( url.startsWith( "file:dogecoin:/D" ) ) { - url.replace( "file:dogecoin:/D", "dogecoin://D" ); - } + url.replace("file:dogecoin", "dogecoin"); + url.replace(":/D", ":D"); if (saveURIs) // Before main window is ready: savedPaymentRequests.append(url); diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h index 1f2fdd466..f1ffc9008 100644 --- a/src/qt/paymentserver.h +++ b/src/qt/paymentserver.h @@ -59,6 +59,7 @@ public slots: // Signal this when the main window's UI is ready // to display payment requests to the user void uiReady(); + void handleDogeURI(const QUrl& url); private slots: void handleURIConnection();