From c1c4bcc889d59f5a4f714d6802e5592054f5cacf Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sat, 1 Mar 2025 15:54:50 +0500 Subject: [PATCH 1/7] Disable Win11 rounded window corners when the status bar is hidden --- src/qt/qt_mainwindow.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 61f5f6fe1..9802a2666 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -122,6 +122,19 @@ extern int qt_nvr_save(void); #include "x11_util.h" #endif +#ifdef Q_OS_WINDOWS +#include +#ifndef DWMWA_WINDOW_CORNER_PREFERENCE +#define DWMWA_WINDOW_CORNER_PREFERENCE 33 +#endif +#ifndef DWMWCP_DEFAULT +#define DWMWCP_DEFAULT 0 +#endif +#ifndef DWMWCP_DONOTROUND +#define DWMWCP_DONOTROUND 1 +#endif +#endif + #ifdef Q_OS_MACOS # include "cocoa_keyboard.hpp" // The namespace is required to avoid clashing typedefs; we only use this @@ -181,6 +194,10 @@ MainWindow::MainWindow(QWidget *parent) status->setSoundGainAction(ui->actionSound_gain); ui->stackedWidget->setMouseTracking(true); statusBar()->setVisible(!hide_status_bar); +#ifdef Q_OS_WINDOWS + auto cornerPreference = (hide_status_bar ? DWMWCP_DONOTROUND : DWMWCP_DEFAULT); + DwmSetWindowAttribute((HWND) this->winId(), DWMWA_WINDOW_CORNER_PREFERENCE, (LPCVOID) &cornerPreference, sizeof(cornerPreference)); +#endif statusBar()->setStyleSheet("QStatusBar::item {border: None; } QStatusBar QLabel { margin-right: 2px; margin-bottom: 1px; }"); this->centralWidget()->setStyleSheet("background-color: black;"); ui->toolBar->setVisible(!hide_tool_bar); @@ -1833,6 +1850,10 @@ MainWindow::on_actionHide_status_bar_triggered() hide_status_bar ^= 1; ui->actionHide_status_bar->setChecked(hide_status_bar); statusBar()->setVisible(!hide_status_bar); +#ifdef Q_OS_WINDOWS + auto cornerPreference = (hide_status_bar ? DWMWCP_DONOTROUND : DWMWCP_DEFAULT); + DwmSetWindowAttribute((HWND) main_window->winId(), DWMWA_WINDOW_CORNER_PREFERENCE, (LPCVOID) &cornerPreference, sizeof(cornerPreference)); +#endif if (vid_resize >= 2) { setFixedSize(fixed_size_x, fixed_size_y + menuBar()->height() + (hide_status_bar ? 0 : statusBar()->height()) + (hide_tool_bar ? 0 : ui->toolBar->height())); } else { From d6fa4d4f98f15f6b21ebffcff0bfa3a2f6b8a76a Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Thu, 6 Mar 2025 22:20:13 +0500 Subject: [PATCH 2/7] Disable Win11 rounded corners on the secondary monitor windows --- src/qt/qt_mainwindow.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 9802a2666..036f56375 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -816,6 +816,10 @@ MainWindow::initRendererMonitorSlot(int monitor_index) if (vid_resize == 2) secondaryRenderer->setFixedSize(fixed_size_x, fixed_size_y); secondaryRenderer->setWindowIcon(this->windowIcon()); +#ifdef Q_OS_WINDOWS + auto cornerPreference = DWMWCP_DONOTROUND; + DwmSetWindowAttribute((HWND) secondaryRenderer->winId(), DWMWA_WINDOW_CORNER_PREFERENCE, (LPCVOID) &cornerPreference, sizeof(cornerPreference)); +#endif if (show_second_monitors) { secondaryRenderer->show(); if (window_remember) { From e6f96352e083a9df48e87babed6e3afadf7a0e89 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sat, 1 Mar 2025 02:01:00 +0500 Subject: [PATCH 3/7] Fix serial passthrough configure buttons not re-enabling when the checkboxes are toggled --- src/qt/qt_settingsports.cpp | 43 ++++++++++++++++--------------------- src/qt/qt_settingsports.hpp | 14 ++++++------ 2 files changed, 25 insertions(+), 32 deletions(-) diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index 9679c9e21..3855a8b68 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -68,21 +68,14 @@ SettingsPorts::SettingsPorts(QWidget *parent) for (int i = 0; i < SERIAL_MAX; i++) { auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); auto *checkBoxPass = findChild(QString("checkBoxSerialPassThru%1").arg(i + 1)); + auto *buttonPass = findChild(QString("pushButtonSerialPassThru%1").arg(i + 1)); if (checkBox != NULL) checkBox->setChecked(com_ports[i].enabled > 0); - if (checkBoxPass != NULL) + if (checkBoxPass != NULL) { checkBoxPass->setChecked(serial_passthrough_enabled[i]); + buttonPass->setEnabled(serial_passthrough_enabled[i]); + } } - - ui->pushButtonSerialPassThru1->setEnabled(serial_passthrough_enabled[0]); - ui->pushButtonSerialPassThru2->setEnabled(serial_passthrough_enabled[1]); - ui->pushButtonSerialPassThru3->setEnabled(serial_passthrough_enabled[2]); - ui->pushButtonSerialPassThru4->setEnabled(serial_passthrough_enabled[3]); -#if 0 - ui->pushButtonSerialPassThru5->setEnabled(serial_passthrough_enabled[4]); - ui->pushButtonSerialPassThru6->setEnabled(serial_passthrough_enabled[5]); - ui->pushButtonSerialPassThru7->setEnabled(serial_passthrough_enabled[6]); -#endif } SettingsPorts::~SettingsPorts() @@ -181,45 +174,45 @@ SettingsPorts::on_pushButtonSerialPassThru7_clicked() #endif void -SettingsPorts::on_checkBoxSerialPassThru1_clicked(bool checked) +SettingsPorts::on_checkBoxSerialPassThru1_stateChanged(int state) { - ui->pushButtonSerialPassThru1->setEnabled(checked); + ui->pushButtonSerialPassThru1->setEnabled(state == Qt::Checked); } void -SettingsPorts::on_checkBoxSerialPassThru2_clicked(bool checked) +SettingsPorts::on_checkBoxSerialPassThru2_stateChanged(int state) { - ui->pushButtonSerialPassThru2->setEnabled(checked); + ui->pushButtonSerialPassThru2->setEnabled(state == Qt::Checked); } void -SettingsPorts::on_checkBoxSerialPassThru3_clicked(bool checked) +SettingsPorts::on_checkBoxSerialPassThru3_stateChanged(int state) { - ui->pushButtonSerialPassThru3->setEnabled(checked); + ui->pushButtonSerialPassThru3->setEnabled(state == Qt::Checked); } void -SettingsPorts::on_checkBoxSerialPassThru4_clicked(bool checked) +SettingsPorts::on_checkBoxSerialPassThru4_stateChanged(int state) { - ui->pushButtonSerialPassThru4->setEnabled(checked); + ui->pushButtonSerialPassThru4->setEnabled(state == Qt::Checked); } #if 0 void -SettingsPorts::on_checkBoxSerialPassThru5_clicked(bool checked) +SettingsPorts::on_checkBoxSerialPassThru5_stateChanged(int state) { - ui->pushButtonSerialPassThru5->setEnabled(checked); + ui->pushButtonSerialPassThru5->setEnabled(state == Qt::Checked); } void -SettingsPorts::on_checkBoxSerialPassThru6_clicked(bool checked) +SettingsPorts::on_checkBoxSerialPassThru6_stateChanged(int state) { - ui->pushButtonSerialPassThru6->setEnabled(checked); + ui->pushButtonSerialPassThru6->setEnabled(state == Qt::Checked); } void -SettingsPorts::on_checkBoxSerialPassThru7_clicked(bool checked) +SettingsPorts::on_checkBoxSerialPassThru7_stateChanged(int state) { - ui->pushButtonSerialPassThru7->setEnabled(checked); + ui->pushButtonSerialPassThru7->setEnabled(state == Qt::Checked); } #endif diff --git a/src/qt/qt_settingsports.hpp b/src/qt/qt_settingsports.hpp index fb9cdb343..cba5bceff 100644 --- a/src/qt/qt_settingsports.hpp +++ b/src/qt/qt_settingsports.hpp @@ -18,14 +18,14 @@ public: #if 0 private slots: - void on_checkBoxSerialPassThru7_clicked(bool checked); - void on_checkBoxSerialPassThru6_clicked(bool checked); - void on_checkBoxSerialPassThru5_clicked(bool checked); + void on_checkBoxSerialPassThru7_stateChanged(int state); + void on_checkBoxSerialPassThru6_stateChanged(int state); + void on_checkBoxSerialPassThru5_stateChanged(int state); #endif - void on_checkBoxSerialPassThru4_clicked(bool checked); - void on_checkBoxSerialPassThru3_clicked(bool checked); - void on_checkBoxSerialPassThru2_clicked(bool checked); - void on_checkBoxSerialPassThru1_clicked(bool checked); + void on_checkBoxSerialPassThru4_stateChanged(int state); + void on_checkBoxSerialPassThru3_stateChanged(int state); + void on_checkBoxSerialPassThru2_stateChanged(int state); + void on_checkBoxSerialPassThru1_stateChanged(int state); private slots: #if 0 From b018017c55a5f2c8c80cc6816369ac56ef76811f Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sat, 1 Mar 2025 02:05:30 +0500 Subject: [PATCH 4/7] Disable serial passthrough checkboxes when the corresponding port is disabled --- src/qt/qt_settingsports.cpp | 54 ++++++++++++++++++++++++++++++++++++- src/qt/qt_settingsports.hpp | 22 ++++++++++----- 2 files changed, 68 insertions(+), 8 deletions(-) diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index 3855a8b68..e5a8039a4 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -72,8 +72,9 @@ SettingsPorts::SettingsPorts(QWidget *parent) if (checkBox != NULL) checkBox->setChecked(com_ports[i].enabled > 0); if (checkBoxPass != NULL) { + checkBoxPass->setEnabled(com_ports[i].enabled > 0); checkBoxPass->setChecked(serial_passthrough_enabled[i]); - buttonPass->setEnabled(serial_passthrough_enabled[i]); + buttonPass->setEnabled((com_ports[i].enabled > 0) && serial_passthrough_enabled[i]); } } } @@ -173,6 +174,57 @@ SettingsPorts::on_pushButtonSerialPassThru7_clicked() } #endif +void +SettingsPorts::on_checkBoxSerial1_stateChanged(int state) +{ + ui->checkBoxSerialPassThru1->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru1->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru1->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial2_stateChanged(int state) +{ + ui->checkBoxSerialPassThru2->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru2->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru2->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial3_stateChanged(int state) +{ + ui->checkBoxSerialPassThru3->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru3->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru3->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial4_stateChanged(int state) +{ + ui->checkBoxSerialPassThru4->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru4->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru4->isChecked()); +} + +#if 0 +void +SettingsPorts::on_checkBoxSerial5_stateChanged(int state) +{ + ui->checkBoxSerialPassThru5->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru5->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru5->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial6_stateChanged(int state) +{ + ui->checkBoxSerialPassThru6->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru6->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru6->isChecked()); +} + +void +SettingsPorts::on_checkBoxSerial7_stateChanged(int state) +{ + ui->checkBoxSerialPassThru7->setEnabled(state == Qt::Checked); + ui->pushButtonSerialPassThru7->setEnabled((state == Qt::Checked) && ui->checkBoxSerialPassThru7->isChecked()); +} +#endif + void SettingsPorts::on_checkBoxSerialPassThru1_stateChanged(int state) { diff --git a/src/qt/qt_settingsports.hpp b/src/qt/qt_settingsports.hpp index cba5bceff..7d332509c 100644 --- a/src/qt/qt_settingsports.hpp +++ b/src/qt/qt_settingsports.hpp @@ -16,8 +16,8 @@ public: void save(); -#if 0 private slots: +#if 0 void on_checkBoxSerialPassThru7_stateChanged(int state); void on_checkBoxSerialPassThru6_stateChanged(int state); void on_checkBoxSerialPassThru5_stateChanged(int state); @@ -27,7 +27,16 @@ private slots: void on_checkBoxSerialPassThru2_stateChanged(int state); void on_checkBoxSerialPassThru1_stateChanged(int state); -private slots: +#if 0 + void on_checkBoxSerial7_stateChanged(int state); + void on_checkBoxSerial6_stateChanged(int state); + void on_checkBoxSerial5_stateChanged(int state); +#endif + void on_checkBoxSerial4_stateChanged(int state); + void on_checkBoxSerial3_stateChanged(int state); + void on_checkBoxSerial2_stateChanged(int state); + void on_checkBoxSerial1_stateChanged(int state); + #if 0 void on_pushButtonSerialPassThru7_clicked(); void on_pushButtonSerialPassThru6_clicked(); @@ -38,11 +47,10 @@ private slots: void on_pushButtonSerialPassThru2_clicked(); void on_pushButtonSerialPassThru1_clicked(); -private slots: - void on_checkBoxParallel4_stateChanged(int arg1); - void on_checkBoxParallel3_stateChanged(int arg1); - void on_checkBoxParallel2_stateChanged(int arg1); - void on_checkBoxParallel1_stateChanged(int arg1); + void on_checkBoxParallel4_stateChanged(int state); + void on_checkBoxParallel3_stateChanged(int state); + void on_checkBoxParallel2_stateChanged(int state); + void on_checkBoxParallel1_stateChanged(int state); private: Ui::SettingsPorts *ui; From 3bbeae91d1c405ea979b948c3407f3cef3479327 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Sat, 1 Mar 2025 15:22:36 +0500 Subject: [PATCH 5/7] Add plumbing for updates on machine change to the port settings page --- src/qt/qt_settings.cpp | 2 + src/qt/qt_settingsports.cpp | 149 +++++++++++++++++++----------------- src/qt/qt_settingsports.hpp | 69 +++++++++-------- 3 files changed, 116 insertions(+), 104 deletions(-) diff --git a/src/qt/qt_settings.cpp b/src/qt/qt_settings.cpp index 67064b73a..471558e22 100644 --- a/src/qt/qt_settings.cpp +++ b/src/qt/qt_settings.cpp @@ -153,6 +153,8 @@ Settings::Settings(QWidget *parent) &SettingsSound::onCurrentMachineChanged); connect(machine, &SettingsMachine::currentMachineChanged, network, &SettingsNetwork::onCurrentMachineChanged); + connect(machine, &SettingsMachine::currentMachineChanged, ports, + &SettingsPorts::onCurrentMachineChanged); connect(machine, &SettingsMachine::currentMachineChanged, storageControllers, &SettingsStorageControllers::onCurrentMachineChanged); connect(machine, &SettingsMachine::currentMachineChanged, otherPeripherals, diff --git a/src/qt/qt_settingsports.cpp b/src/qt/qt_settingsports.cpp index e5a8039a4..630c843b9 100644 --- a/src/qt/qt_settingsports.cpp +++ b/src/qt/qt_settingsports.cpp @@ -38,6 +38,40 @@ SettingsPorts::SettingsPorts(QWidget *parent) , ui(new Ui::SettingsPorts) { ui->setupUi(this); + onCurrentMachineChanged(machine); +} + +SettingsPorts::~SettingsPorts() +{ + delete ui; +} + +void +SettingsPorts::save() +{ + for (int i = 0; i < PARALLEL_MAX; i++) { + auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); + auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); + if (cbox != NULL) + lpt_ports[i].device = cbox->currentData().toInt(); + if (checkBox != NULL) + lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0; + } + + for (int i = 0; i < SERIAL_MAX; i++) { + auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); + auto *checkBoxPass = findChild(QString("checkBoxSerialPassThru%1").arg(i + 1)); + if (checkBox != NULL) + com_ports[i].enabled = checkBox->isChecked() ? 1 : 0; + if (checkBoxPass != NULL) + serial_passthrough_enabled[i] = checkBoxPass->isChecked(); + } +} + +void +SettingsPorts::onCurrentMachineChanged(int machineId) +{ + this->machineId = machineId; for (int i = 0; i < PARALLEL_MAX; i++) { auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); @@ -79,33 +113,6 @@ SettingsPorts::SettingsPorts(QWidget *parent) } } -SettingsPorts::~SettingsPorts() -{ - delete ui; -} - -void -SettingsPorts::save() -{ - for (int i = 0; i < PARALLEL_MAX; i++) { - auto *cbox = findChild(QString("comboBoxLpt%1").arg(i + 1)); - auto *checkBox = findChild(QString("checkBoxParallel%1").arg(i + 1)); - if (cbox != NULL) - lpt_ports[i].device = cbox->currentData().toInt(); - if (checkBox != NULL) - lpt_ports[i].enabled = checkBox->isChecked() ? 1 : 0; - } - - for (int i = 0; i < SERIAL_MAX; i++) { - auto *checkBox = findChild(QString("checkBoxSerial%1").arg(i + 1)); - auto *checkBoxPass = findChild(QString("checkBoxSerialPassThru%1").arg(i + 1)); - if (checkBox != NULL) - com_ports[i].enabled = checkBox->isChecked() ? 1 : 0; - if (checkBoxPass != NULL) - serial_passthrough_enabled[i] = checkBoxPass->isChecked(); - } -} - void SettingsPorts::on_checkBoxParallel1_stateChanged(int state) { @@ -130,50 +137,6 @@ SettingsPorts::on_checkBoxParallel4_stateChanged(int state) ui->comboBoxLpt4->setEnabled(state == Qt::Checked); } -void -SettingsPorts::on_pushButtonSerialPassThru1_clicked() -{ - DeviceConfig::ConfigureDevice(&serial_passthrough_device, 1, qobject_cast(Settings::settings)); -} - -void -SettingsPorts::on_pushButtonSerialPassThru2_clicked() -{ - DeviceConfig::ConfigureDevice(&serial_passthrough_device, 2, qobject_cast(Settings::settings)); -} - -void -SettingsPorts::on_pushButtonSerialPassThru3_clicked() -{ - DeviceConfig::ConfigureDevice(&serial_passthrough_device, 3, qobject_cast(Settings::settings)); -} - -void -SettingsPorts::on_pushButtonSerialPassThru4_clicked() -{ - DeviceConfig::ConfigureDevice(&serial_passthrough_device, 4, qobject_cast(Settings::settings)); -} - -#if 0 -void -SettingsPorts::on_pushButtonSerialPassThru5_clicked() -{ - DeviceConfig::ConfigureDevice(&serial_passthrough_device, 5, qobject_cast(Settings::settings)); -} - -void -SettingsPorts::on_pushButtonSerialPassThru6_clicked() -{ - DeviceConfig::ConfigureDevice(&serial_passthrough_device, 6, qobject_cast(Settings::settings)); -} - -void -SettingsPorts::on_pushButtonSerialPassThru7_clicked() -{ - DeviceConfig::ConfigureDevice(&serial_passthrough_device, 7, qobject_cast(Settings::settings)); -} -#endif - void SettingsPorts::on_checkBoxSerial1_stateChanged(int state) { @@ -268,3 +231,47 @@ SettingsPorts::on_checkBoxSerialPassThru7_stateChanged(int state) ui->pushButtonSerialPassThru7->setEnabled(state == Qt::Checked); } #endif + +void +SettingsPorts::on_pushButtonSerialPassThru1_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 1, qobject_cast(Settings::settings)); +} + +void +SettingsPorts::on_pushButtonSerialPassThru2_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 2, qobject_cast(Settings::settings)); +} + +void +SettingsPorts::on_pushButtonSerialPassThru3_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 3, qobject_cast(Settings::settings)); +} + +void +SettingsPorts::on_pushButtonSerialPassThru4_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 4, qobject_cast(Settings::settings)); +} + +#if 0 +void +SettingsPorts::on_pushButtonSerialPassThru5_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 5, qobject_cast(Settings::settings)); +} + +void +SettingsPorts::on_pushButtonSerialPassThru6_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 6, qobject_cast(Settings::settings)); +} + +void +SettingsPorts::on_pushButtonSerialPassThru7_clicked() +{ + DeviceConfig::ConfigureDevice(&serial_passthrough_device, 7, qobject_cast(Settings::settings)); +} +#endif diff --git a/src/qt/qt_settingsports.hpp b/src/qt/qt_settingsports.hpp index 7d332509c..83560914f 100644 --- a/src/qt/qt_settingsports.hpp +++ b/src/qt/qt_settingsports.hpp @@ -16,44 +16,47 @@ public: void save(); +public slots: + void onCurrentMachineChanged(int machineId); + private slots: -#if 0 - void on_checkBoxSerialPassThru7_stateChanged(int state); - void on_checkBoxSerialPassThru6_stateChanged(int state); - void on_checkBoxSerialPassThru5_stateChanged(int state); -#endif - void on_checkBoxSerialPassThru4_stateChanged(int state); - void on_checkBoxSerialPassThru3_stateChanged(int state); - void on_checkBoxSerialPassThru2_stateChanged(int state); - void on_checkBoxSerialPassThru1_stateChanged(int state); - -#if 0 - void on_checkBoxSerial7_stateChanged(int state); - void on_checkBoxSerial6_stateChanged(int state); - void on_checkBoxSerial5_stateChanged(int state); -#endif - void on_checkBoxSerial4_stateChanged(int state); - void on_checkBoxSerial3_stateChanged(int state); - void on_checkBoxSerial2_stateChanged(int state); - void on_checkBoxSerial1_stateChanged(int state); - -#if 0 - void on_pushButtonSerialPassThru7_clicked(); - void on_pushButtonSerialPassThru6_clicked(); - void on_pushButtonSerialPassThru5_clicked(); -#endif - void on_pushButtonSerialPassThru4_clicked(); - void on_pushButtonSerialPassThru3_clicked(); - void on_pushButtonSerialPassThru2_clicked(); - void on_pushButtonSerialPassThru1_clicked(); - - void on_checkBoxParallel4_stateChanged(int state); - void on_checkBoxParallel3_stateChanged(int state); - void on_checkBoxParallel2_stateChanged(int state); void on_checkBoxParallel1_stateChanged(int state); + void on_checkBoxParallel2_stateChanged(int state); + void on_checkBoxParallel3_stateChanged(int state); + void on_checkBoxParallel4_stateChanged(int state); + + void on_checkBoxSerial1_stateChanged(int state); + void on_checkBoxSerial2_stateChanged(int state); + void on_checkBoxSerial3_stateChanged(int state); + void on_checkBoxSerial4_stateChanged(int state); +#if 0 + void on_checkBoxSerial5_stateChanged(int state); + void on_checkBoxSerial6_stateChanged(int state); + void on_checkBoxSerial7_stateChanged(int state); +#endif + void on_checkBoxSerialPassThru1_stateChanged(int state); + void on_checkBoxSerialPassThru2_stateChanged(int state); + void on_checkBoxSerialPassThru3_stateChanged(int state); + void on_checkBoxSerialPassThru4_stateChanged(int state); +#if 0 + void on_checkBoxSerialPassThru5_stateChanged(int state); + void on_checkBoxSerialPassThru6_stateChanged(int state); + void on_checkBoxSerialPassThru7_stateChanged(int state); +#endif + + void on_pushButtonSerialPassThru1_clicked(); + void on_pushButtonSerialPassThru2_clicked(); + void on_pushButtonSerialPassThru3_clicked(); + void on_pushButtonSerialPassThru4_clicked(); +#if 0 + void on_pushButtonSerialPassThru5_clicked(); + void on_pushButtonSerialPassThru6_clicked(); + void on_pushButtonSerialPassThru7_clicked(); +#endif private: Ui::SettingsPorts *ui; + int machineId = 0; }; #endif // QT_SETTINGSPORTS_HPP From 676087bcaecd2986f48fdc919b430481023c06b9 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Fri, 7 Mar 2025 00:11:45 +0500 Subject: [PATCH 6/7] Refactor into a function --- src/qt/qt_mainwindow.cpp | 22 +++------------------- src/qt/qt_util.cpp | 22 ++++++++++++++++++++++ src/qt/qt_util.hpp | 3 +++ 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 036f56375..1cc6c33c9 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -122,19 +122,6 @@ extern int qt_nvr_save(void); #include "x11_util.h" #endif -#ifdef Q_OS_WINDOWS -#include -#ifndef DWMWA_WINDOW_CORNER_PREFERENCE -#define DWMWA_WINDOW_CORNER_PREFERENCE 33 -#endif -#ifndef DWMWCP_DEFAULT -#define DWMWCP_DEFAULT 0 -#endif -#ifndef DWMWCP_DONOTROUND -#define DWMWCP_DONOTROUND 1 -#endif -#endif - #ifdef Q_OS_MACOS # include "cocoa_keyboard.hpp" // The namespace is required to avoid clashing typedefs; we only use this @@ -195,8 +182,7 @@ MainWindow::MainWindow(QWidget *parent) ui->stackedWidget->setMouseTracking(true); statusBar()->setVisible(!hide_status_bar); #ifdef Q_OS_WINDOWS - auto cornerPreference = (hide_status_bar ? DWMWCP_DONOTROUND : DWMWCP_DEFAULT); - DwmSetWindowAttribute((HWND) this->winId(), DWMWA_WINDOW_CORNER_PREFERENCE, (LPCVOID) &cornerPreference, sizeof(cornerPreference)); + util::setWin11RoundedCorners(this->winId(), (hide_status_bar ? false : true)); #endif statusBar()->setStyleSheet("QStatusBar::item {border: None; } QStatusBar QLabel { margin-right: 2px; margin-bottom: 1px; }"); this->centralWidget()->setStyleSheet("background-color: black;"); @@ -817,8 +803,7 @@ MainWindow::initRendererMonitorSlot(int monitor_index) secondaryRenderer->setFixedSize(fixed_size_x, fixed_size_y); secondaryRenderer->setWindowIcon(this->windowIcon()); #ifdef Q_OS_WINDOWS - auto cornerPreference = DWMWCP_DONOTROUND; - DwmSetWindowAttribute((HWND) secondaryRenderer->winId(), DWMWA_WINDOW_CORNER_PREFERENCE, (LPCVOID) &cornerPreference, sizeof(cornerPreference)); + util::setWin11RoundedCorners(secondaryRenderer->winId(), false); #endif if (show_second_monitors) { secondaryRenderer->show(); @@ -1855,8 +1840,7 @@ MainWindow::on_actionHide_status_bar_triggered() ui->actionHide_status_bar->setChecked(hide_status_bar); statusBar()->setVisible(!hide_status_bar); #ifdef Q_OS_WINDOWS - auto cornerPreference = (hide_status_bar ? DWMWCP_DONOTROUND : DWMWCP_DEFAULT); - DwmSetWindowAttribute((HWND) main_window->winId(), DWMWA_WINDOW_CORNER_PREFERENCE, (LPCVOID) &cornerPreference, sizeof(cornerPreference)); + util::setWin11RoundedCorners(main_window->winId(), (hide_status_bar ? false : true)); #endif if (vid_resize >= 2) { setFixedSize(fixed_size_x, fixed_size_y + menuBar()->height() + (hide_status_bar ? 0 : statusBar()->height()) + (hide_tool_bar ? 0 : ui->toolBar->height())); diff --git a/src/qt/qt_util.cpp b/src/qt/qt_util.cpp index 5c9059272..0c78c2f5e 100644 --- a/src/qt/qt_util.cpp +++ b/src/qt/qt_util.cpp @@ -26,6 +26,19 @@ #include #include "qt_util.hpp" +#ifdef Q_OS_WINDOWS +# include +# ifndef DWMWA_WINDOW_CORNER_PREFERENCE +# define DWMWA_WINDOW_CORNER_PREFERENCE 33 +# endif +# ifndef DWMWCP_DEFAULT +# define DWMWCP_DEFAULT 0 +# endif +# ifndef DWMWCP_DONOTROUND +# define DWMWCP_DONOTROUND 1 +# endif +#endif + extern "C" { #include <86box/86box.h> #include <86box/config.h> @@ -48,6 +61,15 @@ screenOfWidget(QWidget *widget) #endif } +#ifdef Q_OS_WINDOWS +void +setWin11RoundedCorners(WId hwnd, bool enable) +{ + auto cornerPreference = (enable ? DWMWCP_DEFAULT : DWMWCP_DONOTROUND); + DwmSetWindowAttribute((HWND) hwnd, DWMWA_WINDOW_CORNER_PREFERENCE, (LPCVOID) &cornerPreference, sizeof(cornerPreference)); +} +#endif + QString DlgFilter(std::initializer_list extensions, bool last) { diff --git a/src/qt/qt_util.hpp b/src/qt/qt_util.hpp index 6a0bdc30b..9432610b6 100644 --- a/src/qt/qt_util.hpp +++ b/src/qt/qt_util.hpp @@ -13,6 +13,9 @@ static constexpr auto UUID_MIN_LENGTH = 36; QString DlgFilter(std::initializer_list extensions, bool last = false); /* Returns screen the widget is on */ QScreen *screenOfWidget(QWidget *widget); +#ifdef Q_OS_WINDOWS +void setWin11RoundedCorners(WId hwnd, bool enable); +#endif QString currentUuid(); void storeCurrentUuid(); bool compareUuid(); From 05a005b6f0a681b965ab60ae7638c2c2408fd8e7 Mon Sep 17 00:00:00 2001 From: Alexander Babikov Date: Fri, 7 Mar 2025 05:21:16 +0500 Subject: [PATCH 7/7] Initialize the sound icon menu pointer Fixes a crash when clicking the icon --- src/qt/qt_machinestatus.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/qt/qt_machinestatus.cpp b/src/qt/qt_machinestatus.cpp index 3c3f4019f..a00cc032b 100644 --- a/src/qt/qt_machinestatus.cpp +++ b/src/qt/qt_machinestatus.cpp @@ -259,6 +259,7 @@ MachineStatus::MachineStatus(QObject *parent) { d = std::make_unique(this); muteUnmuteAction = nullptr; + soundMenu = nullptr; connect(refreshTimer, &QTimer::timeout, this, &MachineStatus::refreshIcons); refreshTimer->start(75); }