Files
86Box/src/qt/qt_settingsports.cpp

115 lines
3.1 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
* Serial/Parallel ports 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 16:09:01 +06:00
* Cacodemon345
2022-02-07 15:00:02 +06:00
*
2023-01-06 15:36:05 -05:00
* Copyright 2022 Cacodemon345
* Copyright 2022 Jasmine Iwanek
* Copyright 2021 Joakim L. Gilje
2022-02-07 15:00:02 +06:00
*/
2021-11-25 10:20:56 +01:00
#include "qt_settingsports.hpp"
#include "ui_qt_settingsports.h"
extern "C" {
#include <86box/86box.h>
#include <86box/timer.h>
#include <86box/device.h>
#include <86box/machine.h>
#include <86box/lpt.h>
2022-07-28 16:50:49 -04:00
#include <86box/serial.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
SettingsPorts::SettingsPorts(QWidget *parent)
: QWidget(parent)
, ui(new Ui::SettingsPorts)
2021-11-25 10:20:56 +01:00
{
ui->setupUi(this);
for (int i = 0; i < PARALLEL_MAX; i++) {
2022-11-19 08:49:04 -05:00
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
auto *model = cbox->model();
int c = 0;
int selectedRow = 0;
2021-11-25 10:20:56 +01:00
while (true) {
2022-11-19 08:49:04 -05:00
const char *lptName = lpt_device_get_name(c);
2021-11-25 10:20:56 +01:00
if (lptName == nullptr) {
break;
}
2022-01-06 16:58:11 +06:00
Models::AddEntry(model, tr(lptName), c);
2021-11-25 10:20:56 +01:00
if (c == lpt_ports[i].device) {
selectedRow = c;
}
c++;
}
cbox->setCurrentIndex(selectedRow);
2022-11-19 08:49:04 -05:00
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
2021-11-25 10:20:56 +01:00
checkBox->setChecked(lpt_ports[i].enabled > 0);
cbox->setEnabled(lpt_ports[i].enabled > 0);
}
for (int i = 0; i < SERIAL_MAX; i++) {
2022-11-19 08:49:04 -05:00
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1));
2022-07-28 16:50:49 -04:00
checkBox->setChecked(com_ports[i].enabled > 0);
2021-11-25 10:20:56 +01:00
}
}
SettingsPorts::~SettingsPorts()
{
delete ui;
}
2022-11-19 08:49:04 -05:00
void
SettingsPorts::save()
{
for (int i = 0; i < PARALLEL_MAX; i++) {
2022-11-19 08:49:04 -05:00
auto *cbox = findChild<QComboBox *>(QString("comboBoxLpt%1").arg(i + 1));
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxParallel%1").arg(i + 1));
lpt_ports[i].device = cbox->currentData().toInt();
2021-11-25 10:20:56 +01:00
lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
}
for (int i = 0; i < SERIAL_MAX; i++) {
2022-11-19 08:49:04 -05:00
auto *checkBox = findChild<QCheckBox *>(QString("checkBoxSerial%1").arg(i + 1));
2022-07-28 16:50:49 -04:00
com_ports[i].enabled = checkBox->isChecked() ? 1 : 0;
2021-11-25 10:20:56 +01:00
}
}
2022-11-19 08:49:04 -05:00
void
SettingsPorts::on_checkBoxParallel1_stateChanged(int state)
{
2021-11-25 10:20:56 +01:00
ui->comboBoxLpt1->setEnabled(state == Qt::Checked);
}
2022-11-19 08:49:04 -05:00
void
SettingsPorts::on_checkBoxParallel2_stateChanged(int state)
{
2021-11-25 10:20:56 +01:00
ui->comboBoxLpt2->setEnabled(state == Qt::Checked);
}
2022-11-19 08:49:04 -05:00
void
SettingsPorts::on_checkBoxParallel3_stateChanged(int state)
{
2021-11-25 10:20:56 +01:00
ui->comboBoxLpt3->setEnabled(state == Qt::Checked);
}
2022-11-19 08:49:04 -05:00
void
SettingsPorts::on_checkBoxParallel4_stateChanged(int state)
{
ui->comboBoxLpt4->setEnabled(state == Qt::Checked);
}