configuration fixes

* moved CONFIG_MIDI and CONFIG_MIDI_IN to own blocks when constructing
  comboboxes in deviceconfig
* use Models::AddEntry in deviceconfig
* sub-handling of CONFIG_HEX16 and CONFIG_HEX20 in CONFIG_SELECTION
  block when constructing, and use corresponding config_setter
* make sure SCSI controller- and ISAMEM-deviceconfig calls up
  deviceconfig with an instance number
* midi input and midi output was mixed when constructing soundsettings
  when loading prev. settings
This commit is contained in:
Joakim L. Gilje
2021-12-06 10:29:53 +01:00
parent 2788793d07
commit 07c9da30de
7 changed files with 82 additions and 108 deletions

View File

@@ -15,6 +15,7 @@ extern "C" {
}
#include "qt_filefield.hpp"
#include "qt_models_common.hpp"
DeviceConfig::DeviceConfig(QWidget *parent) :
QDialog(parent),
@@ -28,12 +29,12 @@ DeviceConfig::~DeviceConfig()
delete ui;
}
void DeviceConfig::ConfigureDevice(const _device_* device) {
void DeviceConfig::ConfigureDevice(const _device_* device, int instance) {
DeviceConfig dc;
dc.setWindowTitle(QString("%1 Device Configuration").arg(device->name));
device_context_t device_context;
device_set_context(&device_context, device, 0);
device_set_context(&device_context, device, instance);
const auto* config = device->config;
while (config->type != -1) {
@@ -47,9 +48,47 @@ void DeviceConfig::ConfigureDevice(const _device_* device) {
dc.ui->formLayout->addRow(config->description, cbox);
break;
}
case CONFIG_SELECTION:
case CONFIG_MIDI:
{
auto* cbox = new QComboBox();
cbox->setObjectName(config->name);
auto* model = cbox->model();
int currentIndex = -1;
int selected = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
for (int i = 0; i < plat_midi_get_num_devs(); i++) {
char midiName[512] = { 0 };
plat_midi_get_dev_name(i, midiName);
Models::AddEntry(model, midiName, i);
if (selected == i) {
currentIndex = i;
}
}
dc.ui->formLayout->addRow(config->description, cbox);
cbox->setCurrentIndex(currentIndex);
break;
}
case CONFIG_MIDI_IN:
{
auto* cbox = new QComboBox();
cbox->setObjectName(config->name);
auto* model = cbox->model();
int currentIndex = -1;
int selected = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
for (int i = 0; i < plat_midi_in_get_num_devs(); i++) {
char midiName[512] = { 0 };
plat_midi_in_get_dev_name(i, midiName);
Models::AddEntry(model, midiName, i);
if (selected == i) {
currentIndex = i;
}
}
dc.ui->formLayout->addRow(config->description, cbox);
cbox->setCurrentIndex(currentIndex);
break;
}
case CONFIG_SELECTION:
case CONFIG_HEX16:
case CONFIG_HEX20:
{
@@ -57,50 +96,23 @@ void DeviceConfig::ConfigureDevice(const _device_* device) {
cbox->setObjectName(config->name);
auto* model = cbox->model();
int currentIndex = -1;
int selected = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
int selected;
switch (config->type) {
case CONFIG_SELECTION:
selected = config_get_int(device_context.name, const_cast<char*>(config->name), config->default_int);
break;
case CONFIG_HEX16:
selected = config_get_hex16(device_context.name, const_cast<char*>(config->name), config->default_int);
break;
case CONFIG_HEX20:
selected = config_get_hex20(device_context.name, const_cast<char*>(config->name), config->default_int);
break;
}
if (config->type == CONFIG_MIDI) {
for (int i = 0; i < plat_midi_get_num_devs(); i++) {
char midiName[512] = { 0 };
plat_midi_get_dev_name(i, midiName);
int rows = model->rowCount();
model->insertRow(rows);
auto idx = model->index(rows, 0);
model->setData(idx, midiName, Qt::DisplayRole);
model->setData(idx, i, Qt::UserRole);
if (selected == i) {
currentIndex = idx.row();
}
}
} else if (config->type == CONFIG_MIDI_IN) {
for (int i = 0; i < plat_midi_in_get_num_devs(); i++) {
char midiName[512] = { 0 };
plat_midi_in_get_dev_name(i, midiName);
int rows = model->rowCount();
model->insertRow(rows);
auto idx = model->index(rows, 0);
model->setData(idx, midiName, Qt::DisplayRole);
model->setData(idx, i, Qt::UserRole);
if (selected == i) {
currentIndex = idx.row();
}
}
} else {
for (auto* sel = config->selection; (sel->description != nullptr) && (strlen(sel->description) > 0); ++sel) {
int rows = model->rowCount();
model->insertRow(rows);
auto idx = model->index(rows, 0);
model->setData(idx, sel->description, Qt::DisplayRole);
model->setData(idx, sel->value, Qt::UserRole);
if (selected == sel->value) {
currentIndex = idx.row();
}
for (auto* sel = config->selection; (sel->description != nullptr) && (strlen(sel->description) > 0); ++sel) {
int row = Models::AddEntry(model, sel->description, sel->value);
if (selected == sel->value) {
currentIndex = row;
}
}
dc.ui->formLayout->addRow(config->description, cbox);
@@ -145,16 +157,26 @@ void DeviceConfig::ConfigureDevice(const _device_* device) {
config_set_int(device_context.name, const_cast<char*>(config->name), cbox->isChecked() ? 1 : 0);
break;
}
case CONFIG_SELECTION:
case CONFIG_MIDI:
case CONFIG_MIDI_IN:
case CONFIG_HEX16:
case CONFIG_HEX20:
case CONFIG_SELECTION:
{
auto* cbox = dc.findChild<QComboBox*>(config->name);
config_set_int(device_context.name, const_cast<char*>(config->name), cbox->currentData().toInt());
break;
}
case CONFIG_HEX16:
{
auto* cbox = dc.findChild<QComboBox*>(config->name);
config_set_hex16(device_context.name, const_cast<char*>(config->name), cbox->currentData().toInt());
break;
}
case CONFIG_HEX20:
{
auto* cbox = dc.findChild<QComboBox*>(config->name);
config_set_hex20(device_context.name, const_cast<char*>(config->name), cbox->currentData().toInt());
break;
}
case CONFIG_FNAME:
{
auto* fbox = dc.findChild<FileField*>(config->name);

View File

@@ -19,7 +19,7 @@ public:
explicit DeviceConfig(QWidget *parent = nullptr);
~DeviceConfig();
static void ConfigureDevice(const _device_* device);
static void ConfigureDevice(const _device_* device, int instance = 0);
static QString DeviceName(const _device_* device, const char* internalName, int bus);
private:
Ui::DeviceConfig *ui;

View File

@@ -96,7 +96,7 @@ void SettingsOtherPeripherals::on_comboBoxCard1_currentIndexChanged(int index) {
}
void SettingsOtherPeripherals::on_pushButtonConfigureCard1_clicked() {
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard1->currentData().toInt()));
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard1->currentData().toInt()), 1);
}
void SettingsOtherPeripherals::on_comboBoxCard2_currentIndexChanged(int index) {
@@ -107,7 +107,7 @@ void SettingsOtherPeripherals::on_comboBoxCard2_currentIndexChanged(int index) {
}
void SettingsOtherPeripherals::on_pushButtonConfigureCard2_clicked() {
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard2->currentData().toInt()));
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard2->currentData().toInt()), 2);
}
void SettingsOtherPeripherals::on_comboBoxCard3_currentIndexChanged(int index) {
@@ -118,7 +118,7 @@ void SettingsOtherPeripherals::on_comboBoxCard3_currentIndexChanged(int index) {
}
void SettingsOtherPeripherals::on_pushButtonConfigureCard3_clicked() {
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard3->currentData().toInt()));
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard3->currentData().toInt()), 3);
}
void SettingsOtherPeripherals::on_comboBoxCard4_currentIndexChanged(int index) {
@@ -129,5 +129,5 @@ void SettingsOtherPeripherals::on_comboBoxCard4_currentIndexChanged(int index) {
}
void SettingsOtherPeripherals::on_pushButtonConfigureCard4_clicked() {
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard4->currentData().toInt()));
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard4->currentData().toInt()), 4);
}

