Add ability to search for machines in machine settings (#6268)

This commit is contained in:
Cacodemon345
2025-10-03 02:48:49 +06:00
committed by GitHub
parent 375033c5b0
commit b45452d434
26 changed files with 217 additions and 95 deletions

View File

@@ -2996,3 +2996,6 @@ msgstr ""
msgid "Dark"
msgstr ""
msgid "Search:"
msgstr ""

View File

@@ -2993,3 +2993,6 @@ msgstr "Světlé"
msgid "Dark"
msgstr "Tmavé"
msgid "Search:"
msgstr "Hledat:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Licht"
msgid "Dark"
msgstr "Dunkel"
msgid "Search:"
msgstr "Suche:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Luz"
msgid "Dark"
msgstr "Oscuro"
msgid "Search:"
msgstr "Buscar:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Vaalea"
msgid "Dark"
msgstr "Tumma"
msgid "Search:"
msgstr "Haku:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Lumière"
msgid "Dark"
msgstr "Sombre"
msgid "Search:"
msgstr "Recherche:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Svjetlo"
msgid "Dark"
msgstr "Tamno"
msgid "Search:"
msgstr "Pretraživanje:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Chiara"
msgid "Dark"
msgstr "Scura"
msgid "Search:"
msgstr "Ricerca:"

View File

@@ -2993,3 +2993,6 @@ msgstr "光"
msgid "Dark"
msgstr "暗闇"
msgid "Search:"
msgstr "検索:"

View File

@@ -2993,3 +2993,6 @@ msgstr "빛"
msgid "Dark"
msgstr "어둠"
msgid "Search:"
msgstr "찾기:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Lys"
msgid "Dark"
msgstr "Mørk"
msgid "Search:"
msgstr "Søk:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Licht"
msgid "Dark"
msgstr "Donker"
msgid "Search:"
msgstr "Zoekopdracht:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Światło"
msgid "Dark"
msgstr "Ciemny"
msgid "Search:"
msgstr "Szukaj:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Claro"
msgid "Dark"
msgstr "Escuro"
msgid "Search:"
msgstr "Busca:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Claro"
msgid "Dark"
msgstr "Escuro"
msgid "Search:"
msgstr "Pesquisa:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Светлая"
msgid "Dark"
msgstr "Тёмная"
msgid "Search:"
msgstr "Поиск:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Svetlo"
msgid "Dark"
msgstr "Tmavá"
msgid "Search:"
msgstr "Hľadať:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Svetloba"
msgid "Dark"
msgstr "Temno"
msgid "Search:"
msgstr "Iskanje:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Ljus"
msgid "Dark"
msgstr "Mörk"
msgid "Search:"
msgstr "Söka:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Işık"
msgid "Dark"
msgstr "Karanlık"
msgid "Search:"
msgstr "Aramak:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Світло"
msgid "Dark"
msgstr "Темний"
msgid "Search:"
msgstr "Пошук:"

View File

@@ -2993,3 +2993,6 @@ msgstr "Ánh sáng"
msgid "Dark"
msgstr "Tối"
msgid "Search:"
msgstr "Tìm kiếm:"

View File

@@ -2993,3 +2993,6 @@ msgstr "亮色"
msgid "Dark"
msgstr "暗色"
msgid "Search:"
msgstr "搜索:"

View File

@@ -2993,3 +2993,6 @@ msgstr "光"
msgid "Dark"
msgstr "黑暗"
msgid "Search:"
msgstr "搜尋:"

View File

@@ -22,6 +22,10 @@
#include <QFrame>
#include <QVBoxLayout>
#include <QDialogButtonBox>
#include <QStandardItem>
#include <QStandardItemModel>
#include <QCompleter>
#include <QTimer>
#include <algorithm>
@@ -57,6 +61,16 @@ SettingsMachine::SettingsMachine(QWidget *parent)
break;
}
auto machineListCompleter = new QCompleter(ui->lineEditSearch);
auto machineListModel = new QStandardItemModel(machineListCompleter);
machineListCompleter->setModel(machineListModel);
ui->lineEditSearch->setCompleter(machineListCompleter);
connect(ui->lineEditSearch, &QLineEdit::editingFinished, this, [this] () { ui->lineEditSearch->setText("");} );
machineListCompleter->setCompletionMode(QCompleter::PopupCompletion);
machineListCompleter->setFilterMode(Qt::MatchContains);
machineListCompleter->setCompletionRole(Qt::DisplayRole);
machineListCompleter->setCaseSensitivity(Qt::CaseInsensitive);
auto warning_icon = QIcon(":/misc/qt/icons/warning.ico");
ui->softFloatWarningIcon->setPixmap(warning_icon.pixmap(warning_icon.actualSize(QSize(16, 16))));
ui->softFloatWarningIcon->setVisible(false);
@@ -108,8 +122,13 @@ SettingsMachine::SettingsMachine(QWidget *parent)
cur_j = 0;
}
if (machine_available(j))
if (machine_available(j)) {
QStandardItem* item = new QStandardItem(machines[j].name);
item->setData(machine_types[machine_get_type(j)].id);
machineListModel->appendRow(item);
cur_j++;
}
j++;
} while (miname != nullptr);
@@ -120,6 +139,26 @@ SettingsMachine::SettingsMachine(QWidget *parent)
ui->radioButtonLargerFrames->setChecked(force_10ms);
ui->radioButtonSmallerFrames->setChecked(!force_10ms);
connect(machineListCompleter, QOverload<const QModelIndex &>::of(&QCompleter::activated), this, [this] (const QModelIndex& idx) {
ui->lineEditSearch->setText("");
int machineIdType = idx.model()->data(idx, Qt::UserRole + 1).toInt();
auto name = idx.model()->data(idx, Qt::DisplayRole).toString();
for (int i = 0; i < ui->comboBoxMachineType->model()->rowCount(); i++) {
if (ui->comboBoxMachineType->model()->data(ui->comboBoxMachineType->model()->index(i, 0), Qt::UserRole).toInt() == machineIdType) {
ui->comboBoxMachineType->setCurrentIndex(i);
for (int j = 0; j < ui->comboBoxMachine->model()->rowCount(); j++) {
if (ui->comboBoxMachine->model()->data(ui->comboBoxMachine->model()->index(j, 0), Qt::DisplayRole).toString() == name) {
ui->comboBoxMachine->setCurrentIndex(j);
break;
}
}
break;
}
}
QTimer::singleShot(0, ui->lineEditSearch, &QLineEdit::clear);
});
#ifndef USE_DYNAREC
ui->checkBoxDynamicRecompiler->setEnabled(false);
ui->checkBoxDynamicRecompiler->setVisible(false);

