Merge pull request #87 from lightwave-lab/open-with-macos

Open with macos
This commit is contained in:
Matthias Köfferlein 2018-03-11 22:08:49 +01:00 committed by GitHub
commit dc5792d768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 55 additions and 0 deletions

View File

@ -18,6 +18,21 @@
<string>APPL</string>
<key>CFBundleVersion</key>
<string>${VERSION}</string>
<key>CFBundleShortVersionString</key>
<string>${VERSION}</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
<string>gds</string>
</array>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleTypeIconFile</key>
<string>${ICONFILE}</string>
</dict>
</array>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSPrincipalClass</key>

BIN
macbuild/build4mac_env.pyc Normal file

Binary file not shown.

BIN
macbuild/build4mac_util.pyc Normal file

Binary file not shown.

View File

@ -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<QFileOpenEvent *>(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 ()
{

View File

@ -28,6 +28,9 @@
#include <QApplication>
#include <QEventLoop>
#ifdef __APPLE__
# include <QEvent>
#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 ();