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()) if (!AcquireHostDisplay())
{ {
ReportFormattedError("Failed to acquire host display"); ReportFormattedError("Failed to acquire host display");
OnSystemDestroyed();
return false; return false;
} }

View File

@ -184,9 +184,17 @@ void MainWindow::focusDisplayWidget()
m_display_widget->setFocus(); m_display_widget->setFocus();
} }
void MainWindow::onEmulationStarted() void MainWindow::onEmulationStarting()
{ {
m_emulation_running = true; 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); updateEmulationActions(false, true);
} }
@ -503,7 +511,8 @@ void MainWindow::connectSignals()
connect(m_ui.actionStartDisc, &QAction::triggered, this, &MainWindow::onStartDiscActionTriggered); connect(m_ui.actionStartDisc, &QAction::triggered, this, &MainWindow::onStartDiscActionTriggered);
connect(m_ui.actionStartBios, &QAction::triggered, this, &MainWindow::onStartBIOSActionTriggered); 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.actionChangeDisc, &QAction::triggered, [this] { m_ui.menuChangeDisc->exec(QCursor::pos()); });
connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered); connect(m_ui.actionChangeDiscFromFile, &QAction::triggered, this, &MainWindow::onChangeDiscFromFileActionTriggered);
connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this, connect(m_ui.actionChangeDiscFromGameList, &QAction::triggered, this,
@ -555,6 +564,7 @@ void MainWindow::connectSignals()
connect(m_host_interface, &QtHostInterface::updateDisplayRequested, this, &MainWindow::updateDisplay, connect(m_host_interface, &QtHostInterface::updateDisplayRequested, this, &MainWindow::updateDisplay,
Qt::BlockingQueuedConnection); Qt::BlockingQueuedConnection);
connect(m_host_interface, &QtHostInterface::focusDisplayWidgetRequested, this, &MainWindow::focusDisplayWidget); 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::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

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

View File

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

View File

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