Builder-style file chooser.
More...
#include <file_chooser.hpp>
|
| using | ResultCallback = std::function<void(std::vector<std::string>)> |
| | Callback signature shared by every dialog kind.
|
Builder-style file chooser.
Usage:
chooser.
open([](
const std::vector<std::string>& paths) {
if (!paths.empty()) load_preset(paths.front());
});
void open(ResultCallback callback) const
Show an open dialog.
FileChooser & set_title(std::string title)
Dialog window title.
FileChooser & set_initial_directory(std::string path)
Initial directory the dialog opens to. Empty == platform default.
FileChooser & add_extension_filter(std::string description, std::string extensions)
Convenience wrapper: append a description + semicolon-separated extension list.
open() calls the open-file dialog (single-selection unless set_allow_multiple(true)). save() calls the save dialog. The chooser can be reused across multiple calls; per-call results never mutate the builder state.
◆ ResultCallback
Callback signature shared by every dialog kind.
- open() yields 0 or 1 paths (or N when allow_multiple is true).
- save() yields 0 or 1 paths.
- choose_folder() yields 0 or 1 paths. An empty vector means the user cancelled or no backend was installed.
◆ FileChooser()
| pulp::view::FileChooser::FileChooser |
( |
| ) |
|
|
default |
◆ add_extension_filter()
| FileChooser & pulp::view::FileChooser::add_extension_filter |
( |
std::string | description, |
|
|
std::string | extensions ) |
Convenience wrapper: append a description + semicolon-separated extension list.
Equivalent to add_filter({desc, exts}).
◆ add_filter()
◆ allow_multiple()
| bool pulp::view::FileChooser::allow_multiple |
( |
| ) |
const |
|
inline |
◆ choose_folder()
| void pulp::view::FileChooser::choose_folder |
( |
ResultCallback | callback | ) |
const |
Show a folder-chooser dialog.
Filters are ignored. Runs the callback exactly once.
◆ clear_filters()
| FileChooser & pulp::view::FileChooser::clear_filters |
( |
| ) |
|
Clear all filters. Returns *this so the call chain still flows.
◆ default_name()
| const std::string & pulp::view::FileChooser::default_name |
( |
| ) |
const |
|
inline |
◆ filters()
Read-only view of accumulated filters (preserves insertion order).
◆ initial_directory()
| const std::string & pulp::view::FileChooser::initial_directory |
( |
| ) |
const |
|
inline |
◆ open()
Show an open dialog.
Runs the callback exactly once with the selected paths (empty on cancel / no-backend). Callback may be null — the dialog still runs, but the result is discarded.
◆ save()
Show a save dialog. Runs the callback exactly once.
◆ set_allow_multiple()
| FileChooser & pulp::view::FileChooser::set_allow_multiple |
( |
bool | allow | ) |
|
When true, open() invokes the platform multi-file dialog and the callback may receive more than one path.
Defaults to false.
◆ set_default_name()
| FileChooser & pulp::view::FileChooser::set_default_name |
( |
std::string | name | ) |
|
Default filename suggested in save dialogs.
Ignored by open() / choose_folder(). Empty == platform default.
◆ set_initial_directory()
| FileChooser & pulp::view::FileChooser::set_initial_directory |
( |
std::string | path | ) |
|
Initial directory the dialog opens to. Empty == platform default.
◆ set_title()
| FileChooser & pulp::view::FileChooser::set_title |
( |
std::string | title | ) |
|
Dialog window title.
Defaults differ per dialog kind (Open / Save / Choose Folder); set explicitly when you want a custom prompt.
◆ title()
| const std::string & pulp::view::FileChooser::title |
( |
| ) |
const |
|
inline |
The documentation for this class was generated from the following file: