Qt: Add a method for the emulation thread to focus the display widget

This commit is contained in:
Connor McLaughlin 2020-02-26 19:26:14 +10:00
parent e9dea6e0f7
commit 27c9f2d834
4 changed files with 22 additions and 8 deletions

View file

@ -84,11 +84,6 @@ void MainWindow::destroyDisplayWindow()
m_display_widget = nullptr; m_display_widget = nullptr;
} }
void MainWindow::toggleFullscreen()
{
setFullscreen(!m_display_widget->isFullScreen());
}
void MainWindow::setFullscreen(bool fullscreen) void MainWindow::setFullscreen(bool fullscreen)
{ {
if (fullscreen) if (fullscreen)
@ -110,6 +105,19 @@ void MainWindow::setFullscreen(bool fullscreen)
m_ui.actionFullscreen->setChecked(fullscreen); m_ui.actionFullscreen->setChecked(fullscreen);
} }
void MainWindow::toggleFullscreen()
{
setFullscreen(!m_display_widget->isFullScreen());
}
void MainWindow::focusDisplayWidget()
{
if (m_ui.mainContainer->currentIndex() != 1)
return;
m_display_widget->setFocus();
}
void MainWindow::onEmulationStarted() void MainWindow::onEmulationStarted()
{ {
m_emulation_running = true; m_emulation_running = true;
@ -349,6 +357,7 @@ void MainWindow::connectSignals()
connect(m_host_interface, &QtHostInterface::destroyDisplayWindowRequested, this, &MainWindow::destroyDisplayWindow); connect(m_host_interface, &QtHostInterface::destroyDisplayWindowRequested, this, &MainWindow::destroyDisplayWindow);
connect(m_host_interface, &QtHostInterface::setFullscreenRequested, this, &MainWindow::setFullscreen); connect(m_host_interface, &QtHostInterface::setFullscreenRequested, this, &MainWindow::setFullscreen);
connect(m_host_interface, &QtHostInterface::toggleFullscreenRequested, this, &MainWindow::toggleFullscreen); connect(m_host_interface, &QtHostInterface::toggleFullscreenRequested, this, &MainWindow::toggleFullscreen);
connect(m_host_interface, &QtHostInterface::focusDisplayWidgetRequested, this, &MainWindow::focusDisplayWidget);
connect(m_host_interface, &QtHostInterface::emulationStarted, this, &MainWindow::onEmulationStarted); connect(m_host_interface, &QtHostInterface::emulationStarted, this, &MainWindow::onEmulationStarted);
connect(m_host_interface, &QtHostInterface::emulationStopped, this, &MainWindow::onEmulationStopped); connect(m_host_interface, &QtHostInterface::emulationStopped, this, &MainWindow::onEmulationStopped);
connect(m_host_interface, &QtHostInterface::emulationPaused, this, &MainWindow::onEmulationPaused); connect(m_host_interface, &QtHostInterface::emulationPaused, this, &MainWindow::onEmulationPaused);

View file

@ -29,6 +29,7 @@ private Q_SLOTS:
void destroyDisplayWindow(); void destroyDisplayWindow();
void setFullscreen(bool fullscreen); void setFullscreen(bool fullscreen);
void toggleFullscreen(); void toggleFullscreen();
void focusDisplayWidget();
void onEmulationStarted(); void onEmulationStarted();
void onEmulationStopped(); void onEmulationStopped();
void onEmulationPaused(bool paused); void onEmulationPaused(bool paused);

View file

@ -303,10 +303,13 @@ void QtHostInterface::OnSystemPaused(bool paused)
{ {
HostInterface::OnSystemPaused(paused); HostInterface::OnSystemPaused(paused);
if (!paused)
wakeThread();
emit emulationPaused(paused); emit emulationPaused(paused);
if (!paused)
{
wakeThread();
emit focusDisplayWidgetRequested();
}
} }
void QtHostInterface::OnSystemDestroyed() void QtHostInterface::OnSystemDestroyed()

View file

@ -75,6 +75,7 @@ Q_SIGNALS:
void destroyDisplayWindowRequested(); void destroyDisplayWindowRequested();
void setFullscreenRequested(bool fullscreen); void setFullscreenRequested(bool fullscreen);
void toggleFullscreenRequested(); void toggleFullscreenRequested();
void focusDisplayWidgetRequested();
void systemPerformanceCountersUpdated(float speed, float fps, float vps, float avg_frame_time, void systemPerformanceCountersUpdated(float speed, float fps, float vps, float avg_frame_time,
float worst_frame_time); float worst_frame_time);
void runningGameChanged(const QString& filename, const QString& game_code, const QString& game_title); void runningGameChanged(const QString& filename, const QString& game_code, const QString& game_title);