From dd83bdb0f6fb84274876b44f8d8ef4a545e0d092 Mon Sep 17 00:00:00 2001 From: Cacodemon345 Date: Wed, 9 Feb 2022 00:29:19 +0600 Subject: [PATCH] * Fix fixed size window sizing * Fix device config windows not appearing centered and modal under Wayland --- src/qt/qt_deviceconfig.cpp | 5 +++-- src/qt/qt_deviceconfig.hpp | 6 +++++- src/qt/qt_settings.cpp | 4 ++++ src/qt/qt_settings.hpp | 1 + src/qt/qt_settingsdisplay.cpp | 4 ++-- src/qt/qt_settingsinput.cpp | 2 +- src/qt/qt_settingsmachine.cpp | 2 +- src/qt/qt_settingsnetwork.cpp | 2 +- src/qt/qt_settingsotherperipherals.cpp | 10 +++++----- src/qt/qt_settingssound.cpp | 16 ++++++++-------- src/qt/qt_settingsstoragecontrollers.cpp | 16 ++++++++-------- src/qt/qt_styleoverride.cpp | 8 +++++++- src/qt/qt_styleoverride.hpp | 3 ++- 13 files changed, 48 insertions(+), 31 deletions(-) diff --git a/src/qt/qt_deviceconfig.cpp b/src/qt/qt_deviceconfig.cpp index c51a8a49e..ac967f678 100644 --- a/src/qt/qt_deviceconfig.cpp +++ b/src/qt/qt_deviceconfig.cpp @@ -18,6 +18,7 @@ */ #include "qt_deviceconfig.hpp" #include "ui_qt_deviceconfig.h" +#include "qt_settings.hpp" #include #include @@ -47,8 +48,8 @@ DeviceConfig::~DeviceConfig() delete ui; } -void DeviceConfig::ConfigureDevice(const _device_* device, int instance) { - DeviceConfig dc; +void DeviceConfig::ConfigureDevice(const _device_* device, int instance, Settings* settings) { + DeviceConfig dc(settings); dc.setWindowTitle(QString("%1 Device Configuration").arg(device->name)); device_context_t device_context; diff --git a/src/qt/qt_deviceconfig.hpp b/src/qt/qt_deviceconfig.hpp index 8062c1851..2662df11c 100644 --- a/src/qt/qt_deviceconfig.hpp +++ b/src/qt/qt_deviceconfig.hpp @@ -3,6 +3,8 @@ #include +#include "qt_settings.hpp" + extern "C" { struct _device_; } @@ -11,6 +13,8 @@ namespace Ui { class DeviceConfig; } +class Settings; + class DeviceConfig : public QDialog { Q_OBJECT @@ -19,7 +23,7 @@ public: explicit DeviceConfig(QWidget *parent = nullptr); ~DeviceConfig(); - static void ConfigureDevice(const _device_* device, int instance = 0); + static void ConfigureDevice(const _device_* device, int instance = 0, Settings* settings = nullptr); static QString DeviceName(const _device_* device, const char* internalName, int bus); private: Ui::DeviceConfig *ui; diff --git a/src/qt/qt_settings.cpp b/src/qt/qt_settings.cpp index c8312013a..25493ae2d 100644 --- a/src/qt/qt_settings.cpp +++ b/src/qt/qt_settings.cpp @@ -97,6 +97,7 @@ int SettingsModel::rowCount(const QModelIndex &parent) const { return pages.size(); } +Settings* Settings::settings = nullptr;; Settings::Settings(QWidget *parent) : QDialog(parent), ui(new Ui::Settings) @@ -142,6 +143,8 @@ Settings::Settings(QWidget *parent) : connect(ui->listView->selectionModel(), &QItemSelectionModel::currentChanged, this, [this](const QModelIndex ¤t, const QModelIndex &previous) { ui->stackedWidget->setCurrentIndex(current.row()); }); + + Settings::settings = this; } Settings::~Settings() @@ -149,6 +152,7 @@ Settings::~Settings() delete ui; delete Harddrives::busTrackClass; Harddrives::busTrackClass = nullptr; + Settings::settings = nullptr; } void Settings::save() { diff --git a/src/qt/qt_settings.hpp b/src/qt/qt_settings.hpp index 49137b8b7..7e0a78cfa 100644 --- a/src/qt/qt_settings.hpp +++ b/src/qt/qt_settings.hpp @@ -28,6 +28,7 @@ public: ~Settings(); void save(); + static Settings* settings; protected slots: void accept() override; diff --git a/src/qt/qt_settingsdisplay.cpp b/src/qt/qt_settingsdisplay.cpp index b3a2cfd0d..394033a47 100644 --- a/src/qt/qt_settingsdisplay.cpp +++ b/src/qt/qt_settingsdisplay.cpp @@ -93,11 +93,11 @@ void SettingsDisplay::onCurrentMachineChanged(int machineId) { void SettingsDisplay::on_pushButtonConfigure_clicked() { auto* device = video_card_getdevice(ui->comboBoxVideo->currentData().toInt()); - DeviceConfig::ConfigureDevice(device); + DeviceConfig::ConfigureDevice(device, 0, qobject_cast(Settings::settings)); } void SettingsDisplay::on_pushButtonConfigureVoodoo_clicked() { - DeviceConfig::ConfigureDevice(&voodoo_device); + DeviceConfig::ConfigureDevice(&voodoo_device, 0, qobject_cast(Settings::settings)); } void SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index) { diff --git a/src/qt/qt_settingsinput.cpp b/src/qt/qt_settingsinput.cpp index 120065a88..c735153d9 100644 --- a/src/qt/qt_settingsinput.cpp +++ b/src/qt/qt_settingsinput.cpp @@ -122,7 +122,7 @@ void SettingsInput::on_comboBoxJoystick_currentIndexChanged(int index) { void SettingsInput::on_pushButtonConfigureMouse_clicked() { int mouseId = ui->comboBoxMouse->currentData().toInt(); - DeviceConfig::ConfigureDevice(mouse_get_device(mouseId)); + DeviceConfig::ConfigureDevice(mouse_get_device(mouseId), 0, qobject_cast(Settings::settings)); } static int get_axis(JoystickConfiguration& jc, int axis, int joystick_nr) { diff --git a/src/qt/qt_settingsmachine.cpp b/src/qt/qt_settingsmachine.cpp index 37d66e9c0..7f402de1b 100644 --- a/src/qt/qt_settingsmachine.cpp +++ b/src/qt/qt_settingsmachine.cpp @@ -282,5 +282,5 @@ void SettingsMachine::on_pushButtonConfigure_clicked() { // deviceconfig_inst_open int machineId = ui->comboBoxMachine->currentData().toInt(); const auto* device = machine_getdevice(machineId); - DeviceConfig::ConfigureDevice(device); + DeviceConfig::ConfigureDevice(device, 0, qobject_cast(Settings::settings)); } diff --git a/src/qt/qt_settingsnetwork.cpp b/src/qt/qt_settingsnetwork.cpp index 836e3f83d..290fea43b 100644 --- a/src/qt/qt_settingsnetwork.cpp +++ b/src/qt/qt_settingsnetwork.cpp @@ -124,6 +124,6 @@ void SettingsNetwork::on_comboBoxAdapter_currentIndexChanged(int index) { } void SettingsNetwork::on_pushButtonConfigure_clicked() { - DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxAdapter->currentData().toInt())); + DeviceConfig::ConfigureDevice(network_card_getdevice(ui->comboBoxAdapter->currentData().toInt()), 0, qobject_cast(Settings::settings)); } diff --git a/src/qt/qt_settingsotherperipherals.cpp b/src/qt/qt_settingsotherperipherals.cpp index ffa7391a8..ebf849d28 100644 --- a/src/qt/qt_settingsotherperipherals.cpp +++ b/src/qt/qt_settingsotherperipherals.cpp @@ -127,7 +127,7 @@ void SettingsOtherPeripherals::on_comboBoxRTC_currentIndexChanged(int index) { } void SettingsOtherPeripherals::on_pushButtonConfigureRTC_clicked() { - DeviceConfig::ConfigureDevice(isartc_get_device(ui->comboBoxRTC->currentData().toInt())); + DeviceConfig::ConfigureDevice(isartc_get_device(ui->comboBoxRTC->currentData().toInt()), 0, qobject_cast(Settings::settings)); } void SettingsOtherPeripherals::on_comboBoxCard1_currentIndexChanged(int index) { @@ -138,7 +138,7 @@ void SettingsOtherPeripherals::on_comboBoxCard1_currentIndexChanged(int index) { } void SettingsOtherPeripherals::on_pushButtonConfigureCard1_clicked() { - DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard1->currentData().toInt()), 1); + DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard1->currentData().toInt()), 1, qobject_cast(Settings::settings)); } void SettingsOtherPeripherals::on_comboBoxCard2_currentIndexChanged(int index) { @@ -149,7 +149,7 @@ void SettingsOtherPeripherals::on_comboBoxCard2_currentIndexChanged(int index) { } void SettingsOtherPeripherals::on_pushButtonConfigureCard2_clicked() { - DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard2->currentData().toInt()), 2); + DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard2->currentData().toInt()), 2, qobject_cast(Settings::settings)); } void SettingsOtherPeripherals::on_comboBoxCard3_currentIndexChanged(int index) { @@ -160,7 +160,7 @@ void SettingsOtherPeripherals::on_comboBoxCard3_currentIndexChanged(int index) { } void SettingsOtherPeripherals::on_pushButtonConfigureCard3_clicked() { - DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard3->currentData().toInt()), 3); + DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard3->currentData().toInt()), 3, qobject_cast(Settings::settings)); } void SettingsOtherPeripherals::on_comboBoxCard4_currentIndexChanged(int index) { @@ -171,5 +171,5 @@ void SettingsOtherPeripherals::on_comboBoxCard4_currentIndexChanged(int index) { } void SettingsOtherPeripherals::on_pushButtonConfigureCard4_clicked() { - DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard4->currentData().toInt()), 4); + DeviceConfig::ConfigureDevice(isamem_get_device(ui->comboBoxCard4->currentData().toInt()), 4, qobject_cast(Settings::settings)); } diff --git a/src/qt/qt_settingssound.cpp b/src/qt/qt_settingssound.cpp index 7277f4007..5cf1114b0 100644 --- a/src/qt/qt_settingssound.cpp +++ b/src/qt/qt_settingssound.cpp @@ -177,7 +177,7 @@ void SettingsSound::on_comboBoxSoundCard_currentIndexChanged(int index) { void SettingsSound::on_pushButtonConfigureSoundCard_clicked() { - DeviceConfig::ConfigureDevice(sound_card_getdevice(ui->comboBoxSoundCard->currentData().toInt())); + DeviceConfig::ConfigureDevice(sound_card_getdevice(ui->comboBoxSoundCard->currentData().toInt()), 0, qobject_cast(Settings::settings)); } void SettingsSound::on_comboBoxMidiOut_currentIndexChanged(int index) { @@ -190,7 +190,7 @@ void SettingsSound::on_comboBoxMidiOut_currentIndexChanged(int index) { } void SettingsSound::on_pushButtonConfigureMidiOut_clicked() { - DeviceConfig::ConfigureDevice(midi_device_getdevice(ui->comboBoxMidiOut->currentData().toInt())); + DeviceConfig::ConfigureDevice(midi_device_getdevice(ui->comboBoxMidiOut->currentData().toInt()), 0, qobject_cast(Settings::settings)); } void SettingsSound::on_comboBoxMidiIn_currentIndexChanged(int index) { @@ -203,7 +203,7 @@ void SettingsSound::on_comboBoxMidiIn_currentIndexChanged(int index) { } void SettingsSound::on_pushButtonConfigureMidiIn_clicked() { - DeviceConfig::ConfigureDevice(midi_in_device_getdevice(ui->comboBoxMidiIn->currentData().toInt())); + DeviceConfig::ConfigureDevice(midi_in_device_getdevice(ui->comboBoxMidiIn->currentData().toInt()), 0, qobject_cast(Settings::settings)); } void SettingsSound::on_checkBoxMPU401_stateChanged(int state) { @@ -224,20 +224,20 @@ void SettingsSound::on_checkBoxGUS_stateChanged(int state) { void SettingsSound::on_pushButtonConfigureMPU401_clicked() { if (machine_has_bus(machineId, MACHINE_BUS_MCA) > 0) { - DeviceConfig::ConfigureDevice(&mpu401_mca_device); + DeviceConfig::ConfigureDevice(&mpu401_mca_device, 0, qobject_cast(Settings::settings)); } else { - DeviceConfig::ConfigureDevice(&mpu401_device); + DeviceConfig::ConfigureDevice(&mpu401_device, 0, qobject_cast(Settings::settings)); } } void SettingsSound::on_pushButtonConfigureSSI2001_clicked() { - DeviceConfig::ConfigureDevice(&ssi2001_device); + DeviceConfig::ConfigureDevice(&ssi2001_device, 0, qobject_cast(Settings::settings)); } void SettingsSound::on_pushButtonConfigureCMS_clicked() { - DeviceConfig::ConfigureDevice(&cms_device); + DeviceConfig::ConfigureDevice(&cms_device, 0, qobject_cast(Settings::settings)); } void SettingsSound::on_pushButtonConfigureGUS_clicked() { - DeviceConfig::ConfigureDevice(&gus_device); + DeviceConfig::ConfigureDevice(&gus_device, 0, qobject_cast(Settings::settings)); } diff --git a/src/qt/qt_settingsstoragecontrollers.cpp b/src/qt/qt_settingsstoragecontrollers.cpp index 0b66cec0a..2427b5774 100644 --- a/src/qt/qt_settingsstoragecontrollers.cpp +++ b/src/qt/qt_settingsstoragecontrollers.cpp @@ -188,19 +188,19 @@ void SettingsStorageControllers::on_checkBoxQuaternaryIDE_stateChanged(int arg1) } void SettingsStorageControllers::on_pushButtonHD_clicked() { - DeviceConfig::ConfigureDevice(hdc_get_device(ui->comboBoxHD->currentData().toInt())); + DeviceConfig::ConfigureDevice(hdc_get_device(ui->comboBoxHD->currentData().toInt()), 0, qobject_cast(Settings::settings)); } void SettingsStorageControllers::on_pushButtonFD_clicked() { - DeviceConfig::ConfigureDevice(fdc_card_getdevice(ui->comboBoxFD->currentData().toInt())); + DeviceConfig::ConfigureDevice(fdc_card_getdevice(ui->comboBoxFD->currentData().toInt()), 0, qobject_cast(Settings::settings)); } void SettingsStorageControllers::on_pushButtonTertiaryIDE_clicked() { - DeviceConfig::ConfigureDevice(&ide_ter_device); + DeviceConfig::ConfigureDevice(&ide_ter_device, 0, qobject_cast(Settings::settings)); } void SettingsStorageControllers::on_pushButtonQuaternaryIDE_clicked() { - DeviceConfig::ConfigureDevice(&ide_qua_device); + DeviceConfig::ConfigureDevice(&ide_qua_device, 0, qobject_cast(Settings::settings)); } void SettingsStorageControllers::on_comboBoxSCSI1_currentIndexChanged(int index) { @@ -233,17 +233,17 @@ void SettingsStorageControllers::on_comboBoxSCSI4_currentIndexChanged(int index) void SettingsStorageControllers::on_pushButtonSCSI1_clicked() { - DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI1->currentData().toInt()), 1); + DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI1->currentData().toInt()), 1, qobject_cast(Settings::settings)); } void SettingsStorageControllers::on_pushButtonSCSI2_clicked() { - DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI2->currentData().toInt()), 2); + DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI2->currentData().toInt()), 2, qobject_cast(Settings::settings)); } void SettingsStorageControllers::on_pushButtonSCSI3_clicked() { - DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI3->currentData().toInt()), 3); + DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI3->currentData().toInt()), 3, qobject_cast(Settings::settings)); } void SettingsStorageControllers::on_pushButtonSCSI4_clicked() { - DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI4->currentData().toInt()), 4); + DeviceConfig::ConfigureDevice(scsi_card_getdevice(ui->comboBoxSCSI4->currentData().toInt()), 4, qobject_cast(Settings::settings)); } diff --git a/src/qt/qt_styleoverride.cpp b/src/qt/qt_styleoverride.cpp index 20d45e94a..628f4c143 100644 --- a/src/qt/qt_styleoverride.cpp +++ b/src/qt/qt_styleoverride.cpp @@ -33,6 +33,12 @@ void StyleOverride::polish(QWidget* widget) { QProxyStyle::polish(widget); /* Disable title bar context help buttons globally as they are unused. */ - if (widget->isWindow()) + if (widget->isWindow()) { + if (widget->layout() && widget->minimumSize() == widget->maximumSize()) { + widget->setFixedSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX)); + widget->layout()->setSizeConstraint(QLayout::SetFixedSize); + widget->setWindowFlag(Qt::MSWindowsFixedSizeDialogHint, true); + } widget->setWindowFlag(Qt::WindowContextHelpButtonHint, false); + } } diff --git a/src/qt/qt_styleoverride.hpp b/src/qt/qt_styleoverride.hpp index fa365d946..9a2223322 100644 --- a/src/qt/qt_styleoverride.hpp +++ b/src/qt/qt_styleoverride.hpp @@ -3,6 +3,7 @@ #include #include +#include class StyleOverride : public QProxyStyle { @@ -16,4 +17,4 @@ public: void polish(QWidget* widget) override; }; -#endif \ No newline at end of file +#endif