diff --git a/linux.md b/linux.md index 2823de5e..957b24a4 100644 --- a/linux.md +++ b/linux.md @@ -70,14 +70,14 @@ The joystick uses evdev (``--device-name /dev/input/by-id/id_of_device``). This is based on Qt. * keyboard shortcuts are listed in the menu entries -* graphics: runs the native NTSC code * joystick: it uses QtGamepad * emulator runs in the main UI thread * Qt timers are very coarse: the emulator needs to dynamically adapt the cycles to execute * the app runs at 60FPS with correction for uneven timer deltas. * full speed when disk spins execute up to 5 ms real wall clock of emulator code (then returns to Qt) -* (standard) audio is supported and there are a few configuration options to tune the latency (default very conservative 200ms) +* audio is supported and there are a few configuration options to tune the latency (default very conservative 200ms) * Open Apple and Solid Apple can be emulated using AltGr and Menu (unfortunately, Alt does not work well) +* ``yaml`` files can be dropped to restore a saved state ### ra2 diff --git a/source/frontends/qt/qapple.cpp b/source/frontends/qt/qapple.cpp index 90303e49..2700a847 100644 --- a/source/frontends/qt/qapple.cpp +++ b/source/frontends/qt/qapple.cpp @@ -44,6 +44,9 @@ #include #include #include +#include +#include +#include #include @@ -204,6 +207,8 @@ QApple::QApple(QWidget *parent) : on_actionPause_triggered(); initialiseEmulator(); loadEmulator(myFrame, myOptions); + + setAcceptDrops(true); } QApple::~QApple() @@ -554,3 +559,32 @@ void QApple::on_actionQuit_triggered() { this->close(); } + +void QApple::dragEnterEvent(QDragEnterEvent *event) +{ + if (event->mimeData()->hasUrls()) + { + event->acceptProposedAction(); + } +} + +void QApple::dropEvent(QDropEvent *event) +{ + const QMimeData* mimeData = event->mimeData(); + + if (mimeData->hasUrls()) + { + const QList urlList = mimeData->urls(); + + if (!urlList.isEmpty()) + { + // just use first file + const QString file = urlList.first().toLocalFile(); + if (!file.isEmpty()) + { + event->acceptProposedAction(); + loadStateFile(file); + } + } + } +} diff --git a/source/frontends/qt/qapple.h b/source/frontends/qt/qapple.h index cb14ad2e..11fc95dd 100644 --- a/source/frontends/qt/qapple.h +++ b/source/frontends/qt/qapple.h @@ -38,8 +38,10 @@ public slots: void startEmulator(); protected: - void closeEvent(QCloseEvent * event) override; + void closeEvent(QCloseEvent *event) override; void timerEvent(QTimerEvent *event) override; + void dragEnterEvent(QDragEnterEvent *event) override; + void dropEvent(QDropEvent *event) override; private slots: