UI: Cleanup advanced audio window
This converts the advanced audio window to use a ui form, so it is easier to modify in the future. This also fixes sizing issues with the control widgets, as before the audio tracks would be clipped, because the widgets in the window were too wide.
This commit is contained in:
parent
7d2fae69de
commit
295386781f
6 changed files with 394 additions and 147 deletions
|
|
@ -1,9 +1,3 @@
|
|||
#include <QVBoxLayout>
|
||||
#include <QHBoxLayout>
|
||||
#include <QGridLayout>
|
||||
#include <QScrollArea>
|
||||
#include <QPushButton>
|
||||
#include <QLabel>
|
||||
#include "window-basic-adv-audio.hpp"
|
||||
#include "window-basic-main.hpp"
|
||||
#include "item-widget-helpers.hpp"
|
||||
|
|
@ -11,124 +5,34 @@
|
|||
#include "obs-app.hpp"
|
||||
#include "qt-wrappers.hpp"
|
||||
|
||||
#include "ui_OBSAdvAudio.h"
|
||||
|
||||
Q_DECLARE_METATYPE(OBSSource);
|
||||
|
||||
OBSBasicAdvAudio::OBSBasicAdvAudio(QWidget *parent)
|
||||
: QDialog(parent),
|
||||
ui(new Ui::OBSAdvAudio),
|
||||
sourceAddedSignal(obs_get_signal_handler(), "source_activate",
|
||||
OBSSourceAdded, this),
|
||||
sourceRemovedSignal(obs_get_signal_handler(), "source_deactivate",
|
||||
OBSSourceRemoved, this),
|
||||
showInactive(false)
|
||||
{
|
||||
QScrollArea *scrollArea;
|
||||
QVBoxLayout *vlayout;
|
||||
QWidget *widget;
|
||||
QLabel *label;
|
||||
|
||||
QLabel *volLabel = new QLabel(QTStr("Basic.AdvAudio.Volume"));
|
||||
volLabel->setStyleSheet("font-weight: bold;");
|
||||
volLabel->setContentsMargins(0, 0, 6, 0);
|
||||
|
||||
usePercent = new QCheckBox();
|
||||
usePercent->setStyleSheet("font-weight: bold;");
|
||||
usePercent->setText("%");
|
||||
connect(usePercent, SIGNAL(toggled(bool)), this,
|
||||
SLOT(SetVolumeType(bool)));
|
||||
ui->setupUi(this);
|
||||
|
||||
VolumeType volType = (VolumeType)config_get_int(
|
||||
GetGlobalConfig(), "BasicWindow", "AdvAudioVolumeType");
|
||||
|
||||
if (volType == VolumeType::Percent)
|
||||
usePercent->setChecked(true);
|
||||
|
||||
QHBoxLayout *volLayout = new QHBoxLayout();
|
||||
volLayout->setContentsMargins(0, 0, 0, 0);
|
||||
volLayout->addWidget(volLabel);
|
||||
volLayout->addWidget(usePercent);
|
||||
volLayout->addStretch();
|
||||
|
||||
int idx = 0;
|
||||
mainLayout = new QGridLayout;
|
||||
mainLayout->setContentsMargins(0, 0, 0, 0);
|
||||
label = new QLabel("");
|
||||
mainLayout->addWidget(label, 0, idx++);
|
||||
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++);
|
||||
mainLayout->addLayout(volLayout, 0, idx++);
|
||||
label = new QLabel(QTStr("Basic.AdvAudio.Mono"));
|
||||
label->setStyleSheet("font-weight: bold;");
|
||||
mainLayout->addWidget(label, 0, idx++);
|
||||
label = new QLabel(QTStr("Basic.AdvAudio.Balance"));
|
||||
label->setStyleSheet("font-weight: bold;");
|
||||
mainLayout->addWidget(label, 0, idx++);
|
||||
label = new QLabel(QTStr("Basic.AdvAudio.SyncOffset"));
|
||||
label->setStyleSheet("font-weight: bold;");
|
||||
mainLayout->addWidget(label, 0, idx++);
|
||||
if (obs_audio_monitoring_available()) {
|
||||
label = new QLabel(QTStr("Basic.AdvAudio.Monitoring"));
|
||||
label->setStyleSheet("font-weight: bold;");
|
||||
mainLayout->addWidget(label, 0, idx++);
|
||||
}
|
||||
label = new QLabel(QTStr("Basic.AdvAudio.AudioTracks"));
|
||||
label->setStyleSheet("font-weight: bold;");
|
||||
mainLayout->addWidget(label, 0, idx++);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
vlayout = new QVBoxLayout;
|
||||
vlayout->setContentsMargins(11, 11, 11, 11);
|
||||
vlayout->addWidget(scrollArea);
|
||||
vlayout->addLayout(buttonLayout);
|
||||
setLayout(vlayout);
|
||||
|
||||
connect(activeOnly, SIGNAL(clicked(bool)), this,
|
||||
SLOT(ActiveOnlyChanged(bool)));
|
||||
|
||||
connect(closeButton, &QPushButton::clicked, [this]() { close(); });
|
||||
ui->usePercent->setChecked(true);
|
||||
|
||||
installEventFilter(CreateShortcutFilter());
|
||||
|
||||
/* enum user scene/sources */
|
||||
obs_enum_sources(EnumSources, this);
|
||||
|
||||
resize(1100, 340);
|
||||
setWindowTitle(QTStr("Basic.AdvAudio"));
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
setSizeGripEnabled(true);
|
||||
setWindowModality(Qt::NonModal);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
}
|
||||
|
||||
OBSBasicAdvAudio::~OBSBasicAdvAudio()
|
||||
|
|
@ -175,12 +79,12 @@ inline void OBSBasicAdvAudio::AddAudioSource(obs_source_t *source)
|
|||
if (controls[i]->GetSource() == source)
|
||||
return;
|
||||
}
|
||||
OBSAdvAudioCtrl *control = new OBSAdvAudioCtrl(mainLayout, source);
|
||||
OBSAdvAudioCtrl *control = new OBSAdvAudioCtrl(ui->mainLayout, source);
|
||||
|
||||
InsertQObjectByName(controls, control);
|
||||
|
||||
for (auto control : controls) {
|
||||
control->ShowAudioControl(mainLayout);
|
||||
control->ShowAudioControl(ui->mainLayout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -210,11 +114,11 @@ void OBSBasicAdvAudio::SourceRemoved(OBSSource source)
|
|||
}
|
||||
}
|
||||
|
||||
void OBSBasicAdvAudio::SetVolumeType(bool percent)
|
||||
void OBSBasicAdvAudio::on_usePercent_toggled(bool checked)
|
||||
{
|
||||
VolumeType type;
|
||||
|
||||
if (percent)
|
||||
if (checked)
|
||||
type = VolumeType::Percent;
|
||||
else
|
||||
type = VolumeType::dB;
|
||||
|
|
@ -226,7 +130,7 @@ void OBSBasicAdvAudio::SetVolumeType(bool percent)
|
|||
(int)type);
|
||||
}
|
||||
|
||||
void OBSBasicAdvAudio::ActiveOnlyChanged(bool checked)
|
||||
void OBSBasicAdvAudio::on_activeOnly_toggled(bool checked)
|
||||
{
|
||||
SetShowInactive(!checked);
|
||||
}
|
||||
|
|
@ -237,7 +141,7 @@ void OBSBasicAdvAudio::SetShowInactive(bool show)
|
|||
return;
|
||||
|
||||
showInactive = show;
|
||||
activeOnly->setChecked(!showInactive);
|
||||
|
||||
sourceAddedSignal.Disconnect();
|
||||
sourceRemovedSignal.Disconnect();
|
||||
|
||||
|
|
@ -275,7 +179,7 @@ void OBSBasicAdvAudio::SetIconsVisible(bool visible)
|
|||
{
|
||||
showVisible = visible;
|
||||
|
||||
QLayoutItem *item = mainLayout->itemAtPosition(0, 0);
|
||||
QLayoutItem *item = ui->mainLayout->itemAtPosition(0, 0);
|
||||
QLabel *headerLabel = qobject_cast<QLabel *>(item->widget());
|
||||
visible ? headerLabel->show() : headerLabel->hide();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue