all repos — mgba @ eb4c41d6fc8ab1ed16e9812e4f54a1de93d6cc3c

mGBA Game Boy Advance Emulator

Qt: Drag and drop game loading (fixes #146)
Jeffrey Pfau jeffrey@endrift.com
Sun, 25 Jan 2015 04:53:24 -0800
commit

eb4c41d6fc8ab1ed16e9812e4f54a1de93d6cc3c

parent

0367a9db067e0c177aae24a0dbdc4e1ad3511668

3 files changed, 27 insertions(+), 0 deletions(-)

jump to
M CHANGESCHANGES

@@ -20,6 +20,7 @@ - Save directory of last loaded file

- Support BPS patches - Configurable game overrides - Support loading 7-Zip files + - Drag and drop game loading Bugfixes: - ARM7: Extend prefetch by one stage - GBA Audio: Support 16-bit writes to FIFO audio
M src/platform/qt/Window.cppsrc/platform/qt/Window.cpp

@@ -11,6 +11,7 @@ #include <QKeyEvent>

#include <QKeySequence> #include <QMenuBar> #include <QMessageBox> +#include <QMimeData> #include <QStackedLayout> #include "ConfigController.h"

@@ -54,6 +55,7 @@ , m_shortcutController(new ShortcutController(this))

{ setWindowTitle(PROJECT_NAME); setFocusPolicy(Qt::StrongFocus); + setAcceptDrops(true); m_controller = new GameController(this); m_controller->setInputController(&m_inputController); m_controller->setOverrides(m_config->overrides());

@@ -324,6 +326,28 @@

void Window::focusOutEvent(QFocusEvent*) { m_controller->setTurbo(false, false); m_controller->clearKeys(); +} + +void Window::dragEnterEvent(QDragEnterEvent* event) { + if (event->mimeData()->hasFormat("text/uri-list")) { + event->acceptProposedAction(); + } +} + +void Window::dropEvent(QDropEvent* event) { + QString uris = event->mimeData()->data("text/uri-list"); + uris = uris.trimmed(); + if (uris.contains("\n")) { + // Only one file please + return; + } + QUrl url(uris); + if (!url.isLocalFile()) { + // No remote loading + return; + } + event->accept(); + m_controller->loadGame(url.path()); } void Window::toggleFullScreen() {
M src/platform/qt/Window.hsrc/platform/qt/Window.h

@@ -91,6 +91,8 @@ virtual void keyReleaseEvent(QKeyEvent* event) override;

virtual void resizeEvent(QResizeEvent*) override; virtual void closeEvent(QCloseEvent*) override; virtual void focusOutEvent(QFocusEvent*) override; + virtual void dragEnterEvent(QDragEnterEvent*) override; + virtual void dropEvent(QDropEvent*) override; private slots: void gameStarted(GBAThread*);