diff --git a/app/mainwindow.cpp b/app/mainwindow.cpp index de44bf4..698d8bc 100644 --- a/app/mainwindow.cpp +++ b/app/mainwindow.cpp @@ -160,6 +160,10 @@ MainWindow::MainWindow(QWidget *parent) installResizeCapture(m_graphicsView->viewport()); installResizeCapture(m_gv); installResizeCapture(m_gv->viewport()); + +#ifdef Q_OS_MACOS + qApp->installEventFilter(this); +#endif // Q_OS_MACOS } MainWindow::~MainWindow() @@ -653,6 +657,19 @@ QSize MainWindow::sizeHint() const return QSize(710, 530); } +#ifdef Q_OS_MACOS +bool MainWindow::eventFilter(QObject *obj, QEvent *event) +{ + Q_UNUSED(obj); + if (event->type() == QEvent::FileOpen) { + QFileOpenEvent *fileOpenEvent = static_cast(event); + showUrls({fileOpenEvent->url()}); + return true; + } + return false; +} +#endif // Q_OS_MACOS + void MainWindow::on_actionOpen_triggered() { QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation); diff --git a/app/mainwindow.h b/app/mainwindow.h index 2850901..7c34645 100644 --- a/app/mainwindow.h +++ b/app/mainwindow.h @@ -77,6 +77,9 @@ protected slots: protected: QSize sizeHint() const override; +#ifdef Q_OS_MACOS + bool eventFilter(QObject *obj, QEvent *event) override; +#endif // Q_OS_MACOS private slots: void on_actionOpen_triggered();