From 962fca2b92e1bf4525e5dcc726399c54b7c22c1b Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Sat, 29 Oct 2022 12:20:24 +0600 Subject: [PATCH] qt: Add earlier drive checkbox in CD-ROM settings --- src/qt/qt_settingsfloppycdrom.cpp | 23 +++++++++++++++++++++-- src/qt/qt_settingsfloppycdrom.hpp | 2 ++ src/qt/qt_settingsfloppycdrom.ui | 7 +++++++ 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/qt/qt_settingsfloppycdrom.cpp b/src/qt/qt_settingsfloppycdrom.cpp index 6bf9859ce..32943f9a6 100644 --- a/src/qt/qt_settingsfloppycdrom.cpp +++ b/src/qt/qt_settingsfloppycdrom.cpp @@ -73,6 +73,12 @@ static void setCDROMSpeed(QAbstractItemModel* model, const QModelIndex& idx, uin model->setData(i, speed, Qt::UserRole); } +static void setCDROMEarly(QAbstractItemModel* model, const QModelIndex& idx, bool early) { + auto i = idx.siblingAtColumn(2); + model->setData(i, (early == true) ? QObject::tr("On") : QObject::tr("Off")); + model->setData(i, early, Qt::UserRole); +} + SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent) : QWidget(parent), ui(new Ui::SettingsFloppyCDROM) @@ -120,15 +126,17 @@ SettingsFloppyCDROM::SettingsFloppyCDROM(QWidget *parent) : Models::AddEntry(model, QString("%1x").arg(i + 1), i + 1); } - model = new QStandardItemModel(0, 2, this); + model = new QStandardItemModel(0, 3, this); ui->tableViewCDROM->setModel(model); model->setHeaderData(0, Qt::Horizontal, tr("Bus")); model->setHeaderData(1, Qt::Horizontal, tr("Speed")); + model->setHeaderData(2, Qt::Horizontal, tr("Earlier drive")); model->insertRows(0, CDROM_NUM); for (int i = 0; i < CDROM_NUM; i++) { auto idx = model->index(i, 0); setCDROMBus(model, idx, cdrom[i].bus_type, cdrom[i].res); setCDROMSpeed(model, idx.siblingAtColumn(1), cdrom[i].speed); + setCDROMEarly(model, idx.siblingAtColumn(2), cdrom[i].early); Harddrives::busTrackClass->device_track(1, DEV_CDROM, cdrom[i].bus_type, cdrom[i].bus_type == CDROM_BUS_ATAPI ? cdrom[i].ide_channel : cdrom[i].scsi_device_id); } ui->tableViewCDROM->resizeColumnsToContents(); @@ -154,7 +162,7 @@ void SettingsFloppyCDROM::save() { /* Removable devices category */ model = ui->tableViewCDROM->model(); for (int i = 0; i < CDROM_NUM; i++) { - cdrom[i].is_dir = 0; + cdrom[i].is_dir = 0; cdrom[i].priv = NULL; cdrom[i].ops = NULL; cdrom[i].image = NULL; @@ -165,6 +173,7 @@ void SettingsFloppyCDROM::save() { cdrom[i].bus_type = model->index(i, 0).data(Qt::UserRole).toUInt(); cdrom[i].res = model->index(i, 0).data(Qt::UserRole + 1).toUInt(); cdrom[i].speed = model->index(i, 1).data(Qt::UserRole).toUInt(); + cdrom[i].early = model->index(i, 2).data(Qt::UserRole).toUInt(); } } @@ -179,6 +188,7 @@ void SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t) { uint8_t bus = current.siblingAtColumn(0).data(Qt::UserRole).toUInt(); uint8_t channel = current.siblingAtColumn(0).data(Qt::UserRole + 1).toUInt(); uint8_t speed = current.siblingAtColumn(1).data(Qt::UserRole).toUInt(); + bool early = current.siblingAtColumn(2).data(Qt::UserRole).toBool(); ui->comboBoxBus->setCurrentIndex(-1); auto* model = ui->comboBoxBus->model(); @@ -194,6 +204,7 @@ void SettingsFloppyCDROM::onCDROMRowChanged(const QModelIndex ¤t) { } ui->comboBoxSpeed->setCurrentIndex(speed == 0 ? 7 : speed - 1); + ui->checkBoxEarlierDrive->setChecked(early); } void SettingsFloppyCDROM::on_checkBoxTurboTimings_stateChanged(int arg1) { @@ -219,6 +230,7 @@ void SettingsFloppyCDROM::on_comboBoxBus_currentIndexChanged(int index) { bool enabled = (bus != CDROM_BUS_DISABLED); ui->comboBoxChannel->setEnabled(enabled); ui->comboBoxSpeed->setEnabled(enabled); + ui->checkBoxEarlierDrive->setEnabled(enabled); Harddrives::populateBusChannels(ui->comboBoxChannel->model(), bus); } @@ -251,3 +263,10 @@ void SettingsFloppyCDROM::on_comboBoxChannel_activated(int) { ui->comboBoxChannel->currentData().toUInt()); Harddrives::busTrackClass->device_track(1, DEV_CDROM, ui->tableViewCDROM->model()->data(i, Qt::UserRole).toInt(), ui->tableViewCDROM->model()->data(i, Qt::UserRole + 1).toInt()); } + +void SettingsFloppyCDROM::on_checkBoxEarlierDrive_stateChanged(int arg1) +{ + auto idx = ui->tableViewCDROM->selectionModel()->currentIndex(); + setCDROMEarly(ui->tableViewCDROM->model(), idx.siblingAtColumn(2), (arg1 == Qt::Checked) ? true : false); +} + diff --git a/src/qt/qt_settingsfloppycdrom.hpp b/src/qt/qt_settingsfloppycdrom.hpp index f68646ab0..4f50031cf 100644 --- a/src/qt/qt_settingsfloppycdrom.hpp +++ b/src/qt/qt_settingsfloppycdrom.hpp @@ -28,6 +28,8 @@ private slots: void onFloppyRowChanged(const QModelIndex ¤t); void onCDROMRowChanged(const QModelIndex ¤t); + void on_checkBoxEarlierDrive_stateChanged(int arg1); + private: Ui::SettingsFloppyCDROM *ui; }; diff --git a/src/qt/qt_settingsfloppycdrom.ui b/src/qt/qt_settingsfloppycdrom.ui index 8f7ffa995..6233e9e7b 100644 --- a/src/qt/qt_settingsfloppycdrom.ui +++ b/src/qt/qt_settingsfloppycdrom.ui @@ -145,6 +145,13 @@ + + + + Earlier drive + + +