2 Commits

Author SHA1 Message Date
64c4d2e064 feat(macOS): support file open event for association 2024-12-03 23:37:53 +08:00
e64b871a2f feat: macOS bundle support 2024-12-03 01:15:20 +08:00
5 changed files with 22 additions and 3 deletions

View File

@ -13,6 +13,7 @@ jobs:
uses: jurplel/install-qt-action@v4
with:
version: '6.8.1'
modules: 'qtimageformats'
- name: Run a qt project
run: |
cmake . -Bbuild

View File

@ -212,7 +212,7 @@ elseif (APPLE)
# See https://cmake.org/cmake/help/v3.15/prop_tgt/MACOSX_BUNDLE_INFO_PLIST.html
set_target_properties(${EXE_NAME} PROPERTIES
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_INFO_PLIST dist/MacOSXBundleInfo.plist.in
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/dist/MacOSXBundleInfo.plist.in
MACOSX_BUNDLE_BUNDLE_NAME "Pineapple Pictures"
MACOSX_BUNDLE_GUI_IDENTIFIER net.blumia.pineapple-pictures
MACOSX_BUNDLE_ICON_FILE app-icon.icns # contains the .icns file name, *without* the path.

View File

@ -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<QFileOpenEvent *>(event);
showUrls({fileOpenEvent->url()});
return true;
}
return false;
}
#endif // Q_OS_MACOS
void MainWindow::on_actionOpen_triggered()
{
QStringList picturesLocations = QStandardPaths::standardLocations(QStandardPaths::PicturesLocation);

View File

@ -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();

View File

@ -30,8 +30,6 @@
<true/>
<key>NSHumanReadableCopyright</key>
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
</dict>
<dict>
<key>CFBundleDocumentTypes</key>
<array>
<!-- JPEG -->