Placeholders: Support for macOS #6290
authorMarkus Goetz <markus@woboq.com>
Thu, 19 Apr 2018 11:34:02 +0000 (13:34 +0200)
committerKevin Ottens <kevin.ottens@nextcloud.com>
Tue, 15 Dec 2020 09:57:51 +0000 (10:57 +0100)
cmake/modules/MacOSXBundleInfo.plist.in
src/gui/application.cpp
src/gui/application.h

index b753d9e5e3c2859714c30fffa5440bd35493fabd..55a9df55223256d1b5842081eaf5800dcf4071c4 100644 (file)
         <false/>
         <key>SUPublicDSAKeyFile</key>
         <string>dsa_pub.pem</string>
+
+<key>UTExportedTypeDeclarations</key>
+<array>
+    <dict>
+        <key>UTTypeIdentifier</key>
+        <string>@APPLICATION_REV_DOMAIN@.placeholder</string>
+        <key>UTTypeTagSpecification</key>
+        <dict>
+            <key>public.filename-extension</key>
+            <string>@APPLICATION_PLACEHOLDER_SUFFIX@</string>
+            <key>public.mime-type</key>
+            <string>application/octet-stream</string>
+        </dict>
+        <key>UTTypeConformsTo</key>
+         <array>
+             <string>public.data</string>
+         </array>
+    </dict>
+</array>
+
+<key>CFBundleDocumentTypes</key>
+<array>
+    <dict>
+        <key>CFBundleTypeName</key>
+        <string>@APPLICATION_EXECUTABLE@ Download Placeholder</string>
+        <key>CFBundleTypeRole</key>
+        <string>Editor</string>
+        <key>LSHandlerRank</key>
+        <string>Owner</string>
+        <key>LSItemContentTypes</key>
+        <array>
+            <string>@APPLICATION_REV_DOMAIN@.placeholder</string>
+        </array>
+    </dict>
+</array>
+
+
 </dict>
 </plist>
index 77bfaeef0ca6f26eebb450d908462445c0c1b860..8490547c0d4aeb4f67dffea2705dfbf88369baf4 100644 (file)
@@ -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<QFileOpenEvent *>(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
index d771c1422eee54ab789e0cd6d1e6c7090421bd74..546dc809b9fb93b26a186f35d2910180bea69000 100644 (file)
@@ -83,6 +83,7 @@ protected:
     void parseOptions(const QStringList &);
     void setupTranslations();
     void setupLogging();
+    bool event(QEvent *event);
 
 signals:
     void folderRemoved();