2014-11-26 23:02:44 +03:00
|
|
|
#include <AppleEvents.h>
|
|
|
|
#include <MacTypes.h>
|
|
|
|
#include <CoreServices/CoreServices.h>
|
2010-03-26 01:02:45 +03:00
|
|
|
#include <QApplication>
|
2010-02-02 04:07:02 +03:00
|
|
|
#include "MainWindow.h"
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
OSErr eventHandler(const AppleEvent *ev, AppleEvent *reply, SRefCon refcon);
|
|
|
|
}
|
|
|
|
|
|
|
|
OSErr eventHandler(const AppleEvent *, AppleEvent *, SRefCon )
|
|
|
|
{
|
|
|
|
// FIXME: Ugly hack; just using the first MainWindow we can find
|
|
|
|
MainWindow *mainwin = NULL;
|
|
|
|
foreach (QWidget *w, QApplication::topLevelWidgets()) {
|
|
|
|
mainwin = qobject_cast<MainWindow*>(w);
|
|
|
|
if (mainwin) break;
|
|
|
|
}
|
|
|
|
if (mainwin) {
|
2013-12-22 10:43:08 +04:00
|
|
|
mainwin->actionReloadRenderPreview();
|
2010-02-02 04:07:02 +03:00
|
|
|
}
|
|
|
|
return noErr;
|
|
|
|
}
|
|
|
|
|
|
|
|
void installAppleEventHandlers()
|
|
|
|
{
|
|
|
|
// Reload handler
|
|
|
|
OSErr err = AEInstallEventHandler('SCAD', 'relo', NewAEEventHandlerUPP(eventHandler), 0, true);
|
2014-02-04 10:22:02 +04:00
|
|
|
__Require_noErr(err, CantInstallAppleEventHandler);
|
2010-02-02 04:07:02 +03:00
|
|
|
return;
|
|
|
|
|
|
|
|
CantInstallAppleEventHandler:
|
|
|
|
fprintf(stderr, "AEInstallEventHandler() failed: %d\n", err); ;
|
|
|
|
}
|