QtGui: Handle file open events

Handle file open events received by Dolphin. This allows Wii/GC files to be
opened when double-clicked or dropped on the Dolphin application on macOS.
This commit is contained in:
Vincent Duvert
2019-06-11 23:00:02 +02:00
parent c34388f75b
commit 2f63b71bde
5 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// Copyright 2019 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include <QFileOpenEvent>
#include "DolphinQt/QtUtils/FileOpenEventFilter.h"
FileOpenEventFilter::FileOpenEventFilter(QObject* event_source) : QObject(event_source)
{
event_source->installEventFilter(this);
}
bool FileOpenEventFilter::eventFilter(QObject* object, QEvent* event)
{
if (event->type() == QEvent::FileOpen)
{
auto* openEvent = static_cast<QFileOpenEvent*>(event);
emit fileOpened(openEvent->file());
return true;
}
return false;
}

View File

@ -0,0 +1,20 @@
// Copyright 2019 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#pragma once
#include <QObject>
class FileOpenEventFilter : public QObject
{
Q_OBJECT
public:
explicit FileOpenEventFilter(QObject* event_source);
signals:
void fileOpened(const QString& file_name);
private:
bool eventFilter(QObject* object, QEvent* event) override;
};