Nui
file_dialog_options.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <nui/core.hpp>
4 
5 #include <optional>
6 #include <string>
7 #include <vector>
8 #include <filesystem>
9 
10 #ifdef NUI_BACKEND
11 # include <nlohmann/json.hpp>
12 #endif
13 
14 namespace Nui::FileDialog
15 {
16  struct Filter
17  {
18  std::string name;
19  std::vector<std::string> masks;
20  };
21 
22 // This way aggregate initialization can be done without needing to add extra braces
23 #define COMMON_DIALOG_OPTIONS() \
24  std::optional<std::string> title = std::nullopt; \
25  std::optional<std::filesystem::path> defaultPath = std::nullopt; \
26  std::vector<Filter> filters = {}; \
27  bool forcePath = false
28 
30  {
32 
33  bool allowMultiSelect = false;
34  };
35 
37  {
39  };
40 
42  {
44 
45  bool forceOverwrite = false;
46  };
47 
48 #ifdef NUI_BACKEND
50 
51  void to_json(nlohmann::json& json, OpenDialogOptions const& options);
52  void from_json(nlohmann::json const& json, OpenDialogOptions& options);
53 
54  void to_json(nlohmann::json& json, DirectoryDialogOptions const& options);
55  void from_json(nlohmann::json const& json, DirectoryDialogOptions& options);
56 
57  void to_json(nlohmann::json& json, SaveDialogOptions const& options);
58  void from_json(nlohmann::json const& json, SaveDialogOptions& options);
59 #endif
60 }
Definition: file_dialog.hpp:6
void to_json(nlohmann::json &json, OpenDialogOptions const &options)
Definition: file_dialog_options.cpp:34
void from_json(nlohmann::json const &json, OpenDialogOptions &options)
Definition: file_dialog_options.cpp:40
NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(FetchOptions, method, headers, body, verbose, followRedirects, maxRedirects, autoReferer, dontDecodeBody, verifyPeer, verifyHost)
Definition: file_dialog_options.hpp:37
Definition: file_dialog_options.hpp:17
std::string name
Definition: file_dialog_options.hpp:18
std::vector< std::string > masks
Definition: file_dialog_options.hpp:19
Definition: file_dialog_options.hpp:30
bool allowMultiSelect
Definition: file_dialog_options.hpp:33
Definition: file_dialog_options.hpp:42
bool forceOverwrite
Definition: file_dialog_options.hpp:45