diff options
| author | Alan Westbrook <[email protected]> | 2014-02-06 22:23:46 -0800 |
|---|---|---|
| committer | Alan Westbrook <[email protected]> | 2014-02-06 22:23:46 -0800 |
| commit | f62bb24297b2702be42fbd9cf1bf4f3839b8eb2a (patch) | |
| tree | 6437783493f7d526e6f8d70207a009148ecfe27b | |
| parent | Version updates and read me to include boost instructions (diff) | |
| download | discoin-f62bb24297b2702be42fbd9cf1bf4f3839b8eb2a.tar.xz discoin-f62bb24297b2702be42fbd9cf1bf4f3839b8eb2a.zip | |
Fix some URI handling weirdness in Qt
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.
| -rw-r--r-- | src/qt/paymentserver.cpp | 13 | ||||
| -rw-r--r-- | 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 <QLocalServer> #include <QLocalSocket> #include <QStringList> +#include <QDesktopServices> #if QT_VERSION < 0x050000 #include <QUrl> #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(); |