Qt: Fix automatic binding button in per-game controller settings

This commit is contained in:
Stenzek 2024-10-12 18:42:27 +10:00
parent 1e119c8e2d
commit 21ec3c1152
No known key found for this signature in database
4 changed files with 21 additions and 7 deletions

View File

@ -4,6 +4,7 @@
#include "controllerbindingwidgets.h"
#include "controllersettingswindow.h"
#include "controllersettingwidgetbinder.h"
#include "mainwindow.h"
#include "qthost.h"
#include "qtutils.h"
#include "settingswindow.h"
@ -271,7 +272,10 @@ void ControllerBindingWidget::onAutomaticBindingClicked()
QMenu menu(this);
bool added = false;
for (const auto& [identifier, device_name] : m_dialog->getDeviceList())
const auto& device_list = m_dialog->isEditingGameSettings() ?
g_main_window->getControllerSettingsWindow()->getDeviceList() :
m_dialog->getDeviceList();
for (const auto& [identifier, device_name] : device_list)
{
// we set it as data, because the device list could get invalidated while the menu is up
const QString qidentifier = QString::fromStdString(identifier);

View File

@ -78,7 +78,13 @@ ControllerGlobalSettingsWidget::ControllerGlobalSettingsWidget(QWidget* parent,
}
if (dialog->isEditingGameSettings())
m_ui.deviceListGroup->setEnabled(false);
{
m_ui.mainLayout->removeWidget(m_ui.deviceListGroup);
delete m_ui.deviceList;
m_ui.deviceList = nullptr;
delete m_ui.deviceListGroup;
m_ui.deviceListGroup = nullptr;
}
connect(m_ui.multitapMode, &QComboBox::currentIndexChanged, this, [this]() { emit bindingSetupChanged(); });

View File

@ -481,8 +481,11 @@ void ControllerSettingsWindow::createWidgets()
m_ui.settingsContainer->addWidget(m_global_settings);
connect(m_global_settings, &ControllerGlobalSettingsWidget::bindingSetupChanged, this,
&ControllerSettingsWindow::createWidgets);
for (const auto& [identifier, device_name] : m_device_list)
m_global_settings->addDeviceToList(QString::fromStdString(identifier), QString::fromStdString(device_name));
if (isEditingGlobalSettings())
{
for (const auto& [identifier, device_name] : m_device_list)
m_global_settings->addDeviceToList(QString::fromStdString(identifier), QString::fromStdString(device_name));
}
}
// load mtap settings

View File

@ -102,6 +102,10 @@ public:
/// Opens the editor for a specific input profile.
void openInputProfileEditor(const std::string_view name);
/// Returns pointer to settings window.
SettingsWindow* getSettingsWindow();
ControllerSettingsWindow* getControllerSettingsWindow();
public Q_SLOTS:
/// Updates debug menu visibility (hides if disabled).
void updateDebugMenuVisibility();
@ -240,10 +244,7 @@ private:
void updateDisplayWidgetCursor();
void updateDisplayRelatedActions(bool has_surface, bool render_to_main, bool fullscreen);
SettingsWindow* getSettingsWindow();
void doSettings(const char* category = nullptr);
ControllerSettingsWindow* getControllerSettingsWindow();
void doControllerSettings(ControllerSettingsWindow::Category category = ControllerSettingsWindow::Category::Count);
void updateDebugMenuCPUExecutionMode();