Files
86Box/src/qt/qt_settingsotherperipherals.cpp

216 lines
6.4 KiB
C++
Raw Normal View History

2022-02-07 15:00:02 +06:00
/*
2023-01-06 15:36:05 -05:00
* 86Box A hypervisor and IBM PC system emulator that specializes in
* running old operating systems and software designed for IBM
* PC systems and compatibles from 1981 through fairly recent
* system designs based on the PCI bus.
2022-02-07 15:00:02 +06:00
*
2023-01-06 15:36:05 -05:00
* This file is part of the 86Box distribution.
2022-02-07 15:00:02 +06:00
*
2023-01-06 15:36:05 -05:00
* Other peripherals configuration UI module.
2022-02-07 15:00:02 +06:00
*
*
*
2023-01-06 15:36:05 -05:00
* Authors: Joakim L. Gilje <jgilje@jgilje.net>
2022-02-07 15:00:02 +06:00
*
2023-01-06 15:36:05 -05:00
* Copyright 2021 Joakim L. Gilje
2022-02-07 15:00:02 +06:00
*/
2021-11-25 10:20:56 +01:00
#include "qt_settingsotherperipherals.hpp"
#include "ui_qt_settingsotherperipherals.h"
extern "C" {
#include <86box/86box.h>
#include <86box/device.h>
#include <86box/machine.h>
2021-11-25 10:20:56 +01:00
#include <86box/isamem.h>
#include <86box/isartc.h>
#include <86box/unittester.h>
2021-11-25 10:20:56 +01:00
}
#include "qt_deviceconfig.hpp"
#include "qt_models_common.hpp"
2022-11-19 08:49:04 -05:00
SettingsOtherPeripherals::SettingsOtherPeripherals(QWidget *parent)
: QWidget(parent)
, ui(new Ui::SettingsOtherPeripherals)
2021-11-25 10:20:56 +01:00
{
ui->setupUi(this);
onCurrentMachineChanged(machine);
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::onCurrentMachineChanged(int machineId)
{
this->machineId = machineId;
2021-11-25 10:20:56 +01:00
bool machineHasIsa = (machine_has_bus(machineId, MACHINE_BUS_ISA) > 0);
ui->checkBoxISABugger->setChecked((machineHasIsa && (bugger_enabled > 0)) ? true : false);
2021-11-25 10:20:56 +01:00
ui->checkBoxPOSTCard->setChecked(postcard_enabled > 0 ? true : false);
ui->checkBoxUnitTester->setChecked(unittester_enabled > 0 ? true : false);
ui->checkBoxISABugger->setEnabled(machineHasIsa);
ui->pushButtonConfigureUT->setEnabled(unittester_enabled > 0);
ui->comboBoxRTC->setEnabled(machineHasIsa);
ui->pushButtonConfigureRTC->setEnabled(machineHasIsa);
2021-11-25 10:20:56 +01:00
ui->comboBoxCard1->clear();
ui->comboBoxCard2->clear();
ui->comboBoxCard3->clear();
ui->comboBoxCard4->clear();
ui->comboBoxRTC->clear();
2022-11-19 08:49:04 -05:00
auto *model = ui->comboBoxRTC->model();
int d = 0;
int selectedRow = 0;
2021-11-25 10:20:56 +01:00
while (true) {
QString name = DeviceConfig::DeviceName(isartc_get_device(d), isartc_get_internal_name(d), 0);
if (name.isEmpty()) {
break;
}
if (!device_is_valid(isartc_get_device(d), machineId)) {
break;
}
2021-11-25 10:20:56 +01:00
int row = Models::AddEntry(model, name, d);
if (d == isartc_type) {
selectedRow = row;
}
++d;
}
ui->comboBoxRTC->setCurrentIndex(selectedRow);
for (int c = 0; c < ISAMEM_MAX; c++) {
2022-11-19 08:49:04 -05:00
auto *cbox = findChild<QComboBox *>(QString("comboBoxCard%1").arg(c + 1));
model = cbox->model();
d = 0;
2021-11-25 10:20:56 +01:00
selectedRow = 0;
while (true) {
QString name = DeviceConfig::DeviceName(isamem_get_device(d), isamem_get_internal_name(d), 0);
if (name.isEmpty()) {
break;
}
if (!device_is_valid(isamem_get_device(d), machineId)) {
break;
}
2021-11-25 10:20:56 +01:00
int row = Models::AddEntry(model, name, d);
if (d == isamem_type[c]) {
2021-11-25 10:20:56 +01:00
selectedRow = row;
}
++d;
}
cbox->setCurrentIndex(-1);
cbox->setCurrentIndex(selectedRow);
cbox->setEnabled(machineHasIsa);
findChild<QPushButton *>(QString("pushButtonConfigureCard%1").arg(c + 1))->setEnabled(isamem_type[c] != 0 && machineHasIsa);
2021-11-25 10:20:56 +01:00
}
}
SettingsOtherPeripherals::~SettingsOtherPeripherals()
{
delete ui;
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::save()
{
2021-11-25 10:20:56 +01:00
/* Other peripherals category */
bugger_enabled = ui->checkBoxISABugger->isChecked() ? 1 : 0;
postcard_enabled = ui->checkBoxPOSTCard->isChecked() ? 1 : 0;
unittester_enabled = ui->checkBoxUnitTester->isChecked() ? 1 : 0;
isartc_type = ui->comboBoxRTC->currentData().toInt();
2021-11-25 10:20:56 +01:00
/* ISA memory boards. */
for (int i = 0; i < ISAMEM_MAX; i++) {
2022-11-19 08:49:04 -05:00
auto *cbox = findChild<QComboBox *>(QString("comboBoxCard%1").arg(i + 1));
2021-11-25 10:20:56 +01:00
isamem_type[i] = cbox->currentData().toInt();
}
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_comboBoxRTC_currentIndexChanged(int index)
{
2021-11-25 10:20:56 +01:00
if (index < 0) {
return;
}
ui->pushButtonConfigureRTC->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA));
2021-11-25 10:20:56 +01:00
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_pushButtonConfigureRTC_clicked()
{
DeviceConfig::ConfigureDevice(isartc_get_device(ui->comboBoxRTC->currentData().toInt()), 0, qobject_cast<Settings *>(Settings::settings));
2021-11-25 10:20:56 +01:00
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_comboBoxCard1_currentIndexChanged(int index)
{
2021-11-25 10:20:56 +01:00
if (index < 0) {
return;
}
ui->pushButtonConfigureCard1->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA));
2021-11-25 10:20:56 +01:00
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_pushButtonConfigureCard1_clicked()
{
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard1->currentData().toInt()), 1, qobject_cast<Settings *>(Settings::settings));
2021-11-25 10:20:56 +01:00
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_comboBoxCard2_currentIndexChanged(int index)
{
2021-11-25 10:20:56 +01:00
if (index < 0) {
return;
}
ui->pushButtonConfigureCard2->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA));
2021-11-25 10:20:56 +01:00
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_pushButtonConfigureCard2_clicked()
{
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard2->currentData().toInt()), 2, qobject_cast<Settings *>(Settings::settings));
2021-11-25 10:20:56 +01:00
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_comboBoxCard3_currentIndexChanged(int index)
{
2021-11-25 10:20:56 +01:00
if (index < 0) {
return;
}
ui->pushButtonConfigureCard3->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA));
2021-11-25 10:20:56 +01:00
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_pushButtonConfigureCard3_clicked()
{
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard3->currentData().toInt()), 3, qobject_cast<Settings *>(Settings::settings));
2021-11-25 10:20:56 +01:00
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_comboBoxCard4_currentIndexChanged(int index)
{
2021-11-25 10:20:56 +01:00
if (index < 0) {
return;
}
ui->pushButtonConfigureCard4->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA));
2021-11-25 10:20:56 +01:00
}
2022-11-19 08:49:04 -05:00
void
SettingsOtherPeripherals::on_pushButtonConfigureCard4_clicked()
{
DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard4->currentData().toInt()), 4, qobject_cast<Settings *>(Settings::settings));
2021-11-25 10:20:56 +01:00
}
void
SettingsOtherPeripherals::on_checkBoxUnitTester_stateChanged(int arg1)
{
ui->pushButtonConfigureUT->setEnabled(arg1 != 0);
}
void
SettingsOtherPeripherals::on_pushButtonConfigureUT_clicked()
{
DeviceConfig::ConfigureDevice(&unittester_device);
}