mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
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:
24
Source/Core/DolphinQt/QtUtils/FileOpenEventFilter.cpp
Normal file
24
Source/Core/DolphinQt/QtUtils/FileOpenEventFilter.cpp
Normal 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;
|
||||
}
|
20
Source/Core/DolphinQt/QtUtils/FileOpenEventFilter.h
Normal file
20
Source/Core/DolphinQt/QtUtils/FileOpenEventFilter.h
Normal 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;
|
||||
};
|
Reference in New Issue
Block a user