clang-format: Increase column limit from 80 to 120

This commit is contained in:
Ryan Foster
2024-10-04 17:33:58 -04:00
parent 109f64c446
commit a1fbf1015f
736 changed files with 22684 additions and 45435 deletions

View File

@@ -38,8 +38,7 @@
using namespace std;
static void CreateTransitionScene(OBSSource scene, const char *text,
uint32_t color);
static void CreateTransitionScene(OBSSource scene, const char *text, uint32_t color);
OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
: QDialog(parent),
@@ -47,16 +46,12 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
main(qobject_cast<OBSBasic *>(parent)),
acceptClicked(false),
source(source_),
removedSignal(obs_source_get_signal_handler(source), "remove",
OBSBasicProperties::SourceRemoved, this),
renamedSignal(obs_source_get_signal_handler(source), "rename",
OBSBasicProperties::SourceRenamed, this),
removedSignal(obs_source_get_signal_handler(source), "remove", OBSBasicProperties::SourceRemoved, this),
renamedSignal(obs_source_get_signal_handler(source), "rename", OBSBasicProperties::SourceRenamed, this),
oldSettings(obs_data_create())
{
int cx = (int)config_get_int(App()->GetAppConfig(), "PropertiesWindow",
"cx");
int cy = (int)config_get_int(App()->GetAppConfig(), "PropertiesWindow",
"cy");
int cx = (int)config_get_int(App()->GetAppConfig(), "PropertiesWindow", "cx");
int cy = (int)config_get_int(App()->GetAppConfig(), "PropertiesWindow", "cy");
enum obs_source_type type = obs_source_get_type(source);
@@ -74,18 +69,15 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
OBSDataAutoRelease nd_settings = obs_source_get_settings(source);
obs_data_apply(oldSettings, nd_settings);
view = new OBSPropertiesView(
nd_settings.Get(), source,
(PropertiesReloadCallback)obs_source_properties,
(PropertiesUpdateCallback) nullptr, // No special handling required for undo/redo
(PropertiesVisualUpdateCb)obs_source_update);
view = new OBSPropertiesView(nd_settings.Get(), source, (PropertiesReloadCallback)obs_source_properties,
(PropertiesUpdateCallback) nullptr, // No special handling required for undo/redo
(PropertiesVisualUpdateCb)obs_source_update);
view->setMinimumHeight(150);
ui->propertiesLayout->addWidget(view);
if (type == OBS_SOURCE_TYPE_TRANSITION) {
connect(view, &OBSPropertiesView::PropertiesRefreshed, this,
&OBSBasicProperties::AddPreviewButton);
connect(view, &OBSPropertiesView::PropertiesRefreshed, this, &OBSBasicProperties::AddPreviewButton);
}
view->show();
@@ -96,36 +88,27 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
obs_source_inc_showing(source);
updatePropertiesSignal.Connect(obs_source_get_signal_handler(source),
"update_properties",
OBSBasicProperties::UpdateProperties,
this);
updatePropertiesSignal.Connect(obs_source_get_signal_handler(source), "update_properties",
OBSBasicProperties::UpdateProperties, this);
auto addDrawCallback = [this]() {
obs_display_add_draw_callback(ui->preview->GetDisplay(),
OBSBasicProperties::DrawPreview,
this);
obs_display_add_draw_callback(ui->preview->GetDisplay(), OBSBasicProperties::DrawPreview, this);
};
auto addTransitionDrawCallback = [this]() {
obs_display_add_draw_callback(
ui->preview->GetDisplay(),
OBSBasicProperties::DrawTransitionPreview, this);
obs_display_add_draw_callback(ui->preview->GetDisplay(), OBSBasicProperties::DrawTransitionPreview,
this);
};
uint32_t caps = obs_source_get_output_flags(source);
bool drawable_type = type == OBS_SOURCE_TYPE_INPUT ||
type == OBS_SOURCE_TYPE_SCENE;
bool drawable_type = type == OBS_SOURCE_TYPE_INPUT || type == OBS_SOURCE_TYPE_SCENE;
bool drawable_preview = (caps & OBS_SOURCE_VIDEO) != 0;
if (drawable_preview && drawable_type) {
ui->preview->show();
connect(ui->preview, &OBSQTDisplay::DisplayCreated,
addDrawCallback);
connect(ui->preview, &OBSQTDisplay::DisplayCreated, addDrawCallback);
} else if (type == OBS_SOURCE_TYPE_TRANSITION) {
sourceA =
obs_source_create_private("scene", "sourceA", nullptr);
sourceB =
obs_source_create_private("scene", "sourceB", nullptr);
sourceA = obs_source_create_private("scene", "sourceA", nullptr);
sourceB = obs_source_create_private("scene", "sourceB", nullptr);
uint32_t colorA = 0xFFB26F52;
uint32_t colorB = 0xFF6FB252;
@@ -141,15 +124,13 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
OBSDataAutoRelease settings = obs_source_get_settings(source);
sourceClone = obs_source_create_private(
obs_source_get_id(source), "clone", settings);
sourceClone = obs_source_create_private(obs_source_get_id(source), "clone", settings);
obs_source_inc_active(sourceClone);
obs_transition_set(sourceClone, sourceA);
auto updateCallback = [=]() {
OBSDataAutoRelease settings =
obs_source_get_settings(source);
OBSDataAutoRelease settings = obs_source_get_settings(source);
obs_source_update(sourceClone, settings);
obs_transition_clear(sourceClone);
@@ -162,8 +143,7 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
connect(view, &OBSPropertiesView::Changed, updateCallback);
ui->preview->show();
connect(ui->preview, &OBSQTDisplay::DisplayCreated,
addTransitionDrawCallback);
connect(ui->preview, &OBSQTDisplay::DisplayCreated, addTransitionDrawCallback);
} else {
ui->preview->hide();
@@ -182,8 +162,7 @@ OBSBasicProperties::~OBSBasicProperties()
void OBSBasicProperties::AddPreviewButton()
{
QPushButton *playButton =
new QPushButton(QTStr("PreviewTransition"), this);
QPushButton *playButton = new QPushButton(QTStr("PreviewTransition"), this);
VScrollArea *area = view;
area->widget()->layout()->addWidget(playButton);
@@ -202,8 +181,7 @@ void OBSBasicProperties::AddPreviewButton()
}
obs_transition_set(sourceClone, start);
obs_transition_start(sourceClone, OBS_TRANSITION_MODE_AUTO,
main->GetTransitionDuration(), end);
obs_transition_start(sourceClone, OBS_TRANSITION_MODE_AUTO, main->GetTransitionDuration(), end);
direction = !direction;
start = nullptr;
@@ -243,29 +221,24 @@ static obs_source_t *CreateLabel(const char *name, size_t h)
const char *text_source_id = "text_ft2_source";
#endif
obs_source_t *txtSource =
obs_source_create_private(text_source_id, name, settings);
obs_source_t *txtSource = obs_source_create_private(text_source_id, name, settings);
return txtSource;
}
static void CreateTransitionScene(OBSSource scene, const char *text,
uint32_t color)
static void CreateTransitionScene(OBSSource scene, const char *text, uint32_t color)
{
OBSDataAutoRelease settings = obs_data_create();
obs_data_set_int(settings, "width", obs_source_get_width(scene));
obs_data_set_int(settings, "height", obs_source_get_height(scene));
obs_data_set_int(settings, "color", color);
OBSSourceAutoRelease colorBG = obs_source_create_private(
"color_source", "background", settings);
OBSSourceAutoRelease colorBG = obs_source_create_private("color_source", "background", settings);
obs_scene_add(obs_scene_from_source(scene), colorBG);
OBSSourceAutoRelease label =
CreateLabel(text, obs_source_get_height(scene));
obs_sceneitem_t *item =
obs_scene_add(obs_scene_from_source(scene), label);
OBSSourceAutoRelease label = CreateLabel(text, obs_source_get_height(scene));
obs_sceneitem_t *item = obs_scene_add(obs_scene_from_source(scene), label);
vec2 size;
vec2_set(&size, obs_source_get_width(scene),
@@ -281,8 +254,7 @@ static void CreateTransitionScene(OBSSource scene, const char *text,
void OBSBasicProperties::SourceRemoved(void *data, calldata_t *)
{
QMetaObject::invokeMethod(static_cast<OBSBasicProperties *>(data),
"close");
QMetaObject::invokeMethod(static_cast<OBSBasicProperties *>(data), "close");
}
void OBSBasicProperties::SourceRenamed(void *data, calldata_t *params)
@@ -290,22 +262,19 @@ void OBSBasicProperties::SourceRenamed(void *data, calldata_t *params)
const char *name = calldata_string(params, "new_name");
QString title = QTStr("Basic.PropertiesWindow").arg(QT_UTF8(name));
QMetaObject::invokeMethod(static_cast<OBSBasicProperties *>(data),
"setWindowTitle", Q_ARG(QString, title));
QMetaObject::invokeMethod(static_cast<OBSBasicProperties *>(data), "setWindowTitle", Q_ARG(QString, title));
}
void OBSBasicProperties::UpdateProperties(void *data, calldata_t *)
{
QMetaObject::invokeMethod(static_cast<OBSBasicProperties *>(data)->view,
"ReloadProperties");
QMetaObject::invokeMethod(static_cast<OBSBasicProperties *>(data)->view, "ReloadProperties");
}
static bool ConfirmReset(QWidget *parent)
{
QMessageBox::StandardButton button;
button = OBSMessageBox::question(parent, QTStr("ConfirmReset.Title"),
QTStr("ConfirmReset.Text"),
button = OBSMessageBox::question(parent, QTStr("ConfirmReset.Title"), QTStr("ConfirmReset.Text"),
QMessageBox::Yes | QMessageBox::No);
return button == QMessageBox::Yes;
@@ -317,42 +286,33 @@ void OBSBasicProperties::on_buttonBox_clicked(QAbstractButton *button)
if (val == QDialogButtonBox::AcceptRole) {
std::string scene_uuid =
obs_source_get_uuid(main->GetCurrentSceneSource());
std::string scene_uuid = obs_source_get_uuid(main->GetCurrentSceneSource());
auto undo_redo = [scene_uuid](const std::string &data) {
OBSDataAutoRelease settings =
obs_data_create_from_json(data.c_str());
OBSSourceAutoRelease source = obs_get_source_by_uuid(
obs_data_get_string(settings, "undo_uuid"));
OBSDataAutoRelease settings = obs_data_create_from_json(data.c_str());
OBSSourceAutoRelease source =
obs_get_source_by_uuid(obs_data_get_string(settings, "undo_uuid"));
obs_source_reset_settings(source, settings);
obs_source_update_properties(source);
OBSSourceAutoRelease scene_source =
obs_get_source_by_uuid(scene_uuid.c_str());
OBSSourceAutoRelease scene_source = obs_get_source_by_uuid(scene_uuid.c_str());
OBSBasic::Get()->SetCurrentScene(scene_source.Get(),
true);
OBSBasic::Get()->SetCurrentScene(scene_source.Get(), true);
};
OBSDataAutoRelease new_settings = obs_data_create();
OBSDataAutoRelease curr_settings =
obs_source_get_settings(source);
OBSDataAutoRelease curr_settings = obs_source_get_settings(source);
obs_data_apply(new_settings, curr_settings);
obs_data_set_string(new_settings, "undo_uuid",
obs_source_get_uuid(source));
obs_data_set_string(oldSettings, "undo_uuid",
obs_source_get_uuid(source));
obs_data_set_string(new_settings, "undo_uuid", obs_source_get_uuid(source));
obs_data_set_string(oldSettings, "undo_uuid", obs_source_get_uuid(source));
std::string undo_data(obs_data_get_json(oldSettings));
std::string redo_data(obs_data_get_json(new_settings));
if (undo_data.compare(redo_data) != 0)
main->undo_s.add_action(
QTStr("Undo.Properties")
.arg(obs_source_get_name(source)),
undo_redo, undo_redo, undo_data, redo_data);
main->undo_s.add_action(QTStr("Undo.Properties").arg(obs_source_get_name(source)), undo_redo,
undo_redo, undo_data, redo_data);
acceptClicked = true;
close();
@@ -417,8 +377,7 @@ void OBSBasicProperties::DrawPreview(void *data, uint32_t cx, uint32_t cy)
gs_viewport_pop();
}
void OBSBasicProperties::DrawTransitionPreview(void *data, uint32_t cx,
uint32_t cy)
void OBSBasicProperties::DrawTransitionPreview(void *data, uint32_t cx, uint32_t cy)
{
OBSBasicProperties *window = static_cast<OBSBasicProperties *>(data);
@@ -450,16 +409,11 @@ void OBSBasicProperties::DrawTransitionPreview(void *data, uint32_t cx,
void OBSBasicProperties::Cleanup()
{
config_set_int(App()->GetAppConfig(), "PropertiesWindow", "cx",
width());
config_set_int(App()->GetAppConfig(), "PropertiesWindow", "cy",
height());
config_set_int(App()->GetAppConfig(), "PropertiesWindow", "cx", width());
config_set_int(App()->GetAppConfig(), "PropertiesWindow", "cy", height());
obs_display_remove_draw_callback(ui->preview->GetDisplay(),
OBSBasicProperties::DrawPreview, this);
obs_display_remove_draw_callback(
ui->preview->GetDisplay(),
OBSBasicProperties::DrawTransitionPreview, this);
obs_display_remove_draw_callback(ui->preview->GetDisplay(), OBSBasicProperties::DrawPreview, this);
obs_display_remove_draw_callback(ui->preview->GetDisplay(), OBSBasicProperties::DrawTransitionPreview, this);
}
void OBSBasicProperties::reject()
@@ -481,21 +435,18 @@ void OBSBasicProperties::closeEvent(QCloseEvent *event)
Cleanup();
}
bool OBSBasicProperties::nativeEvent(const QByteArray &, void *message,
qintptr *)
bool OBSBasicProperties::nativeEvent(const QByteArray &, void *message, qintptr *)
{
#ifdef _WIN32
const MSG &msg = *static_cast<MSG *>(message);
switch (msg.message) {
case WM_MOVE:
for (OBSQTDisplay *const display :
findChildren<OBSQTDisplay *>()) {
for (OBSQTDisplay *const display : findChildren<OBSQTDisplay *>()) {
display->OnMove();
}
break;
case WM_DISPLAYCHANGE:
for (OBSQTDisplay *const display :
findChildren<OBSQTDisplay *>()) {
for (OBSQTDisplay *const display : findChildren<OBSQTDisplay *>()) {
display->OnDisplayChange();
}
}
@@ -524,10 +475,9 @@ bool OBSBasicProperties::ConfirmQuit()
{
QMessageBox::StandardButton button;
button = OBSMessageBox::question(
this, QTStr("Basic.PropertiesWindow.ConfirmTitle"),
QTStr("Basic.PropertiesWindow.Confirm"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
button = OBSMessageBox::question(this, QTStr("Basic.PropertiesWindow.ConfirmTitle"),
QTStr("Basic.PropertiesWindow.Confirm"),
QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel);
switch (button) {
case QMessageBox::Save: