diff --git a/macbuild/Resources/Info.plist.template b/macbuild/Resources/Info.plist.template index 74090cbb3..65fa6d47a 100644 --- a/macbuild/Resources/Info.plist.template +++ b/macbuild/Resources/Info.plist.template @@ -18,6 +18,21 @@ APPL CFBundleVersion ${VERSION} + CFBundleShortVersionString + ${VERSION} + CFBundleDocumentTypes + + + CFBundleTypeExtensions + + gds + + CFBundleTypeRole + Editor + CFBundleTypeIconFile + ${ICONFILE} + + CFBundleSignature ???? NSPrincipalClass 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 ac4f3dea4..ac26af7fe 100644 --- a/src/lay/lay/layApplication.cc +++ b/src/lay/lay/layApplication.cc @@ -1391,6 +1391,35 @@ GuiApplication::force_update_app_menu () #endif } +#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) +{ + if (event->type() == QEvent::FileOpen) { + QFileOpenEvent *openEvent = static_cast(event); + 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); +} +#endif + + int GuiApplication::exec () { 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 ();