Qt: Handle Overridden Graphics Backend

This fixes an issue where the game specific graphics backend would be saved as the global setting after playing a game.

This also now displays the currently running graphics backend when looking in the graphics configuration window.
This commit is contained in:
Patrick Ferry 2023-12-23 23:31:52 +00:00
parent 57327be7f3
commit 1c68f4231b
2 changed files with 11 additions and 3 deletions

View File

@ -182,7 +182,10 @@ void GeneralWidget::SaveSettings()
{ {
// Video Backend // Video Backend
const auto current_backend = m_backend_combo->currentData().toString().toStdString(); const auto current_backend = m_backend_combo->currentData().toString().toStdString();
if (Config::Get(Config::MAIN_GFX_BACKEND) != current_backend) if (Config::Get(Config::MAIN_GFX_BACKEND) == current_backend)
return;
if (Config::GetActiveLayerForConfig(Config::MAIN_GFX_BACKEND) == Config::LayerType::Base)
{ {
auto warningMessage = VideoBackendBase::GetAvailableBackends()[m_backend_combo->currentIndex()] auto warningMessage = VideoBackendBase::GetAvailableBackends()[m_backend_combo->currentIndex()]
->GetWarningMessage(); ->GetWarningMessage();
@ -203,8 +206,10 @@ void GeneralWidget::SaveSettings()
return; return;
} }
} }
emit BackendChanged(QString::fromStdString(current_backend));
} }
Config::SetBaseOrCurrent(Config::MAIN_GFX_BACKEND, current_backend);
emit BackendChanged(QString::fromStdString(current_backend));
} }
void GeneralWidget::OnEmulationStateChanged(bool running) void GeneralWidget::OnEmulationStateChanged(bool running)
@ -215,6 +220,10 @@ void GeneralWidget::OnEmulationStateChanged(bool running)
const bool supports_adapters = !g_Config.backend_info.Adapters.empty(); const bool supports_adapters = !g_Config.backend_info.Adapters.empty();
m_adapter_combo->setEnabled(!running && supports_adapters); m_adapter_combo->setEnabled(!running && supports_adapters);
std::string current_backend = m_backend_combo->currentData().toString().toStdString();
if (Config::Get(Config::MAIN_GFX_BACKEND) != current_backend)
emit BackendChanged(QString::fromStdString(Config::Get(Config::MAIN_GFX_BACKEND)));
} }
void GeneralWidget::AddDescriptions() void GeneralWidget::AddDescriptions()

View File

@ -67,7 +67,6 @@ void GraphicsWindow::CreateMainLayout()
void GraphicsWindow::OnBackendChanged(const QString& backend_name) void GraphicsWindow::OnBackendChanged(const QString& backend_name)
{ {
Config::SetBase(Config::MAIN_GFX_BACKEND, backend_name.toStdString());
VideoBackendBase::PopulateBackendInfoFromUI(m_main_window->GetWindowSystemInfo()); VideoBackendBase::PopulateBackendInfoFromUI(m_main_window->GetWindowSystemInfo());
setWindowTitle( setWindowTitle(