Initial Qt Commit
This commit is contained in:
105
src/qt/qt_settingsdisplay.cpp
Normal file
105
src/qt/qt_settingsdisplay.cpp
Normal file
@@ -0,0 +1,105 @@
|
||||
#include "qt_settingsdisplay.hpp"
|
||||
#include "ui_qt_settingsdisplay.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
extern "C" {
|
||||
#include <86box/86box.h>
|
||||
#include <86box/device.h>
|
||||
#include <86box/machine.h>
|
||||
#include <86box/video.h>
|
||||
}
|
||||
|
||||
#include "qt_deviceconfig.hpp"
|
||||
#include "qt_models_common.hpp"
|
||||
|
||||
SettingsDisplay::SettingsDisplay(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
ui(new Ui::SettingsDisplay)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
onCurrentMachineChanged(machine);
|
||||
}
|
||||
|
||||
SettingsDisplay::~SettingsDisplay()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void SettingsDisplay::save() {
|
||||
gfxcard = ui->comboBoxVideo->currentData().toInt();
|
||||
voodoo_enabled = ui->checkBoxVoodoo->isChecked() ? 1 : 0;
|
||||
}
|
||||
|
||||
void SettingsDisplay::onCurrentMachineChanged(int machineId) {
|
||||
// win_settings_video_proc, WM_INITDIALOG
|
||||
this->machineId = machineId;
|
||||
|
||||
auto* machine = &machines[machineId];
|
||||
auto* model = ui->comboBoxVideo->model();
|
||||
auto removeRows = model->rowCount();
|
||||
|
||||
int c = 0;
|
||||
int selectedRow = 0;
|
||||
while (true) {
|
||||
/* Skip "internal" if machine doesn't have it. */
|
||||
if ((c == 1) && !(machine->flags & MACHINE_VIDEO)) {
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
|
||||
const device_t* video_dev = video_card_getdevice(c);
|
||||
QString name = DeviceConfig::DeviceName(video_dev, video_get_internal_name(c), 1);
|
||||
if (name.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (video_card_available(c) &&
|
||||
device_is_valid(video_dev, machine->flags)) {
|
||||
int row = Models::AddEntry(model, name, c);
|
||||
if (c == gfxcard) {
|
||||
selectedRow = row - removeRows;
|
||||
}
|
||||
}
|
||||
|
||||
c++;
|
||||
}
|
||||
model->removeRows(0, removeRows);
|
||||
|
||||
if (machine->flags & MACHINE_VIDEO_ONLY) {
|
||||
ui->comboBoxVideo->setEnabled(false);
|
||||
selectedRow = 1;
|
||||
} else {
|
||||
ui->comboBoxVideo->setEnabled(true);
|
||||
}
|
||||
ui->comboBoxVideo->setCurrentIndex(selectedRow);
|
||||
}
|
||||
|
||||
void SettingsDisplay::on_pushButtonConfigure_clicked() {
|
||||
auto* device = video_card_getdevice(ui->comboBoxVideo->currentData().toInt());
|
||||
DeviceConfig::ConfigureDevice(device);
|
||||
}
|
||||
|
||||
void SettingsDisplay::on_pushButtonConfigureVoodoo_clicked() {
|
||||
DeviceConfig::ConfigureDevice(&voodoo_device);
|
||||
}
|
||||
|
||||
void SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index) {
|
||||
if (index < 0) {
|
||||
return;
|
||||
}
|
||||
int videoCard = ui->comboBoxVideo->currentData().toInt();
|
||||
ui->pushButtonConfigure->setEnabled(video_card_has_config(videoCard) > 0);
|
||||
|
||||
bool machineHasPci = machines[machineId].flags & MACHINE_BUS_PCI;
|
||||
ui->checkBoxVoodoo->setEnabled(machineHasPci);
|
||||
if (machineHasPci) {
|
||||
ui->checkBoxVoodoo->setChecked(voodoo_enabled);
|
||||
}
|
||||
ui->pushButtonConfigureVoodoo->setEnabled(machineHasPci && ui->checkBoxVoodoo->isChecked());
|
||||
}
|
||||
|
||||
void SettingsDisplay::on_checkBoxVoodoo_stateChanged(int state) {
|
||||
ui->pushButtonConfigureVoodoo->setEnabled(state == Qt::Checked);
|
||||
}
|
||||
Reference in New Issue
Block a user