Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) DlgControllerLearning: make control box completer usable #14260

Merged
merged 2 commits into from
Jan 30, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions src/controllers/dlgcontrollerlearning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ DlgControllerLearning::DlgControllerLearning(QWidget* parent,

comboBoxChosenControl->completer()->setCompletionMode(
QCompleter::PopupCompletion);
comboBoxChosenControl->completer()->setCaseSensitivity(Qt::CaseInsensitive);
comboBoxChosenControl->completer()->setFilterMode(Qt::MatchContains);

populateComboBox();
connect(comboBoxChosenControl,
QOverload<int>::of(&QComboBox::currentIndexChanged),
Expand Down Expand Up @@ -150,17 +153,17 @@ DlgControllerLearning::DlgControllerLearning(QWidget* parent,
void DlgControllerLearning::populateComboBox() {
// Sort all of the controls and add them to the combo box
comboBoxChosenControl->clear();
// Add a blank item so the lineedit is initially empty
comboBoxChosenControl->addItem("", QVariant::fromValue(ConfigKey()));
// Note: changes here might break the completer, so remember to test that
QList<NamedControl> sorted_controls;
foreach (ConfigKey key, m_pControlPickerMenu->controlsAvailable()) {
sorted_controls.push_back(
NamedControl(m_pControlPickerMenu->controlTitleForConfigKey(key),
key));
for (const ConfigKey& key : m_pControlPickerMenu->controlsAvailable()) {
sorted_controls.push_back(NamedControl(
m_pControlPickerMenu->controlTitleForConfigKey(key),
key));
}
std::sort(sorted_controls.begin(), sorted_controls.end(),
namedControlComparator);
foreach(NamedControl control, sorted_controls)
{
std::sort(sorted_controls.begin(), sorted_controls.end(), namedControlComparator);
for (const NamedControl& control : std::as_const(sorted_controls)) {
comboBoxChosenControl->addItem(control.first,
QVariant::fromValue(control.second));
}
Expand Down
Loading