Skip to content

Commit

Permalink
+ fixes #1860: Can not open a FreeCAD project in FreeCAD by double-cl…
Browse files Browse the repository at this point in the history
…icking the project file on Macintosh
  • Loading branch information
wwmayer committed Nov 29, 2015
1 parent b2080f9 commit 76c238f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/Gui/GuiApplication.cpp
Expand Up @@ -30,6 +30,7 @@
# include <QDataStream>
# include <QDebug>
# include <QFileInfo>
# include <QFileOpenEvent>
# include <QSessionManager>
# include <QTimer>
#endif
Expand All @@ -47,6 +48,7 @@
#endif

#include "GuiApplication.h"
#include "Application.h"
#include "SpaceballEvent.h"
#include "MainWindow.h"

Expand Down Expand Up @@ -144,6 +146,21 @@ void GUIApplication::commitData(QSessionManager &manager)
}
}

bool GUIApplication::event(QEvent * ev)
{
if (ev->type() == QEvent::FileOpen) {
QString file = static_cast<QFileOpenEvent*>(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 {
Expand Down
3 changes: 3 additions & 0 deletions src/Gui/GuiApplication.h
Expand Up @@ -49,6 +49,9 @@ class GUIApplication : public GUIApplicationNativeEventAware
bool notify (QObject * receiver, QEvent * event);
void commitData(QSessionManager &manager);

protected:
bool event(QEvent * event);

private:
int systemExit;
};
Expand Down
13 changes: 13 additions & 0 deletions src/MacAppBundle/FreeCAD.app/Contents/Info.plist
Expand Up @@ -34,5 +34,18 @@
<string>NSApplication</string>
<key>NSHighResolutionCapable</key>
<string>True</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleTypeExtensions</key>
<array>
<string>fcstd</string>
</array>
<key>LSIsAppleDefaultForType</key>
<true/>
</dict>
</array>
</dict>
</plist>

0 comments on commit 76c238f

Please sign in to comment.