Clean QT Other Peripherals UI

This commit is contained in:
Jasmine Iwanek
2025-05-04 19:30:48 -04:00
parent d55f6b2887
commit c992a44b44
3 changed files with 164 additions and 160 deletions

View File

@@ -11,8 +11,10 @@
*
*
* Authors: Joakim L. Gilje <jgilje@jgilje.net>
* Jasmine Iwanek <jriwanek@gmail.com>
*
* Copyright 2021 Joakim L. Gilje
* Copyright 2025 Jasmine Iwanek
*/
#include "qt_settingsotherperipherals.hpp"
#include "ui_qt_settingsotherperipherals.h"
@@ -44,84 +46,86 @@ SettingsOtherPeripherals::onCurrentMachineChanged(int machineId)
this->machineId = machineId;
bool machineHasIsa = (machine_has_bus(machineId, MACHINE_BUS_ISA) > 0);
ui->pushButtonConfigureRTC->setEnabled(machineHasIsa);
ui->comboBoxRTC->setEnabled(machineHasIsa);
ui->checkBoxISABugger->setEnabled(machineHasIsa);
ui->pushButtonConfigureUT->setEnabled(unittester_enabled > 0);
ui->checkBoxKeyCard->setEnabled(machineHasIsa);
ui->pushButtonConfigureKeyCard->setEnabled(novell_keycard_enabled > 0);
ui->checkBoxISABugger->setChecked((machineHasIsa && (bugger_enabled > 0)) ? true : false);
ui->checkBoxPOSTCard->setChecked(postcard_enabled > 0 ? true : false);
ui->checkBoxUnitTester->setChecked(unittester_enabled > 0 ? true : false);
ui->checkBoxKeyCard->setChecked((machineHasIsa && (novell_keycard_enabled > 0)) ? true : false);
ui->checkBoxISABugger->setEnabled(machineHasIsa);
ui->checkBoxKeyCard->setEnabled(machineHasIsa);
ui->pushButtonConfigureKeyCard->setEnabled(novell_keycard_enabled > 0);
ui->pushButtonConfigureUT->setEnabled(unittester_enabled > 0);
ui->comboBoxRTC->setEnabled(machineHasIsa);
ui->pushButtonConfigureRTC->setEnabled(machineHasIsa);
ui->comboBoxCard1->clear();
ui->comboBoxCard2->clear();
ui->comboBoxCard3->clear();
ui->comboBoxCard4->clear();
ui->comboBoxRTC->clear();
auto *model = ui->comboBoxRTC->model();
int d = 0;
for (uint8_t i = 0; i < ISAMEM_MAX; ++i)
if (auto *cb = findChild<QComboBox *>(QString("comboBoxIsaMemCard%1").arg(i + 1)))
cb->clear();
int c = 0;
int selectedRow = 0;
// ISA RTC Cards
auto *model = ui->comboBoxRTC->model();
while (true) {
QString name = DeviceConfig::DeviceName(isartc_get_device(d), isartc_get_internal_name(d), 0);
if (name.isEmpty()) {
const QString name = DeviceConfig::DeviceName(isartc_get_device(c), isartc_get_internal_name(c), 0);
if (name.isEmpty())
break;
}
if (!device_is_valid(isartc_get_device(d), machineId)) {
if (!device_is_valid(isartc_get_device(c), machineId))
break;
}
int row = Models::AddEntry(model, name, d);
if (d == isartc_type) {
int row = Models::AddEntry(model, name, c);
if (c == isartc_type)
selectedRow = row;
}
++d;
++c;
}
ui->comboBoxRTC->setCurrentIndex(selectedRow);
ui->pushButtonConfigureRTC->setEnabled((isartc_type != 0) && isartc_has_config(isartc_type) && machineHasIsa);
// ISA Memory Expansion Card
QComboBox * cbox[ISAMEM_MAX] = { 0 };
QAbstractItemModel *models[ISAMEM_MAX] = { 0 };
int removeRows_[ISAMEM_MAX] = { 0 };
int selectedRows[ISAMEM_MAX] = { 0 };
// ISA Memory Expansion Cards
QComboBox *isamem_cbox[ISAMEM_MAX] = { 0 };
QAbstractItemModel *isamem_models[ISAMEM_MAX] = { 0 };
int isamem_removeRows_[ISAMEM_MAX] = { 0 };
int isamem_selectedRows[ISAMEM_MAX] = { 0 };
for (uint8_t c = 0; c < ISAMEM_MAX; ++c) {
cbox[c] = findChild<QComboBox *>(QString("comboBoxCard%1").arg(c + 1));
models[c] = cbox[c]->model();
removeRows_[c] = models[c]->rowCount();
for (uint8_t i = 0; i < ISAMEM_MAX; ++i) {
isamem_cbox[i] = findChild<QComboBox *>(QString("comboBoxIsaMemCard%1").arg(i + 1));
isamem_models[i] = isamem_cbox[i]->model();
isamem_removeRows_[i] = isamem_models[i]->rowCount();
}
d = 0;
c = 0;
while (true) {
const QString name = DeviceConfig::DeviceName(isamem_get_device(d),
isamem_get_internal_name(d), 0);
const QString name = DeviceConfig::DeviceName(isamem_get_device(c),
isamem_get_internal_name(c), 0);
if (name.isEmpty())
break;
if (device_is_valid(isamem_get_device(d), machineId)) {
for (uint8_t c = 0; c < ISAMEM_MAX; ++c) {
int row = Models::AddEntry(models[c], name, d);
if (device_is_valid(isamem_get_device(c), machineId)) {
for (uint8_t i = 0; i < ISAMEM_MAX; ++i) {
int row = Models::AddEntry(isamem_models[i], name, c);
if (d == isamem_type[c])
selectedRows[c] = row - removeRows_[c];
if (c == isamem_type[i])
isamem_selectedRows[i] = row - isamem_removeRows_[i];
}
}
d++;
c++;
}
for (uint8_t c = 0; c < ISAMEM_MAX; ++c) {
models[c]->removeRows(0, removeRows_[c]);
cbox[c]->setEnabled(models[c]->rowCount() > 1);
cbox[c]->setCurrentIndex(-1);
cbox[c]->setCurrentIndex(selectedRows[c]);
findChild<QPushButton *>(QString("pushButtonConfigureCard%1").arg(c + 1))->setEnabled((isamem_type[c] != 0) &&
isamem_has_config(isamem_type[c]) && machineHasIsa);
for (uint8_t i = 0; i < ISAMEM_MAX; ++i) {
isamem_models[i]->removeRows(0, isamem_removeRows_[i]);
isamem_cbox[i]->setEnabled(isamem_models[i]->rowCount() > 1);
isamem_cbox[i]->setCurrentIndex(-1);
isamem_cbox[i]->setCurrentIndex(isamem_selectedRows[i]);
findChild<QPushButton *>(QString("pushButtonConfigureIsaMemCard%1").arg(i + 1))->setEnabled((isamem_type[i] != 0) &&
isamem_has_config(isamem_type[i]) && machineHasIsa);
}
}
@@ -134,15 +138,15 @@ void
SettingsOtherPeripherals::save()
{
/* Other peripherals category */
isartc_type = ui->comboBoxRTC->currentData().toInt();
bugger_enabled = ui->checkBoxISABugger->isChecked() ? 1 : 0;
postcard_enabled = ui->checkBoxPOSTCard->isChecked() ? 1 : 0;
unittester_enabled = ui->checkBoxUnitTester->isChecked() ? 1 : 0;
novell_keycard_enabled = ui->checkBoxKeyCard->isChecked() ? 1 : 0;
isartc_type = ui->comboBoxRTC->currentData().toInt();
/* ISA memory boards. */
for (int i = 0; i < ISAMEM_MAX; i++) {
auto *cbox = findChild<QComboBox *>(QString("comboBoxCard%1").arg(i + 1));
auto *cbox = findChild<QComboBox *>(QString("comboBoxIsaMemCard%1").arg(i + 1));
isamem_type[i] = cbox->currentData().toInt();
}
}
@@ -150,9 +154,9 @@ SettingsOtherPeripherals::save()
void
SettingsOtherPeripherals::on_comboBoxRTC_currentIndexChanged(int index)
{
if (index < 0) {
if (index < 0)
return;
}
ui->pushButtonConfigureRTC->setEnabled((index != 0) && isartc_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA));
}
@@ -163,63 +167,63 @@ SettingsOtherPeripherals::on_pushButtonConfigureRTC_clicked()
}
void
SettingsOtherPeripherals::on_comboBoxCard1_currentIndexChanged(int index)
SettingsOtherPeripherals::on_comboBoxIsaMemCard1_currentIndexChanged(int index)
{
if (index < 0) {
if (index < 0)
return;
}
ui->pushButtonConfigureCard1->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA));
ui->pushButtonConfigureIsaMemCard1->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA));
}
void
SettingsOtherPeripherals::on_pushButtonConfigureCard1_clicked()
SettingsOtherPeripherals::on_pushButtonConfigureIsaMemCard1_clicked()
{
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard1->currentData().toInt()), 1);
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxIsaMemCard1->currentData().toInt()), 1);
}
void
SettingsOtherPeripherals::on_comboBoxCard2_currentIndexChanged(int index)
SettingsOtherPeripherals::on_comboBoxIsaMemCard2_currentIndexChanged(int index)
{
if (index < 0) {
if (index < 0)
return;
}
ui->pushButtonConfigureCard2->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA));
ui->pushButtonConfigureIsaMemCard2->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA));
}
void
SettingsOtherPeripherals::on_pushButtonConfigureCard2_clicked()
SettingsOtherPeripherals::on_pushButtonConfigureIsaMemCard2_clicked()
{
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard2->currentData().toInt()), 2);
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxIsaMemCard2->currentData().toInt()), 2);
}
void
SettingsOtherPeripherals::on_comboBoxCard3_currentIndexChanged(int index)
SettingsOtherPeripherals::on_comboBoxIsaMemCard3_currentIndexChanged(int index)
{
if (index < 0) {
if (index < 0)
return;
}
ui->pushButtonConfigureCard3->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA));
ui->pushButtonConfigureIsaMemCard3->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA));
}
void
SettingsOtherPeripherals::on_pushButtonConfigureCard3_clicked()
SettingsOtherPeripherals::on_pushButtonConfigureIsaMemCard3_clicked()
{
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard3->currentData().toInt()), 3);
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxIsaMemCard3->currentData().toInt()), 3);
}
void
SettingsOtherPeripherals::on_comboBoxCard4_currentIndexChanged(int index)
SettingsOtherPeripherals::on_comboBoxIsaMemCard4_currentIndexChanged(int index)
{
if (index < 0) {
if (index < 0)
return;
}
ui->pushButtonConfigureCard4->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA));
ui->pushButtonConfigureIsaMemCard4->setEnabled((index != 0) && isamem_has_config(index) && machine_has_bus(machineId, MACHINE_BUS_ISA));
}
void
SettingsOtherPeripherals::on_pushButtonConfigureCard4_clicked()
SettingsOtherPeripherals::on_pushButtonConfigureIsaMemCard4_clicked()
{
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard4->currentData().toInt()), 4);
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxIsaMemCard4->currentData().toInt()), 4);
}
void
@@ -234,13 +238,12 @@ SettingsOtherPeripherals::on_pushButtonConfigureUT_clicked()
DeviceConfig::ConfigureDevice(&unittester_device);
}
void SettingsOtherPeripherals::on_pushButtonConfigureKeyCard_clicked()
{
DeviceConfig::ConfigureDevice(&novell_keycard_device);
}
void SettingsOtherPeripherals::on_checkBoxKeyCard_stateChanged(int arg1)
{
ui->pushButtonConfigureKeyCard->setEnabled(arg1 != 0);
}
void SettingsOtherPeripherals::on_pushButtonConfigureKeyCard_clicked()
{
DeviceConfig::ConfigureDevice(&novell_keycard_device);
}

