From b81c87958f9a580aea8525467a482a35736958a1 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Wed, 25 Dec 2024 15:11:40 +1000 Subject: [PATCH] Qt: Fix F3 getting intercepted when game/FSUI active --- src/duckstation-qt/mainwindow.cpp | 24 +++++++++++++++++++----- src/duckstation-qt/mainwindow.h | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 2c4ee64ec..d42cfc9e5 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -371,6 +371,7 @@ void MainWindow::createDisplayWidget(bool fullscreen, bool render_to_main, bool } updateDisplayRelatedActions(true, render_to_main, fullscreen); + updateShortcutActions(false); // We need the surface visible. QGuiApplication::sync(); @@ -405,6 +406,7 @@ void MainWindow::releaseRenderWindow() m_display_created = false; updateDisplayRelatedActions(false, false, false); + updateShortcutActions(false); m_ui.actionViewSystemDisplay->setEnabled(false); m_ui.actionFullscreen->setEnabled(false); @@ -1739,11 +1741,7 @@ void MainWindow::updateEmulationActions(bool starting, bool running, bool cheevo m_ui.actionViewGameProperties->setDisabled(starting_or_not_running); - m_shortcuts.open_file->setEnabled(!starting_or_running); - m_shortcuts.game_list_refresh->setEnabled(!starting_or_running); - m_shortcuts.game_list_search->setEnabled(!starting_or_running); - m_shortcuts.game_grid_zoom_in->setEnabled(!starting_or_running); - m_shortcuts.game_grid_zoom_out->setEnabled(!starting_or_running); + updateShortcutActions(starting); if (starting_or_running) { @@ -1767,6 +1765,18 @@ void MainWindow::updateEmulationActions(bool starting, bool running, bool cheevo m_ui.statusBar->clearMessage(); } +void MainWindow::updateShortcutActions(bool starting) +{ + const bool starting_or_running = starting || s_system_valid; + const bool is_showing_game_list = isShowingGameList(); + + m_shortcuts.open_file->setEnabled(!starting_or_running); + m_shortcuts.game_list_refresh->setEnabled(is_showing_game_list); + m_shortcuts.game_list_search->setEnabled(is_showing_game_list); + m_shortcuts.game_grid_zoom_in->setEnabled(is_showing_game_list); + m_shortcuts.game_grid_zoom_out->setEnabled(is_showing_game_list); +} + void MainWindow::updateStatusBarWidgetVisibility() { auto Update = [this](QWidget* widget, bool visible, int stretch) { @@ -1915,6 +1925,8 @@ void MainWindow::switchToGameListView() QtUtils::ProcessEventsWithSleep(QEventLoop::ExcludeUserInputEvents, [this]() { return static_cast(m_display_widget); }); } + + updateShortcutActions(false); } m_game_list_widget->setFocus(); @@ -1932,6 +1944,8 @@ void MainWindow::switchToEmulationView() if (s_system_paused && !m_was_paused_on_surface_loss) g_emu_thread->setSystemPaused(false); + updateShortcutActions(false); + if (m_display_widget) m_display_widget->setFocus(); } diff --git a/src/duckstation-qt/mainwindow.h b/src/duckstation-qt/mainwindow.h index 5941595b8..17daa6700 100644 --- a/src/duckstation-qt/mainwindow.h +++ b/src/duckstation-qt/mainwindow.h @@ -225,6 +225,7 @@ private: void connectSignals(); void updateEmulationActions(bool starting, bool running, bool cheevos_challenge_mode); + void updateShortcutActions(bool starting); void updateStatusBarWidgetVisibility(); void updateWindowTitle(); void updateWindowState(bool force_visible = false);