diff options
Diffstat (limited to 'src/yuzu/main.cpp')
-rw-r--r-- | src/yuzu/main.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index 451e4a4d6..160613ee1 100644 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -675,6 +675,24 @@ void GMainWindow::RestoreUIState() { Debugger::ToggleConsole(); } +void GMainWindow::OnAppFocusStateChanged(Qt::ApplicationState state) { + if (!UISettings::values.pause_when_in_background) { + return; + } + if (state != Qt::ApplicationHidden && state != Qt::ApplicationInactive && + state != Qt::ApplicationActive) { + LOG_DEBUG(Frontend, "ApplicationState unusual flag: {} ", state); + } + if (ui.action_Pause->isEnabled() && + (state & (Qt::ApplicationHidden | Qt::ApplicationInactive))) { + auto_paused = true; + OnPauseGame(); + } else if (ui.action_Start->isEnabled() && auto_paused && state == Qt::ApplicationActive) { + auto_paused = false; + OnStartGame(); + } +} + void GMainWindow::ConnectWidgetEvents() { connect(game_list, &GameList::GameChosen, this, &GMainWindow::OnGameListLoadFile); connect(game_list, &GameList::OpenDirectory, this, &GMainWindow::OnGameListOpenDirectory); @@ -1821,6 +1839,10 @@ void GMainWindow::OnLoadAmiibo() { return; } + LoadAmiibo(filename); +} + +void GMainWindow::LoadAmiibo(const QString& filename) { Core::System& system{Core::System::GetInstance()}; Service::SM::ServiceManager& sm = system.ServiceManager(); auto nfc = sm.GetService<Service::NFP::Module::Interface>("nfp:user"); @@ -2171,10 +2193,19 @@ static bool IsSingleFileDropEvent(QDropEvent* event) { } void GMainWindow::dropEvent(QDropEvent* event) { - if (IsSingleFileDropEvent(event) && ConfirmChangeGame()) { - const QMimeData* mimeData = event->mimeData(); - QString filename = mimeData->urls().at(0).toLocalFile(); - BootGame(filename); + if (!IsSingleFileDropEvent(event)) { + return; + } + + const QMimeData* mime_data = event->mimeData(); + const QString filename = mime_data->urls().at(0).toLocalFile(); + + if (emulation_running && QFileInfo(filename).suffix() == QStringLiteral("bin")) { + LoadAmiibo(filename); + } else { + if (ConfirmChangeGame()) { + BootGame(filename); + } } } @@ -2320,6 +2351,9 @@ int main(int argc, char* argv[]) { // After settings have been loaded by GMainWindow, apply the filter main_window.show(); + QObject::connect(&app, &QGuiApplication::applicationStateChanged, &main_window, + &GMainWindow::OnAppFocusStateChanged); + Settings::LogSettings(); int result = app.exec(); |