Qt: Add screenshot button

This commit is contained in:
Connor McLaughlin 2020-03-16 00:06:39 +10:00
parent ffb760c79d
commit 282998d0bb
4 changed files with 24 additions and 0 deletions

View File

@ -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);

View File

@ -163,6 +163,7 @@
<addaction name="actionReset"/>
<addaction name="actionPause"/>
<addaction name="actionChangeDisc"/>
<addaction name="actionScreenshot"/>
<addaction name="separator"/>
<addaction name="actionLoadState"/>
<addaction name="actionSaveState"/>
@ -444,6 +445,15 @@
<string>Show MDEC State</string>
</property>
</action>
<action name="actionScreenshot">
<property name="icon">
<iconset resource="resources/icons.qrc">
<normaloff>:/icons/video-display.png</normaloff>:/icons/video-display.png</iconset>
</property>
<property name="text">
<string>&amp;Screenshot</string>
</property>
</action>
</widget>
<resources>
<include location="resources/icons.qrc"/>

View File

@ -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())

View File

@ -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.