View File

@@ -20,22 +20,23 @@ public slots:
void onCurrentMachineChanged(int machineId);
private slots:
void on_pushButtonConfigureCard4_clicked();
void on_comboBoxCard4_currentIndexChanged(int index);
void on_pushButtonConfigureCard3_clicked();
void on_comboBoxCard3_currentIndexChanged(int index);
void on_pushButtonConfigureCard2_clicked();
void on_comboBoxCard2_currentIndexChanged(int index);
void on_pushButtonConfigureCard1_clicked();
void on_comboBoxCard1_currentIndexChanged(int index);
void on_pushButtonConfigureRTC_clicked();
void on_comboBoxRTC_currentIndexChanged(int index);
void on_pushButtonConfigureRTC_clicked();
void on_comboBoxIsaMemCard1_currentIndexChanged(int index);
void on_pushButtonConfigureIsaMemCard1_clicked();
void on_comboBoxIsaMemCard2_currentIndexChanged(int index);
void on_pushButtonConfigureIsaMemCard2_clicked();
void on_comboBoxIsaMemCard3_currentIndexChanged(int index);
void on_pushButtonConfigureIsaMemCard3_clicked();
void on_comboBoxIsaMemCard4_currentIndexChanged(int index);
void on_pushButtonConfigureIsaMemCard4_clicked();
void on_checkBoxUnitTester_stateChanged(int arg1);
void on_pushButtonConfigureUT_clicked();
void on_pushButtonConfigureKeyCard_clicked();
void on_checkBoxKeyCard_stateChanged(int arg1);
void on_pushButtonConfigureKeyCard_clicked();
private:
Ui::SettingsOtherPeripherals *ui;

