From 8dcfd50a7d3bb88bdac4e1bc287e6a4f09ed72e1 Mon Sep 17 00:00:00 2001 From: Markus Goetz Date: Thu, 19 Apr 2018 13:34:02 +0200 Subject: [PATCH] Placeholders: Support for macOS #6290 --- cmake/modules/MacOSXBundleInfo.plist.in | 37 +++++++++++++++++++++++++ src/gui/application.cpp | 14 ++++++++++ src/gui/application.h | 1 + 3 files changed, 52 insertions(+) diff --git a/cmake/modules/MacOSXBundleInfo.plist.in b/cmake/modules/MacOSXBundleInfo.plist.in index b753d9e5e..55a9df552 100644 --- a/cmake/modules/MacOSXBundleInfo.plist.in +++ b/cmake/modules/MacOSXBundleInfo.plist.in @@ -36,5 +36,42 @@ SUPublicDSAKeyFile dsa_pub.pem + +UTExportedTypeDeclarations + + + UTTypeIdentifier + @APPLICATION_REV_DOMAIN@.placeholder + UTTypeTagSpecification + + public.filename-extension + @APPLICATION_PLACEHOLDER_SUFFIX@ + public.mime-type + application/octet-stream + + UTTypeConformsTo + + public.data + + + + +CFBundleDocumentTypes + + + CFBundleTypeName + @APPLICATION_EXECUTABLE@ Download Placeholder + CFBundleTypeRole + Editor + LSHandlerRank + Owner + LSItemContentTypes + + @APPLICATION_REV_DOMAIN@.placeholder + + + + + diff --git a/src/gui/application.cpp b/src/gui/application.cpp index 77bfaeef0..8490547c0 100644 --- a/src/gui/application.cpp +++ b/src/gui/application.cpp @@ -706,4 +706,18 @@ void Application::openPlaceholder(const QString &filename) }); } +bool Application::event(QEvent *event) +{ +#ifdef Q_OS_MAC + if (event->type() == QEvent::FileOpen) { + QFileOpenEvent *openEvent = static_cast(event); + qCDebug(lcApplication) << "QFileOpenEvent" << openEvent->file(); + // placeholder file, open it after the Folder were created (if the app is not terminated) + QString fn = openEvent->file(); + QTimer::singleShot(0, this, [this, fn] { openPlaceholder(fn); }); + } +#endif + return SharedTools::QtSingleApplication::event(event); +} + } // namespace OCC diff --git a/src/gui/application.h b/src/gui/application.h index d771c1422..546dc809b 100644 --- a/src/gui/application.h +++ b/src/gui/application.h @@ -83,6 +83,7 @@ protected: void parseOptions(const QStringList &); void setupTranslations(); void setupLogging(); + bool event(QEvent *event); signals: void folderRemoved(); -- 2.30.2