Qt: Add option to exit Big Picture UI

This commit is contained in:
Stenzek 2023-09-05 20:12:54 +10:00
parent 37f830d8b9
commit 6a53929e31
4 changed files with 31 additions and 9 deletions

View File

@ -288,9 +288,6 @@ std::optional<WindowInfo> MainWindow::acquireRenderWindow(bool recreate_window,
updateWindowTitle(); updateWindowTitle();
updateWindowState(); updateWindowState();
m_ui.actionStartFullscreenUI->setEnabled(false);
m_ui.actionStartFullscreenUI2->setEnabled(false);
updateDisplayWidgetCursor(); updateDisplayWidgetCursor();
updateDisplayRelatedActions(true, render_to_main, fullscreen); updateDisplayRelatedActions(true, render_to_main, fullscreen);
m_display_widget->setFocus(); m_display_widget->setFocus();
@ -405,8 +402,6 @@ void MainWindow::releaseRenderWindow()
m_ui.actionViewSystemDisplay->setEnabled(false); m_ui.actionViewSystemDisplay->setEnabled(false);
m_ui.actionFullscreen->setEnabled(false); m_ui.actionFullscreen->setEnabled(false);
m_ui.actionStartFullscreenUI->setEnabled(true);
m_ui.actionStartFullscreenUI2->setEnabled(true);
} }
void MainWindow::destroyDisplayWidget(bool show_game_list) void MainWindow::destroyDisplayWidget(bool show_game_list)
@ -1184,6 +1179,20 @@ void MainWindow::onCheatsMenuAboutToShow()
populateCheatsMenu(m_ui.menuCheats); populateCheatsMenu(m_ui.menuCheats);
} }
void MainWindow::onStartFullscreenUITriggered()
{
if (m_display_widget)
g_emu_thread->stopFullscreenUI();
else
g_emu_thread->startFullscreenUI();
}
void MainWindow::onFullscreenUIStateChange(bool running)
{
m_ui.actionStartFullscreenUI->setText(running ? tr("Stop Big Picture Mode") : tr("Start Big Picture Mode"));
m_ui.actionStartFullscreenUI2->setText(running ? tr("Exit Big Picture") : tr("Big Picture"));
}
void MainWindow::onRemoveDiscActionTriggered() void MainWindow::onRemoveDiscActionTriggered()
{ {
g_emu_thread->changeDisc(QString()); g_emu_thread->changeDisc(QString());
@ -1633,6 +1642,8 @@ void MainWindow::updateEmulationActions(bool starting, bool running, bool cheevo
m_ui.actionStartDisc->setDisabled(starting || running); m_ui.actionStartDisc->setDisabled(starting || running);
m_ui.actionStartBios->setDisabled(starting || running); m_ui.actionStartBios->setDisabled(starting || running);
m_ui.actionResumeLastState->setDisabled(starting || running || cheevos_challenge_mode); m_ui.actionResumeLastState->setDisabled(starting || running || cheevos_challenge_mode);
m_ui.actionStartFullscreenUI->setDisabled(starting || running);
m_ui.actionStartFullscreenUI2->setDisabled(starting || running);
m_ui.actionPowerOff->setDisabled(starting || !running); m_ui.actionPowerOff->setDisabled(starting || !running);
m_ui.actionPowerOffWithoutSaving->setDisabled(starting || !running); m_ui.actionPowerOffWithoutSaving->setDisabled(starting || !running);
@ -1879,6 +1890,8 @@ void MainWindow::connectSignals()
connect(m_ui.menuSaveState, &QMenu::aboutToShow, this, &MainWindow::onSaveStateMenuAboutToShow); connect(m_ui.menuSaveState, &QMenu::aboutToShow, this, &MainWindow::onSaveStateMenuAboutToShow);
connect(m_ui.menuCheats, &QMenu::aboutToShow, this, &MainWindow::onCheatsMenuAboutToShow); connect(m_ui.menuCheats, &QMenu::aboutToShow, this, &MainWindow::onCheatsMenuAboutToShow);
connect(m_ui.actionCheats, &QAction::triggered, [this] { m_ui.menuCheats->exec(QCursor::pos()); }); connect(m_ui.actionCheats, &QAction::triggered, [this] { m_ui.menuCheats->exec(QCursor::pos()); });
connect(m_ui.actionStartFullscreenUI, &QAction::triggered, this, &MainWindow::onStartFullscreenUITriggered);
connect(m_ui.actionStartFullscreenUI2, &QAction::triggered, this, &MainWindow::onStartFullscreenUITriggered);
connect(m_ui.actionRemoveDisc, &QAction::triggered, this, &MainWindow::onRemoveDiscActionTriggered); connect(m_ui.actionRemoveDisc, &QAction::triggered, this, &MainWindow::onRemoveDiscActionTriggered);
connect(m_ui.actionAddGameDirectory, &QAction::triggered, connect(m_ui.actionAddGameDirectory, &QAction::triggered,
[this]() { getSettingsDialog()->getGameListSettingsWidget()->addSearchDirectory(this); }); [this]() { getSettingsDialog()->getGameListSettingsWidget()->addSearchDirectory(this); });
@ -1945,8 +1958,6 @@ void MainWindow::connectSignals()
connect(m_ui.actionGridViewRefreshCovers, &QAction::triggered, m_game_list_widget, connect(m_ui.actionGridViewRefreshCovers, &QAction::triggered, m_game_list_widget,
&GameListWidget::refreshGridCovers); &GameListWidget::refreshGridCovers);
connect(m_ui.actionStartFullscreenUI, &QAction::triggered, g_emu_thread, &EmuThread::startFullscreenUI);
connect(m_ui.actionStartFullscreenUI2, &QAction::triggered, g_emu_thread, &EmuThread::startFullscreenUI);
connect(g_emu_thread, &EmuThread::settingsResetToDefault, this, &MainWindow::onSettingsResetToDefault, connect(g_emu_thread, &EmuThread::settingsResetToDefault, this, &MainWindow::onSettingsResetToDefault,
Qt::QueuedConnection); Qt::QueuedConnection);
connect(g_emu_thread, &EmuThread::errorReported, this, &MainWindow::reportError, Qt::BlockingQueuedConnection); connect(g_emu_thread, &EmuThread::errorReported, this, &MainWindow::reportError, Qt::BlockingQueuedConnection);
@ -1964,6 +1975,7 @@ void MainWindow::connectSignals()
connect(g_emu_thread, &EmuThread::systemResumed, this, &MainWindow::onSystemResumed); connect(g_emu_thread, &EmuThread::systemResumed, this, &MainWindow::onSystemResumed);
connect(g_emu_thread, &EmuThread::runningGameChanged, this, &MainWindow::onRunningGameChanged); connect(g_emu_thread, &EmuThread::runningGameChanged, this, &MainWindow::onRunningGameChanged);
connect(g_emu_thread, &EmuThread::mouseModeRequested, this, &MainWindow::onMouseModeRequested); connect(g_emu_thread, &EmuThread::mouseModeRequested, this, &MainWindow::onMouseModeRequested);
connect(g_emu_thread, &EmuThread::fullscreenUIStateChange, this, &MainWindow::onFullscreenUIStateChange);
#ifdef WITH_CHEEVOS #ifdef WITH_CHEEVOS
connect(g_emu_thread, &EmuThread::achievementsChallengeModeChanged, this, connect(g_emu_thread, &EmuThread::achievementsChallengeModeChanged, this,
&MainWindow::onAchievementsChallengeModeChanged); &MainWindow::onAchievementsChallengeModeChanged);

View File

@ -142,6 +142,8 @@ private Q_SLOTS:
void onLoadStateMenuAboutToShow(); void onLoadStateMenuAboutToShow();
void onSaveStateMenuAboutToShow(); void onSaveStateMenuAboutToShow();
void onCheatsMenuAboutToShow(); void onCheatsMenuAboutToShow();
void onStartFullscreenUITriggered();
void onFullscreenUIStateChange(bool running);
void onRemoveDiscActionTriggered(); void onRemoveDiscActionTriggered();
void onViewToolbarActionToggled(bool checked); void onViewToolbarActionToggled(bool checked);
void onViewLockToolbarActionToggled(bool checked); void onViewLockToolbarActionToggled(bool checked);

View File

@ -475,6 +475,8 @@ void EmuThread::startFullscreenUI()
return; return;
} }
emit fullscreenUIStateChange(true);
// poll more frequently so we don't lose events // poll more frequently so we don't lose events
stopBackgroundControllerPollTimer(); stopBackgroundControllerPollTimer();
startBackgroundControllerPollTimer(); startBackgroundControllerPollTimer();
@ -488,7 +490,7 @@ void EmuThread::stopFullscreenUI()
QMetaObject::invokeMethod(this, &EmuThread::stopFullscreenUI, Qt::QueuedConnection); QMetaObject::invokeMethod(this, &EmuThread::stopFullscreenUI, Qt::QueuedConnection);
// wait until the host display is gone // wait until the host display is gone
while (g_gpu_device) while (!QtHost::IsSystemValid() && g_gpu_device)
QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1); QApplication::processEvents(QEventLoop::ExcludeUserInputEvents, 1);
return; return;
@ -497,10 +499,15 @@ void EmuThread::stopFullscreenUI()
if (System::IsValid()) if (System::IsValid())
shutdownSystem(); shutdownSystem();
if (m_run_fullscreen_ui)
{
m_run_fullscreen_ui = false;
emit fullscreenUIStateChange(false);
}
if (!g_gpu_device) if (!g_gpu_device)
return; return;
m_run_fullscreen_ui = false;
Host::ReleaseGPUDevice(); Host::ReleaseGPUDevice();
Host::ReleaseRenderWindow(); Host::ReleaseRenderWindow();
} }

View File

@ -140,6 +140,7 @@ Q_SIGNALS:
void runningGameChanged(const QString& filename, const QString& game_serial, const QString& game_title); void runningGameChanged(const QString& filename, const QString& game_serial, const QString& game_title);
void inputProfileLoaded(); void inputProfileLoaded();
void mouseModeRequested(bool relative, bool hide_cursor); void mouseModeRequested(bool relative, bool hide_cursor);
void fullscreenUIStateChange(bool running);
void achievementsRefreshed(quint32 id, const QString& game_info_string, quint32 total, quint32 points); void achievementsRefreshed(quint32 id, const QString& game_info_string, quint32 total, quint32 points);
void achievementsChallengeModeChanged(); void achievementsChallengeModeChanged();
void cheatEnabled(quint32 index, bool enabled); void cheatEnabled(quint32 index, bool enabled);