From 94edb7f5d6828cad0f73efde11e3ba8a41b12da0 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 17 Jun 2015 12:07:55 -0700 Subject: [PATCH] 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. --- obs/data/locale/en-US.ini | 4 +++ obs/data/themes/Dark.qss | 13 ++++++++++ obs/data/themes/Default.qss | 13 ++++++++++ obs/window-basic-settings.cpp | 48 +++++++++++++++++++++++++++++++++++ obs/window-basic-settings.hpp | 5 ++++ 5 files changed, 83 insertions(+) diff --git a/obs/data/locale/en-US.ini b/obs/data/locale/en-US.ini index 057508455..7a20fa175 100644 --- a/obs/data/locale/en-US.ini +++ b/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" diff --git a/obs/data/themes/Dark.qss b/obs/data/themes/Dark.qss index 1699afc30..28f7c28db 100644 --- a/obs/data/themes/Dark.qss +++ b/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; +} diff --git a/obs/data/themes/Default.qss b/obs/data/themes/Default.qss index 91df9b610..e2aefc9ab 100644 --- a/obs/data/themes/Default.qss +++ b/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; +} diff --git a/obs/window-basic-settings.cpp b/obs/window-basic-settings.cpp index 9fc3a506f..d5497ec9e 100644 --- a/obs/window-basic-settings.cpp +++ b/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( + ui->advOutRecTopContainer->layout()); + + formLayout->addRow(nullptr, advOutRecWarning); + } +} diff --git a/obs/window-basic-settings.hpp b/obs/window-basic-settings.hpp index 2c7022bbb..2666cdf72 100644 --- a/obs/window-basic-settings.hpp +++ b/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 advOutRecWarning; + using AudioSource_t = std::tuple, QPointer, @@ -257,6 +260,8 @@ private slots: void AdvancedChanged(); void AdvancedChangedRestart(); + void AdvOutRecCheckWarnings(); + protected: virtual void closeEvent(QCloseEvent *event);