View File

@@ -27,9 +27,9 @@
<number>0</number>
</property>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<layout class="QHBoxLayout" name="horizontalLayoutRtc">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="labelRtc">
<property name="text">
<string>ISA RTC:</string>
</property>
@@ -58,20 +58,74 @@
</layout>
</item>
<item>
<widget class="QGroupBox" name="groupBox">
<widget class="QGroupBox" name="groupBoxMem">
<property name="title">
<string>ISA Memory Expansion</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="2">
<widget class="QPushButton" name="pushButtonConfigureCard2">
<layout class="QGridLayout" name="gridLayoutMem">
<item row="0" column="0">
<widget class="QLabel" name="labelIsaMemCard1">
<property name="text">
<string>Card 1:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxIsaMemCard1">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonConfigureIsaMemCard1">
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="labelIsaMemCard2">
<property name="text">
<string>Card 2:</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="comboBoxCard2">
<widget class="QComboBox" name="comboBoxIsaMemCard2">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QPushButton" name="pushButtonConfigureIsaMemCard2">
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="labelIsaMemCard3">
<property name="text">
<string>Card 3:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxIsaMemCard3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -84,68 +138,21 @@
</widget>
</item>
<item row="2" column="2">
<widget class="QPushButton" name="pushButtonConfigureCard3">
<widget class="QPushButton" name="pushButtonConfigureIsaMemCard3">
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_3">
<item row="3" column="0">
<widget class="QLabel" name="labelIsaMemCard4">
<property name="text">
<string>Card 2:</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="text">
<string>Card 3:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QPushButton" name="pushButtonConfigureCard1">
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="comboBoxCard1">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxVisibleItems">
<number>30</number>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Card 1:</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QComboBox" name="comboBoxCard3">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maxVisibleItems">
<number>30</number>
<string>Card 4:</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="comboBoxCard4">
<widget class="QComboBox" name="comboBoxIsaMemCard4">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
@@ -158,24 +165,17 @@
</widget>
</item>
<item row="3" column="2">
<widget class="QPushButton" name="pushButtonConfigureCard4">
<widget class="QPushButton" name="pushButtonConfigureIsaMemCard4">
<property name="text">
<string>Configure</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Card 4:</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<layout class="QHBoxLayout" name="horizontalLayoutIBPC">
<item>
<widget class="QCheckBox" name="checkBoxISABugger">
<property name="text">
@@ -193,7 +193,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<layout class="QHBoxLayout" name="horizontalLayoutUT">
<item>
<widget class="QCheckBox" name="checkBoxUnitTester">
<property name="sizePolicy">
@@ -217,7 +217,7 @@
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_6">
<layout class="QHBoxLayout" name="horizontalLayoutKeyCard">
<property name="topMargin">
<number>0</number>
</property>