libobs: Add filter for save file path property - #10190
Conversation
|
Please squash your commits into one, as the documentation change is directly tied to the code change. |
011210e to
daa92e3
Compare
|
@WizardCM- Squashed the commits, and pushed the update. Please let me know if there is anything else you need. |
| that the user can browse. If type is a save path, | ||
| then describes the file types the file can be | ||
| saved as. Items are separated via double semicolons. |
There was a problem hiding this comment.
Does this functionality actually prohibit the user from choosing a custom filename with a different extension than the one provided by the filter?
I've seen multiple variants how save dialogs like this can behave, some just add the "correct" file extension to whatever the user provided (so if I choose to save a text file as test.jpg but the file format is "Plain Text" I end up with test.jpg.txt), others parse the file extension from the file name and block saving, yet others just ignore it completely and allow me to save a text file as test.jpg.
There was a problem hiding this comment.
This opens a native dialog on all operating systems I think, so that's a concern of the OS
Description
File path properties allow for filters to be set that limit the file types shown in the file select dialog. QT allows the same filters to be used in a File Save dialog, to limit the file types/extensions a user can save a file as. This PR uses the provided

filtervalue in theobs_properties_add_pathto limit the save-as file types/extensions in the file save dialog. This can be seen in the sample dialog below, where the save as type of Preset (*.snoise) is populated in the dropdown. This has the added benefit of automatically adding the file extension provided to the saved file. Currently forOBS_PATH_FILE_SAVEdialogs, the filters are silently ignored.Motivation and Context
This feature is useful for plugin authors, as it will allow limiting the file types and extensions for any file saved through the save dialog box.
How Has This Been Tested?
This has been tested on Windows 11 with the latest HEAD of obs studio for a save file dialog being developed in an upcoming plugin I am working on.
Types of changes
Checklist: