From f62bb24297b2702be42fbd9cf1bf4f3839b8eb2a Mon Sep 17 00:00:00 2001 From: Alan Westbrook Date: Thu, 6 Feb 2014 22:23:46 -0800 Subject: [PATCH] Fix some URI handling weirdness in Qt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit remove whack paths like file:dogecoin: change out dogecoin:/D for dogecoin:D Add a local URI handler so it doesn’t have to go through the system if we try a local url. --- src/qt/paymentserver.cpp | 13 ++++++++++--- src/qt/paymentserver.h | 1 + 2 files changed, 11 insertions(+), 3 deletions(-) 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();