-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support MIME types in file dialog filters on macOS and Linux. #99350
base: master
Are you sure you want to change the base?
Conversation
1dcfe9d
to
f039cac
Compare
servers/display_server.h
Outdated
@@ -153,6 +153,8 @@ class DisplayServer : public Object { | |||
FEATURE_NATIVE_DIALOG_INPUT, | |||
FEATURE_NATIVE_DIALOG_FILE, | |||
FEATURE_NATIVE_DIALOG_FILE_EXTRA, | |||
FEATURE_NATIVE_DIALOG_FILE_MIME, | |||
FEATURE_NATIVE_DIALOG_FILE_EXT, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The feature flag for file extensions is unnecessary, as it is supported across all platforms (I have already submitted a PR for Android). It would be better to remove this flag, as Android can handle file extensions even without the PR. If the MIME type is not provided, app simply defaults to showing all file types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bruvzg My PR for adding file extension support for Android is now merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed FEATURE_NATIVE_DIALOG_FILE_EXT
and updated to use send both extensions and MIMEs to Android Java part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Everything looks good to me! Just a few minor comments to address.
@@ -138,11 +138,11 @@ | |||
<param index="6" name="callback" type="Callable" /> | |||
<description> | |||
Displays OS native dialog for selecting files or directories in the file system. | |||
Each filter string in the [param filters] array should be formatted like this: [code]*.txt,*.doc;Text Files[/code]. The description text of the filter is optional and can be omitted. See also [member FileDialog.filters]. | |||
Each filter string in the [param filters] array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set. See also [member FileDialog.filters]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each filter string in the [param filters] array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set. See also [member FileDialog.filters]. | |
Each filter string in the [param filters] array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. It is recommended to set both file extension and MIME type. See also [member FileDialog.filters]. |
Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int[/code]. [b]On Android,[/b] callback argument [code]selected_filter_index[/code] is always zero. | ||
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_FILE] feature. Supported platforms include Linux (X11/Wayland), Windows, macOS, and Android. | ||
[b]Note:[/b] [param current_directory] might be ignored. | ||
[b]Note:[/b] On Android, the filter strings in the [param filters] array should be specified using MIME types, for example:[code]image/png, image/jpeg"[/code]. Additionally, the [param mode] [constant FILE_DIALOG_MODE_OPEN_ANY] is not supported on Android. | ||
[b]Note:[/b] Embedded file dialog, and Windows file dialog support only file extensions, Android, Linux and macOS file dialogs also support MIME types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[b]Note:[/b] Embedded file dialog, and Windows file dialog support only file extensions, Android, Linux and macOS file dialogs also support MIME types. | |
[b]Note:[/b] Embedded file dialog and Windows file dialog support only file extensions, while Android, Linux, and macOS file dialogs also support MIME types. |
@@ -161,14 +161,15 @@ | |||
<param index="8" name="callback" type="Callable" /> | |||
<description> | |||
Displays OS native dialog for selecting files or directories in the file system with additional user selectable options. | |||
Each filter string in the [param filters] array should be formatted like this: [code]*.txt,*.doc;Text Files[/code]. The description text of the filter is optional and can be omitted. See also [member FileDialog.filters]. | |||
Each filter string in the [param filters] array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set. See also [member FileDialog.filters]. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each filter string in the [param filters] array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set. See also [member FileDialog.filters]. | |
Each filter string in the [param filters] array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. It is recommended to set both file extension and MIME type. See also [member FileDialog.filters]. |
[param options] is array of [Dictionary]s with the following keys: | ||
- [code]"name"[/code] - option's name [String]. | ||
- [code]"values"[/code] - [PackedStringArray] of values. If empty, boolean option (check box) is used. | ||
- [code]"default"[/code] - default selected option index ([int]) or default boolean value ([bool]). | ||
Callbacks have the following arguments: [code]status: bool, selected_paths: PackedStringArray, selected_filter_index: int, selected_option: Dictionary[/code]. | ||
[b]Note:[/b] This method is implemented if the display server has the [constant FEATURE_NATIVE_DIALOG_FILE_EXTRA] feature. Supported platforms include Linux (X11/Wayland), Windows, and macOS. | ||
[b]Note:[/b] [param current_directory] might be ignored. | ||
[b]Note:[/b] Embedded file dialog, and Windows file dialog support only file extensions, Android, Linux and macOS file dialogs also support MIME types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[b]Note:[/b] Embedded file dialog, and Windows file dialog support only file extensions, Android, Linux and macOS file dialogs also support MIME types. | |
[b]Note:[/b] Embedded file dialog and Windows file dialog support only file extensions, while Android, Linux, and macOS file dialogs also support MIME types. |
The available file type filters. Each filter string in the array should be formatted like this: [code]*.txt,*.doc;Text Files[/code]. The description text of the filter is optional and can be omitted. | ||
[b]Note:[/b] For android native dialog, MIME types are used like this: [code]image/*, application/pdf[/code]. | ||
The available file type filters. Each filter string in the array should be formatted like this: [code]*.png,*.jpg,*.jpeg;Image Files;image/png,image/jpeg[/code]. The description text of the filter is optional and can be omitted. Both file extensions and MIME type should be always set. | ||
[b]Note:[/b] Embedded file dialog, and Windows file dialog support only file extensions, Android, Linux and macOS file dialogs also support MIME types. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[b]Note:[/b] Embedded file dialog, and Windows file dialog support only file extensions, Android, Linux and macOS file dialogs also support MIME types. | |
[b]Note:[/b] Embedded file dialog and Windows file dialog support only file extensions, while Android, Linux, and macOS file dialogs also support MIME types. |
Changes file filter format from
extension_list;name
toextension_list;name;mime_type_list
.Embedded and Windows use only extensions.
Android use only MIMEs.
macOS and Linux use both.