2016-02-23 23:16:51 +00:00
|
|
|
#include <QVBoxLayout>
|
2017-06-29 19:01:10 +00:00
|
|
|
#include <QHBoxLayout>
|
2016-02-23 23:16:51 +00:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QScrollArea>
|
2017-06-29 19:01:10 +00:00
|
|
|
#include <QPushButton>
|
2016-02-23 23:16:51 +00:00
|
|
|
#include <QLabel>
|
|
|
|
#include "window-basic-adv-audio.hpp"
|
|
|
|
#include "window-basic-main.hpp"
|
|
|
|
#include "adv-audio-control.hpp"
|
|
|
|
#include "obs-app.hpp"
|
|
|
|
#include "qt-wrappers.hpp"
|
|
|
|
|
|
|
|
Q_DECLARE_METATYPE(OBSSource);
|
|
|
|
|
|
|
|
OBSBasicAdvAudio::OBSBasicAdvAudio(QWidget *parent)
|
|
|
|
: QDialog(parent),
|
|
|
|
sourceAddedSignal(obs_get_signal_handler(), "source_activate",
|
|
|
|
OBSSourceAdded, this),
|
|
|
|
sourceRemovedSignal(obs_get_signal_handler(), "source_deactivate",
|
|
|
|
OBSSourceRemoved, this)
|
|
|
|
{
|
|
|
|
QScrollArea *scrollArea;
|
|
|
|
QVBoxLayout *vlayout;
|
|
|
|
QWidget *widget;
|
|
|
|
QLabel *label;
|
|
|
|
|
2017-04-19 19:54:15 +00:00
|
|
|
int idx = 0;
|
2016-02-23 23:16:51 +00:00
|
|
|
mainLayout = new QGridLayout;
|
|
|
|
mainLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
label = new QLabel(QTStr("Basic.AdvAudio.Name"));
|
|
|
|
label->setAlignment(Qt::AlignHCenter);
|
2017-04-19 19:54:15 +00:00
|
|
|
mainLayout->addWidget(label, 0, idx++);
|
2016-02-23 23:16:51 +00:00
|
|
|
label = new QLabel(QTStr("Basic.AdvAudio.Volume"));
|
|
|
|
label->setAlignment(Qt::AlignHCenter);
|
2017-04-19 19:54:15 +00:00
|
|
|
mainLayout->addWidget(label, 0, idx++);
|
2016-02-23 23:16:51 +00:00
|
|
|
label = new QLabel(QTStr("Basic.AdvAudio.Mono"));
|
|
|
|
label->setAlignment(Qt::AlignHCenter);
|
2017-04-19 19:54:15 +00:00
|
|
|
mainLayout->addWidget(label, 0, idx++);
|
2016-02-23 23:16:51 +00:00
|
|
|
label = new QLabel(QTStr("Basic.AdvAudio.Panning"));
|
|
|
|
label->setAlignment(Qt::AlignHCenter);
|
2017-04-19 19:54:15 +00:00
|
|
|
mainLayout->addWidget(label, 0, idx++);
|
2016-02-23 23:16:51 +00:00
|
|
|
label = new QLabel(QTStr("Basic.AdvAudio.SyncOffset"));
|
|
|
|
label->setAlignment(Qt::AlignHCenter);
|
2017-04-19 19:54:15 +00:00
|
|
|
mainLayout->addWidget(label, 0, idx++);
|
2018-02-19 19:54:37 +00:00
|
|
|
#if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO
|
2017-04-19 19:54:15 +00:00
|
|
|
label = new QLabel(QTStr("Basic.AdvAudio.Monitoring"));
|
|
|
|
label->setAlignment(Qt::AlignHCenter);
|
|
|
|
mainLayout->addWidget(label, 0, idx++);
|
|
|
|
#endif
|
2016-02-23 23:16:51 +00:00
|
|
|
label = new QLabel(QTStr("Basic.AdvAudio.AudioTracks"));
|
|
|
|
label->setAlignment(Qt::AlignHCenter);
|
2017-04-19 19:54:15 +00:00
|
|
|
mainLayout->addWidget(label, 0, idx++);
|
2016-02-23 23:16:51 +00:00
|
|
|
|
|
|
|
controlArea = new QWidget;
|
|
|
|
controlArea->setLayout(mainLayout);
|
|
|
|
controlArea->setSizePolicy(QSizePolicy::Preferred,
|
|
|
|
QSizePolicy::Preferred);
|
|
|
|
|
|
|
|
vlayout = new QVBoxLayout;
|
|
|
|
vlayout->addWidget(controlArea);
|
|
|
|
//vlayout->setAlignment(controlArea, Qt::AlignTop);
|
|
|
|
widget = new QWidget;
|
|
|
|
widget->setLayout(vlayout);
|
|
|
|
widget->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Maximum);
|
|
|
|
|
|
|
|
scrollArea = new QScrollArea;
|
|
|
|
scrollArea->setWidget(widget);
|
|
|
|
scrollArea->setWidgetResizable(true);
|
|
|
|
|
2017-06-29 19:01:10 +00:00
|
|
|
QPushButton *closeButton = new QPushButton(QTStr("Close"));
|
|
|
|
|
|
|
|
QHBoxLayout *buttonLayout = new QHBoxLayout;
|
|
|
|
buttonLayout->addStretch();
|
|
|
|
buttonLayout->addWidget(closeButton);
|
|
|
|
|
2016-02-23 23:16:51 +00:00
|
|
|
vlayout = new QVBoxLayout;
|
|
|
|
vlayout->setContentsMargins(11, 11, 11, 11);
|
|
|
|
vlayout->addWidget(scrollArea);
|
2017-06-29 19:01:10 +00:00
|
|
|
vlayout->addLayout(buttonLayout);
|
2016-02-23 23:16:51 +00:00
|
|
|
setLayout(vlayout);
|
|
|
|
|
2017-06-29 19:01:10 +00:00
|
|
|
connect(closeButton, &QPushButton::clicked, [this] () {close();});
|
|
|
|
|
2016-02-23 23:16:51 +00:00
|
|
|
installEventFilter(CreateShortcutFilter());
|
|
|
|
|
|
|
|
/* enum user scene/sources */
|
|
|
|
obs_enum_sources(EnumSources, this);
|
|
|
|
|
|
|
|
resize(1000, 340);
|
|
|
|
setWindowTitle(QTStr("Basic.AdvAudio"));
|
|
|
|
setSizeGripEnabled(true);
|
|
|
|
setWindowModality(Qt::NonModal);
|
|
|
|
setAttribute(Qt::WA_DeleteOnClose, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
OBSBasicAdvAudio::~OBSBasicAdvAudio()
|
|
|
|
{
|
|
|
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(parent());
|
|
|
|
|
|
|
|
for (size_t i = 0; i < controls.size(); ++i)
|
|
|
|
delete controls[i];
|
|
|
|
|
|
|
|
main->SaveProject();
|
|
|
|
}
|
|
|
|
|
|
|
|
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))
|
|
|
|
dialog->AddAudioSource(source);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicAdvAudio::OBSSourceAdded(void *param, calldata_t *calldata)
|
|
|
|
{
|
|
|
|
OBSSource source((obs_source_t*)calldata_ptr(calldata, "source"));
|
|
|
|
|
|
|
|
QMetaObject::invokeMethod(reinterpret_cast<OBSBasicAdvAudio*>(param),
|
|
|
|
"SourceAdded", Q_ARG(OBSSource, source));
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicAdvAudio::OBSSourceRemoved(void *param, calldata_t *calldata)
|
|
|
|
{
|
|
|
|
OBSSource source((obs_source_t*)calldata_ptr(calldata, "source"));
|
|
|
|
|
|
|
|
QMetaObject::invokeMethod(reinterpret_cast<OBSBasicAdvAudio*>(param),
|
|
|
|
"SourceRemoved", Q_ARG(OBSSource, source));
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void OBSBasicAdvAudio::AddAudioSource(obs_source_t *source)
|
|
|
|
{
|
|
|
|
OBSAdvAudioCtrl *control = new OBSAdvAudioCtrl(mainLayout, source);
|
|
|
|
controls.push_back(control);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicAdvAudio::SourceAdded(OBSSource source)
|
|
|
|
{
|
|
|
|
uint32_t flags = obs_source_get_output_flags(source);
|
|
|
|
|
|
|
|
if ((flags & OBS_SOURCE_AUDIO) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
AddAudioSource(source);
|
|
|
|
}
|
|
|
|
|
|
|
|
void OBSBasicAdvAudio::SourceRemoved(OBSSource source)
|
|
|
|
{
|
|
|
|
uint32_t flags = obs_source_get_output_flags(source);
|
|
|
|
|
|
|
|
if ((flags & OBS_SOURCE_AUDIO) == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (size_t i = 0; i < controls.size(); i++) {
|
|
|
|
if (controls[i]->GetSource() == source) {
|
|
|
|
delete controls[i];
|
|
|
|
controls.erase(controls.begin() + i);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|