Merge pull request #2267 from exeldro/advAudioAll
UI: add option to show all sources to adv audio dialog
This commit is contained in:
commit
ef116f9e5f
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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"
|
||||
@ -876,6 +877,7 @@ Basic.Settings.Advanced.AutoRemux.MP4="(record as mkv)"
|
||||
|
||||
# advanced audio properties
|
||||
Basic.AdvAudio="Advanced Audio Properties"
|
||||
Basic.AdvAudio.ActiveOnly="Active Sources Only"
|
||||
Basic.AdvAudio.Name="Name"
|
||||
Basic.AdvAudio.Volume="Volume"
|
||||
Basic.AdvAudio.Mono="Mono"
|
||||
|
@ -18,7 +18,8 @@ OBSBasicAdvAudio::OBSBasicAdvAudio(QWidget *parent)
|
||||
sourceAddedSignal(obs_get_signal_handler(), "source_activate",
|
||||
OBSSourceAdded, this),
|
||||
sourceRemovedSignal(obs_get_signal_handler(), "source_deactivate",
|
||||
OBSSourceRemoved, this)
|
||||
OBSSourceRemoved, this),
|
||||
showInactive(false)
|
||||
{
|
||||
QScrollArea *scrollArea;
|
||||
QVBoxLayout *vlayout;
|
||||
@ -31,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++);
|
||||
@ -70,7 +74,12 @@ OBSBasicAdvAudio::OBSBasicAdvAudio(QWidget *parent)
|
||||
|
||||
QPushButton *closeButton = new QPushButton(QTStr("Close"));
|
||||
|
||||
activeOnly = new QCheckBox();
|
||||
activeOnly->setChecked(!showInactive);
|
||||
activeOnly->setText(QTStr("Basic.AdvAudio.ActiveOnly"));
|
||||
|
||||
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
||||
buttonLayout->addWidget(activeOnly);
|
||||
buttonLayout->addStretch();
|
||||
buttonLayout->addWidget(closeButton);
|
||||
|
||||
@ -80,6 +89,9 @@ OBSBasicAdvAudio::OBSBasicAdvAudio(QWidget *parent)
|
||||
vlayout->addLayout(buttonLayout);
|
||||
setLayout(vlayout);
|
||||
|
||||
connect(activeOnly, SIGNAL(clicked(bool)), this,
|
||||
SLOT(ActiveOnlyChanged(bool)));
|
||||
|
||||
connect(closeButton, &QPushButton::clicked, [this]() { close(); });
|
||||
|
||||
installEventFilter(CreateShortcutFilter());
|
||||
@ -115,7 +127,8 @@ bool OBSBasicAdvAudio::EnumSources(void *param, obs_source_t *source)
|
||||
OBSBasicAdvAudio *dialog = reinterpret_cast<OBSBasicAdvAudio *>(param);
|
||||
uint32_t flags = obs_source_get_output_flags(source);
|
||||
|
||||
if ((flags & OBS_SOURCE_AUDIO) != 0 && obs_source_active(source))
|
||||
if ((flags & OBS_SOURCE_AUDIO) != 0 &&
|
||||
(dialog->showInactive || obs_source_active(source)))
|
||||
dialog->AddAudioSource(source);
|
||||
|
||||
return true;
|
||||
@ -139,6 +152,10 @@ void OBSBasicAdvAudio::OBSSourceRemoved(void *param, calldata_t *calldata)
|
||||
|
||||
inline void OBSBasicAdvAudio::AddAudioSource(obs_source_t *source)
|
||||
{
|
||||
for (size_t i = 0; i < controls.size(); i++) {
|
||||
if (controls[i]->GetSource() == source)
|
||||
return;
|
||||
}
|
||||
OBSAdvAudioCtrl *control = new OBSAdvAudioCtrl(mainLayout, source);
|
||||
|
||||
InsertQObjectByName(controls, control);
|
||||
@ -217,3 +234,46 @@ void OBSBasicAdvAudio::ShowContextMenu(const QPoint &pos)
|
||||
|
||||
contextMenu->exec(mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void OBSBasicAdvAudio::ActiveOnlyChanged(bool checked)
|
||||
{
|
||||
SetShowInactive(!checked);
|
||||
}
|
||||
|
||||
void OBSBasicAdvAudio::SetShowInactive(bool show)
|
||||
{
|
||||
if (showInactive == show)
|
||||
return;
|
||||
|
||||
showInactive = show;
|
||||
activeOnly->setChecked(!showInactive);
|
||||
sourceAddedSignal.Disconnect();
|
||||
sourceRemovedSignal.Disconnect();
|
||||
|
||||
if (showInactive) {
|
||||
sourceAddedSignal.Connect(obs_get_signal_handler(),
|
||||
"source_create", OBSSourceAdded,
|
||||
this);
|
||||
sourceRemovedSignal.Connect(obs_get_signal_handler(),
|
||||
"source_remove", OBSSourceRemoved,
|
||||
this);
|
||||
|
||||
obs_enum_sources(EnumSources, this);
|
||||
} else {
|
||||
sourceAddedSignal.Connect(obs_get_signal_handler(),
|
||||
"source_activate", OBSSourceAdded,
|
||||
this);
|
||||
sourceRemovedSignal.Connect(obs_get_signal_handler(),
|
||||
"source_deactivate",
|
||||
OBSSourceRemoved, this);
|
||||
|
||||
for (size_t i = 0; i < controls.size(); i++) {
|
||||
const auto source = controls[i]->GetSource();
|
||||
if (!obs_source_active(source)) {
|
||||
delete controls[i];
|
||||
controls.erase(controls.begin() + i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#include <obs.hpp>
|
||||
#include <QDialog>
|
||||
#include <vector>
|
||||
#include <QCheckBox>
|
||||
#include <QPointer>
|
||||
|
||||
class OBSAdvAudioCtrl;
|
||||
class QGridLayout;
|
||||
@ -15,8 +17,10 @@ class OBSBasicAdvAudio : public QDialog {
|
||||
private:
|
||||
QWidget *controlArea;
|
||||
QGridLayout *mainLayout;
|
||||
QPointer<QCheckBox> activeOnly;
|
||||
OBSSignal sourceAddedSignal;
|
||||
OBSSignal sourceRemovedSignal;
|
||||
bool showInactive;
|
||||
|
||||
std::vector<OBSAdvAudioCtrl *> controls;
|
||||
|
||||
@ -33,8 +37,10 @@ public slots:
|
||||
|
||||
void ShowContextMenu(const QPoint &pos);
|
||||
void SetVolumeType();
|
||||
void ActiveOnlyChanged(bool checked);
|
||||
|
||||
public:
|
||||
OBSBasicAdvAudio(QWidget *parent);
|
||||
~OBSBasicAdvAudio();
|
||||
void SetShowInactive(bool showInactive);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user