From 4db29d337d8fa84b096f0b75273c8541201ed3dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20=C3=87EL=C4=B0K?= Date: Tue, 23 Nov 2021 22:59:43 +0300 Subject: [PATCH] added zano url-scheme handler for MacOS, Windows, Linux (#311) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added zano url-scheme handler MacOS, Windows, Linux setups * pass parameters to executable and print console * added event filter for url-scheme handling in MacOS Co-authored-by: Barış Çelik --- .../qt-daemon/application/urleventfilter.cpp | 18 ++++++++++++++++++ src/gui/qt-daemon/application/urleventfilter.h | 12 ++++++++++++ src/gui/qt-daemon/main.cpp | 12 +++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 src/gui/qt-daemon/application/urleventfilter.cpp create mode 100644 src/gui/qt-daemon/application/urleventfilter.h diff --git a/src/gui/qt-daemon/application/urleventfilter.cpp b/src/gui/qt-daemon/application/urleventfilter.cpp new file mode 100644 index 00000000..d7e4e35e --- /dev/null +++ b/src/gui/qt-daemon/application/urleventfilter.cpp @@ -0,0 +1,18 @@ +#include "urleventfilter.h" +#include + +bool URLEventFilter::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::FileOpen) { + QFileOpenEvent *fileEvent = static_cast(event); + if(!fileEvent->url().isEmpty()) + { + QMessageBox msg; + msg.setText(fileEvent->url().toString()); + msg.exec(); + } + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } + }; diff --git a/src/gui/qt-daemon/application/urleventfilter.h b/src/gui/qt-daemon/application/urleventfilter.h new file mode 100644 index 00000000..54341dbd --- /dev/null +++ b/src/gui/qt-daemon/application/urleventfilter.h @@ -0,0 +1,12 @@ +#include +#include +#include + +class URLEventFilter : public QObject +{ + Q_OBJECT +public: + URLEventFilter() : QObject(){}; +protected: + bool eventFilter(QObject *obj, QEvent *event) override; +}; \ No newline at end of file diff --git a/src/gui/qt-daemon/main.cpp b/src/gui/qt-daemon/main.cpp index a37f6241..f32dde0f 100644 --- a/src/gui/qt-daemon/main.cpp +++ b/src/gui/qt-daemon/main.cpp @@ -12,7 +12,9 @@ //#include "qtlogger.h" #include "include_base_utils.h" #include "currency_core/currency_config.h" - +#ifdef Q_OS_DARWIN +#include "application/urleventfilter.h" +#endif int main(int argc, char *argv[]) { @@ -27,6 +29,8 @@ int main(int argc, char *argv[]) // _set_FMA3_enable(0); //#endif // ARCH_CPU_X86_64 && _MSC_VER <= 1800 + if(argc > 1) + std::cout << argv[1] << std::endl; #ifdef _MSC_VER #ifdef _WIN64 @@ -62,6 +66,12 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); + +#ifdef Q_OS_DARWIN + URLEventFilter url_event_filter; + app.installEventFilter(&url_event_filter); +#endif + MainWindow viewer; if (!viewer.init_backend(argc, argv)) {