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.
This commit is contained in:
Alan Westbrook 2014-02-06 22:23:46 -08:00
parent 64bd2e4536
commit f62bb24297
2 changed files with 11 additions and 3 deletions

View file

@ -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);

View file

@ -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();