Browse Source

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).
gxalpha 1 year ago
parent
commit
9eca7b7525

+ 4 - 0
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,

+ 14 - 0
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;

+ 5 - 0
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();

+ 5 - 1
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),

+ 10 - 3
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);