Browse Source

UI: Add warning if using no/multiple tracks

Certain output formats don't support multiple tracks, so it's important
to warn the user if they select multiple tracks.

Also warn the user if they select no tracks.
jp9000 10 years ago
parent
commit
94edb7f5d6

+ 4 - 0
obs/data/locale/en-US.ini

@@ -426,3 +426,7 @@ Push-to-talk="Push-to-talk"
 # scene item hotkeys
 SceneItemShow="Show '%1'"
 SceneItemHide="Hide '%1'"
+
+# Output warnings
+OutputWarnings.NoTracksSelected="You must select at least one track"
+OutputWarnings.MultiTrackRecording="Warning: Certain formats (such as FLV) do not support multiple tracks per recording"

+ 13 - 0
obs/data/themes/Dark.qss

@@ -495,3 +495,16 @@ MuteCheckBox::indicator:unchecked {
 OBSHotkeyLabel[hotkeyPairHover=true] {
     color: red;
 }
+
+
+/* Label warning/error */
+
+QLabel#warningLabel {
+    color: rgb(192, 128, 0);
+    font-weight: bold;
+}
+
+QLabel#errorLabel {
+    color: rgb(192, 0, 0);
+    font-weight: bold;
+}

+ 13 - 0
obs/data/themes/Default.qss

@@ -60,3 +60,16 @@ VolumeMeter {
     qproperty-peakColor: rgb(62, 241, 43);
     qproperty-peakHoldColor: rgb(0, 0, 0);
 }
+
+
+/* Label warning/error */
+
+QLabel#warningLabel {
+    color: rgb(192, 128, 0);
+    font-weight: bold;
+}
+
+QLabel#errorLabel {
+    color: rgb(192, 0, 0);
+    font-weight: bold;
+}

+ 48 - 0
obs/window-basic-settings.cpp

@@ -379,6 +379,17 @@ OBSBasicSettings::OBSBasicSettings(QWidget *parent)
 			"hotkey_unregister", ReloadHotkeysIgnore, this);
 
 	LoadSettings(false);
+
+	// Add warning checks to advanced output recording section controls
+	connect(ui->advOutRecTrack1, SIGNAL(clicked()),
+			this, SLOT(AdvOutRecCheckWarnings()));
+	connect(ui->advOutRecTrack2, SIGNAL(clicked()),
+			this, SLOT(AdvOutRecCheckWarnings()));
+	connect(ui->advOutRecTrack3, SIGNAL(clicked()),
+			this, SLOT(AdvOutRecCheckWarnings()));
+	connect(ui->advOutRecTrack4, SIGNAL(clicked()),
+			this, SLOT(AdvOutRecCheckWarnings()));
+	AdvOutRecCheckWarnings();
 }
 
 void OBSBasicSettings::SaveCombo(QComboBox *widget, const char *section,
@@ -2533,3 +2544,40 @@ void OBSBasicSettings::AdvancedChanged()
 		EnableApplyButton(true);
 	}
 }
+
+void OBSBasicSettings::AdvOutRecCheckWarnings()
+{
+	auto Checked = [](QCheckBox *box)
+	{
+		return box->isChecked() ? 1 : 0;
+	};
+
+	QString msg;
+	uint32_t tracks =
+		Checked(ui->advOutRecTrack1) +
+		Checked(ui->advOutRecTrack2) +
+		Checked(ui->advOutRecTrack3) +
+		Checked(ui->advOutRecTrack4);
+	const char *objectName = nullptr;
+
+	if (tracks == 0) {
+		msg = QTStr("OutputWarnings.NoTracksSelected");
+		objectName = "errorLabel";
+
+	} else if (tracks > 1) {
+		msg = QTStr("OutputWarnings.MultiTrackRecording");
+		objectName = "warningLabel";
+	}
+
+	delete advOutRecWarning;
+
+	if (!msg.isEmpty()) {
+		advOutRecWarning = new QLabel(msg, this);
+		advOutRecWarning->setObjectName(objectName);
+
+		QFormLayout *formLayout = reinterpret_cast<QFormLayout*>(
+				ui->advOutRecTopContainer->layout());
+
+		formLayout->addRow(nullptr, advOutRecWarning);
+	}
+}

+ 5 - 0
obs/window-basic-settings.hpp

@@ -31,6 +31,7 @@ class OBSBasic;
 class QAbstractButton;
 class QComboBox;
 class QCheckBox;
+class QLabel;
 class OBSPropertiesView;
 class OBSHotkeyWidget;
 
@@ -102,6 +103,8 @@ private:
 	OBSPropertiesView *streamEncoderProps = nullptr;
 	OBSPropertiesView *recordEncoderProps = nullptr;
 
+	QPointer<QLabel> advOutRecWarning;
+
 	using AudioSource_t =
 		std::tuple<OBSWeakSource,
 			QPointer<QCheckBox>, QPointer<QSpinBox>,
@@ -257,6 +260,8 @@ private slots:
 	void AdvancedChanged();
 	void AdvancedChangedRestart();
 
+	void AdvOutRecCheckWarnings();
+
 protected:
 	virtual void closeEvent(QCloseEvent *event);