pub struct FileDialogConfig {Show 55 fields
pub file_system: Arc<dyn FileSystem + Send + Sync>,
pub storage: FileDialogStorage,
pub labels: FileDialogLabels,
pub keybindings: FileDialogKeyBindings,
pub opening_mode: OpeningMode,
pub as_modal: bool,
pub modal_overlay_color: Color32,
pub initial_directory: PathBuf,
pub default_file_name: String,
pub allow_file_overwrite: bool,
pub allow_path_edit_to_save_file_without_extension: bool,
pub directory_separator: String,
pub canonicalize_paths: bool,
pub load_via_thread: bool,
pub truncate_filenames: bool,
pub err_icon: String,
pub warn_icon: String,
pub default_file_icon: String,
pub default_folder_icon: String,
pub pinned_icon: String,
pub device_icon: String,
pub removable_device_icon: String,
pub file_filters: Vec<FileFilter>,
pub default_file_filter: Option<String>,
pub file_icon_filters: Vec<IconFilter>,
pub quick_accesses: Vec<QuickAccess>,
pub title: Option<String>,
pub id: Option<Id>,
pub default_pos: Option<Pos2>,
pub fixed_pos: Option<Pos2>,
pub default_size: Vec2,
pub max_size: Option<Vec2>,
pub min_size: Vec2,
pub anchor: Option<(Align2, Vec2)>,
pub resizable: bool,
pub movable: bool,
pub title_bar: bool,
pub show_top_panel: bool,
pub show_parent_button: bool,
pub show_back_button: bool,
pub show_forward_button: bool,
pub show_new_folder_button: bool,
pub show_current_path: bool,
pub show_path_edit_button: bool,
pub show_menu_button: bool,
pub show_reload_button: bool,
pub show_hidden_option: bool,
pub show_system_files_option: bool,
pub show_search: bool,
pub right_panel_width: Option<f32>,
pub show_left_panel: bool,
pub show_pinned_folders: bool,
pub show_places: bool,
pub show_devices: bool,
pub show_removable_devices: bool,
}
Expand description
Contains configuration values of a file dialog.
The configuration of a file dialog can be set using FileDialog::with_config
.
If you only need to configure a single file dialog, you don’t need to
manually use a FileDialogConfig
object. FileDialog
provides setter methods for
each of these configuration options, for example: FileDialog::initial_directory
or FileDialog::default_size
.
FileDialogConfig
is useful when you need to configure multiple FileDialog
objects with the
same or almost the same options.
§Example
use egui_file_dialog::{FileDialog, FileDialogConfig};
let config = FileDialogConfig {
initial_directory: std::path::PathBuf::from("/app/config"),
fixed_pos: Some(egui::Pos2::new(40.0, 40.0)),
show_left_panel: false,
..Default::default()
};
let file_dialog_a = FileDialog::with_config(config.clone())
.id("file-dialog-a");
let file_dialog_b = FileDialog::with_config(config.clone());
Fields§
§file_system: Arc<dyn FileSystem + Send + Sync>
File system browsed by the file dialog; may be native or virtual.
storage: FileDialogStorage
Persistent data of the file dialog.
labels: FileDialogLabels
The labels that the dialog uses.
keybindings: FileDialogKeyBindings
Keybindings used by the file dialog.
opening_mode: OpeningMode
Sets which directory is loaded when opening the file dialog.
as_modal: bool
If the file dialog should be visible as a modal window. This means that the input outside the window is not registered.
modal_overlay_color: Color32
Color of the overlay that is displayed under the modal to prevent user interaction.
initial_directory: PathBuf
The first directory that will be opened when the dialog opens.
default_file_name: String
The default filename when opening the dialog in DialogMode::SaveFile
mode.
allow_file_overwrite: bool
If the user is allowed to select an already existing file when the dialog is
in DialogMode::SaveFile
mode.
allow_path_edit_to_save_file_without_extension: bool
If the path edit is allowed to select the path as the file to save if it does not have an extension.
This can lead to confusion if the user wants to open a directory with the path edit, types it incorrectly and the dialog tries to select the incorrectly typed folder as the file to be saved.
This only affects the DialogMode::SaveFile
mode.
directory_separator: String
Sets the separator of the directories when displaying a path. Currently only used when the current path is displayed in the top panel.
canonicalize_paths: bool
If the paths in the file dialog should be canonicalized before use.
load_via_thread: bool
If the directory content should be loaded via a separate thread. This prevents the application from blocking when loading large directories or from slow hard drives.
truncate_filenames: bool
If we should truncate the filenames in the middle
err_icon: String
The icon that is used to display error messages.
warn_icon: String
The icon that is used to display warning messages.
default_file_icon: String
The default icon used to display files.
default_folder_icon: String
The default icon used to display folders.
pinned_icon: String
The icon used to display pinned paths in the left panel.
device_icon: String
The icon used to display devices in the left panel.
removable_device_icon: String
The icon used to display removable devices in the left panel.
file_filters: Vec<FileFilter>
File filters presented to the user in a dropdown.
default_file_filter: Option<String>
Name of the file filter to be selected by default.
file_icon_filters: Vec<IconFilter>
Sets custom icons for different files or folders.
Use FileDialogConfig::set_file_icon
to add a new icon to this list.
quick_accesses: Vec<QuickAccess>
Custom sections added to the left sidebar for quick access.
Use FileDialogConfig::add_quick_access
to add a new section to this list.
title: Option<String>
If set, the window title will be overwritten and set to the fixed value instead of being set dynamically.
id: Option<Id>
The ID of the window.
default_pos: Option<Pos2>
The default position of the window.
fixed_pos: Option<Pos2>
Sets the window position and prevents it from being dragged around.
default_size: Vec2
The default size of the window.
max_size: Option<Vec2>
The maximum size of the window.
min_size: Vec2
The minimum size of the window.
anchor: Option<(Align2, Vec2)>
The anchor of the window.
resizable: bool
If the window is resizable.
movable: bool
If the window is movable.
title_bar: bool
If the title bar of the window is shown.
show_top_panel: bool
If the top panel with the navigation buttons, current path display and search input should be visible.
Whether the parent folder button should be visible at the top.
Whether the back button should be visible at the top.
Whether the forward button should be visible at the top.
If the button to create a new folder should be visible at the top.
show_current_path: bool
If the current path display in the top panel should be visible.
If the button to text edit the current path should be visible.
If the menu button containing the reload button and other options should be visible.
If the reload button inside the top panel menu should be visible.
If the show hidden files and folders option inside the top panel menu should be visible.
show_system_files_option: bool
If the show system files option inside the top panel menu should be visible.
show_search: bool
If the search input in the top panel should be visible.
right_panel_width: Option<f32>
Set the width of the right panel, if used
show_left_panel: bool
If the sidebar with the shortcut directories such as “Home”, “Documents” etc. should be visible.
show_pinned_folders: bool
If pinned folders should be listed in the left sidebar. Disabling this will also disable the functionality to pin a folder.
show_places: bool
If the Places section in the left sidebar should be visible.
show_devices: bool
If the Devices section in the left sidebar should be visible.
show_removable_devices: bool
If the Removable Devices section in the left sidebar should be visible.
Implementations§
Source§impl FileDialogConfig
impl FileDialogConfig
Sourcepub fn default_from_filesystem(
file_system: Arc<dyn FileSystem + Send + Sync>,
) -> Self
pub fn default_from_filesystem( file_system: Arc<dyn FileSystem + Send + Sync>, ) -> Self
Creates a new configuration with default values
Source§impl FileDialogConfig
impl FileDialogConfig
Sourcepub fn storage(self, storage: FileDialogStorage) -> Self
pub fn storage(self, storage: FileDialogStorage) -> Self
Sets the storage used by the file dialog. Storage includes all data that is persistently stored between multiple file dialog instances.
Sourcepub fn add_file_filter(
self,
name: &str,
filter: Arc<dyn Fn(&Path) -> bool + Send + Sync>,
) -> Self
pub fn add_file_filter( self, name: &str, filter: Arc<dyn Fn(&Path) -> bool + Send + Sync>, ) -> Self
Adds a new file filter the user can select from a dropdown widget.
NOTE: The name must be unique. If a filter with the same name already exists, it will be overwritten.
§Arguments
name
- Display name of the filterfilter
- Sets a filter function that checks whether a given Path matches the criteria for this filter.
§Examples
use std::sync::Arc;
use egui_file_dialog::FileDialogConfig;
let config = FileDialogConfig::default()
.add_file_filter(
"PNG files",
Arc::new(|path| path.extension().unwrap_or_default() == "png"))
.add_file_filter(
"JPG files",
Arc::new(|path| path.extension().unwrap_or_default() == "jpg"));
Sourcepub fn set_file_icon(
self,
icon: &str,
filter: Arc<dyn Fn(&Path) -> bool + Send + Sync>,
) -> Self
pub fn set_file_icon( self, icon: &str, filter: Arc<dyn Fn(&Path) -> bool + Send + Sync>, ) -> Self
Sets a new icon for specific files or folders.
§Arguments
icon
- The icon that should be used.filter
- Sets a filter function that checks whether a given Path matches the criteria for this icon.
§Examples
use std::sync::Arc;
use egui_file_dialog::FileDialogConfig;
let config = FileDialogConfig::default()
// .png files should use the "document with picture (U+1F5BB)" icon.
.set_file_icon("🖻", Arc::new(|path| path.extension().unwrap_or_default() == "png"))
// .git directories should use the "web-github (U+E624)" icon.
.set_file_icon("", Arc::new(|path| path.file_name().unwrap_or_default() == ".git"));
Sourcepub fn add_quick_access(
self,
heading: &str,
builder: impl FnOnce(&mut QuickAccess),
) -> Self
pub fn add_quick_access( self, heading: &str, builder: impl FnOnce(&mut QuickAccess), ) -> Self
Adds a new custom quick access section to the left panel of the file dialog.
§Examples
use egui_file_dialog::FileDialogConfig;
FileDialogConfig::default()
.add_quick_access("My App", |s| {
s.add_path("Config", "/app/config");
s.add_path("Themes", "/app/themes");
s.add_path("Languages", "/app/languages");
});
Trait Implementations§
Source§impl Clone for FileDialogConfig
impl Clone for FileDialogConfig
Source§fn clone(&self) -> FileDialogConfig
fn clone(&self) -> FileDialogConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more