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:
@@ -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;
|
||||
}
|
||||
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user