diff --git a/res/info.plist.in b/res/info.plist.in
index 306f41f01..e7595b3f8 100644
--- a/res/info.plist.in
+++ b/res/info.plist.in
@@ -28,5 +28,18 @@
NSHumanReadableCopyright
${MACOSX_BUNDLE_COPYRIGHT}
+ CFBundleDocumentTypes
+
+
+ CFBundleTypeExtensions
+
+ gba
+
+ CFBundleTypeName
+ Game Boy Advance ROM Image
+ CFBundleTypeRole
+ Viewer
+
+
diff --git a/src/platform/qt/CMakeLists.txt b/src/platform/qt/CMakeLists.txt
index 1df82a57f..7cc50c27f 100644
--- a/src/platform/qt/CMakeLists.txt
+++ b/src/platform/qt/CMakeLists.txt
@@ -28,6 +28,7 @@ set(SOURCE_FILES
AudioDevice.cpp
AudioProcessor.cpp
Display.cpp
+ GBAApp.cpp
GameController.cpp
LoadSaveState.cpp
LogView.cpp
diff --git a/src/platform/qt/GBAApp.cpp b/src/platform/qt/GBAApp.cpp
new file mode 100644
index 000000000..daf58e59a
--- /dev/null
+++ b/src/platform/qt/GBAApp.cpp
@@ -0,0 +1,32 @@
+#include "GBAApp.h"
+
+#include "GameController.h"
+
+#include
+
+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(event)->file());
+ return true;
+ }
+ return QApplication::event(event);
+}
diff --git a/src/platform/qt/GBAApp.h b/src/platform/qt/GBAApp.h
new file mode 100644
index 000000000..a101b0ed5
--- /dev/null
+++ b/src/platform/qt/GBAApp.h
@@ -0,0 +1,34 @@
+#ifndef QGBA_APP_H
+#define QGBA_APP_H
+
+#include
+
+#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
diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h
index 9125559fd..9d6fe38d0 100644
--- a/src/platform/qt/Window.h
+++ b/src/platform/qt/Window.h
@@ -26,6 +26,8 @@ public:
Window(QWidget* parent = nullptr);
virtual ~Window();
+ GameController* controller() { return m_controller; }
+
static GBAKey mapKey(int qtKey);
void optionsPassed(StartupOptions*);
diff --git a/src/platform/qt/main.cpp b/src/platform/qt/main.cpp
index 555f648c2..8841fe4bb 100644
--- a/src/platform/qt/main.cpp
+++ b/src/platform/qt/main.cpp
@@ -1,24 +1,7 @@
-#include
+#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();
}