-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMacOSXApplication.h
40 lines (32 loc) · 1.05 KB
/
MacOSXApplication.h
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
33
34
35
36
37
38
39
40
#ifndef MACOSXAPPLICATION_H
#define MACOSXAPPLICATION_H
#include <QApplication>
#include <QFileOpenEvent>
#include <QEvent>
#include "AnsiString.h"
typedef bool (*OSX_OPEN_CALLBACK)(const char *fname, void *user_data);
typedef struct {
int step;
void *userdata;
AnsiString data;
} MacOSXStep;
class MacOSXApplication : public QApplication{
Q_OBJECT
OSX_OPEN_CALLBACK open_callback;
public:
void *userdata;
MacOSXApplication(OSX_OPEN_CALLBACK open_callback, void *user_data, int &argc, char **argv) : QApplication(argc, argv){
this->open_callback = open_callback;
this->userdata = user_data;
}
protected:
bool event(QEvent *ev){ // the open file event handler
if (ev->type() == QEvent::FileOpen) {
const QString file_name = static_cast<QFileOpenEvent*>(ev)->file();
if (open_callback(file_name.toUtf8().data(), userdata))
return true;
}
return QApplication::event(ev);
}
};
#endif // MACOSXAPPLICATION_H