From f7ebe6fb9f0e0d2beb84874bb3623e138e362037 Mon Sep 17 00:00:00 2001 From: Roy Shilkrot Date: Sun, 21 Jul 2024 22:28:07 -0400 Subject: [PATCH] chore: Update version to 0.3.4 and add "Save to source settings" option in output mapping --- buildspec.json | 2 +- src/mapping-data.h | 1 + src/ui/outputmapping.cpp | 2 ++ src/ui/outputmapping.ui | 17 +++++++++++++++-- src/url-source-callbacks.cpp | 21 ++++++++++++++++++--- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/buildspec.json b/buildspec.json index 119c580..9cdd1a8 100644 --- a/buildspec.json +++ b/buildspec.json @@ -37,7 +37,7 @@ } }, "name": "obs-urlsource", - "version": "0.3.3", + "version": "0.3.4", "author": "Roy Shilkrot", "website": "https://github.com/occ-ai/obs-urlsource", "email": "roy.shil@gmail.com", diff --git a/src/mapping-data.h b/src/mapping-data.h index a21ced1..e757987 100644 --- a/src/mapping-data.h +++ b/src/mapping-data.h @@ -7,6 +7,7 @@ #include const std::string none_internal_rendering = "None / Internal rendering"; +const std::string save_to_setting = "Save to source settings"; struct output_mapping { std::string name; diff --git a/src/ui/outputmapping.cpp b/src/ui/outputmapping.cpp index f0cb828..f062441 100644 --- a/src/ui/outputmapping.cpp +++ b/src/ui/outputmapping.cpp @@ -133,6 +133,8 @@ QComboBox *OutputMapping::createSourcesComboBox() QComboBox *comboBox = new QComboBox(this); // add "Internal Renderer" to the comboBox comboBox->addItem(QString::fromStdString(none_internal_rendering)); + // add "Save to source settings" to the comboBox + comboBox->addItem(QString::fromStdString(save_to_setting)); // add all text and media sources to the comboBox obs_enum_sources(add_sources_to_combobox, comboBox); // connect comboBox to update_handler diff --git a/src/ui/outputmapping.ui b/src/ui/outputmapping.ui index a1c2266..97d9065 100644 --- a/src/ui/outputmapping.ui +++ b/src/ui/outputmapping.ui @@ -6,8 +6,8 @@ 0 0 - 515 - 398 + 457 + 387 @@ -147,6 +147,19 @@ Use {{body}} variable for unparsed object/array representation of the entire res + + + + <html><head/><body><p>Learn More about <a href="https://doc.qt.io/qt-6/richtext-html-subset.html"><span style=" text-decoration: underline; color:#007af4;">supported HTML and CSS</span></a>, and <a href="https://github.com/pantor/inja"><span style=" text-decoration: underline; color:#007af4;">advanced templating</span></a> functions like loops.</p></body></html> + + + Qt::RichText + + + true + + + diff --git a/src/url-source-callbacks.cpp b/src/url-source-callbacks.cpp index dfa6f98..8854968 100644 --- a/src/url-source-callbacks.cpp +++ b/src/url-source-callbacks.cpp @@ -236,12 +236,27 @@ void output_with_mapping(const request_data_handler_response &response, struct u } if (is_valid_output_source_name(mapping.output_source.c_str()) && - mapping.output_source != none_internal_rendering) { + mapping.output_source != none_internal_rendering && + mapping.output_source != save_to_setting) { // If an output source is selected - use it for rendering setTextCallback(text, mapping); } else { - any_internal_rendering = true; - render_internal(text, usd, mapping); + if (mapping.output_source == save_to_setting) { + // If the output source is set to save to settings - save the text to the source settings + obs_data_t *source_settings = obs_source_get_settings(usd->source); + if (source_settings == nullptr) { + obs_log(LOG_ERROR, "Failed to get settings for source"); + } else { + obs_data_set_string(source_settings, "output", + text.c_str()); + obs_source_update(usd->source, source_settings); + obs_data_release(source_settings); + } + } else { + // render the text internally + any_internal_rendering = true; + render_internal(text, usd, mapping); + } } // end if not text source }