From 76c238fc98901ebbcb09063e06864e04231371f6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 29 Nov 2015 15:36:47 +0100 Subject: [PATCH] + fixes #0001860: Can not open a FreeCAD project in FreeCAD by double-clicking the project file on Macintosh --- src/Gui/GuiApplication.cpp | 17 +++++++++++++++++ src/Gui/GuiApplication.h | 3 +++ .../FreeCAD.app/Contents/Info.plist | 13 +++++++++++++ 3 files changed, 33 insertions(+) diff --git a/src/Gui/GuiApplication.cpp b/src/Gui/GuiApplication.cpp index 5cd96d8b0..74183ee38 100644 --- a/src/Gui/GuiApplication.cpp +++ b/src/Gui/GuiApplication.cpp @@ -30,6 +30,7 @@ # include # include # include +# include # include # include #endif @@ -47,6 +48,7 @@ #endif #include "GuiApplication.h" +#include "Application.h" #include "SpaceballEvent.h" #include "MainWindow.h" @@ -144,6 +146,21 @@ void GUIApplication::commitData(QSessionManager &manager) } } +bool GUIApplication::event(QEvent * ev) +{ + if (ev->type() == QEvent::FileOpen) { + QString file = static_cast(ev)->file(); + QFileInfo fi(file); + if (fi.suffix().toLower() == QLatin1String("fcstd")) { + QByteArray fn = file.toUtf8(); + Application::Instance->open(fn, "FreeCAD"); + return true; + } + } + + return GUIApplicationNativeEventAware::event(ev); +} + // ---------------------------------------------------------------------------- class GUISingleApplication::Private { diff --git a/src/Gui/GuiApplication.h b/src/Gui/GuiApplication.h index 69f9b7e69..bc7827623 100644 --- a/src/Gui/GuiApplication.h +++ b/src/Gui/GuiApplication.h @@ -49,6 +49,9 @@ public: bool notify (QObject * receiver, QEvent * event); void commitData(QSessionManager &manager); +protected: + bool event(QEvent * event); + private: int systemExit; }; diff --git a/src/MacAppBundle/FreeCAD.app/Contents/Info.plist b/src/MacAppBundle/FreeCAD.app/Contents/Info.plist index 061b16d6c..32d72cb45 100644 --- a/src/MacAppBundle/FreeCAD.app/Contents/Info.plist +++ b/src/MacAppBundle/FreeCAD.app/Contents/Info.plist @@ -34,5 +34,18 @@ NSApplication NSHighResolutionCapable True + CFBundleDocumentTypes + + + CFBundleTypeRole + Editor + CFBundleTypeExtensions + + fcstd + + LSIsAppleDefaultForType + + +