* Fix fixed size window sizing

* Fix device config windows not appearing centered and modal under Wayland
This commit is contained in:
Cacodemon345
2022-02-09 00:29:19 +06:00
parent dde6bfdce7
commit dd83bdb0f6
13 changed files with 48 additions and 31 deletions

View File

@@ -18,6 +18,7 @@
*/
#include "qt_deviceconfig.hpp"
#include "ui_qt_deviceconfig.h"
#include "qt_settings.hpp"
#include <QDebug>
#include <QComboBox>
@@ -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;

View File

@@ -3,6 +3,8 @@
#include <QDialog>
#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;

View File

@@ -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 &current, 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() {

View File

@@ -28,6 +28,7 @@ public:
~Settings();
void save();
static Settings* settings;
protected slots:
void accept() override;

View File

@@ -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::settings));
}
void SettingsDisplay::on_pushButtonConfigureVoodoo_clicked() {
DeviceConfig::ConfigureDevice(&voodoo_device);
DeviceConfig::ConfigureDevice(&voodoo_device, 0, qobject_cast<Settings*>(Settings::settings));
}
void SettingsDisplay::on_comboBoxVideo_currentIndexChanged(int index) {

View File

@@ -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::settings));
}
static int get_axis(JoystickConfiguration& jc, int axis, int joystick_nr) {

View File

@@ -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::settings));
}

View File

@@ -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::settings));
}

View File

@@ -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::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::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::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::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::settings));
}

View File

@@ -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::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::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::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::settings));
} else {
DeviceConfig::ConfigureDevice(&mpu401_device);
DeviceConfig::ConfigureDevice(&mpu401_device, 0, qobject_cast<Settings*>(Settings::settings));
}
}
void SettingsSound::on_pushButtonConfigureSSI2001_clicked() {
DeviceConfig::ConfigureDevice(&ssi2001_device);
DeviceConfig::ConfigureDevice(&ssi2001_device, 0, qobject_cast<Settings*>(Settings::settings));
}
void SettingsSound::on_pushButtonConfigureCMS_clicked() {
DeviceConfig::ConfigureDevice(&cms_device);
DeviceConfig::ConfigureDevice(&cms_device, 0, qobject_cast<Settings*>(Settings::settings));
}
void SettingsSound::on_pushButtonConfigureGUS_clicked() {
DeviceConfig::ConfigureDevice(&gus_device);
DeviceConfig::ConfigureDevice(&gus_device, 0, qobject_cast<Settings*>(Settings::settings));
}

View File

@@ -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::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::settings));
}
void SettingsStorageControllers::on_pushButtonTertiaryIDE_clicked() {
DeviceConfig::ConfigureDevice(&ide_ter_device);
DeviceConfig::ConfigureDevice(&ide_ter_device, 0, qobject_cast<Settings*>(Settings::settings));
}
void SettingsStorageControllers::on_pushButtonQuaternaryIDE_clicked() {
DeviceConfig::ConfigureDevice(&ide_qua_device);
DeviceConfig::ConfigureDevice(&ide_qua_device, 0, qobject_cast<Settings*>(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::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::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::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::settings));
}

View File

@@ -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);
}
}

View File

@@ -3,6 +3,7 @@
#include <QProxyStyle>
#include <QWidget>
#include <QLayout>
class StyleOverride : public QProxyStyle
{
@@ -16,4 +17,4 @@ public:
void polish(QWidget* widget) override;
};
#endif
#endif