diff --git a/macbuild/Resources/Info.plist.template b/macbuild/Resources/Info.plist.template
index 5cdd0bd83..55dcee2ad 100644
--- a/macbuild/Resources/Info.plist.template
+++ b/macbuild/Resources/Info.plist.template
@@ -18,6 +18,8 @@
APPL
CFBundleVersion
${VERSION}
+ CFBundleShortVersionString
+ ${VERSION}
CFBundleDocumentTypes
diff --git a/macbuild/build4mac_env.pyc b/macbuild/build4mac_env.pyc
new file mode 100644
index 000000000..906f510e1
Binary files /dev/null and b/macbuild/build4mac_env.pyc differ
diff --git a/macbuild/build4mac_util.pyc b/macbuild/build4mac_util.pyc
new file mode 100644
index 000000000..e1194a0e0
Binary files /dev/null and b/macbuild/build4mac_util.pyc differ
diff --git a/src/lay/lay/layApplication.cc b/src/lay/lay/layApplication.cc
index bd39e552e..ac26af7fe 100644
--- a/src/lay/lay/layApplication.cc
+++ b/src/lay/lay/layApplication.cc
@@ -75,11 +75,6 @@
# include
#endif
-#if defined(__APPLE__)
-# include
-# include
-#endif
-
namespace gsi
{
void make_application_decl (bool non_gui_mode);
@@ -1397,12 +1392,27 @@ GuiApplication::force_update_app_menu ()
}
#if defined(__APPLE__)
+// By Thomas Lima (March 7, 2018)
+//
+// This event interceptor catches MacOS "Open With" event, and KLayout should respond
+// similarly to the Drop event in MainWindow::dropEvent.
+//
+// This particular implementation always creates a new window.
+//
+// This was implemented with the inspiration of http://doc.qt.io/qt-5/qfileopenevent.html
bool
-GuiApplication::event(QEvent *event)
+GuiApplication::event (QEvent *event)
{
if (event->type() == QEvent::FileOpen) {
QFileOpenEvent *openEvent = static_cast(event);
- qDebug() << "Open file" << openEvent->file();
+ if (mp_mw)
+ {
+ const std::string tech = mp_mw->initial_technology();
+ const std::string file = tl::to_string (openEvent->file());
+ const int mode = 1; // open in new window
+ mp_mw->load_layout (file, tech, mode);
+ mp_mw->add_mru (file, tech);
+ }
}
return QApplication::event(event);
diff --git a/src/lay/lay/layApplication.h b/src/lay/lay/layApplication.h
index 7eceea849..e82681e2f 100644
--- a/src/lay/lay/layApplication.h
+++ b/src/lay/lay/layApplication.h
@@ -28,6 +28,9 @@
#include
#include
+#ifdef __APPLE__
+# include
+#endif
#include "gsi.h"
@@ -438,6 +441,14 @@ public:
*/
void force_update_app_menu ();
+ /**
+ * @brief Handles MacOS file open
+ * This function is used to process the "Open With" event sent by MacOS.
+ */
+#ifdef __APPLE__
+ bool event (QEvent *event);
+#endif
+
protected:
virtual void setup ();
virtual void shutdown ();