UI: Add Active/Inactive status to adv audio props

Allows the ability to see whether an audio source listed in advanced
audio properties is currently active or inactive (i.e. in an inactive
scene)
This commit is contained in:
Exeldro 2019-12-27 10:59:19 -08:00 committed by jp9000
parent 9f8dc0e218
commit 7f395c14b6
4 changed files with 55 additions and 0 deletions

View file

@ -27,12 +27,14 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
uint32_t flags = obs_source_get_flags(source);
uint32_t mixers = obs_source_get_audio_mixers(source);
activeContainer = new QWidget();
forceMonoContainer = new QWidget();
mixerContainer = new QWidget();
balanceContainer = new QWidget();
labelL = new QLabel();
labelR = new QLabel();
nameLabel = new QLabel();
active = new QLabel();
stackedWidget = new QStackedWidget();
volume = new QDoubleSpinBox();
percent = new QSpinBox();
@ -49,6 +51,9 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
mixer5 = new QCheckBox();
mixer6 = new QCheckBox();
activateSignal.Connect(handler, "activate", OBSSourceActivated, this);
deactivateSignal.Connect(handler, "deactivate", OBSSourceDeactivated,
this);
volChangedSignal.Connect(handler, "volume", OBSSourceVolumeChanged,
this);
syncOffsetSignal.Connect(handler, "audio_sync", OBSSourceSyncChanged,
@ -58,6 +63,9 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
mixersSignal.Connect(handler, "audio_mixers", OBSSourceMixersChanged,
this);
hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
activeContainer->setLayout(hlayout);
hlayout = new QHBoxLayout();
hlayout->setContentsMargins(0, 0, 0, 0);
forceMonoContainer->setLayout(hlayout);
@ -76,6 +84,15 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
nameLabel->setText(QT_UTF8(sourceName));
nameLabel->setAlignment(Qt::AlignVCenter);
bool isActive = obs_source_active(source);
active->setText(isActive ? QTStr("Basic.Stats.Status.Active")
: QTStr("Basic.Stats.Status.Inactive"));
if (isActive)
setThemeID(active, "error");
activeContainer->layout()->addWidget(active);
activeContainer->layout()->setAlignment(active, Qt::AlignVCenter);
activeContainer->setFixedWidth(50);
volume->setMinimum(MIN_DB - 0.1);
volume->setMaximum(MAX_DB);
volume->setSingleStep(0.1);
@ -210,6 +227,7 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
OBSAdvAudioCtrl::~OBSAdvAudioCtrl()
{
nameLabel->deleteLater();
activeContainer->deleteLater();
stackedWidget->deleteLater();
forceMonoContainer->deleteLater();
balanceContainer->deleteLater();
@ -226,6 +244,7 @@ void OBSAdvAudioCtrl::ShowAudioControl(QGridLayout *layout)
int idx = 0;
layout->addWidget(nameLabel, lastRow, idx++);
layout->addWidget(activeContainer, lastRow, idx++);
layout->addWidget(stackedWidget, lastRow, idx++);
layout->addWidget(forceMonoContainer, lastRow, idx++);
layout->addWidget(balanceContainer, lastRow, idx++);
@ -241,6 +260,20 @@ void OBSAdvAudioCtrl::ShowAudioControl(QGridLayout *layout)
/* ------------------------------------------------------------------------- */
/* OBS source callbacks */
void OBSAdvAudioCtrl::OBSSourceActivated(void *param, calldata_t *calldata)
{
QMetaObject::invokeMethod(reinterpret_cast<OBSAdvAudioCtrl *>(param),
"SourceActiveChanged", Q_ARG(bool, true));
UNUSED_PARAMETER(calldata);
}
void OBSAdvAudioCtrl::OBSSourceDeactivated(void *param, calldata_t *calldata)
{
QMetaObject::invokeMethod(reinterpret_cast<OBSAdvAudioCtrl *>(param),
"SourceActiveChanged", Q_ARG(bool, false));
UNUSED_PARAMETER(calldata);
}
void OBSAdvAudioCtrl::OBSSourceFlagsChanged(void *param, calldata_t *calldata)
{
uint32_t flags = (uint32_t)calldata_int(calldata, "flags");
@ -280,6 +313,17 @@ static inline void setCheckboxState(QCheckBox *checkbox, bool checked)
checkbox->blockSignals(false);
}
void OBSAdvAudioCtrl::SourceActiveChanged(bool isActive)
{
if (isActive) {
active->setText(QTStr("Basic.Stats.Status.Active"));
setThemeID(active, "error");
} else {
active->setText(QTStr("Basic.Stats.Status.Inactive"));
setThemeID(active, "");
}
}
void OBSAdvAudioCtrl::SourceFlagsChanged(uint32_t flags)
{
bool forceMonoVal = (flags & OBS_SOURCE_FLAG_FORCE_MONO) != 0;

View file

@ -24,11 +24,13 @@ class OBSAdvAudioCtrl : public QObject {
private:
OBSSource source;
QPointer<QWidget> activeContainer;
QPointer<QWidget> forceMonoContainer;
QPointer<QWidget> mixerContainer;
QPointer<QWidget> balanceContainer;
QPointer<QLabel> nameLabel;
QPointer<QLabel> active;
QPointer<QStackedWidget> stackedWidget;
QPointer<QSpinBox> percent;
QPointer<QDoubleSpinBox> volume;
@ -49,7 +51,11 @@ private:
OBSSignal syncOffsetSignal;
OBSSignal flagsSignal;
OBSSignal mixersSignal;
OBSSignal activateSignal;
OBSSignal deactivateSignal;
static void OBSSourceActivated(void *param, calldata_t *calldata);
static void OBSSourceDeactivated(void *param, calldata_t *calldata);
static void OBSSourceFlagsChanged(void *param, calldata_t *calldata);
static void OBSSourceVolumeChanged(void *param, calldata_t *calldata);
static void OBSSourceSyncChanged(void *param, calldata_t *calldata);
@ -65,6 +71,7 @@ public:
void SetVolumeWidget(VolumeType type);
public slots:
void SourceActiveChanged(bool active);
void SourceFlagsChanged(uint32_t flags);
void SourceVolumeChanged(float volume);
void SourceSyncChanged(int64_t offset);

View file

@ -211,6 +211,7 @@ Basic.Stats.Status.Recording="Recording"
Basic.Stats.Status.Live="LIVE"
Basic.Stats.Status.Reconnecting="Reconnecting"
Basic.Stats.Status.Inactive="Inactive"
Basic.Stats.Status.Active="Active"
Basic.Stats.DroppedFrames="Dropped Frames (Network)"
Basic.Stats.MegabytesSent="Total Data Output"
Basic.Stats.Bitrate="Bitrate"

View file

@ -32,6 +32,9 @@ OBSBasicAdvAudio::OBSBasicAdvAudio(QWidget *parent)
label = new QLabel(QTStr("Basic.AdvAudio.Name"));
label->setStyleSheet("font-weight: bold;");
mainLayout->addWidget(label, 0, idx++);
label = new QLabel(QTStr("Basic.Stats.Status"));
label->setStyleSheet("font-weight: bold;");
mainLayout->addWidget(label, 0, idx++);
label = new QLabel(QTStr("Basic.AdvAudio.Volume"));
label->setStyleSheet("font-weight: bold;");
mainLayout->addWidget(label, 0, idx++);