QApple: support yaml drops.

Signed-off-by: Andrea Odetti <mariofutire@gmail.com>
This commit is contained in:
Andrea Odetti 2021-11-07 16:42:31 +00:00
parent ca05f42721
commit 052ccac8d0
3 changed files with 39 additions and 3 deletions

View file

@ -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

View file

@ -44,6 +44,9 @@
#include <QSettings>
#include <QAudioOutput>
#include <QLabel>
#include <QMimeData>
#include <QDropEvent>
#include <QDragEnterEvent>
#include <algorithm>
@ -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<QUrl> urlList = mimeData->urls();
if (!urlList.isEmpty())
{
// just use first file
const QString file = urlList.first().toLocalFile();
if (!file.isEmpty())
{
event->acceptProposedAction();
loadStateFile(file);
}
}
}
}

View file

@ -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: