macOS: Allow opening ROMs with melonDS from Finder.
This commit is contained in:
parent
883fceb6ce
commit
6ad0e8d61a
|
@ -22,5 +22,17 @@
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSMicrophoneUsageDescription</key>
|
<key>NSMicrophoneUsageDescription</key>
|
||||||
<string>We need microphone access so you can use the emulated DS microphone</string>
|
<string>We need microphone access so you can use the emulated DS microphone</string>
|
||||||
|
<key>CFBundleDocumentTypes</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>CFBundleTypeExtensions</key>
|
||||||
|
<array>
|
||||||
|
<string>nds</string>
|
||||||
|
<string>srl</string>
|
||||||
|
</array>
|
||||||
|
<key>CFBundleTypeRole</key>
|
||||||
|
<string>Viewer</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
|
|
|
@ -2726,7 +2726,23 @@ void emuStop()
|
||||||
OSD::AddMessage(0xFFC040, "Shutdown");
|
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)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
|
@ -2737,8 +2753,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
Platform::Init(argc, argv);
|
Platform::Init(argc, argv);
|
||||||
|
|
||||||
QApplication melon(argc, argv);
|
MelonApplication melon(argc, argv);
|
||||||
melon.setWindowIcon(QIcon(":/melon-icon"));
|
|
||||||
|
|
||||||
// http://stackoverflow.com/questions/14543333/joystick-wont-work-using-sdl
|
// http://stackoverflow.com/questions/14543333/joystick-wont-work-using-sdl
|
||||||
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
SDL_SetHint(SDL_HINT_JOYSTICK_ALLOW_BACKGROUND_EVENTS, "1");
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
#ifndef MAIN_H
|
#ifndef MAIN_H
|
||||||
#define MAIN_H
|
#define MAIN_H
|
||||||
|
|
||||||
|
#include <QApplication>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
|
@ -189,6 +190,14 @@ private:
|
||||||
GLuint screenTexture;
|
GLuint screenTexture;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class MelonApplication : public QApplication
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MelonApplication(int &argc, char** argv);
|
||||||
|
bool event(QEvent* event) override;
|
||||||
|
};
|
||||||
|
|
||||||
class MainWindow : public QMainWindow
|
class MainWindow : public QMainWindow
|
||||||
{
|
{
|
||||||
|
@ -201,6 +210,9 @@ public:
|
||||||
bool hasOGL;
|
bool hasOGL;
|
||||||
QOpenGLContext* getOGLContext();
|
QOpenGLContext* getOGLContext();
|
||||||
|
|
||||||
|
void loadROM(QString filename);
|
||||||
|
void loadROM(QByteArray *romData, QString archiveFileName, QString romFileName);
|
||||||
|
|
||||||
void onAppStateChanged(Qt::ApplicationState state);
|
void onAppStateChanged(Qt::ApplicationState state);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -278,8 +290,6 @@ private:
|
||||||
QList<QString> recentFileList;
|
QList<QString> recentFileList;
|
||||||
QMenu *recentMenu;
|
QMenu *recentMenu;
|
||||||
void updateRecentFilesMenu();
|
void updateRecentFilesMenu();
|
||||||
void loadROM(QString filename);
|
|
||||||
void loadROM(QByteArray *romData, QString archiveFileName, QString romFileName);
|
|
||||||
|
|
||||||
QString pickAndExtractFileFromArchive(QString archiveFileName, QByteArray *romBuffer);
|
QString pickAndExtractFileFromArchive(QString archiveFileName, QByteArray *romBuffer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue