From 282998d0bb6d348cba0a09c1a782bc779edb95ea Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Mon, 16 Mar 2020 00:06:39 +1000 Subject: [PATCH] Qt: Add screenshot button --- src/duckstation-qt/mainwindow.cpp | 2 ++ src/duckstation-qt/mainwindow.ui | 10 ++++++++++ src/duckstation-qt/qthostinterface.cpp | 11 +++++++++++ src/duckstation-qt/qthostinterface.h | 1 + 4 files changed, 24 insertions(+) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index d58cb543e..4e94bfdce 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -378,6 +378,7 @@ void MainWindow::updateEmulationActions(bool starting, bool running) m_ui.actionReset->setDisabled(starting || !running); m_ui.actionPause->setDisabled(starting || !running); m_ui.actionChangeDisc->setDisabled(starting || !running); + m_ui.actionScreenshot->setDisabled(starting || !running); m_ui.menuChangeDisc->setDisabled(starting || !running); m_ui.actionSaveState->setDisabled(starting || !running); @@ -434,6 +435,7 @@ void MainWindow::connectSignals() connect(m_ui.actionPowerOff, &QAction::triggered, m_host_interface, &QtHostInterface::powerOffSystem); 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.actionScreenshot, &QAction::triggered, m_host_interface, &QtHostInterface::saveScreenshot); connect(m_ui.actionLoadState, &QAction::triggered, this, [this]() { m_ui.menuLoadState->exec(QCursor::pos()); }); connect(m_ui.actionSaveState, &QAction::triggered, this, [this]() { m_ui.menuSaveState->exec(QCursor::pos()); }); connect(m_ui.actionExit, &QAction::triggered, this, &MainWindow::close); diff --git a/src/duckstation-qt/mainwindow.ui b/src/duckstation-qt/mainwindow.ui index 912d65c54..b3e146460 100644 --- a/src/duckstation-qt/mainwindow.ui +++ b/src/duckstation-qt/mainwindow.ui @@ -163,6 +163,7 @@ + @@ -444,6 +445,15 @@ Show MDEC State + + + + :/icons/video-display.png:/icons/video-display.png + + + &Screenshot + + diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 0f0090f1f..75ee59e5f 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -588,6 +588,17 @@ void QtHostInterface::stopDumpingAudio() StopDumpingAudio(); } +void QtHostInterface::saveScreenshot() +{ + if (!isOnWorkerThread()) + { + QMetaObject::invokeMethod(this, "saveScreenshot"); + return; + } + + SaveScreenshot(nullptr, true, true); +} + void QtHostInterface::enableBackgroundControllerPolling() { if (!isOnWorkerThread()) diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index dc33681f4..3502aa525 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -97,6 +97,7 @@ public Q_SLOTS: void saveState(bool global, qint32 slot, bool block_until_done = false); void startDumpingAudio(); void stopDumpingAudio(); + void saveScreenshot(); /// Enables controller polling even without a system active. Must be matched by a call to /// disableBackgroundControllerPolling.