diff --git a/src/main.cpp b/src/main.cpp index ccde0a2..6ede0f0 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -243,6 +243,9 @@ public: }); #endif + // For MacOS, we have an event filter + a.installEventFilter(w); + // Check if starting headless if (parser.isSet(headlessOption)) { Settings::getInstance()->setHeadless(true); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index aea54c6..c3abfc7 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -745,6 +745,20 @@ void MainWindow::balancesReady() { } +// Event filter for MacOS specific handling of payment URIs +bool MainWindow::eventFilter(QObject *object, QEvent *event) { + if (event->type() == QEvent::FileOpen) { + QFileOpenEvent *fileEvent = static_cast(event); + if (!fileEvent->url().isEmpty()) + payZcashURI(fileEvent->url().toString()); + + return true; + } + + return QObject::eventFilter(object, event); +} + + // Pay the Zcash URI by showing a confirmation window. If the URI parameter is empty, the UI // will prompt for one. void MainWindow::payZcashURI(QString uri) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 311f82d..1a80213 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -118,6 +118,7 @@ private: void doImport(QList* keys); void restoreSavedStates(); + bool eventFilter(QObject *object, QEvent *event); bool uiPaymentsReady = false; QString pendingURIPayment;