[Native File Dialog] Add support for adding custom options to the dialogs.
Add support for adding custom options (checkboxes and optionboxes) to the dialogs (both native and built-in).
This commit is contained in:
@ -38,6 +38,8 @@
|
||||
#include "scene/gui/option_button.h"
|
||||
#include "scene/gui/tree.h"
|
||||
|
||||
class GridContainer;
|
||||
|
||||
class FileDialog : public ConfirmationDialog {
|
||||
GDCLASS(FileDialog, ConfirmationDialog);
|
||||
|
||||
@ -70,6 +72,7 @@ private:
|
||||
Button *makedir = nullptr;
|
||||
Access access = ACCESS_RESOURCES;
|
||||
VBoxContainer *vbox = nullptr;
|
||||
GridContainer *grid_options = nullptr;
|
||||
FileMode mode;
|
||||
LineEdit *dir = nullptr;
|
||||
HBoxContainer *drives_container = nullptr;
|
||||
@ -128,6 +131,15 @@ private:
|
||||
Color icon_pressed_color;
|
||||
} theme_cache;
|
||||
|
||||
struct Option {
|
||||
String name;
|
||||
Vector<String> values;
|
||||
int default_idx = 0;
|
||||
};
|
||||
Vector<Option> options;
|
||||
Dictionary selected_options;
|
||||
bool options_dirty = false;
|
||||
|
||||
void update_dir();
|
||||
void update_file_name();
|
||||
void update_file_list();
|
||||
@ -159,15 +171,23 @@ private:
|
||||
|
||||
virtual void shortcut_input(const Ref<InputEvent> &p_event) override;
|
||||
|
||||
void _native_dialog_cb(bool p_ok, const Vector<String> &p_files, int p_filter);
|
||||
void _native_dialog_cb(bool p_ok, const Vector<String> &p_files, int p_filter, const Dictionary &p_selected_options);
|
||||
|
||||
bool _is_open_should_be_disabled();
|
||||
|
||||
TypedArray<Dictionary> _get_options() const;
|
||||
void _update_option_controls();
|
||||
void _option_changed_checkbox_toggled(bool p_pressed, const String &p_name);
|
||||
void _option_changed_item_selected(int p_idx, const String &p_name);
|
||||
|
||||
virtual void _post_popup() override;
|
||||
|
||||
protected:
|
||||
void _validate_property(PropertyInfo &p_property) const;
|
||||
void _notification(int p_what);
|
||||
bool _set(const StringName &p_name, const Variant &p_value);
|
||||
bool _get(const StringName &p_name, Variant &r_ret) const;
|
||||
void _get_property_list(List<PropertyInfo> *p_list) const;
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
@ -190,6 +210,20 @@ public:
|
||||
void set_current_file(const String &p_file);
|
||||
void set_current_path(const String &p_path);
|
||||
|
||||
String get_option_name(int p_option) const;
|
||||
Vector<String> get_option_values(int p_option) const;
|
||||
int get_option_default(int p_option) const;
|
||||
void set_option_name(int p_option, const String &p_name);
|
||||
void set_option_values(int p_option, const Vector<String> &p_values);
|
||||
void set_option_default(int p_option, int p_index);
|
||||
|
||||
void add_option(const String &p_name, const Vector<String> &p_values, int p_index);
|
||||
|
||||
void set_option_count(int p_count);
|
||||
int get_option_count() const;
|
||||
|
||||
Dictionary get_selected_options() const;
|
||||
|
||||
void set_root_subfolder(const String &p_root);
|
||||
String get_root_subfolder() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user