Skip to content

Commit

Permalink
chore: Update version to 0.3.4 and add "Save to source settings" opti…
Browse files Browse the repository at this point in the history
…on in output mapping
  • Loading branch information
royshil committed Jul 22, 2024
1 parent 9da372d commit f7ebe6f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 6 deletions.
2 changes: 1 addition & 1 deletion buildspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "[email protected]",
Expand Down
1 change: 1 addition & 0 deletions src/mapping-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <nlohmann/json.hpp>

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;
Expand Down
2 changes: 2 additions & 0 deletions src/ui/outputmapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 15 additions & 2 deletions src/ui/outputmapping.ui
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>515</width>
<height>398</height>
<width>457</width>
<height>387</height>
</rect>
</property>
<property name="windowTitle">
Expand Down Expand Up @@ -147,6 +147,19 @@ Use {{body}} variable for unparsed object/array representation of the entire res
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Learn More about &lt;a href=&quot;https://doc.qt.io/qt-6/richtext-html-subset.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;supported HTML and CSS&lt;/span&gt;&lt;/a&gt;, and &lt;a href=&quot;https://github.com/pantor/inja&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#007af4;&quot;&gt;advanced templating&lt;/span&gt;&lt;/a&gt; functions like loops.&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="textFormat">
<enum>Qt::RichText</enum>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
Expand Down
21 changes: 18 additions & 3 deletions src/url-source-callbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit f7ebe6f

Please sign in to comment.