feat(macOS): support file open event for association
This commit is contained in:
parent
e64b871a2f
commit
64c4d2e064
@ -160,6 +160,10 @@ MainWindow::MainWindow(QWidget *parent)
|
|||||||
installResizeCapture(m_graphicsView->viewport());
|
installResizeCapture(m_graphicsView->viewport());
|
||||||
installResizeCapture(m_gv);
|
installResizeCapture(m_gv);
|
||||||
installResizeCapture(m_gv->viewport());
|
installResizeCapture(m_gv->viewport());
|
||||||
|
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
qApp->installEventFilter(this);
|
||||||
|
#endif // Q_OS_MACOS
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
@ -653,6 +657,19 @@ QSize MainWindow::sizeHint() const
|
|||||||
return QSize(710, 530);
|
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<QFileOpenEvent *>(event);
|
||||||
|
showUrls({fileOpenEvent->url()});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif // Q_OS_MACOS
|
||||||
|
|
||||||
void MainWindow::on_actionOpen_triggered()
|
void MainWindow::on_actionOpen_triggered()
|
||||||
{
|
{
|
||||||
QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
|
QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);
|
||||||
|
@ -77,6 +77,9 @@ protected slots:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const override;
|
||||||
|
#ifdef Q_OS_MACOS
|
||||||
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
||||||
|
#endif // Q_OS_MACOS
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void on_actionOpen_triggered();
|
void on_actionOpen_triggered();
|
||||||
|
Loading…
Reference in New Issue
Block a user