Added ROM file drag and drop into Qt main window feature. This will load the ROM into the emulator when dropped.

This commit is contained in:
mjbudd77 2021-05-29 09:16:30 -04:00
parent 10f599fd5b
commit 9cdbdb31b0
2 changed files with 26 additions and 0 deletions

View File

@ -140,6 +140,7 @@ consoleWin_t::consoleWin_t(QWidget *parent)
setWindowTitle( tr(FCEU_NAME_AND_VERSION) );
setWindowIcon(QIcon(":fceux1.png"));
setAcceptDrops(true);
gameTimer = new QTimer( this );
#if QT_VERSION >= QT_VERSION_CHECK(6,0,0)
@ -616,6 +617,27 @@ void consoleWin_t::keyReleaseEvent(QKeyEvent *event)
event->accept();
}
void consoleWin_t::dragEnterEvent(QDragEnterEvent *event)
{
if (event->mimeData()->hasUrls() )
{
event->acceptProposedAction();
}
}
void consoleWin_t::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasUrls() )
{
QList<QUrl> urls = event->mimeData()->urls();
fceuWrapperLock();
LoadGame( urls[0].path().toStdString().c_str() );
fceuWrapperUnLock();
event->accept();
}
}
//---------------------------------------------------------------------------
void consoleWin_t::initHotKeys(void)
{

View File

@ -16,6 +16,8 @@
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QKeyEvent>
#include <QDragEnterEvent>
#include <QDropEvent>
#include <QTimer>
#include <QThread>
#include <QCursor>
@ -257,6 +259,8 @@ class consoleWin_t : public QMainWindow
void closeEvent(QCloseEvent *event);
void keyPressEvent(QKeyEvent *event);
void keyReleaseEvent(QKeyEvent *event);
void dragEnterEvent(QDragEnterEvent *event);
void dropEvent(QDropEvent *event);
void syncActionConfig( QAction *act, const char *property );
void showErrorMsgWindow(void);