2022-04-01 02:30:32 +02:00
|
|
|
#include "file_dialogs.hpp"
|
2022-12-27 18:30:38 +01:00
|
|
|
#include "utf8_strings.hpp"
|
2022-04-01 02:30:32 +02:00
|
|
|
|
2022-04-09 00:54:06 +02:00
|
|
|
#include <cstring>
|
|
|
|
|
2022-04-01 02:30:32 +02:00
|
|
|
namespace feis {
|
2022-04-09 00:54:06 +02:00
|
|
|
std::optional<std::filesystem::path> save_file_dialog() {
|
2022-04-01 02:30:32 +02:00
|
|
|
char const* options[1] = {"*.memon"};
|
2022-04-09 00:54:06 +02:00
|
|
|
return convert_char_array(tinyfd_saveFileDialog(
|
2022-04-01 02:30:32 +02:00
|
|
|
"Save File",
|
|
|
|
nullptr,
|
|
|
|
1,
|
|
|
|
options,
|
|
|
|
nullptr
|
2022-04-09 00:54:06 +02:00
|
|
|
));
|
|
|
|
};
|
|
|
|
|
|
|
|
std::optional<std::filesystem::path> open_file_dialog() {
|
|
|
|
return convert_char_array(tinyfd_openFileDialog(
|
|
|
|
"Open File",
|
|
|
|
nullptr,
|
|
|
|
0,
|
|
|
|
nullptr,
|
|
|
|
nullptr,
|
|
|
|
false
|
|
|
|
));
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
std::optional<std::filesystem::path> convert_char_array(const char* utf8_path) {
|
|
|
|
if (utf8_path == nullptr) {
|
2022-04-01 02:30:32 +02:00
|
|
|
return {};
|
|
|
|
} else {
|
2022-12-27 18:30:38 +01:00
|
|
|
const std::string utf8_string{utf8_path, utf8_path+std::strlen(utf8_path)};
|
|
|
|
return to_path(utf8_string);
|
2022-04-01 02:30:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|