mirror of https://github.com/mgba-emu/mgba.git
Support FileOpen events on OS X
This commit is contained in:
parent
8fc3ef27ad
commit
8aa5880afd
|
@ -28,5 +28,18 @@
|
|||
<true/>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>${MACOSX_BUNDLE_COPYRIGHT}</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>gba</string>
|
||||
</array>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>Game Boy Advance ROM Image</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Viewer</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
|
@ -28,6 +28,7 @@ set(SOURCE_FILES
|
|||
AudioDevice.cpp
|
||||
AudioProcessor.cpp
|
||||
Display.cpp
|
||||
GBAApp.cpp
|
||||
GameController.cpp
|
||||
LoadSaveState.cpp
|
||||
LogView.cpp
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
#include "GBAApp.h"
|
||||
|
||||
#include "GameController.h"
|
||||
|
||||
#include <QFileOpenEvent>
|
||||
|
||||
using namespace QGBA;
|
||||
|
||||
GBAApp::GBAApp(int& argc, char* argv[])
|
||||
: QApplication(argc, argv)
|
||||
{
|
||||
QApplication::setApplicationName(PROJECT_NAME);
|
||||
QApplication::setApplicationVersion(PROJECT_VERSION);
|
||||
|
||||
if (parseCommandArgs(&m_opts, argc, argv, 0)) {
|
||||
m_window.optionsPassed(&m_opts);
|
||||
}
|
||||
|
||||
m_window.show();
|
||||
}
|
||||
|
||||
GBAApp::~GBAApp() {
|
||||
freeOptions(&m_opts);
|
||||
}
|
||||
|
||||
bool GBAApp::event(QEvent* event) {
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
m_window.controller()->loadGame(static_cast<QFileOpenEvent*>(event)->file());
|
||||
return true;
|
||||
}
|
||||
return QApplication::event(event);
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
#ifndef QGBA_APP_H
|
||||
#define QGBA_APP_H
|
||||
|
||||
#include <QApplication>
|
||||
|
||||
#include "Window.h"
|
||||
|
||||
extern "C" {
|
||||
#include "platform/commandline.h"
|
||||
}
|
||||
|
||||
namespace QGBA {
|
||||
|
||||
class GameController;
|
||||
|
||||
class GBAApp : public QApplication {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
GBAApp(int& argc, char* argv[]);
|
||||
virtual ~GBAApp();
|
||||
|
||||
protected:
|
||||
bool event(QEvent*);
|
||||
|
||||
private:
|
||||
Window m_window;
|
||||
|
||||
StartupOptions m_opts;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -26,6 +26,8 @@ public:
|
|||
Window(QWidget* parent = nullptr);
|
||||
virtual ~Window();
|
||||
|
||||
GameController* controller() { return m_controller; }
|
||||
|
||||
static GBAKey mapKey(int qtKey);
|
||||
|
||||
void optionsPassed(StartupOptions*);
|
||||
|
|
|
@ -1,24 +1,7 @@
|
|||
#include <QApplication>
|
||||
#include "GBAApp.h"
|
||||
#include "Window.h"
|
||||
|
||||
extern "C" {
|
||||
#include "platform/commandline.h"
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
QApplication application(argc, argv);
|
||||
QApplication::setApplicationName(PROJECT_NAME);
|
||||
QApplication::setApplicationVersion(PROJECT_VERSION);
|
||||
|
||||
QGBA::Window window;
|
||||
|
||||
struct StartupOptions opts;
|
||||
if (parseCommandArgs(&opts, argc, argv, 0)) {
|
||||
window.optionsPassed(&opts);
|
||||
}
|
||||
window.show();
|
||||
|
||||
int rcode = application.exec();
|
||||
freeOptions(&opts);
|
||||
return rcode;
|
||||
QGBA::GBAApp application(argc, argv);
|
||||
return application.exec();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue