summaryrefslogtreecommitdiff
path: root/src/AppleEvents.cc
blob: 3102792cbcc2db9fa7a4c942711b0c56a23d23b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <Carbon/Carbon.h>
#include <QApplication>
#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) {
		mainwin->actionReloadRenderCSG();
	}
	return noErr;
}

void installAppleEventHandlers()
{
	// Reload handler
  OSErr err = AEInstallEventHandler('SCAD', 'relo', NewAEEventHandlerUPP(eventHandler), 0, true);
  require_noerr(err, CantInstallAppleEventHandler);
	return;

CantInstallAppleEventHandler:
	fprintf(stderr, "AEInstallEventHandler() failed: %d\n", err);	;
}
contact: Jan Huwald // Impressum