Loading...
Searching...
No Matches
ml::FileDialog Class Reference

Thin wrapper around the native OS file-open / file-save dialog. More...

#include <Malena/Utilities/FileDialog.h>

Classes

struct  Filter

Static Public Member Functions

static std::string open (const std::vector< Filter > &filters={}, const std::string &defaultPath="")
 Show an open-file dialog. Returns the selected path or "".
static std::vector< std::string > openMultiple (const std::vector< Filter > &filters={}, const std::string &defaultPath="")
 Show a multi-select open dialog. Returns selected paths or {}.
static std::string save (const std::vector< Filter > &filters={}, const std::string &defaultPath="", const std::string &defaultName="")
 Show a save-file dialog. Returns the chosen path or "".

Detailed Description

Thin wrapper around the native OS file-open / file-save dialog.

All methods are blocking — the SFML event loop is suspended while the dialog is open, which is normal behaviour for desktop applications. Returns an empty string (or empty vector) when the user cancels.

Usage

// Open a single file
std::string path = ml::FileDialog::open({{"Quiz Files", "json,quiz"}});
if (!path.empty()) loadQuiz(path);
// Save a file
std::string out = ml::FileDialog::save({{"JSON", "json"}}, "", "quiz.json");
// Open multiple files
auto paths = ml::FileDialog::openMultiple({{"Images", "png,jpg"}});
static std::vector< std::string > openMultiple(const std::vector< Filter > &filters={}, const std::string &defaultPath="")
Show a multi-select open dialog. Returns selected paths or {}.
static std::string save(const std::vector< Filter > &filters={}, const std::string &defaultPath="", const std::string &defaultName="")
Show a save-file dialog. Returns the chosen path or "".
static std::string open(const std::vector< Filter > &filters={}, const std::string &defaultPath="")
Show an open-file dialog. Returns the selected path or "".

Definition at line 32 of file FileDialog.h.

Member Function Documentation

◆ open()

std::string ml::FileDialog::open ( const std::vector< Filter > & filters = {},
const std::string & defaultPath = "" )
static

Show an open-file dialog. Returns the selected path or "".

◆ openMultiple()

std::vector< std::string > ml::FileDialog::openMultiple ( const std::vector< Filter > & filters = {},
const std::string & defaultPath = "" )
static

Show a multi-select open dialog. Returns selected paths or {}.

◆ save()

std::string ml::FileDialog::save ( const std::vector< Filter > & filters = {},
const std::string & defaultPath = "",
const std::string & defaultName = "" )
static

Show a save-file dialog. Returns the chosen path or "".


The documentation for this class was generated from the following file: