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)) {