aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl/main.cpp
diff options
context:
space:
mode:
authorNadia Holmquist Pedersen <nadia@nhp.sh>2021-08-23 10:27:03 +0200
committerNadia Holmquist Pedersen <nadia@nhp.sh>2021-08-23 10:27:03 +0200
commit6ad0e8d61a3511494dd2fc1c8ffa1ab051ea273c (patch)
treed7cf38dc8fc69798b904cab8d66fe92e39410823 /src/frontend/qt_sdl/main.cpp
parent883fceb6ce99b9c8abcd698ea73663c8c3ded0e0 (diff)
macOS: Allow opening ROMs with melonDS from Finder.
Diffstat (limited to 'src/frontend/qt_sdl/main.cpp')
-rw-r--r--src/frontend/qt_sdl/main.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/frontend/qt_sdl/main.cpp b/src/frontend/qt_sdl/main.cpp
index 272df3c..e2ee89a 100644
--- a/src/frontend/qt_sdl/main.cpp
+++ b/src/frontend/qt_sdl/main.cpp
@@ -2726,7 +2726,23 @@ void emuStop()
OSD::AddMessage(0xFFC040, "Shutdown");
}
+MelonApplication::MelonApplication(int& argc, char** argv)
+ : QApplication(argc, argv)
+{
+ setWindowIcon(QIcon(":/melon-icon"));
+}
+bool MelonApplication::event(QEvent *event)
+{
+ if (event->type() == QEvent::FileOpen)
+ {
+ QFileOpenEvent *openEvent = static_cast<QFileOpenEvent*>(event);
+ printf("%s\n", openEvent->file().toUtf8().constData());
+ mainWindow->loadROM(openEvent->file());
+ }
+
+ return QApplication::event(event);
+}
int main(int argc, char** argv)
{
@@ -2737,8 +2753,7 @@ int main(int argc, char** argv)
Platform::Init(argc, argv);
- QApplication melon(argc, argv);
- melon.setWindowIcon(QIcon(":/melon-icon"));
+ MelonApplication melon(argc, argv);
// http://stackoverflow.com/questions/14543333/joystick-wont-work-using-sdl
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");