View File

@@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>458</width>
<height>459</height>
<height>492</height>
</rect>
</property>
<property name="windowTitle">
@@ -41,73 +41,38 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Machine type:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxMachineType">
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Machine:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="comboBoxMachine">
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonConfigure">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0">
<item row="3" column="0">
<widget class="QLabel" name="label_3">
<property name="text">
<string>CPU type:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<item row="6" column="1">
<widget class="QSpinBox" name="spinBoxRAM">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="6" column="0">
<widget class="QLabel" name="label_6">
<property name="text">
<string>Memory:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
@@ -141,7 +106,7 @@
<string>Frequency:</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignVCenter</set>
</property>
</widget>
</item>
@@ -161,28 +126,7 @@
</layout>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>FPU:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBoxFPU">
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Wait states:</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QWidget" name="widget_4" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<property name="leftMargin">
@@ -233,23 +177,89 @@
</layout>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_6">
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Memory:</string>
<string>Machine type:</string>
</property>
</widget>
</item>
<item row="5" column="1">
<widget class="QSpinBox" name="spinBoxRAM">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxMachineType">
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="QComboBox" name="comboBoxFPU">
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item row="5" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Wait states:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QWidget" name="widget_3" native="true">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QComboBox" name="comboBoxMachine">
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pushButtonConfigure">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>FPU:</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>Search:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lineEditSearch"/>
</item>
</layout>
</widget>
</item>
@@ -302,7 +312,7 @@
<item>
<spacer name="softFloatHorizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -328,7 +338,7 @@
<string>CPU frame size</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
@@ -351,7 +361,7 @@
<item row="0" column="1">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -400,7 +410,7 @@
<item row="1" column="1">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -415,7 +425,7 @@
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
<enum>Qt::Orientation::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
@@ -428,6 +438,7 @@
</layout>
</widget>
<tabstops>
<tabstop>lineEditSearch</tabstop>
<tabstop>comboBoxMachineType</tabstop>
<tabstop>comboBoxMachine</tabstop>
<tabstop>pushButtonConfigure</tabstop>