From 069bdd471c0a5d62b32beb992d50865b7987634d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Fri, 24 Jan 2020 14:50:54 +1000 Subject: [PATCH] Qt: Stub saving resume state when powering off --- src/duckstation-qt/mainwindow.cpp | 2 +- src/duckstation-qt/qthostinterface.cpp | 14 ++++++++------ src/duckstation-qt/qthostinterface.h | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index 05081d2c9..934eb993c 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -271,7 +271,7 @@ void MainWindow::connectSignals() &MainWindow::onChangeDiscFromGameListActionTriggered); connect(m_ui.actionAddGameDirectory, &QAction::triggered, [this]() { getSettingsDialog()->getGameListSettingsWidget()->addSearchDirectory(this); }); - connect(m_ui.actionPowerOff, &QAction::triggered, m_host_interface, &QtHostInterface::powerOffSystem); + connect(m_ui.actionPowerOff, &QAction::triggered, [this]() { m_host_interface->powerOffSystem(true, false); }); connect(m_ui.actionReset, &QAction::triggered, m_host_interface, &QtHostInterface::resetSystem); connect(m_ui.actionPause, &QAction::toggled, m_host_interface, &QtHostInterface::pauseSystem); connect(m_ui.actionLoadState, &QAction::triggered, this, [this]() { m_ui.menuLoadState->exec(QCursor::pos()); }); diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 263253f78..4d96af4a7 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -383,21 +383,23 @@ void QtHostInterface::addButtonToInputMap(const QString& binding, InputButtonHan } } -void QtHostInterface::powerOffSystem() +void QtHostInterface::powerOffSystem(bool save_resume_state /* = false */, bool block_until_done /* = false */) { if (!isOnWorkerThread()) { - QMetaObject::invokeMethod(this, "powerOffSystem", Qt::QueuedConnection); + QMetaObject::invokeMethod(this, "powerOffSystem", + block_until_done ? Qt::BlockingQueuedConnection : Qt::QueuedConnection, + Q_ARG(bool, save_resume_state), Q_ARG(bool, block_until_done)); return; } if (!m_system) - { - Log_ErrorPrintf("powerOffSystem() called without system"); return; - } - m_system.reset(); + if (save_resume_state) + Log_InfoPrintf("TODO: Save resume state"); + + DestroySystem(); m_audio_stream->PauseOutput(true); m_display_window->destroyDeviceContext(); diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index 7a12297e4..ddb91e15e 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -74,7 +74,7 @@ Q_SIGNALS: public Q_SLOTS: void applySettings(); - void powerOffSystem(); + void powerOffSystem(bool save_resume_state = false, bool block_until_done = false); void resetSystem(); void pauseSystem(bool paused); void changeDisc(QString new_disc_filename);