View File

@@ -18,32 +18,14 @@ public:
void save();
private slots:
void on_pushButtonConfigureCard4_clicked();
private slots:
void on_comboBoxCard4_currentIndexChanged(int index);
private slots:
void on_pushButtonConfigureCard3_clicked();
private slots:
void on_comboBoxCard3_currentIndexChanged(int index);
private slots:
void on_pushButtonConfigureCard2_clicked();
private slots:
void on_comboBoxCard2_currentIndexChanged(int index);
private slots:
void on_pushButtonConfigureCard1_clicked();
private slots:
void on_comboBoxCard1_currentIndexChanged(int index);
private slots:
void on_pushButtonConfigureRTC_clicked();
private slots:
void on_comboBoxRTC_currentIndexChanged(int index);
private:

View File

@@ -87,7 +87,7 @@ void SettingsSound::onCurrentMachineChanged(int machineId) {
if (midi_device_available(c)) {
int row = Models::AddEntry(model, name, c);
if (c == midi_input_device_current) {
if (c == midi_device_current) {
selectedRow = row - removeRows;
}
}
@@ -110,7 +110,7 @@ void SettingsSound::onCurrentMachineChanged(int machineId) {
if (midi_in_device_available(c)) {
int row = Models::AddEntry(model, name, c);
if (c == midi_device_current) {
if (c == midi_input_device_current) {
selectedRow = row - removeRows;
}
}

View File

@@ -217,17 +217,17 @@ void SettingsStorageControllers::on_comboBoxSCSI4_currentIndexChanged(int index)
void SettingsStorageControllers::on_pushButtonSCSI1_clicked() {
DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI1->currentData().toInt()));
DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI1->currentData().toInt()), 1);
}
void SettingsStorageControllers::on_pushButtonSCSI2_clicked() {
DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI2->currentData().toInt()));
DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI2->currentData().toInt()), 2);
}
void SettingsStorageControllers::on_pushButtonSCSI3_clicked() {
DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI3->currentData().toInt()));
DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI3->currentData().toInt()), 3);
}
void SettingsStorageControllers::on_pushButtonSCSI4_clicked() {
DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI4->currentData().toInt()));
DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI4->currentData().toInt()), 4);
}

View File

@@ -22,50 +22,20 @@ public slots:
private slots:
void on_pushButtonSCSI4_clicked();
private slots:
void on_pushButtonSCSI3_clicked();
private slots:
void on_pushButtonSCSI2_clicked();
private slots:
void on_pushButtonSCSI1_clicked();
private slots:
void on_comboBoxSCSI4_currentIndexChanged(int index);
private slots:
void on_comboBoxSCSI3_currentIndexChanged(int index);
private slots:
void on_comboBoxSCSI2_currentIndexChanged(int index);
private slots:
void on_comboBoxSCSI1_currentIndexChanged(int index);
private slots:
void on_pushButtonQuaternaryIDE_clicked();
private slots:
void on_pushButtonTertiaryIDE_clicked();
private slots:
void on_pushButtonFD_clicked();
private slots:
void on_pushButtonHD_clicked();
private slots:
void on_checkBoxQuaternaryIDE_stateChanged(int arg1);
private slots:
void on_checkBoxTertiaryIDE_stateChanged(int arg1);
private slots:
void on_comboBoxFD_currentIndexChanged(int index);
private slots:
void on_comboBoxHD_currentIndexChanged(int index);
private: