yolobs-studio/UI/frontend-plugins/decklink-output-ui/DecklinkOutputUI.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

148 lines
3.2 KiB
C++
Raw Normal View History

2019-07-27 12:47:10 +00:00
#include "DecklinkOutputUI.h"
#include <obs-module.h>
#include <util/platform.h>
#include <util/util.hpp>
#include "decklink-ui-main.h"
DecklinkOutputUI::DecklinkOutputUI(QWidget *parent)
2019-09-22 21:19:10 +00:00
: QDialog(parent), ui(new Ui_Output)
2019-07-27 12:47:10 +00:00
{
ui->setupUi(this);
setSizeGripEnabled(true);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
propertiesView = nullptr;
previewPropertiesView = nullptr;
}
void DecklinkOutputUI::ShowHideDialog()
{
SetupPropertiesView();
SetupPreviewPropertiesView();
setVisible(!isVisible());
}
void DecklinkOutputUI::SetupPropertiesView()
{
if (propertiesView)
delete propertiesView;
obs_data_t *settings = obs_data_create();
OBSData data = load_settings();
if (data)
obs_data_apply(settings, data);
2019-09-22 21:19:10 +00:00
propertiesView = new OBSPropertiesView(
settings, "decklink_output",
(PropertiesReloadCallback)obs_get_output_properties, 170);
2019-07-27 12:47:10 +00:00
ui->propertiesLayout->addWidget(propertiesView);
obs_data_release(settings);
2019-09-22 21:19:10 +00:00
connect(propertiesView, SIGNAL(Changed()), this,
SLOT(PropertiesChanged()));
2019-07-27 12:47:10 +00:00
}
void DecklinkOutputUI::SaveSettings()
{
2019-09-22 21:19:10 +00:00
BPtr<char> modulePath =
obs_module_get_config_path(obs_current_module(), "");
2019-07-27 12:47:10 +00:00
os_mkdirs(modulePath);
2019-09-22 21:19:10 +00:00
BPtr<char> path = obs_module_get_config_path(
obs_current_module(), "decklinkOutputProps.json");
2019-07-27 12:47:10 +00:00
obs_data_t *settings = propertiesView->GetSettings();
if (settings)
obs_data_save_json_safe(settings, path, "tmp", "bak");
}
void DecklinkOutputUI::SetupPreviewPropertiesView()
{
if (previewPropertiesView)
delete previewPropertiesView;
obs_data_t *settings = obs_data_create();
OBSData data = load_preview_settings();
if (data)
obs_data_apply(settings, data);
2019-09-22 21:19:10 +00:00
previewPropertiesView = new OBSPropertiesView(
settings, "decklink_output",
(PropertiesReloadCallback)obs_get_output_properties, 170);
2019-07-27 12:47:10 +00:00
ui->previewPropertiesLayout->addWidget(previewPropertiesView);
obs_data_release(settings);
2019-09-22 21:19:10 +00:00
connect(previewPropertiesView, SIGNAL(Changed()), this,
SLOT(PreviewPropertiesChanged()));
2019-07-27 12:47:10 +00:00
}
void DecklinkOutputUI::SavePreviewSettings()
{
char *modulePath = obs_module_get_config_path(obs_current_module(), "");
os_mkdirs(modulePath);
2019-09-22 21:19:10 +00:00
char *path = obs_module_get_config_path(
obs_current_module(), "decklinkPreviewOutputProps.json");
2019-07-27 12:47:10 +00:00
obs_data_t *settings = previewPropertiesView->GetSettings();
if (settings)
obs_data_save_json_safe(settings, path, "tmp", "bak");
}
2020-03-25 08:07:22 +00:00
void DecklinkOutputUI::on_outputButton_clicked()
2019-07-27 12:47:10 +00:00
{
SaveSettings();
2020-03-25 08:07:22 +00:00
output_toggle();
2019-07-27 12:47:10 +00:00
}
void DecklinkOutputUI::PropertiesChanged()
{
SaveSettings();
}
2020-03-25 08:07:22 +00:00
void DecklinkOutputUI::OutputStateChanged(bool active)
2019-07-27 12:47:10 +00:00
{
2020-03-25 08:07:22 +00:00
QString text;
if (active) {
text = QString(obs_module_text("Stop"));
} else {
text = QString(obs_module_text("Start"));
}
ui->outputButton->setChecked(active);
ui->outputButton->setText(text);
2019-07-27 12:47:10 +00:00
}
2020-03-25 08:07:22 +00:00
void DecklinkOutputUI::on_previewOutputButton_clicked()
2019-07-27 12:47:10 +00:00
{
2020-03-25 08:07:22 +00:00
SavePreviewSettings();
preview_output_toggle();
2019-07-27 12:47:10 +00:00
}
void DecklinkOutputUI::PreviewPropertiesChanged()
{
SavePreviewSettings();
2020-03-25 08:07:22 +00:00
}
void DecklinkOutputUI::PreviewOutputStateChanged(bool active)
{
QString text;
if (active) {
text = QString(obs_module_text("Stop"));
} else {
text = QString(obs_module_text("Start"));
}
ui->previewOutputButton->setChecked(active);
ui->previewOutputButton->setText(text);
}