From 9eca7b75252666f2c9790adbce497f52cf72b41f Mon Sep 17 00:00:00 2001 From: gxalpha Date: Sun, 26 May 2024 01:19:36 +0200 Subject: [PATCH] UI: Fix Qt 6.7 checkbox signal deprecations qt/qtbase@3512fb1ec5ff088772170540c4e91b1886fbea45 deprecated the stateChanged signal of QCheckBoxes in favor of a new checkStateChanged signal. The signals are the same, except that now the enum type is passed explicitly (before the enum was passed as an argument but defined as an int). --- UI/properties-view.cpp | 4 ++++ UI/window-basic-settings.cpp | 14 ++++++++++++++ UI/window-basic-settings.hpp | 5 +++++ UI/window-basic-transform.cpp | 6 +++++- UI/window-youtube-actions.cpp | 13 ++++++++++--- 5 files changed, 38 insertions(+), 4 deletions(-) diff --git a/UI/properties-view.cpp b/UI/properties-view.cpp index 6f34b14d3..d7d5b3787 100644 --- a/UI/properties-view.cpp +++ b/UI/properties-view.cpp @@ -273,7 +273,11 @@ QWidget *OBSPropertiesView::AddCheckbox(obs_property_t *prop) QCheckBox *checkbox = new QCheckBox(QT_UTF8(desc)); checkbox->setCheckState(val ? Qt::Checked : Qt::Unchecked); +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + return NewWidget(prop, checkbox, &QCheckBox::checkStateChanged); +#else return NewWidget(prop, checkbox, &QCheckBox::stateChanged); +#endif } QWidget *OBSPropertiesView::AddText(obs_property_t *prop, QFormLayout *layout, diff --git a/UI/window-basic-settings.cpp b/UI/window-basic-settings.cpp index 6d1b4ae94..d89dd6e7a 100644 --- a/UI/window-basic-settings.cpp +++ b/UI/window-basic-settings.cpp @@ -790,8 +790,13 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent) &OBSBasicSettings::SimpleReplayBufferChanged); connect(ui->simpleRBSecMax, &QSpinBox::valueChanged, this, &OBSBasicSettings::SimpleReplayBufferChanged); +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + connect(ui->advOutSplitFile, &QCheckBox::checkStateChanged, this, + &OBSBasicSettings::AdvOutSplitFileChanged); +#else connect(ui->advOutSplitFile, &QCheckBox::stateChanged, this, &OBSBasicSettings::AdvOutSplitFileChanged); +#endif connect(ui->advOutSplitFileType, &QComboBox::currentIndexChanged, this, &OBSBasicSettings::AdvOutSplitFileChanged); connect(ui->advReplayBuf, &QCheckBox::toggled, this, @@ -1360,8 +1365,13 @@ void OBSBasicSettings::LoadGeneralSettings() "HideOBSWindowsFromCapture"); ui->hideOBSFromCapture->setChecked(hideWindowFromCapture); +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + connect(ui->hideOBSFromCapture, &QCheckBox::checkStateChanged, + this, &OBSBasicSettings::HideOBSWindowWarning); +#else connect(ui->hideOBSFromCapture, &QCheckBox::stateChanged, this, &OBSBasicSettings::HideOBSWindowWarning); +#endif } #endif @@ -4713,7 +4723,11 @@ void OBSBasicSettings::SpeakerLayoutChanged(int idx) UpdateAudioWarnings(); } +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) +void OBSBasicSettings::HideOBSWindowWarning(Qt::CheckState state) +#else void OBSBasicSettings::HideOBSWindowWarning(int state) +#endif { if (loading || state == Qt::Unchecked) return; diff --git a/UI/window-basic-settings.hpp b/UI/window-basic-settings.hpp index c6f550c14..e15c25934 100644 --- a/UI/window-basic-settings.hpp +++ b/UI/window-basic-settings.hpp @@ -454,7 +454,12 @@ private slots: void on_colorPreset_currentIndexChanged(int idx); void GeneralChanged(); + +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + void HideOBSWindowWarning(Qt::CheckState state); +#else void HideOBSWindowWarning(int state); +#endif void AudioChanged(); void AudioChangedRestart(); void ReloadAudioSources(); diff --git a/UI/window-basic-transform.cpp b/UI/window-basic-transform.cpp index f0add7ec3..472f98d24 100644 --- a/UI/window-basic-transform.cpp +++ b/UI/window-basic-transform.cpp @@ -71,9 +71,13 @@ OBSBasicTransform::OBSBasicTransform(OBSSceneItem item, OBSBasic *parent) &OBSBasicTransform::OnCropChanged); HookWidget(ui->cropBottom, ISCROLL_CHANGED, &OBSBasicTransform::OnCropChanged); +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + HookWidget(ui->cropToBounds, &QCheckBox::checkStateChanged, + &OBSBasicTransform::OnControlChanged); +#else HookWidget(ui->cropToBounds, &QCheckBox::stateChanged, &OBSBasicTransform::OnControlChanged); - +#endif ui->buttonBox->button(QDialogButtonBox::Close)->setDefault(true); connect(ui->buttonBox->button(QDialogButtonBox::Reset), diff --git a/UI/window-youtube-actions.cpp b/UI/window-youtube-actions.cpp index e0b27cef1..52d905f91 100644 --- a/UI/window-youtube-actions.cpp +++ b/UI/window-youtube-actions.cpp @@ -67,10 +67,17 @@ OBSYoutubeActions::OBSYoutubeActions(QWidget *parent, Auth *auth, [](const QString &link) { QDesktopServices::openUrl(link); }); ui->scheduledTime->setVisible(false); +#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0) + connect(ui->checkScheduledLater, &QCheckBox::checkStateChanged, this, + [&](Qt::CheckState state) +#else connect(ui->checkScheduledLater, &QCheckBox::stateChanged, this, - [&](int state) { - ui->scheduledTime->setVisible(state); - if (state) { + [&](int state) +#endif + { + const bool checked = (state == Qt::Checked); + ui->scheduledTime->setVisible(checked); + if (checked) { ui->checkAutoStart->setVisible(true); ui->checkAutoStop->setVisible(true); ui->helpAutoStartStop->setVisible(true);