From 17c3e803a4db87b483b98454030590bcf5012ea1 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Thu, 23 Dec 2021 17:05:11 +0600 Subject: [PATCH] Qt UI improvements * Port https://github.com/86Box/86Box/commit/209b5d9cd1b5ec63fca324aaea8f4dcc1160e21c to Qt UI * Remove dividers from status bar * Make OpenGL ES available as an option only if ANGLE is used --- src/qt/qt_mainwindow.cpp | 8 ++++--- src/qt/qt_settings.cpp | 1 + src/qt/qt_settingsotherperipherals.cpp | 30 +++++++++++++++++++++----- src/qt/qt_settingsotherperipherals.hpp | 5 +++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 8e4dcc1de..e4ad4ad04 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -57,6 +57,7 @@ MainWindow::MainWindow(QWidget *parent) : ui->setupUi(this); ui->stackedWidget->setMouseTracking(true); statusBar()->setVisible(!hide_status_bar); + statusBar()->setStyleSheet("QStatusBar::item {border: None;}"); this->setWindowIcon(QIcon(":/settings/win/icons/86Box-yellow.ico")); @@ -252,8 +253,8 @@ MainWindow::MainWindow(QWidget *parent) : } #ifdef Q_OS_WINDOWS - /* qt opengles doesn't work (yet?) so hide the menu option */ - ui->actionHardware_Renderer_OpenGL_ES->setVisible(false); + /* Make the option visible only if ANGLE is loaded. */ + ui->actionHardware_Renderer_OpenGL_ES->setVisible(QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGLES); #endif setFocusPolicy(Qt::StrongFocus); @@ -890,10 +891,11 @@ uint16_t x11_keycode_to_keysym(uint32_t keycode) void MainWindow::on_actionFullscreen_triggered() { if (video_fullscreen > 0) { + showNormal(); ui->menubar->show(); ui->statusbar->show(); - showNormal(); video_fullscreen = 0; + setGeometry(geometry()); } else { ui->menubar->hide(); ui->statusbar->hide(); diff --git a/src/qt/qt_settings.cpp b/src/qt/qt_settings.cpp index 5caa68249..7284d0cad 100644 --- a/src/qt/qt_settings.cpp +++ b/src/qt/qt_settings.cpp @@ -112,6 +112,7 @@ Settings::Settings(QWidget *parent) : connect(machine, &SettingsMachine::currentMachineChanged, sound, &SettingsSound::onCurrentMachineChanged); connect(machine, &SettingsMachine::currentMachineChanged, network, &SettingsNetwork::onCurrentMachineChanged); connect(machine, &SettingsMachine::currentMachineChanged, storageControllers, &SettingsStorageControllers::onCurrentMachineChanged); + connect(machine, &SettingsMachine::currentMachineChanged, otherPeripherals, &SettingsOtherPeripherals::onCurrentMachineChanged); connect(ui->listView->selectionModel(), &QItemSelectionModel::currentChanged, this, [this](const QModelIndex ¤t, const QModelIndex &previous) { ui->stackedWidget->setCurrentIndex(current.row()); diff --git a/src/qt/qt_settingsotherperipherals.cpp b/src/qt/qt_settingsotherperipherals.cpp index 834c6bdad..8eb849497 100644 --- a/src/qt/qt_settingsotherperipherals.cpp +++ b/src/qt/qt_settingsotherperipherals.cpp @@ -4,6 +4,7 @@ extern "C" { #include <86box/86box.h> #include <86box/device.h> +#include <86box/machine.h> #include <86box/isamem.h> #include <86box/isartc.h> } @@ -16,9 +17,18 @@ SettingsOtherPeripherals::SettingsOtherPeripherals(QWidget *parent) : ui(new Ui::SettingsOtherPeripherals) { ui->setupUi(this); + onCurrentMachineChanged(machine); +} + +void SettingsOtherPeripherals::onCurrentMachineChanged(int machineId) +{ + this->machineId = machineId; ui->checkBoxISABugger->setChecked(bugger_enabled > 0 ? true : false); ui->checkBoxPOSTCard->setChecked(postcard_enabled > 0 ? true : false); + ui->checkBoxISABugger->setEnabled(machine_has_bus(machineId, MACHINE_BUS_ISA)); + ui->comboBoxRTC->setEnabled(machine_has_bus(machineId, MACHINE_BUS_ISA)); + ui->pushButtonConfigureRTC->setEnabled(machine_has_bus(machineId, MACHINE_BUS_ISA)); auto* model = ui->comboBoxRTC->model(); int d = 0; @@ -29,6 +39,10 @@ SettingsOtherPeripherals::SettingsOtherPeripherals(QWidget *parent) : break; } + if (!device_is_valid(isartc_get_device(d), machineId)) { + break; + } + int row = Models::AddEntry(model, name, d); if (d == isartc_type) { selectedRow = row; @@ -48,6 +62,10 @@ SettingsOtherPeripherals::SettingsOtherPeripherals(QWidget *parent) : break; } + if (!device_is_valid(isamem_get_device(d), machineId)) { + break; + } + int row = Models::AddEntry(model, name, d); if (d == isamem_type[c]) { selectedRow = row; @@ -56,6 +74,8 @@ SettingsOtherPeripherals::SettingsOtherPeripherals(QWidget *parent) : } cbox->setCurrentIndex(-1); cbox->setCurrentIndex(selectedRow); + cbox->setEnabled(machine_has_bus(machineId, MACHINE_BUS_ISA)); + findChild(QString("pushButtonConfigureCard%1").arg(c + 1))->setEnabled(isamem_type[c] != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA)); } } @@ -81,7 +101,7 @@ void SettingsOtherPeripherals::on_comboBoxRTC_currentIndexChanged(int index) { if (index < 0) { return; } - ui->pushButtonConfigureRTC->setEnabled(index != 0); + ui->pushButtonConfigureRTC->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA)); } void SettingsOtherPeripherals::on_pushButtonConfigureRTC_clicked() { @@ -92,7 +112,7 @@ void SettingsOtherPeripherals::on_comboBoxCard1_currentIndexChanged(int index) { if (index < 0) { return; } - ui->pushButtonConfigureCard1->setEnabled(index != 0); + ui->pushButtonConfigureCard1->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA)); } void SettingsOtherPeripherals::on_pushButtonConfigureCard1_clicked() { @@ -103,7 +123,7 @@ void SettingsOtherPeripherals::on_comboBoxCard2_currentIndexChanged(int index) { if (index < 0) { return; } - ui->pushButtonConfigureCard2->setEnabled(index != 0); + ui->pushButtonConfigureCard2->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA)); } void SettingsOtherPeripherals::on_pushButtonConfigureCard2_clicked() { @@ -114,7 +134,7 @@ void SettingsOtherPeripherals::on_comboBoxCard3_currentIndexChanged(int index) { if (index < 0) { return; } - ui->pushButtonConfigureCard3->setEnabled(index != 0); + ui->pushButtonConfigureCard3->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA)); } void SettingsOtherPeripherals::on_pushButtonConfigureCard3_clicked() { @@ -125,7 +145,7 @@ void SettingsOtherPeripherals::on_comboBoxCard4_currentIndexChanged(int index) { if (index < 0) { return; } - ui->pushButtonConfigureCard4->setEnabled(index != 0); + ui->pushButtonConfigureCard4->setEnabled(index != 0 && machine_has_bus(machineId, MACHINE_BUS_ISA)); } void SettingsOtherPeripherals::on_pushButtonConfigureCard4_clicked() { diff --git a/src/qt/qt_settingsotherperipherals.hpp b/src/qt/qt_settingsotherperipherals.hpp index e32704f1b..f8eed2c9e 100644 --- a/src/qt/qt_settingsotherperipherals.hpp +++ b/src/qt/qt_settingsotherperipherals.hpp @@ -16,6 +16,10 @@ public: ~SettingsOtherPeripherals(); void save(); + +public slots: + void onCurrentMachineChanged(int machineId); + private slots: void on_pushButtonConfigureCard4_clicked(); void on_comboBoxCard4_currentIndexChanged(int index); @@ -30,6 +34,7 @@ private slots: private: Ui::SettingsOtherPeripherals *ui; + int machineId{0}; }; #endif // QT_SETTINGSOTHERPERIPHERALS_HPP