Qt: Prevent lag disabling power on buttons when starting

This commit is contained in:
Connor McLaughlin 2020-06-06 03:44:57 +10:00
parent 009e474c51
commit 6acd8b27dd
5 changed files with 19 additions and 2 deletions

View File

@ -93,6 +93,7 @@ bool HostInterface::BootSystem(const SystemBootParameters& parameters)
if (!AcquireHostDisplay())
{
ReportFormattedError("Failed to acquire host display");
OnSystemDestroyed();
return false;
}

View File

@ -184,9 +184,17 @@ void MainWindow::focusDisplayWidget()
m_display_widget->setFocus();
}
void MainWindow::onEmulationStarted()
void MainWindow::onEmulationStarting()
{
m_emulation_running = true;
updateEmulationActions(true, false);
// ensure it gets updated, since the boot can take a while
QGuiApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
}
void MainWindow::onEmulationStarted()
{
updateEmulationActions(false, true);
}
@ -503,7 +511,8 @@ void MainWindow::connectSignals()
connect(m_ui.actionStartDisc, &QAction::triggered, this, &MainWindow::onStartDiscActionTriggered);
connect(m_ui.actionStartBios, &QAction::triggered, this, &MainWindow::onStartBIOSActionTriggered);
connect(m_ui.actionResumeLastState, &QAction::triggered, m_host_interface, &QtHostInterface::resumeSystemFromMostRecentState);
connect(m_ui.actionResumeLastState, &QAction::triggered, m_host_interface,
&QtHostInterface::resumeSystemFromMostRecentState);
connect(m_ui.actionChangeDisc, &QAction::triggered, [this] { m_ui.menuChangeDisc->exec(QCursor::pos()); });
connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered);
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
@ -555,6 +564,7 @@ void MainWindow::connectSignals()
connect(m_host_interface, &QtHostInterface::updateDisplayRequested, this, &MainWindow::updateDisplay,
Qt::BlockingQueuedConnection);
connect(m_host_interface, &QtHostInterface::focusDisplayWidgetRequested, this, &MainWindow::focusDisplayWidget);
connect(m_host_interface, &QtHostInterface::emulationStarting, this, &MainWindow::onEmulationStarting);
connect(m_host_interface, &QtHostInterface::emulationStarted, this, &MainWindow::onEmulationStarted);
connect(m_host_interface, &QtHostInterface::emulationStopped, this, &MainWindow::onEmulationStopped);
connect(m_host_interface, &QtHostInterface::emulationPaused, this, &MainWindow::onEmulationPaused);

View File

@ -33,6 +33,8 @@ private Q_SLOTS:
void updateDisplay(QThread* worker_thread, bool fullscreen, bool render_to_main);
void destroyDisplay();
void focusDisplayWidget();
void onEmulationStarting();
void onEmulationStarted();
void onEmulationStopped();
void onEmulationPaused(bool paused);

View File

@ -209,6 +209,7 @@ void QtHostInterface::bootSystem(const SystemBootParameters& params)
return;
}
emit emulationStarting();
BootSystem(params);
}
@ -221,6 +222,7 @@ void QtHostInterface::resumeSystemFromState(const QString& filename, bool boot_o
return;
}
emit emulationStarting();
if (filename.isEmpty())
HostInterface::ResumeSystemFromMostRecentState();
else
@ -235,6 +237,7 @@ void QtHostInterface::resumeSystemFromMostRecentState()
return;
}
emit emulationStarting();
HostInterface::ResumeSystemFromMostRecentState();
}

View File

@ -93,6 +93,7 @@ Q_SIGNALS:
void errorReported(const QString& message);
void messageReported(const QString& message);
bool messageConfirmed(const QString& message);
void emulationStarting();
void emulationStarted();
void emulationStopped();
void emulationPaused(bool paused);