+ fixes #0001860: Can not open a FreeCAD project in FreeCAD by double-clicking the project file on Macintosh

This commit is contained in:
wmayer 2015-11-29 15:36:47 +01:00
parent b2080f945a
commit 76c238fc98
3 changed files with 33 additions and 0 deletions

View File

@ -30,6 +30,7 @@
# include <QDataStream>
# include <QDebug>
# include <QFileInfo>
# include <QFileOpenEvent>
# include <QSessionManager>
# include <QTimer>
#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<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 {

View File

@ -49,6 +49,9 @@ public:
bool notify (QObject * receiver, QEvent * event);
void commitData(QSessionManager &manager);
protected:
bool event(QEvent * event);
private:
int systemExit;
};

View File

@ -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>