mirror of
https://github.com/PabloMK7/citra.git
synced 2025-09-09 20:30:05 +00:00
qt: Add support for opening files directly on macOS. (#7304)
* Associate 3ds files with Citra in Info.plist * qt: Add support for opening files directly on macOS. --------- Co-authored-by: shinra-electric <50119606+shinra-electric@users.noreply.github.com>
This commit is contained in:
parent
9b147d3f9c
commit
36db566428
3 changed files with 66 additions and 0 deletions
|
@ -229,6 +229,7 @@ GMainWindow::GMainWindow(Core::System& system_)
|
|||
SetDefaultUIGeometry();
|
||||
RestoreUIState();
|
||||
|
||||
ConnectAppEvents();
|
||||
ConnectMenuEvents();
|
||||
ConnectWidgetEvents();
|
||||
|
||||
|
@ -761,6 +762,21 @@ void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) {
|
|||
}
|
||||
}
|
||||
|
||||
bool GApplicationEventFilter::eventFilter(QObject* object, QEvent* event) {
|
||||
if (event->type() == QEvent::FileOpen) {
|
||||
emit FileOpen(static_cast<QFileOpenEvent*>(event));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void GMainWindow::ConnectAppEvents() {
|
||||
const auto filter = new GApplicationEventFilter();
|
||||
QGuiApplication::instance()->installEventFilter(filter);
|
||||
|
||||
connect(filter, &GApplicationEventFilter::FileOpen, this, &GMainWindow::OnFileOpen);
|
||||
}
|
||||
|
||||
void GMainWindow::ConnectWidgetEvents() {
|
||||
connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile);
|
||||
connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory);
|
||||
|
@ -2752,6 +2768,10 @@ bool GMainWindow::DropAction(QDropEvent* event) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void GMainWindow::OnFileOpen(const QFileOpenEvent* event) {
|
||||
BootGame(event->file());
|
||||
}
|
||||
|
||||
void GMainWindow::dropEvent(QDropEvent* event) {
|
||||
DropAction(event);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue